text status window.
--- /dev/null
+/*
+ * ITKit
+ * ITIconAndTextStatusWindow
+ * ITTransientStatusWindow subclass to show an icon and text.
+ *
+ * Original Author : Kent Sutherland <ksutherland@ithinksw.com>
+ * Responsibility : Kent Sutherland <mjudy@ithinksw.com>
+ * Responsibility : Joseph Spiros <joseph.spiros@ithinksw.com>
+ *
+ * Copyright (c) 2002 - 2004 iThink Software.
+ * All Rights Reserved
+ *
+ */
+
+#import <Cocoa/Cocoa.h>
+#import "ITTransientStatusWindow.h"
+
+@interface ITIconAndTextStatusWindow : ITTransientStatusWindow {
+ NSImage *_image;
+}
+
+- (void)setImage:(NSImage *)newImage;
+- (void)buildTextWindowWithString:(NSString *)text;
+
+@end
--- /dev/null
+/*
+ * ITKit
+ * ITIconAndTextStatusWindow
+ * ITTransientStatusWindow subclass to show an icon and text.
+ *
+ * Original Author : Kent Sutherland <ksutherland@ithinksw.com>
+ * Responsibility : Kent Sutherland <mjudy@ithinksw.com>
+ * Responsibility : Joseph Spiros <joseph.spiros@ithinksw.com>
+ *
+ * Copyright (c) 2002 - 2004 iThink Software.
+ * All Rights Reserved
+ *
+ */
+
+#import "ITIconAndTextStatusWindow.h"
+#import "ITWindowPositioning.h"
+#import "ITWindowEffect.h"
+#import "ITImageView.h"
+#import "ITTextField.h"
+
+#define SW_PAD 24.00
+#define SW_SPACE 24.00
+#define SW_MINW 211.00
+#define SW_BORDER 32.00
+#define SW_METER_PAD 4.00
+#define SW_BUTTON_PAD_R 30.00
+#define SW_BUTTON_PAD_B 24.00
+#define SW_BUTTON_DIV 12.00
+#define SW_BUTTON_EXTRA_W 8.00
+#define SW_SHADOW_SAT 1.25
+#define SMALL_DIVISOR 1.33333
+#define MINI_DIVISOR 1.66667
+
+@implementation ITIconAndTextStatusWindow
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark INITIALIZATION / DEALLOCATION METHODS
+/*************************************************************************/
+
+- (id)initWithContentView:(NSView *)contentView
+ exitMode:(ITTransientStatusWindowExitMode)exitMode
+ backgroundType:(ITTransientStatusWindowBackgroundType)backgroundType
+{
+ if ( ( self = [super initWithContentView:contentView exitMode:exitMode backgroundType:backgroundType] ) ) {
+ //Defaults
+ _image = [[NSImage imageNamed:@"NSApplicationIcon"] retain];
+ [self setSizing:ITTransientStatusWindowRegular];
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [_image release];
+ [super dealloc];
+}
+
+- (void)setImage:(NSImage *)newImage
+{
+ [_image autorelease];
+ _image = [newImage copy];
+}
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark INSTANCE METHODS
+/*************************************************************************/
+
+- (NSRect)setupWindowWithDataSize:(NSSize)dataSize
+{
+ float divisor = 1.0;
+ NSRect imageRect;
+ float imageWidth = 0.0;
+ float imageHeight = 0.0;
+ float dataWidth = dataSize.width;
+ float dataHeight = dataSize.height;
+ float contentHeight = 0.0;
+ float windowWidth = 0.0;
+ float windowHeight = 0.0;
+ NSRect visibleFrame = [[self screen] visibleFrame];
+ NSPoint screenOrigin = visibleFrame.origin;
+ float screenWidth = visibleFrame.size.width;
+ float screenHeight = visibleFrame.size.height;
+ float maxWidth = ( screenWidth - (SW_BORDER * 2) );
+ float maxHeight = ( screenHeight - (SW_BORDER * 2) );
+ float excessWidth = 0.0;
+ float excessHeight = 0.0;
+ NSPoint windowOrigin;
+ ITImageView *imageView;
+ BOOL shouldAnimate = ( ! (([self visibilityState] == ITWindowAppearingState) ||
+ ([self visibilityState] == ITWindowVanishingState)) );
+
+ if ( [self sizing] == ITTransientStatusWindowSmall ) {
+ divisor = SMALL_DIVISOR;
+ } else if ( [self sizing] == ITTransientStatusWindowMini ) {
+ divisor = MINI_DIVISOR;
+ }
+
+// Get image width and height.
+ imageWidth = ( [_image size].width / divisor );
+ imageHeight = ( [_image size].height / divisor );
+
+// Set the content height to the greater of the text and image heights.
+ contentHeight = ( ( imageHeight > dataHeight ) ? imageHeight : dataHeight );
+
+// Setup the Window, and remove all its contentview's subviews.
+ windowWidth = ( (SW_PAD / divisor) + imageWidth + (SW_SPACE / divisor) + dataWidth + (SW_PAD / divisor) );
+ windowHeight = ( (SW_PAD / divisor) + contentHeight + (SW_PAD / divisor) );
+
+// Constrain size to max limits. Adjust data sizes accordingly.
+ excessWidth = (windowWidth - maxWidth );
+ excessHeight = (windowHeight - maxHeight);
+
+ if ( excessWidth > 0.0 ) {
+ windowWidth = maxWidth;
+ dataWidth -= excessWidth;
+ }
+
+ if ( excessHeight > 0.0 ) {
+ windowHeight = maxHeight;
+ dataHeight -= excessHeight;
+ }
+
+ if ( [self horizontalPosition] == ITWindowPositionLeft ) {
+ windowOrigin.x = ( SW_BORDER + screenOrigin.x );
+ } else if ( [self horizontalPosition] == ITWindowPositionCenter ) {
+ windowOrigin.x = ( screenOrigin.x + (screenWidth / 2) - (windowWidth / 2) );
+ } else if ( [self horizontalPosition] == ITWindowPositionRight ) {
+ windowOrigin.x = ( screenOrigin.x + screenWidth - (windowWidth + SW_BORDER) );
+ }
+
+ if ( [self verticalPosition] == ITWindowPositionTop ) {
+ windowOrigin.y = ( screenOrigin.y + screenHeight - (windowHeight + SW_BORDER) );
+ } else if ( [self verticalPosition] == ITWindowPositionMiddle ) {
+// Middle-oriented windows should be slightly proud of the screen's middle.
+ windowOrigin.y = ( (screenOrigin.y + (screenHeight / 2) - (windowHeight / 2)) + (screenHeight / 8) );
+ } else if ( [self verticalPosition] == ITWindowPositionBottom ) {
+ windowOrigin.y = ( SW_BORDER + screenOrigin.y );
+ }
+
+ [self setFrame:NSMakeRect( windowOrigin.x,
+ windowOrigin.y,
+ windowWidth,
+ windowHeight) display:YES animate:shouldAnimate];
+
+ [[[self contentView] subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
+
+// Setup, position, fill, and add the image view to the content view.
+ imageRect = NSMakeRect( (SW_PAD / divisor),
+ ((SW_PAD / divisor) + ((contentHeight - imageHeight) / 2)),
+ imageWidth,
+ imageHeight );
+ imageView = [[[ITImageView alloc] initWithFrame:imageRect] autorelease];
+ [imageView setAutoresizingMask:(NSViewMinYMargin | NSViewMaxYMargin)];
+ [imageView setImage:_image];
+ [imageView setCastsShadow:YES];
+ [[self contentView] addSubview:imageView];
+
+ return NSMakeRect( ((SW_PAD / divisor) + imageWidth + (SW_SPACE / divisor)),
+ ((SW_PAD / divisor) + ((contentHeight - dataHeight) / 2)),
+ dataWidth,
+ dataHeight);
+}
+
+- (void)buildTextWindowWithString:(NSString *)text
+{
+ float divisor = 1.0;
+ float dataWidth = 0.0;
+ float dataHeight = 0.0;
+ NSRect dataRect;
+ NSArray *lines = [text componentsSeparatedByString:@"\n"];
+ id oneLine = nil;
+ NSEnumerator *lineEnum = [lines objectEnumerator];
+ float baseFontSize = 18.0;
+ ITTextField *textField;
+ NSFont *font;
+ NSDictionary *attr;
+
+ if ( [self sizing] == ITTransientStatusWindowSmall ) {
+ divisor = SMALL_DIVISOR;
+ } else if ( [self sizing] == ITTransientStatusWindowMini ) {
+ divisor = MINI_DIVISOR;
+ }
+
+ font = [NSFont fontWithName:@"Lucida Grande Bold" size:(baseFontSize / divisor)];
+ attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
+
+// Iterate over each line to get text width and height
+ while ( (oneLine = [lineEnum nextObject]) ) {
+// Get the width of one line, adding 8.0 because Apple sucks donkey rectum.
+ float oneLineWidth = ( [oneLine sizeWithAttributes:attr].width + 8.0 );
+// Add the height of this line to the total text height
+ dataHeight += [oneLine sizeWithAttributes:attr].height;
+// If this line wider than the last one, set it as the text width.
+ dataWidth = ( ( dataWidth > oneLineWidth ) ? dataWidth : oneLineWidth );
+ }
+
+// Add 4.0 to the final dataHeight to accomodate the shadow.
+ dataHeight += 4.0;
+
+ dataRect = [self setupWindowWithDataSize:NSMakeSize(dataWidth, dataHeight)];
+
+// Create, position, setup, fill, and add the text view to the content view.
+ textField = [[[ITTextField alloc] initWithFrame:dataRect] autorelease];
+ [textField setAutoresizingMask:(NSViewHeightSizable | NSViewWidthSizable)];
+ [textField setEditable:NO];
+ [textField setSelectable:NO];
+ [textField setBordered:NO];
+ [textField setDrawsBackground:NO];
+ [textField setFont:font];
+ [textField setTextColor:[NSColor whiteColor]];
+ [textField setCastsShadow:YES];
+ [[textField cell] setWraps:NO];
+ [textField setStringValue:text];
+ [textField setShadowSaturation:SW_SHADOW_SAT];
+ [[self contentView] addSubview:textField];
+
+// Display the window.
+ [[self contentView] setNeedsDisplay:YES];
+}
+
+@end
#import <ITKit/ITTextField.h>
#import <ITKit/ITTransientStatusWindow.h>
+#import <ITKit/ITIconAndTextStatusWindow.h>
+
#import <ITKit/ITCategory-NSView.h>
#import <ITKit/ITCategory-NSMenu.h>
//322
//323
//324
+//370
+//371
+//372
+//373
+//374
+ 3710911905C07F6D00ED0F36 = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.h;
+ path = ITIconAndTextStatusWindow.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 3710911A05C07F6D00ED0F36 = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.c.objc;
+ path = ITIconAndTextStatusWindow.m;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 3710912305C0821000ED0F36 = {
+ fileRef = 3710911A05C07F6D00ED0F36;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 3710912805C0825900ED0F36 = {
+ fileRef = 3710911905C07F6D00ED0F36;
+ isa = PBXBuildFile;
+ settings = {
+ ATTRIBUTES = (
+ Public,
+ );
+ };
+ };
+//370
+//371
+//372
+//373
+//374
//7C0
//7C1
//7C2
children = (
7C992DF9054F5179000B93EA,
7C992DFA054F5179000B93EA,
+ 3710911905C07F6D00ED0F36,
+ 3710911A05C07F6D00ED0F36,
7C992DD8054F5179000B93EA,
7C992DD9054F5179000B93EA,
7C992DFD054F5179000B93EA,
7C992E32054F5179000B93EA,
2AC83141056D00F700A7D7E2,
2AC8319D056D037700A7D7E2,
+ 3710912805C0825900ED0F36,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
7C992E31054F5179000B93EA,
2AC83142056D00F700A7D7E2,
2AC8319E056D037700A7D7E2,
+ 3710912305C0821000ED0F36,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
ITTransientStatusWindowAquaUtility
} ITTransientStatusWindowBackgroundType;
+typedef enum {
+ ITTransientStatusWindowRegular,
+ ITTransientStatusWindowSmall,
+ ITTransientStatusWindowMini
+} ITTransientStatusWindowSizing;
@interface ITTransientStatusWindow : NSWindow <ITWindowPositioning , ITWindowMotility> {
double _effectProgress;
ITVerticalWindowPosition _verticalPosition;
ITHorizontalWindowPosition _horizontalPosition;
+ ITTransientStatusWindowSizing _sizing;
float _screenPadding;
// int _screenNumber;
- (void)appear:(id)sender;
- (void)vanish:(id)sender;
+- (void)setSizing:(ITTransientStatusWindowSizing)newSizing;
+- (ITTransientStatusWindowSizing)sizing;
+
- (ITWindowVisibilityState)visibilityState;
- (void)setVisibilityState:(ITWindowVisibilityState)newState;
}
}
+- (void)setSizing:(ITTransientStatusWindowSizing)newSizing
+{
+ _sizing = newSizing;
+}
+
+- (ITTransientStatusWindowSizing)sizing
+{
+ return _sizing;
+}
+
- (ITWindowVisibilityState)visibilityState
{
return _visibilityState;
IBOutlet ITTextField *testTextField;
// ITTransientStatusWindow Support
- ITTransientStatusWindow *statusWindow;
- IBOutlet NSTextView *swSampleTextView;
- IBOutlet NSPopUpButton *swVanishModePopup;
- IBOutlet NSPopUpButton *swBackgroundTypePopup;
- IBOutlet NSPopUpButton *swDefinedPositionPopup;
- IBOutlet NSTextField *swVanishDelay;
- IBOutlet NSTextField *swShadowSaturation;
- IBOutlet NSSlider *swEntrySpeedSlider;
- IBOutlet NSSlider *swExitSpeedSlider;
+ ITIconAndTextStatusWindow *statusWindow;
+ IBOutlet NSTextView *swSampleTextView;
+ IBOutlet NSPopUpButton *swVanishModePopup;
+ IBOutlet NSPopUpButton *swBackgroundTypePopup;
+ IBOutlet NSPopUpButton *swDefinedPositionPopup;
+ IBOutlet NSTextField *swVanishDelay;
+ IBOutlet NSTextField *swShadowSaturation;
+ IBOutlet NSSlider *swEntrySpeedSlider;
+ IBOutlet NSSlider *swExitSpeedSlider;
}
// ITStatusItem Support
#import "Controller.h"
-#import "ITTransientStatusWindow.h"
+//#import "ITTransientStatusWindow.h"
+#import "ITIconAndTextStatusWindow.h"
#import "ITTSWBackgroundView.h"
#import "ITTextField.h"
#import "ITBevelView.h"
[testTextField setCastsShadow:YES];
[tabView setAllowsDragging:YES];
[bevelView setBevelDepth:10];
- statusWindow = [ITTransientStatusWindow sharedWindow];
+ statusWindow = [ITIconAndTextStatusWindow sharedWindow];
[statusWindow setEntryEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]];
[statusWindow setExitEffect:[[ITDissolveWindowEffect alloc] initWithWindow:statusWindow]];
[[statusWindow entryEffect] setEffectTime:[swEntrySpeedSlider floatValue]];
- (IBAction)buildStatusWindow:(id)sender
{
- NSImageView *imageView = nil;
- ITTextField *textField = nil;
NSImage *image = [NSImage imageNamed:SW_IMAGE];
- NSRect imageRect;
- NSRect textRect;
-
- float imageWidth = 0.0;
- float imageHeight = 0.0;
- float textWidth = 0.0;
- float textHeight = 0.0;
- float contentHeight = 0.0;
- float windowWidth = 0.0;
- float windowHeight = 0.0;
-
- NSString *text = [swSampleTextView string];
- NSArray *lines = [text componentsSeparatedByString:@"\n"];
- id oneLine = nil;
- NSEnumerator *lineEnum = [lines objectEnumerator];
-
- NSFont *font = [NSFont fontWithName:@"Lucida Grande Bold" size:18];
- NSDictionary *attr = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
-
- // Get image width and height.
- imageWidth = [image size].width;
- imageHeight = [image size].height;
-
- // Iterate over each line to get text width and height
- while ( oneLine = [lineEnum nextObject] ) {
- // Get the width of one line, adding 8.0 because Apple sucks donkey rectum.
- float oneLineWidth = ( [oneLine sizeWithAttributes:attr].width + 8.0 );
- // Add the height of this line to the total text height
- textHeight += [oneLine sizeWithAttributes:attr].height;
- // If this line wider than the last one, set it as the text width.
- textWidth = ( ( textWidth > oneLineWidth ) ? textWidth : oneLineWidth );
- }
-
- // Add 4.0 to the final textHeight to accomodate the shadow.
- textHeight += 4.0;
- NSLog(@"%f", textHeight);
- // Set the content height to the greater of the text and image heights.
- contentHeight = ( ( imageHeight > textHeight ) ? imageHeight : textHeight );
-
- // Setup the Window, and remove all its contentview's subviews.
- windowWidth = ( SW_PAD + imageWidth + SW_SPACE + textWidth + SW_PAD );
- windowHeight = ( SW_PAD + contentHeight + SW_PAD );
- [statusWindow setFrame:NSMakeRect(SW_BORDER, SW_BORDER, windowWidth, windowHeight) display:YES animate:YES];
- [[[statusWindow contentView] subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
-
- // Setup, position, fill, and add the image view to the content view.
- imageRect = NSMakeRect( SW_PAD,
- (SW_PAD + ((contentHeight - imageHeight) / 2)),
- imageWidth,
- imageHeight );
- imageView = [[[NSImageView alloc] initWithFrame:imageRect] autorelease];
- [imageView setImage:image];
- [[statusWindow contentView] addSubview:imageView];
-
- // Setup, position, fill, and add the text view to the content view.
- textRect = NSMakeRect( (SW_PAD + imageWidth + SW_SPACE),
- (SW_PAD + ((contentHeight - textHeight) / 2)),
- textWidth,
- textHeight);
- textField = [[[ITTextField alloc] initWithFrame:textRect] autorelease];
- [textField setEditable:NO];
- [textField setSelectable:NO];
- [textField setBordered:NO];
- [textField setDrawsBackground:NO];
- [textField setFont:[NSFont fontWithName:@"Lucida Grande Bold" size:18]];
- [textField setTextColor:[NSColor whiteColor]];
- [textField setCastsShadow:YES];
- [textField setStringValue:text];
- [[statusWindow contentView] addSubview:textField];
-
- [[statusWindow contentView] setNeedsDisplay:YES];
+ NSString *text = [swSampleTextView string];
+ [statusWindow setImage:image];
+ [statusWindow buildTextWindowWithString:text];
}
- (IBAction)toggleStatusWindow:(id)sender