ITKit for MenuTunes
authorMatthew Judy <mjudy@ithinksw.com>
Mon, 27 Jan 2003 09:34:54 +0000 (09:34 +0000)
committerMatthew Judy <mjudy@ithinksw.com>
Mon, 27 Jan 2003 09:34:54 +0000 (09:34 +0000)
Commit Phase 4: Adding the Showcase

This is the final checkin for the new ITKit.  It adds the Showcase into
the new ITKit.  With this, the ITKitTester project becomes obsolete, and
it should be moved to the Attic.  The showcase cannot be run from outside
ProjectBuilder without having the ITKit.framework in a library somewhere.

13 files changed:
Showcase/CD.tiff [new file with mode: 0755]
Showcase/Controller.h [new file with mode: 0755]
Showcase/Controller.m [new file with mode: 0755]
Showcase/English.lproj/InfoPlist.strings [new file with mode: 0755]
Showcase/English.lproj/MainMenu.nib/classes.nib [new file with mode: 0755]
Showcase/English.lproj/MainMenu.nib/info.nib [new file with mode: 0755]
Showcase/English.lproj/MainMenu.nib/keyedobjects.nib [new file with mode: 0755]
Showcase/ITStatusItem.tiff [new file with mode: 0755]
Showcase/ITStatusItemInv.tiff [new file with mode: 0755]
Showcase/Library.tiff [new file with mode: 0755]
Showcase/Radio.tiff [new file with mode: 0755]
Showcase/iPod.tif [new file with mode: 0755]
Showcase/main.m [new file with mode: 0755]

