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 "ITMultilineTextFieldCell.h"
18 #define SW_BORDER 32.0
19 #define SW_IMAGE @"Library"
22 @interface Controller (ITStatusItemSupport)
23 - (void)createStatusItem;
24 - (void)removeStatusItem;
28 @implementation Controller
32 [self createStatusItem];
33 [button setBezelStyle:1001];
34 [button setFont:[NSFont fontWithName:@"Lucida Grande Bold" size:14]];
35 [button setTitle:@"Launch Manually"];
37 [button setFrameSize:NSMakeSize([button frame].size.width + 8, 24)];
38 [testTextField setCastsShadow:YES];
39 [tabView setAllowsDragging:YES];
40 [bevelView setBevelDepth:10];
41 statusWindow = [ITIconAndTextStatusWindow sharedWindow];
42 [statusWindow setEntryEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]];
43 [statusWindow setExitEffect:[[ITDissolveWindowEffect alloc] initWithWindow:statusWindow]];
44 [[statusWindow entryEffect] setEffectTime:[swEntrySpeedSlider floatValue]];
45 [[statusWindow exitEffect] setEffectTime:[swExitSpeedSlider floatValue]];
46 // [tabView setAllowsDragging:YES];
47 [[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
49 [tableView setRowHeight:200];
50 [[tableView tableColumnWithIdentifier:@"custom"] setDataCell:[[[ITMultilineTextFieldCell alloc] init] autorelease]];
51 [[tableView tableColumnWithIdentifier:@"image"] setDataCell:[[[NSImageCell alloc] init] autorelease]];
54 /*************************************************************************/
56 #pragma mark ITStatusItem SUPPORT
57 /*************************************************************************/
59 - (void)createStatusItem
61 statusItem = [[ITStatusItem alloc] initWithStatusBar:[NSStatusBar systemStatusBar]
62 withLength:NSVariableStatusItemLength];
64 if ( [showImageCheckBox state] == NSOnState ) {
65 [statusItem setImage:[NSImage imageNamed:@"ITStatusItem"]];
68 if ( [useInvertedCheckBox state] == NSOnState ) {
69 [statusItem setAlternateImage:[NSImage imageNamed:@"ITStatusItemInv"]];
72 if ( [showTitleCheckBox state] == NSOnState ) {
73 [statusItem setTitle:@"ITStatusItem"];
76 [statusItem setMenu:statusItemMenu];
78 [statusItemMenu addItemWithTitle:[NSString stringWithUTF8String:"★★★★★"]
83 - (void)removeStatusItem
85 [[statusItem statusBar] removeStatusItem:statusItem];
86 [statusItem autorelease];
90 - (IBAction)toggleStatusItem:(id)sender
92 if ( [sender state] == NSOnState ) {
93 [self createStatusItem];
94 [showImageCheckBox setEnabled:YES];
95 [showTitleCheckBox setEnabled:YES];
96 [useInvertedCheckBox setEnabled:YES];
98 [self removeStatusItem];
99 [showImageCheckBox setEnabled:NO];
100 [useInvertedCheckBox setEnabled:NO];
101 [showTitleCheckBox setEnabled:NO];
105 - (IBAction)toggleImage:(id)sender
107 if ( [sender state] == NSOnState ) {
108 [statusItem setImage:[NSImage imageNamed:@"ITStatusItem"]];
109 [statusItem setAlternateImage:[NSImage imageNamed:@"ITStatusItemInv"]];
110 [useInvertedCheckBox setEnabled:YES];
111 [useInvertedCheckBox setState:NSOnState];
113 [statusItem setImage:nil];
114 [statusItem setAlternateImage:nil];
115 [useInvertedCheckBox setEnabled:NO];
116 [useInvertedCheckBox setState:NSOffState];
120 - (IBAction)toggleInvertedImage:(id)sender
122 if ( [sender state] == NSOnState ) {
123 [statusItem setAlternateImage:[NSImage imageNamed:@"ITStatusItemInv"]];
125 [statusItem setAlternateImage:nil];
129 - (IBAction)toggleTitle:(id)sender
131 if ( [sender state] == NSOnState ) {
132 [statusItem setTitle:@"ITStatusItem"];
134 [statusItem setTitle:nil];
139 /*************************************************************************/
141 #pragma mark ITTextView SUPPORT
142 /*************************************************************************/
144 - (IBAction)toggleCastsShadow:(id)sender
146 [testTextField setCastsShadow:([sender state] == NSOnState)];
150 /*************************************************************************/
152 #pragma mark ITTransientStatusWindow SUPPORT
153 /*************************************************************************/
155 - (IBAction)buildStatusWindow:(id)sender
157 NSImage *image = [NSImage imageNamed:SW_IMAGE];
158 NSString *text = [swSampleTextView string];
159 [statusWindow setImage:image];
160 [statusWindow buildTextWindowWithString:text];
163 - (IBAction)toggleStatusWindow:(id)sender
165 if ( ([statusWindow visibilityState] == ITWindowHiddenState) ||
166 ([statusWindow visibilityState] == ITWindowVanishingState) ) {
167 [[statusWindow contentView] setNeedsDisplay:YES];
168 [statusWindow appear:self];
170 [statusWindow vanish:self];
174 - (IBAction)changeWindowSetting:(id)sender
176 if ( [sender tag] == 3010 ) {
178 if ( [sender indexOfSelectedItem] == 0) {
179 [statusWindow setExitMode:ITTransientStatusWindowExitAfterDelay];
180 } else if ( [sender indexOfSelectedItem] == 1) {
181 [statusWindow setExitMode:ITTransientStatusWindowExitOnCommand];
184 } else if ( [sender tag] == 3020 ) {
186 } else if ( [sender tag] == 3030 ) {
187 [statusWindow setExitDelay:[sender floatValue]];
188 } else if ( [sender tag] == 3040 ) {
189 [statusWindow setVerticalPosition:[sender indexOfSelectedItem]];
190 } else if ( [sender tag] == 3050 ) {
191 [statusWindow setHorizontalPosition:[sender indexOfSelectedItem]];
192 } else if ( [sender tag] == 3060 ) {
193 [[statusWindow entryEffect] setEffectTime:[sender floatValue]];
194 } else if ( [sender tag] == 3061 ) {
195 [[statusWindow exitEffect] setEffectTime:[sender floatValue]];
196 } else if ( [sender tag] == 3070 ) {
198 if ( [sender indexOfSelectedItem] == 0 ) {
199 [statusWindow setEntryEffect:[[[ITCutWindowEffect alloc] initWithWindow:statusWindow] autorelease]];
200 } else if ( [sender indexOfSelectedItem] == 1 ) {
201 [statusWindow setEntryEffect:[[[ITDissolveWindowEffect alloc] initWithWindow:statusWindow] autorelease]];
202 } else if ( [sender indexOfSelectedItem] == 2 ) {
203 [statusWindow setEntryEffect:[[[ITSlideVerticallyWindowEffect alloc] initWithWindow:statusWindow] autorelease]];
204 } else if ( [sender indexOfSelectedItem] == 3 ) {
205 [statusWindow setEntryEffect:[[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:statusWindow] autorelease]];
206 } else if ( [sender indexOfSelectedItem] == 4 ) {
207 [statusWindow setEntryEffect:[[[ITPivotWindowEffect alloc] initWithWindow:statusWindow] autorelease]];
210 [[statusWindow entryEffect] setEffectTime:[swEntrySpeedSlider floatValue]];
212 } else if ( [sender tag] == 3080 ) {
214 if ( [sender indexOfSelectedItem] == 0 ) {
215 [statusWindow setExitEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]];
216 } else if ( [sender indexOfSelectedItem] == 1 ) {
217 [statusWindow setExitEffect:[[ITDissolveWindowEffect alloc] initWithWindow:statusWindow]];
218 } else if ( [sender indexOfSelectedItem] == 2 ) {
219 [statusWindow setExitEffect:[[ITSlideVerticallyWindowEffect alloc] initWithWindow:statusWindow]];
220 } else if ( [sender indexOfSelectedItem] == 3 ) {
221 [statusWindow setExitEffect:[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:statusWindow]];
222 } else if ( [sender indexOfSelectedItem] == 4 ) {
223 [statusWindow setExitEffect:[[ITPivotWindowEffect alloc] initWithWindow:statusWindow]];
226 [[statusWindow exitEffect] setEffectTime:[swExitSpeedSlider floatValue]];
228 } else if ( [sender tag] == 3090 ) {
230 if ( [sender indexOfSelectedItem] == 0 ) {
231 [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundMode:ITTSWBackgroundApple];
232 } else if ( [sender indexOfSelectedItem] == 1 ) {
233 [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundMode:ITTSWBackgroundReadable];
234 } else if ( [sender indexOfSelectedItem] == 2 ) {
235 [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundMode:ITTSWBackgroundColored];
238 } else if ( [sender tag] == 3100 ) {
239 [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundColor:[sender color]];
244 /*************************************************************************/
246 #pragma mark ITTabView SUPPORT
247 /*************************************************************************/
249 - (IBAction)toggleTabDragging:(id)sender
251 if ([sender state] == NSOnState) {
252 [tabView setAllowsDragging:YES];
254 [tabView setAllowsDragging:NO];
258 - (IBAction)toggleCommandDragging:(id)sender
260 if ([sender state] == NSOnState) {
261 [tabView setRequiredModifiers:NSCommandKeyMask];
263 [tabView setRequiredModifiers:0];
267 - (IBAction)toggleControlDragging:(id)sender
271 - (IBAction)toggleOptionDragging:(id)sender
275 - (IBAction)toggleShiftDragging:(id)sender
280 /*************************************************************************/
282 #pragma mark ITBevelView SUPPORT
283 /*************************************************************************/
285 - (IBAction)changeBevelViewSetting:(id)sender
287 [bevelView setBevelDepth:[sender intValue]];
291 /*************************************************************************/
293 #pragma mark ITButton SUPPORT
294 /*************************************************************************/
297 /*************************************************************************/
299 #pragma mark NSWindow DELEGATE METHODS
300 /*************************************************************************/
302 - (void)windowWillMiniaturize:(NSNotification *)note
304 [[note object] setMiniwindowImage:[NSImage imageNamed:@"ITStatusItem"]];
307 /*************************************************************************/
309 #pragma mark ITMultilineTextFieldCell SUPPORT
310 /*************************************************************************/
312 - (int)numberOfRowsInTableView:(NSTableView *)aTableView {
316 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex {
317 if ([[aTableColumn dataCell] isKindOfClass:[ITMultilineTextFieldCell class]]) {
319 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];
321 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];
323 } else if ([[aTableColumn dataCell] isKindOfClass:[NSImageCell class]]) {
324 return [NSImage imageNamed:@"NSApplicationIcon"];
326 return @"I like cheese";