2 //#import "ITTransientStatusWindow.h"
3 #import "ITIconAndTextStatusWindow.h"
4 #import "ITTSWBackgroundView.h"
5 #import "ITTextField.h"
6 #import "ITBevelView.h"
7 #import "ITCutWindowEffect.h"
8 #import "ITDissolveWindowEffect.h"
9 #import "ITSlideHorizontallyWindowEffect.h"
10 #import "ITSlideVerticallyWindowEffect.h"
11 #import "ITPivotWindowEffect.h"
12 #import "ITZoomWindowEffect.h"
13 #import "ITMultilineTextFieldCell.h"
19 #define SW_BORDER 32.0
20 #define SW_IMAGE @"Library"
23 @interface Controller (ITStatusItemSupport)
24 - (void)createStatusItem;
25 - (void)removeStatusItem;
29 @implementation Controller
33 [self createStatusItem];
34 [button setBezelStyle:1001];
35 [button setFont:[NSFont fontWithName:@"Lucida Grande Bold" size:14]];
36 [button setTitle:@"Launch Manually"];
38 [button setFrameSize:NSMakeSize([button frame].size.width + 8, 24)];
39 [testTextField setCastsShadow:YES];
40 [tabView setAllowsDragging:YES];
41 [bevelView setBevelDepth:10];
42 statusWindow = [ITIconAndTextStatusWindow sharedWindow];
43 [statusWindow setEntryEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]];
44 [statusWindow setExitEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]];
45 [[statusWindow entryEffect] setEffectTime:[swEntrySpeedSlider floatValue]];
46 [[statusWindow exitEffect] setEffectTime:[swExitSpeedSlider floatValue]];
47 [self populateEffectPopups];
48 // [tabView setAllowsDragging:YES];
49 [[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
51 [tableView setRowHeight:200];
52 [[tableView tableColumnWithIdentifier:@"custom"] setDataCell:[[[ITMultilineTextFieldCell alloc] init] autorelease]];
53 [[tableView tableColumnWithIdentifier:@"image"] setDataCell:[[[NSImageCell alloc] init] autorelease]];
56 /*************************************************************************/
58 #pragma mark ITStatusItem SUPPORT
59 /*************************************************************************/
61 - (void)createStatusItem
63 statusItem = [[ITStatusItem alloc] initWithStatusBar:[NSStatusBar systemStatusBar]
64 withLength:NSVariableStatusItemLength];
66 if ( [showImageCheckBox state] == NSOnState ) {
67 [statusItem setImage:[NSImage imageNamed:@"ITStatusItem"]];
70 if ( [useInvertedCheckBox state] == NSOnState ) {
71 [statusItem setAlternateImage:[NSImage imageNamed:@"ITStatusItemInv"]];
74 if ( [showTitleCheckBox state] == NSOnState ) {
75 [statusItem setTitle:@"ITStatusItem"];
78 [statusItem setMenu:statusItemMenu];
80 [statusItemMenu addItemWithTitle:[NSString stringWithUTF8String:"★★★★★"]
85 - (void)removeStatusItem
87 [[statusItem statusBar] removeStatusItem:statusItem];
88 [statusItem autorelease];
92 - (IBAction)toggleStatusItem:(id)sender
94 if ( [sender state] == NSOnState ) {
95 [self createStatusItem];
96 [showImageCheckBox setEnabled:YES];
97 [showTitleCheckBox setEnabled:YES];
98 [useInvertedCheckBox setEnabled:YES];
100 [self removeStatusItem];
101 [showImageCheckBox setEnabled:NO];
102 [useInvertedCheckBox setEnabled:NO];
103 [showTitleCheckBox setEnabled:NO];
107 - (IBAction)toggleImage:(id)sender
109 if ( [sender state] == NSOnState ) {
110 [statusItem setImage:[NSImage imageNamed:@"ITStatusItem"]];
111 [statusItem setAlternateImage:[NSImage imageNamed:@"ITStatusItemInv"]];
112 [useInvertedCheckBox setEnabled:YES];
113 [useInvertedCheckBox setState:NSOnState];
115 [statusItem setImage:nil];
116 [statusItem setAlternateImage:nil];
117 [useInvertedCheckBox setEnabled:NO];
118 [useInvertedCheckBox setState:NSOffState];
122 - (IBAction)toggleInvertedImage:(id)sender
124 if ( [sender state] == NSOnState ) {
125 [statusItem setAlternateImage:[NSImage imageNamed:@"ITStatusItemInv"]];
127 [statusItem setAlternateImage:nil];
131 - (IBAction)toggleTitle:(id)sender
133 if ( [sender state] == NSOnState ) {
134 [statusItem setTitle:@"ITStatusItem"];
136 [statusItem setTitle:nil];
141 /*************************************************************************/
143 #pragma mark ITTextView SUPPORT
144 /*************************************************************************/
146 - (IBAction)toggleCastsShadow:(id)sender
148 [testTextField setCastsShadow:([sender state] == NSOnState)];
152 /*************************************************************************/
154 #pragma mark ITTransientStatusWindow SUPPORT
155 /*************************************************************************/
157 - (void)populateEffectPopups
159 NSArray *effects = [ITWindowEffect effectClasses];
161 [entryEffectPopup removeAllItems];
162 [exitEffectPopup removeAllItems];
163 for (i = 0; i < [effects count]; i++) {
164 id anItem = [effects objectAtIndex:i];
165 [entryEffectPopup addItemWithTitle:[anItem effectName]];
166 [exitEffectPopup addItemWithTitle:[anItem effectName]];
167 [[entryEffectPopup lastItem] setRepresentedObject:anItem];
168 [[exitEffectPopup lastItem] setRepresentedObject:anItem];
172 - (IBAction)buildStatusWindow:(id)sender
174 NSImage *image = [NSImage imageNamed:SW_IMAGE];
175 NSString *text = [swSampleTextView string];
176 [statusWindow setImage:image];
177 [statusWindow buildTextWindowWithString:text];
180 - (IBAction)toggleStatusWindow:(id)sender
182 if ( ([statusWindow visibilityState] == ITWindowHiddenState) ||
183 ([statusWindow visibilityState] == ITWindowVanishingState) ) {
184 [[statusWindow contentView] setNeedsDisplay:YES];
185 [statusWindow appear:self];
187 [statusWindow vanish:self];
191 - (IBAction)changeWindowSetting:(id)sender
193 if ( [sender tag] == 3010 ) {
195 if ( [sender indexOfSelectedItem] == 0) {
196 [statusWindow setExitMode:ITTransientStatusWindowExitAfterDelay];
197 } else if ( [sender indexOfSelectedItem] == 1) {
198 [statusWindow setExitMode:ITTransientStatusWindowExitOnCommand];
201 } else if ( [sender tag] == 3020 ) {
203 } else if ( [sender tag] == 3030 ) {
204 [statusWindow setExitDelay:[sender floatValue]];
205 } else if ( [sender tag] == 3040 ) {
206 [statusWindow setVerticalPosition:[sender indexOfSelectedItem]];
207 } else if ( [sender tag] == 3050 ) {
208 [statusWindow setHorizontalPosition:[sender indexOfSelectedItem]];
209 } else if ( [sender tag] == 3060 ) {
210 [[statusWindow entryEffect] setEffectTime:[sender floatValue]];
211 } else if ( [sender tag] == 3061 ) {
212 [[statusWindow exitEffect] setEffectTime:[sender floatValue]];
213 } else if ( [sender tag] == 3070 ) {
214 [statusWindow setEntryEffect:[[[[[sender selectedItem] representedObject] alloc] initWithWindow:statusWindow] autorelease]];
215 [[statusWindow entryEffect] setEffectTime:[swEntrySpeedSlider floatValue]];
216 } else if ( [sender tag] == 3080 ) {
217 [statusWindow setExitEffect:[[[[[sender selectedItem] representedObject] alloc] initWithWindow:statusWindow] autorelease]];
218 [[statusWindow exitEffect] setEffectTime:[swExitSpeedSlider floatValue]];
219 } else if ( [sender tag] == 3090 ) {
220 if ( [sender indexOfSelectedItem] == 0 ) {
221 [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundMode:ITTSWBackgroundApple];
222 } else if ( [sender indexOfSelectedItem] == 1 ) {
223 [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundMode:ITTSWBackgroundReadable];
224 } else if ( [sender indexOfSelectedItem] == 2 ) {
225 [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundMode:ITTSWBackgroundColored];
227 } else if ( [sender tag] == 3100 ) {
228 [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundColor:[sender color]];
233 /*************************************************************************/
235 #pragma mark ITTabView SUPPORT
236 /*************************************************************************/
238 - (IBAction)toggleTabDragging:(id)sender
240 if ([sender state] == NSOnState) {
241 [tabView setAllowsDragging:YES];
243 [tabView setAllowsDragging:NO];
247 - (IBAction)toggleCommandDragging:(id)sender
249 if ([sender state] == NSOnState) {
250 [tabView setRequiredModifiers:NSCommandKeyMask];
252 [tabView setRequiredModifiers:0];
256 - (IBAction)toggleControlDragging:(id)sender
260 - (IBAction)toggleOptionDragging:(id)sender
264 - (IBAction)toggleShiftDragging:(id)sender
269 /*************************************************************************/
271 #pragma mark ITBevelView SUPPORT
272 /*************************************************************************/
274 - (IBAction)changeBevelViewSetting:(id)sender
276 [bevelView setBevelDepth:[sender intValue]];
280 /*************************************************************************/
282 #pragma mark ITButton SUPPORT
283 /*************************************************************************/
286 /*************************************************************************/
288 #pragma mark NSWindow DELEGATE METHODS
289 /*************************************************************************/
291 - (void)windowWillMiniaturize:(NSNotification *)note
293 [[note object] setMiniwindowImage:[NSImage imageNamed:@"ITStatusItem"]];
296 /*************************************************************************/
298 #pragma mark ITMultilineTextFieldCell SUPPORT
299 /*************************************************************************/
301 - (int)numberOfRowsInTableView:(NSTableView *)aTableView {
305 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
306 if ([[aTableColumn dataCell] isKindOfClass:[ITMultilineTextFieldCell class]]) {
308 return [NSArray arrayWithObjects:@"Foo", @"Bar", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", @"- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex", nil];
310 return [NSArray arrayWithObjects:[[[NSAttributedString alloc] initWithString:@"This is a demo of ITMultilineTextFieldCell" attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Gill Sans" size:48], NSFontAttributeName, [NSColor purpleColor], NSForegroundColorAttributeName, nil]] autorelease], [[[NSAttributedString alloc] initWithString:@"Bar" attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont fontWithName:@"Gadget" size:20], NSFontAttributeName, nil]] autorelease], [[[NSObject alloc] init] autorelease], nil];
312 } else if ([[aTableColumn dataCell] isKindOfClass:[NSImageCell class]]) {
313 return [NSImage imageNamed:@"NSApplicationIcon"];
315 return @"I like cheese";