diff --git a/Showcase/CD.tiff b/Showcase/CD.tiff
new file mode 100755 (executable)
index 0000000..fae345e
Binary files /dev/null and b/Showcase/CD.tiff differ
diff --git a/Showcase/Controller.h b/Showcase/Controller.h
new file mode 100755 (executable)
index 0000000..85492f3
--- /dev/null
@@ -0,0 +1,45 @@
+#import <ITKit/ITKit.h>
+#import <Cocoa/Cocoa.h>
+
+@interface Controller : NSObject
+{
+    IBOutlet NSWindow *window;
+    
+    // ITStatusItem Support
+    ITStatusItem      *statusItem;
+    IBOutlet NSMenu   *statusItemMenu;
+    IBOutlet NSButton *showStatusItemCheckBox;
+    IBOutlet NSButton *showImageCheckBox;
+    IBOutlet NSButton *useInvertedCheckBox;
+    IBOutlet NSButton *showTitleCheckBox;
+    
+    // ITTabView Support
+    IBOutlet ITTabView *tabView;
+
+    // ITTextField Support
+    IBOutlet ITTextField *testTextField;
+
+    // ITTransientStatusWindow Support
+    ITTransientStatusWindow *statusWindow;
+    IBOutlet NSTextView   *swSampleTextView;
+    IBOutlet NSPopUpButton *swVanishModePopup;
+    IBOutlet NSPopUpButton *swBackgroundTypePopup;
+    IBOutlet NSPopUpButton *swDefinedPositionPopup;
+    IBOutlet NSTextField   *swVanishDelay;
+    IBOutlet NSMatrix      *swVanishOnClick;
+}
+
+// ITStatusItem Support
+- (IBAction)toggleStatusItem:(id)sender;
+- (IBAction)toggleImage:(id)sender;
+- (IBAction)toggleInvertedImage:(id)sender;
+- (IBAction)toggleTitle:(id)sender;
+
+// ITTextField Support
+- (IBAction)toggleCastsShadow:(id)sender;
+
+// ITTransientStatusWindow Support
+- (IBAction)buildStatusWindow:(id)sender;
+- (IBAction)showStatusWindow:(id)sender;
+
+@end
diff --git a/Showcase/Controller.m b/Showcase/Controller.m
new file mode 100755 (executable)
index 0000000..a2ca8d9
--- /dev/null
@@ -0,0 +1,262 @@
+#import "Controller.h"
+#import "ITTransientStatusWindow.h"
+#import "ITTextField.h"
+
+#define SW_PAD    24.0
+#define SW_SPACE  24.0
+#define SW_MINW   211.0
+#define SW_BORDER 32.0
+#define SW_IMAGE  @"Library"
+
+@interface Controller (ITStatusItemSupport)
+- (void)createStatusItem;
+- (void)removeStatusItem;
+@end
+
+
+@implementation Controller
+
+- (void)awakeFromNib
+{
+    [self createStatusItem];
+    [testTextField setCastsShadow:YES];
+    statusWindow = [ITTransientStatusWindow sharedWindow];
+//  [tabView setAllowsDragging:YES];
+}
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark ITStatusItem SUPPORT
+/*************************************************************************/
+
+- (void)createStatusItem
+{
+    statusItem = [[ITStatusItem alloc] initWithStatusBar:[NSStatusBar systemStatusBar]
+                                              withLength:NSVariableStatusItemLength];
+
+    if ( [showImageCheckBox state] == NSOnState ) {
+        [statusItem setImage:[NSImage imageNamed:@"ITStatusItem"]];
+    }
+
+    if ( [useInvertedCheckBox state] == NSOnState ) {
+        [statusItem setAlternateImage:[NSImage imageNamed:@"ITStatusItemInv"]];
+    }
+
+    if ( [showTitleCheckBox state] == NSOnState ) {
+        [statusItem setTitle:@"ITStatusItem"];
+    }
+
+    [statusItem setMenu:statusItemMenu];
+}
+
+- (void)removeStatusItem
+{
+    [[statusItem statusBar] removeStatusItem:statusItem];
+    [statusItem autorelease];
+    statusItem = nil;
+}
+
+- (IBAction)toggleStatusItem:(id)sender
+{
+    if ( [sender state] == NSOnState ) {
+        [self createStatusItem];
+        [showImageCheckBox   setEnabled:YES];
+        [showTitleCheckBox   setEnabled:YES];
+        [useInvertedCheckBox setEnabled:YES];
+    } else {
+        [self removeStatusItem];
+        [showImageCheckBox   setEnabled:NO];
+        [useInvertedCheckBox setEnabled:NO];
+        [showTitleCheckBox   setEnabled:NO];
+    }
+}
+
+- (IBAction)toggleImage:(id)sender
+{
+    if ( [sender state] == NSOnState ) {
+        [statusItem setImage:[NSImage imageNamed:@"ITStatusItem"]];
+        [statusItem setAlternateImage:[NSImage imageNamed:@"ITStatusItemInv"]];
+        [useInvertedCheckBox setEnabled:YES];
+        [useInvertedCheckBox setState:NSOnState];
+    } else {
+        [statusItem setImage:nil];
+        [statusItem setAlternateImage:nil];
+        [useInvertedCheckBox setEnabled:NO];
+        [useInvertedCheckBox setState:NSOffState];
+    }
+}
+
+- (IBAction)toggleInvertedImage:(id)sender
+{
+    if ( [sender state] == NSOnState ) {
+        [statusItem setAlternateImage:[NSImage imageNamed:@"ITStatusItemInv"]];
+    } else {
+        [statusItem setAlternateImage:nil];
+    }
+}
+
+- (IBAction)toggleTitle:(id)sender
+{
+    if ( [sender state] == NSOnState ) {
+        [statusItem setTitle:@"ITStatusItem"];
+    } else {
+        [statusItem setTitle:nil];
+    }
+}
+
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark ITTextView SUPPORT
+/*************************************************************************/
+
+- (IBAction)toggleCastsShadow:(id)sender
+{
+    [testTextField setCastsShadow:([sender state] == NSOnState)];
+}
+
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark ITTransientStatusWindow SUPPORT
+/*************************************************************************/
+
+- (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;
+    
+    // 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];
+    [[[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 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];
+}
+
+/*
+- (IBAction)foo:(id)sender
+{
+
+    maxLineHeight = ( ( maxLineHeight > [cdImage size].height ) ? maxLineHeight : [cdImage size].height );
+    
+    totalWidth  = ( ITTSWPADDING + [cdImage size].width + ITTSWSPACING + maxLineWidth + ITTSWPADDING );
+    totalHeight = ( ITTSWPADDING + maxLineHeight + ITTSWPADDING );
+
+    totalWidth  = ( ( totalWidth  > ITTSWMINW ) ? totalWidth  : ITTSWMINW );
+
+
+    [statusWindow setFrame:NSMakeRect(72.0, 72.0, totalWidth, totalHeight)
+                   display:YES];
+
+    textField = [[[ITTextField alloc] initWithFrame:
+        NSMakeRect((24.0 + [cdImage size].width + 32.0), 24.0, maxLineWidth, maxLineHeight)] autorelease];
+    [[statusWindow contentView] addSubview:textField];
+    [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] lockFocus];
+    [cdImage compositeToPoint:NSMakePoint(ITTSWPADDING, ( ITTSWPADDING + ((maxLineHeight - [cdImage size].height) / ITTSWPADDING)) )
+                    operation:NSCompositeSourceOver];
+    [[statusWindow contentView] unlockFocus];
+}
+*/
+
+- (IBAction)showStatusWindow:(id)sender
+{
+//    [[statusWindow contentView] setNeedsDisplay:YES];
+    [statusWindow setFrame:NSMakeRect( (0.0 - NSWidth([statusWindow frame])),
+                                       SW_BORDER,
+                                       NSWidth([statusWindow frame]),
+                                       NSHeight([statusWindow frame]) )
+                   display:YES];
+    [statusWindow orderFront:self];
+    [statusWindow setFrame:NSMakeRect( SW_BORDER,
+                                       SW_BORDER,
+                                       NSWidth([statusWindow frame]),
+                                       NSHeight([statusWindow frame]) )
+                   display:YES
+                   animate:YES];
+}
+
+
+/*************************************************************************/
+#pragma mark -
+#pragma mark NSWindow DELEGATE METHODS
+/*************************************************************************/
+
+- (void)windowWillMiniaturize:(NSNotification *)note
+{
+    [[note object] setMiniwindowImage:[NSImage imageNamed:@"ITStatusItem"]];
+}
+
+
+@end
diff --git a/Showcase/English.lproj/InfoPlist.strings b/Showcase/English.lproj/InfoPlist.strings
new file mode 100755 (executable)
index 0000000..e5fc941
Binary files /dev/null and b/Showcase/English.lproj/InfoPlist.strings differ
diff --git a/Showcase/English.lproj/MainMenu.nib/classes.nib b/Showcase/English.lproj/MainMenu.nib/classes.nib
new file mode 100755 (executable)
index 0000000..d3f715c
--- /dev/null
@@ -0,0 +1,44 @@
+{
+    IBClasses = (
+        {
+            ACTIONS = {
+                buildStatusWindow = id; 
+                showStatusWindow = id; 
+                toggleCastsShadow = id; 
+                toggleImage = id; 
+                toggleInvertedImage = id; 
+                toggleStatusItem = id; 
+                toggleTitle = id; 
+            }; 
+            CLASS = Controller; 
+            LANGUAGE = ObjC; 
+            OUTLETS = {
+                showImageCheckBox = NSButton; 
+                showStatusItemCheckBox = NSButton; 
+                showTitleCheckBox = NSButton; 
+                statusItemMenu = NSMenu; 
+                swBackgroundTypePopup = NSPopUpButton; 
+                swDefinedPositionPopup = NSPopUpButton; 
+                swSampleTextView = NSTextView; 
+                swVanishDelay = NSTextField; 
+                swVanishModePopup = NSPopUpButton; 
+                swVanishOnClick = NSMatrix; 
+                tabView = ITTabView; 
+                testTextField = ITTextField; 
+                useInvertedCheckBox = NSButton; 
+                window = NSWindow; 
+            }; 
+            SUPERCLASS = NSObject; 
+        }, 
+        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
+        {
+            ACTIONS = {start = id; stop = id; }; 
+            CLASS = ITChasingArrowsView; 
+            LANGUAGE = ObjC; 
+            SUPERCLASS = NSView; 
+        }, 
+        {CLASS = ITTabView; LANGUAGE = ObjC; SUPERCLASS = NSTabView; }, 
+        {CLASS = ITTextField; LANGUAGE = ObjC; SUPERCLASS = NSTextField; }
+    ); 
+    IBVersion = 1; 
+}
\ No newline at end of file
diff --git a/Showcase/English.lproj/MainMenu.nib/info.nib b/Showcase/English.lproj/MainMenu.nib/info.nib
new file mode 100755 (executable)
index 0000000..720d8b2
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>IBDocumentLocation</key>
+       <string>3 3 356 240 0 0 1056 770 </string>
+       <key>IBEditorPositions</key>
+       <dict>
+               <key>197</key>
+               <string>69 252 75 120 0 0 1056 770 </string>
+               <key>29</key>
+               <string>38 293 349 44 0 0 1056 770 </string>
+       </dict>
+       <key>IBFramework Version</key>
+       <string>291.0</string>
+       <key>IBOpenObjects</key>
+       <array>
+               <integer>29</integer>
+               <integer>21</integer>
+       </array>
+       <key>IBSystem Version</key>
+       <string>6G26</string>
+</dict>
+</plist>
diff --git a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib
new file mode 100755 (executable)
index 0000000..c45f757
Binary files /dev/null and b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib differ
diff --git a/Showcase/ITStatusItem.tiff b/Showcase/ITStatusItem.tiff
new file mode 100755 (executable)
index 0000000..5ef43e1
Binary files /dev/null and b/Showcase/ITStatusItem.tiff differ
diff --git a/Showcase/ITStatusItemInv.tiff b/Showcase/ITStatusItemInv.tiff
new file mode 100755 (executable)
index 0000000..5d21a11
Binary files /dev/null and b/Showcase/ITStatusItemInv.tiff differ
diff --git a/Showcase/Library.tiff b/Showcase/Library.tiff
new file mode 100755 (executable)
index 0000000..e858cbd
Binary files /dev/null and b/Showcase/Library.tiff differ
diff --git a/Showcase/Radio.tiff b/Showcase/Radio.tiff
new file mode 100755 (executable)
index 0000000..45f7f9a
Binary files /dev/null and b/Showcase/Radio.tiff differ
diff --git a/Showcase/iPod.tif b/Showcase/iPod.tif
new file mode 100755 (executable)
index 0000000..d9b5f75
Binary files /dev/null and b/Showcase/iPod.tif differ
diff --git a/Showcase/main.m b/Showcase/main.m
new file mode 100755 (executable)
index 0000000..20ec715
--- /dev/null
@@ -0,0 +1,14 @@
+//
+//  main.m
+//  ITKitTester
+//
+//  Created by Matt L. Judy on Sat Dec 07 2002.
+//  Copyright (c) 2002 NibFile.com. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+int main(int argc, const char *argv[])
+{
+    return NSApplicationMain(argc, argv);
+}