OMG HUEG COMMIT!!! IT SI LIEK AN XBOX, BECAUES IT SI SO HUEG!! ALL STATUS WINDOW...
authorMatthew Judy <mjudy@ithinksw.com>
Wed, 1 Oct 2003 11:40:42 +0000 (11:40 +0000)
committerMatthew Judy <mjudy@ithinksw.com>
Wed, 1 Oct 2003 11:40:42 +0000 (11:40 +0000)
14 files changed:
English.lproj/Preferences.nib/info.nib
English.lproj/Preferences.nib/keyedobjects.nib
MainController.m
MenuController.m
OldMainController.m
PreferencesController.m
Rating.tiff [new file with mode: 0755]
StatusWindow.h
StatusWindow.m
StatusWindowController.h
StatusWindowController.m
TODO.rtf
iTunesRemote.m
libValidate.a

index 32b0c27..6d64f8c 100755 (executable)
@@ -3,9 +3,9 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>6 66 356 240 0 0 1152 746 </string>
+       <string>5 69 356 240 0 0 1056 770 </string>
        <key>IBFramework Version</key>
-       <string>291.0</string>
+       <string>286.0</string>
        <key>IBGroupedObjects</key>
        <dict>
                <key>0</key>
@@ -25,6 +25,6 @@
                <integer>6</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>6R65</string>
+       <string>6L60</string>
 </dict>
 </plist>
index fada2b3..5587b1e 100755 (executable)
Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ
index 06ae1d9..523936c 100755 (executable)
@@ -36,7 +36,7 @@ static MainController *sharedController;
         sharedController = self;
         
         remoteArray = [[NSMutableArray alloc] initWithCapacity:1];
-        statusWindowController = [[StatusWindowController alloc] init];
+        statusWindowController = [StatusWindowController sharedController];
         menuController = [[MenuController alloc] init];
         df = [[NSUserDefaults standardUserDefaults] retain];
     }
@@ -89,6 +89,8 @@ static MainController *sharedController;
     
     [statusItem setImage:[NSImage imageNamed:@"MenuNormal"]];
     [statusItem setAlternateImage:[NSImage imageNamed:@"MenuInverted"]];
+
+    [NSApp deactivate];
 }
 
 - (ITMTRemote *)loadRemote
@@ -207,7 +209,7 @@ static MainController *sharedController;
         [menuController rebuildSubmenus];
 
         if ( [df boolForKey:@"showSongInfoOnChange"] ) {
-//            [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
+            [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
         }
     }
 }
@@ -493,10 +495,11 @@ static MainController *sharedController;
     NSString               *album       = nil;
     NSString               *artist      = nil;
     NSString               *time        = nil;
-    int                     trackNumber = 0;
-    int                     trackTotal  = 0;
+    NSString               *track       = nil;
     int                     rating      = -1;
+    
     ITDebugLog(@"Showing track info status window.");
+    
     if ( title ) {
 
         if ( [df boolForKey:@"showAlbum"] ) {
@@ -508,15 +511,23 @@ static MainController *sharedController;
         }
 
         if ( [df boolForKey:@"showTime"] ) {
-            time = [currentRemote currentSongLength];
+            time = [NSString stringWithFormat:@"%@: %@ / %@",
+                @"Time",
+                [currentRemote currentSongElapsed],
+                [currentRemote currentSongLength]];
         }
 
-        if ( [df boolForKey:@"showNumber"] ) {
-            trackNumber = [currentRemote currentSongTrack];
-            trackTotal  = [currentRemote currentAlbumTrackCount];
+        if ( [df boolForKey:@"showTrackNumber"] ) {
+            int trackNo    = [currentRemote currentSongTrack];
+            int trackCount = [currentRemote currentAlbumTrackCount];
+            
+            if ( (trackNo > 0) || (trackCount > 0) ) {
+                track = [NSString stringWithFormat:@"%@: %i %@ %i",
+                    @"Track", trackNo, @"of", trackCount];
+            }
         }
 
-        if ( [df boolForKey:@"showRating"] ) {
+        if ( [df boolForKey:@"showTrackRating"] ) {
             rating = ( [currentRemote currentSongRating] * 5 );
         }
         
@@ -529,8 +540,7 @@ static MainController *sharedController;
                                                    album:album
                                                   artist:artist
                                                     time:time
-                                             trackNumber:trackNumber
-                                              trackTotal:trackTotal
+                                                   track:track
                                                   rating:rating];
 }
 
@@ -652,12 +662,12 @@ static MainController *sharedController;
 
 - (void)toggleShuffle
 {
-    bool newShuffleEnabled = ![currentRemote shuffleEnabled];
+    BOOL newShuffleEnabled = ( ! [currentRemote shuffleEnabled] );
     ITDebugLog(@"Toggling shuffle mode.");
     [currentRemote setShuffleEnabled:newShuffleEnabled];
     //Show shuffle status window
     ITDebugLog(@"Setting shuffle mode to %i", newShuffleEnabled);
-    [statusWindowController showRepeatWindowWithMode:newShuffleEnabled];
+    [statusWindowController showShuffleWindow:newShuffleEnabled];
 }
 
 /*************************************************************************/
index 86a65ec..632d45d 100755 (executable)
                     if ([defaults boolForKey:@"showAlbum"]) {
                         NSString *curAlbum = [currentRemote currentSongAlbum];
                         ITDebugLog(@"Add Track Album (\"%@\") menu item.", curAlbum);
-                        if ([curAlbum length]) {
+                        if ( curAlbum ) {
                             [menu indentItem:
                                 [menu addItemWithTitle:curAlbum action:nil keyEquivalent:@""]];
                         }
                     if ([defaults boolForKey:@"showArtist"]) {
                         NSString *curArtist = [currentRemote currentSongArtist];
                         ITDebugLog(@"Add Track Artist (\"%@\") menu item.", curArtist);
-                        if ([curArtist length]) {
+                        if ( curArtist ) {
                             [menu indentItem:
                                 [menu addItemWithTitle:curArtist action:nil keyEquivalent:@""]];
                         }
                     if ([defaults boolForKey:@"showTrackNumber"]) {
                         int track = [currentRemote currentSongTrack];
                         ITDebugLog(@"Add Track Number (\"Track %i\") menu item.", track);
-                        if (track) {
+                        if ( track ) {
                             [menu indentItem:
                                 [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %i", NSLocalizedString(@"track", @"Track"), track] action:nil keyEquivalent:@""]];
                         }
index 87d184e..0ade694 100755 (executable)
             
             if ([defaults boolForKey:@"showAlbum"]) {
                 NSString *album = [currentRemote currentSongAlbum];
-                if ([album length] > 0) {
+                if ( album ) {
                     [menu insertItemWithTitle:[NSString stringWithFormat:@"  %@", album] action:nil keyEquivalent:@"" atIndex:trackInfoIndex + 1];
                 }
             }
         
         if ([defaults boolForKey:@"showAlbum"]) {
             NSString *trackAlbum = [currentRemote currentSongAlbum];
-            if ([trackAlbum length]) {
+            if ( trackAlbum ) {
                 stringToShow = [stringToShow stringByAppendingString:trackAlbum];
                 stringToShow = [stringToShow stringByAppendingString:@"\n"];
             }
index b827375..590e6de 100755 (executable)
@@ -1,6 +1,7 @@
 #import "PreferencesController.h"
 #import "MainController.h"
 #import "StatusWindow.h"
+#import "StatusWindowController.h"
 #import "CustomMenuTableView.h"
 
 #import <ITKit/ITHotKeyCenter.h>
@@ -105,9 +106,10 @@ static PreferencesController *prefs = nil;
         //Change the launch player checkbox to the proper name
         [launchPlayerAtLaunchCheckbox setTitle:[NSString stringWithFormat:@"Launch %@ when MenuTunes launches", [[controller currentRemote] playerSimpleName]]]; //This isn't localized...
     }
-    [window setLevel:NSStatusWindowLevel];
+
     [window center];
-    [window makeKeyAndOrderFront:self];
+    [NSApp activateIgnoringOtherApps:YES];
+    [window performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.0];
 }
 
 - (IBAction)changeGeneralSetting:(id)sender
@@ -308,12 +310,26 @@ static PreferencesController *prefs = nil;
     [loginWindow release];
     
     if (!found) {
-        if (NSRunInformationalAlertPanel(NSLocalizedString(@"autolaunch", @"Auto-launch MenuTunes"), NSLocalizedString(@"autolaunch_msg", @"Would you like MenuTunes to automatically launch at login?"), @"Yes", @"No", nil) == NSOKButton) {
-            [self setLaunchesAtLogin:YES];
-        }
+        [[StatusWindowController sharedController] showSetupQueryWindow];
     }
 }
 
+- (void)autoLaunchOK
+{
+    [[StatusWindow sharedWindow] setLocked:NO];
+    [[StatusWindow sharedWindow] vanish:self];
+    [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
+    
+    [self setLaunchesAtLogin:YES];
+}
+
+- (void)autoLaunchCancel
+{
+    [[StatusWindow sharedWindow] setLocked:NO];
+    [[StatusWindow sharedWindow] vanish:self];
+    [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
+}
+
 - (IBAction)cancelHotKey:(id)sender
 {
     ITDebugLog(@"Hot key canceled.");
diff --git a/Rating.tiff b/Rating.tiff
new file mode 100755 (executable)
index 0000000..1f875c3
Binary files /dev/null and b/Rating.tiff differ
index 6e72123..8432e05 100755 (executable)
 #import <ITKit/ITKit.h>
 
 
-#define SW_PAD        24.0
-#define SW_SPACE      24.0
-#define SW_MINW      211.0
-#define SW_BORDER     32.0
-#define SW_METER_PAD   4.0
-
+#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
 
 @interface StatusWindow : ITTransientStatusWindow {
     NSImage  *_image;
@@ -33,6 +37,7 @@
 
 - (void)buildTextWindowWithString:(NSString *)text;
 - (void)buildMeterWindowWithCharacter:(NSString *)character
+                                 size:(float)size
                                 count:(int)count
                                active:(int)active;
 - (void)buildDialogWindowWithMessage:(NSString *)message
index 5e1bcfd..0a1ba7f 100755 (executable)
@@ -8,12 +8,15 @@
 
 #import "StatusWindow.h"
 
+
 @interface StatusWindow (Private)
 - (NSRect)setupWindowWithDataSize:(NSSize)dataSize;
 @end
 
+
 @implementation StatusWindow
 
+
 /*************************************************************************/
 #pragma mark -
 #pragma mark INITIALIZATION / DEALLOCATION METHODS
@@ -55,6 +58,7 @@
 - (void)setLocked:(BOOL)flag
 {
     _locked = flag;
+    [self setExitMode:(flag ? ITTransientStatusWindowExitOnCommand : ITTransientStatusWindowExitAfterDelay)];
 }
 
 
 #pragma mark INSTANCE METHODS
 /*************************************************************************/
 
+- (void)appear:(id)sender
+{
+    if ( ! _locked ) {
+        [super appear:sender];
+    }
+}
+
+- (void)vanish:(id)sender
+{
+    if ( ! _locked ) {
+        [super vanish:sender];
+    }
+}
+
 - (NSRect)setupWindowWithDataSize:(NSSize)dataSize
 {
     NSRect       imageRect;
 
 - (void)buildTextWindowWithString:(NSString *)text
 {
-    float         dataWidth     = 0.0;
-    float         dataHeight    = 0.0;
-    NSRect        dataRect;
-    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];
-    ITTextField  *textField;
-    
-//  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 );
-    }
+    if ( ! _locked ) {
+
+        float         dataWidth     = 0.0;
+        float         dataHeight    = 0.0;
+        NSRect        dataRect;
+        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];
+        ITTextField  *textField;
         
-//  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 setEditable:NO];
-    [textField setSelectable:NO];
-    [textField setBordered:NO];
-    [textField setDrawsBackground:NO];
-    [textField setFont:font];
-    [textField setTextColor:[NSColor whiteColor]];
-    [textField setCastsShadow:YES];
-    [textField setStringValue:text];
-    [[self contentView] addSubview:textField];
-    
-//  Display the window.
-    [[self contentView] setNeedsDisplay:YES];
+//      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 setEditable:NO];
+        [textField setSelectable:NO];
+        [textField setBordered:NO];
+        [textField setDrawsBackground:NO];
+        [textField setFont:font];
+        [textField setTextColor:[NSColor whiteColor]];
+        [textField setCastsShadow:YES];
+        [textField setStringValue:text];
+        [textField setShadowSaturation:SW_SHADOW_SAT];
+        [[self contentView] addSubview:textField];
+        
+//      Display the window.
+        [[self contentView] setNeedsDisplay:YES];
+
+    }
 }
 
 - (void)buildMeterWindowWithCharacter:(NSString *)character
+                                 size:(float)size
                                 count:(int)count
                                active:(int)active
 {
-    NSFont       *font        = [NSFont fontWithName:@"Lucida Grande Bold" size:18];
-    NSDictionary *attr        = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
-    NSSize        charSize    = [character sizeWithAttributes:attr];
-    float         cellHeight  = ( charSize.height + 4.0 );                 // Add 4.0 for shadow
-    float         cellWidth   = ( (charSize.width) + SW_METER_PAD ); // Add 8.0 for Apple suck
-    float         dataWidth   = ( cellWidth * count );
-    NSRect        dataRect    = [self setupWindowWithDataSize:NSMakeSize(dataWidth, cellHeight)];
-    NSEnumerator *cellEnum    = nil;
-    id            aCell       = nil;
-    int           activeCount = 0;
-    NSColor      *onColor     = [NSColor whiteColor];
-    NSColor      *offColor    = [NSColor colorWithCalibratedWhite:0.0 alpha:0.50];
-    NSMatrix     *volMatrix   = [[[NSMatrix alloc] initWithFrame:dataRect
-                                                            mode:NSHighlightModeMatrix
-                                                       cellClass:NSClassFromString(@"ITTextFieldCell")
-                                                    numberOfRows:1
-                                                 numberOfColumns:count] autorelease];
-
-    [volMatrix setCellSize:NSMakeSize(cellWidth, cellHeight)];
-    [volMatrix setIntercellSpacing:NSMakeSize(0, 0)];
-
-    cellEnum = [[volMatrix cells] objectEnumerator];
-
-    while ( (aCell = [cellEnum nextObject]) ) {
-        [aCell setEditable:NO];
-        [aCell setSelectable:NO];
-        [aCell setBordered:NO];
-        [aCell setDrawsBackground:NO];
-        [aCell setAlignment:NSCenterTextAlignment];
-        [aCell setFont:font];
-        [aCell setStringValue:character];
-
-        activeCount ++;
-        
-        if ( active >= activeCount ) {
-            [aCell setCastsShadow:YES];
-            [aCell setTextColor:onColor];
-        } else {
-            [aCell setCastsShadow:NO];
-            [aCell setTextColor:offColor];
+    if ( ! _locked ) {
+
+        NSFont       *font        = [NSFont fontWithName:@"Lucida Grande Bold" size:size];
+        NSDictionary *attr        = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
+        NSSize        charSize    = [character sizeWithAttributes:attr];
+        float         cellHeight  = ( charSize.height + 4.0 );                 // Add 4.0 for shadow
+        float         cellWidth   = ( (charSize.width) + SW_METER_PAD ); // Add 8.0 for Apple suck
+        float         dataWidth   = ( cellWidth * count );
+        NSRect        dataRect    = [self setupWindowWithDataSize:NSMakeSize(dataWidth, cellHeight)];
+        NSEnumerator *cellEnum    = nil;
+        id            aCell       = nil;
+        int           activeCount = 0;
+        NSColor      *onColor     = [NSColor whiteColor];
+        NSColor      *offColor    = [NSColor colorWithCalibratedWhite:0.0 alpha:0.50];
+        NSMatrix     *volMatrix   = [[[NSMatrix alloc] initWithFrame:dataRect
+                                                                mode:NSHighlightModeMatrix
+                                                           cellClass:NSClassFromString(@"ITTextFieldCell")
+                                                        numberOfRows:1
+                                                     numberOfColumns:count] autorelease];
+
+        [volMatrix setCellSize:NSMakeSize(cellWidth, cellHeight)];
+        [volMatrix setIntercellSpacing:NSMakeSize(0, 0)];
+
+        cellEnum = [[volMatrix cells] objectEnumerator];
+
+        while ( (aCell = [cellEnum nextObject]) ) {
+            [aCell setEditable:NO];
+            [aCell setSelectable:NO];
+            [aCell setBordered:NO];
+            [aCell setDrawsBackground:NO];
+            [aCell setAlignment:NSCenterTextAlignment];
+            [aCell setFont:font];
+            [aCell setStringValue:character];
+            [aCell setShadowSaturation:SW_SHADOW_SAT];
+
+            activeCount ++;
+
+            if ( active >= activeCount ) {
+                [aCell setCastsShadow:YES];
+                [aCell setTextColor:onColor];
+            } else {
+                [aCell setCastsShadow:NO];
+                [aCell setTextColor:offColor];
+            }
+
         }
+
+        [[self contentView] addSubview:volMatrix];
+        [[self contentView] setNeedsDisplay:YES];
         
     }
-
-    [[self contentView] addSubview:volMatrix];
-    [[self contentView] setNeedsDisplay:YES];
 }
 
 - (void)buildDialogWindowWithMessage:(NSString *)message
                        defaultAction:(SEL)okAction
                      alternateAction:(SEL)alternateAction
 {
+    if ( ! _locked ) {
+
+        float         textWidth     = 0.0;
+        float         textHeight    = 0.0;
+        float         okWidth       = 0.0;
+        float         cancelWidth   = 0.0;
+        float         wideButtonW   = 0.0;
+        float         buttonWidth   = 0.0;
+        float         dataHeight    = 0.0;
+        float         dataWidth     = 0.0;
+        NSRect        dataRect;
+        float         textY         = 0.0;
+        NSRect        textRect;
+        float         textAddBelow  = 32.0;
+        float         dataMinH      = 92.0;
+        float         textMinH      = 48.0;
+        NSArray      *lines         = [message componentsSeparatedByString:@"\n"];
+        id                       oneLine       = nil;
+        NSEnumerator *lineEnum      = [lines objectEnumerator];
+        ITTextField  *textField;
+        ITButton     *okButton;
+        ITButton     *cancelButton;
+        NSColor      *textColor     = [NSColor whiteColor];
+        NSFont       *font          = [NSFont fontWithName:@"Lucida Grande Bold" size:18];
+        NSDictionary *attr          = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
+        NSFont       *buttonFont    = [NSFont fontWithName:@"Lucida Grande Bold" size:14];
+        NSDictionary *buttonAttr    = [NSDictionary dictionaryWithObjectsAndKeys:
+            buttonFont , NSFontAttributeName,
+            textColor  , NSForegroundColorAttributeName, 
+            nil];
+        
+//      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 dataHeight to accomodate the shadow.
+        textHeight += 4.0;
+        
+//      Add extra padding below the text
+        dataHeight = (textHeight + textAddBelow);
+        
+//      Test to see if data height is tall enough
+        if ( dataHeight < dataMinH ) {
+            dataHeight = dataMinH;
+        }
+        
+//      Make the buttons, set the titles, and size them to fit their titles
+        okButton     = [[ITButton alloc] initWithFrame:NSMakeRect(0, 0, 300, 24)];
+        cancelButton = [[ITButton alloc] initWithFrame:NSMakeRect(0, 0, 300, 24)];
+        [okButton     setBezelStyle:ITGrayRoundedBezelStyle];
+        [cancelButton setBezelStyle:ITGrayRoundedBezelStyle];
+        [okButton     setAlignment:NSRightTextAlignment];
+        [cancelButton setAlignment:NSCenterTextAlignment];
+        [okButton     setImagePosition:NSNoImage];
+        [cancelButton setImagePosition:NSNoImage];
+        [okButton     setAttributedTitle:[[[NSAttributedString alloc] initWithString:defaultTitle
+                                                                          attributes:buttonAttr] autorelease]];
+        [cancelButton setAttributedTitle:[[[NSAttributedString alloc] initWithString:alternateTitle
+                                                                          attributes:buttonAttr] autorelease]];
+        [okButton     sizeToFit];
+        [cancelButton sizeToFit];
+        
+//      Get the button widths.  Add any extra width here.
+        okWidth     = ([okButton     frame].size.width + SW_BUTTON_EXTRA_W);
+        cancelWidth = ([cancelButton frame].size.width + SW_BUTTON_EXTRA_W);
+        
+//      Figure out which button is wider.
+        wideButtonW = ( (okWidth > cancelWidth) ? okWidth : cancelWidth );
+
+//      Get the total width of the buttons. Add the divider space.
+        buttonWidth = ( (wideButtonW * 2) + SW_BUTTON_DIV );
 
+//      Set the dataWidth to whichever is greater: text width or button width.
+        dataWidth = ( (textWidth > buttonWidth) ? textWidth : buttonWidth);
+        
+//      Setup the window
+        dataRect = [self setupWindowWithDataSize:NSMakeSize(dataWidth, dataHeight)];
+        
+//      Set an initial vertical point for the textRect's origin.
+        textY = dataRect.origin.y + textAddBelow;
+        
+//      Move that point up if the minimimum height of the text area is not occupied.
+        if ( textHeight < textMinH ) {
+            textY += ( (textMinH - textHeight) / 2 );
+        }
+        
+//      Build the text rect.
+        textRect = NSMakeRect(dataRect.origin.x,
+                              textY,
+                              textWidth,
+                              textHeight);
+        
+//      Create, position, setup, fill, and add the text view to the content view.
+        textField = [[[ITTextField alloc] initWithFrame:textRect] autorelease];
+        [textField setEditable:NO];
+        [textField setSelectable:NO];
+        [textField setBordered:NO];
+        [textField setDrawsBackground:NO];
+        [textField setFont:font];
+        [textField setTextColor:textColor];
+        [textField setCastsShadow:YES];
+        [textField setStringValue:message];
+        [textField setShadowSaturation:SW_SHADOW_SAT];
+        [[self contentView] addSubview:textField];
+        
+//      Set the button frames, and add them to the content view.
+        [okButton setFrame:NSMakeRect( ([[self contentView] frame].size.width - (wideButtonW + SW_BUTTON_PAD_R) ),
+                                       SW_BUTTON_PAD_B,
+                                       wideButtonW,
+                                       24.0)];
+        [cancelButton setFrame:NSMakeRect( ([[self contentView] frame].size.width - ((wideButtonW * 2) + SW_BUTTON_DIV + SW_BUTTON_PAD_R) ),
+                                           SW_BUTTON_PAD_B,
+                                           wideButtonW,
+                                           24.0)];
+        [[self contentView] addSubview:okButton];
+        [[self contentView] addSubview:cancelButton];
+        NSLog(@"%@", [[self contentView] description]);
+
+        [self setIgnoresMouseEvents:NO];
+  
+//      Display the window.
+        [[self contentView] setNeedsDisplay:YES];
+    }
 }
 
 
index 2cf440b..01f36f3 100755 (executable)
@@ -20,9 +20,9 @@
 
 
 typedef enum {
-    StatusWindowRepeatNone,
+    StatusWindowRepeatNone = -1,
     StatusWindowRepeatGroup,
-    StatusWindowRepeatSong
+    StatusWindowRepeatTrack
 } StatusWindowRepeatMode;
 
 
@@ -31,10 +31,12 @@ typedef enum {
     NSUserDefaults *df;
 }
 
++ (StatusWindowController *)sharedController;
+
 - (void)showUpcomingSongsWindowWithTitles:(NSArray *)titleStrings;
 
 - (void)showVolumeWindowWithLevel:(float)level;
-- (void)showRatingWindowWithRating:(int)rating;
+- (void)showRatingWindowWithRating:(float)rating;
 - (void)showShuffleWindow:(BOOL)shuffle;
 - (void)showRepeatWindowWithMode:(StatusWindowRepeatMode)mode;
 - (void)showSetupQueryWindow;
@@ -43,9 +45,8 @@ typedef enum {
                                title:            (NSString *)title
                                album:            (NSString *)album
                               artist:            (NSString *)artist
-                                time:            (NSString *)time
-                         trackNumber:                   (int)trackNumber
-                          trackTotal:                      (int)trackTotal
+                                time:            (NSString *)time  // FLOW: Should probably be NSDate or something.
+                               track:            (NSString *)track
                               rating:                   (int)rating;
 
 
index 49cbf89..e8b1eef 100755 (executable)
@@ -1,13 +1,6 @@
-//
-//  StatusWindowController.m
-//  MenuTunes
-//
-//  Created by Matthew L. Judy on Thu Apr 17 2003.
-//  Copyright (c) 2003 NibFile.com. All rights reserved.
-//
-
 #import "StatusWindowController.h"
 #import "StatusWindow.h"
+#import "PreferencesController.h"
 
 #import <ITKit/ITWindowEffect.h>
 #import <ITKit/ITCutWindowEffect.h>
@@ -16,9 +9,23 @@
 #import <ITKit/ITSlideVerticallyWindowEffect.h>
 #import <ITKit/ITPivotWindowEffect.h>
 
+
+static StatusWindowController *sharedController;
+
+
 @implementation StatusWindowController
 
 
++ (StatusWindowController *)sharedController
+{
+    if ( ! sharedController ) {
+        sharedController = [[StatusWindowController alloc] init];
+    }
+    
+    return sharedController;
+}
+
+
 - (id)init
 {
     if ( ( self = [super init] ) ) {
                                album:            (NSString *)album
                               artist:            (NSString *)artist
                                 time:            (NSString *)time  // FLOW: Should probably be NSDate or something.
-                         trackNumber:                   (int)trackNumber
-                          trackTotal:                      (int)trackTotal
+                               track:            (NSString *)track
                               rating:                   (int)rating
 {
-    [_window setImage:[NSImage imageNamed:@"Library"]];
-    [_window buildTextWindowWithString:title];
+    NSImage  *image = nil;
+    NSString *text  = title;
+    
+    if ( source == ITMTRemoteLibrarySource ) {
+        image = [NSImage imageNamed:@"Library"];
+    } else if ( source == ITMTRemoteCDSource ) {
+        image = [NSImage imageNamed:@"CD"];
+    } else if ( source == ITMTRemoteRadioSource ) {
+        image = [NSImage imageNamed:@"Radio"];
+    } else if ( source == ITMTRemoteiPodSource ) {
+        image = [NSImage imageNamed:@"iPod"];
+    } else if ( source == ITMTRemoteGenericDeviceSource ) {
+        image = [NSImage imageNamed:@"MP3Player"];
+    } else if ( source == ITMTRemoteSharedLibrarySource ) {
+        image = [NSImage imageNamed:@"Library"];
+    }
+
+    [_window setImage:image];
+
+    if ( album ) {
+        text = [text stringByAppendingString:[@"\n" stringByAppendingString:album]];
+    }
+    if ( artist ) {
+        text = [text stringByAppendingString:[@"\n" stringByAppendingString:artist]];
+    }
+    if ( time ) {
+        text = [text stringByAppendingString:[@"\n" stringByAppendingString:time]];
+    }
+    if ( track ) {
+        text = [text stringByAppendingString:[@"\n" stringByAppendingString:track]];
+    }
+    if ( rating > -1 ) {
+
+        NSString *ratingString = [NSString string];
+        NSString *emptyChar    = [NSString stringWithUTF8String:"☆"];
+        NSString *fullChar     = [NSString stringWithUTF8String:"★"];
+        int       i;
+        
+        for ( i = 1; i < 6; i++ ) {
+               
+            if ( rating >= i ) {
+                ratingString = [ratingString stringByAppendingString:fullChar];
+            } else {
+                ratingString = [ratingString stringByAppendingString:emptyChar];
+            }
+        }
+    
+        text = [text stringByAppendingString:[@"\n" stringByAppendingString:ratingString]];
+    }
+    
+    [_window buildTextWindowWithString:text];
     [_window appear:self];
 }
 
 - (void)showUpcomingSongsWindowWithTitles:(NSArray *)titleStrings
 {
-
+//  NSString *bull = [NSString stringWithUTF8String:"‣ "];
+    NSString *bull = [NSString stringWithUTF8String:"♪ "];
+    NSString *end  = [@"\n" stringByAppendingString:bull];
+    [_window setImage:[NSImage imageNamed:@"Upcoming"]];
+    [_window buildTextWindowWithString:[bull stringByAppendingString:[titleStrings componentsJoinedByString:end]]];
+    [_window appear:self];
 }
 
 - (void)showVolumeWindowWithLevel:(float)level
 {
     [_window setImage:[NSImage imageNamed:@"Volume"]];
     [_window buildMeterWindowWithCharacter:[NSString stringWithUTF8String:"▊"]
+                                      size:18
                                      count:10
                                     active:( ceil(level * 100) / 10 )];
     [_window appear:self];
 }
 
-- (void)showRatingWindowWithRating:(int)rating
+- (void)showRatingWindowWithRating:(float)rating
 {
-
+    [_window setImage:[NSImage imageNamed:@"Rating"]];
+    [_window buildMeterWindowWithCharacter:[NSString stringWithUTF8String:"★"]
+                                      size:48
+                                     count:5
+                                    active:( ceil(rating * 100) / 20 )];
+    [_window appear:self];
 }
 
 - (void)showShuffleWindow:(BOOL)shuffle
 {
-
+    [_window setImage:[NSImage imageNamed:@"Shuffle"]];
+    [_window buildTextWindowWithString:( shuffle ? @"Shuffle On" : @"Shuffle Off")];
+    [_window appear:self];
 }
 
 - (void)showRepeatWindowWithMode:(StatusWindowRepeatMode)mode
 {
-
+    NSString *string = nil;
+    
+    if ( mode == StatusWindowRepeatNone ) {
+        string = @"Repeat Off";
+    } else if ( mode == StatusWindowRepeatGroup ) {
+        string = @"Repeat Playlist";
+    } else if ( mode == StatusWindowRepeatTrack ) {
+        string = @"Repeat One Track";
+    }
+    
+    [_window setImage:[NSImage imageNamed:@"Repeat"]];
+    [_window buildTextWindowWithString:string];
+    [_window appear:self];
 }
 
 - (void)showSetupQueryWindow
 {
+    NSString *message = @"Would you like MenuTunes to launch\nautomatically at startup?";
 
+    [_window setImage:[NSImage imageNamed:@"Setup"]];
+    [_window buildDialogWindowWithMessage:message
+                            defaultButton:@"Launch at Startup"
+                          alternateButton:@"Launch Manually"
+                                   target:[PreferencesController sharedPrefs]
+                            defaultAction:@selector(autoLaunchOK)
+                          alternateAction:@selector(autoLaunchCancel)];
+
+    [_window appear:self];
+    [_window setLocked:YES];
 }
 
 
index f73d332..86e1598 100755 (executable)
--- a/TODO.rtf
+++ b/TODO.rtf
       Status: Analyze\
        Issue: iTunesRemote - Toggle loop and shuffle do not work.\
 \
-    Priority: IMPORTANT\
-       Owner: Joseph Spiros\
-      Status: Analyze\
-       Issue: Menu - Needs to show "Space" as the key equivalent.\
-\pard\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\ql\qnatural
-\cf0 \
 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
 \cf0 \
 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
@@ -78,4 +72,10 @@ No entries yet.\
        Issue: Upcoming Songs - should show the last <preference> songs played.\
 \pard\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\ql\qnatural
 \cf0 \
+\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
+\cf0     Priority: FUTURE\
+      Status: Analyze\
+       Issue: Menu - Needs to show "Space" as the key equivalent.\
+\pard\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\ql\qnatural
+\cf0 \
 }
\ No newline at end of file
index c00d5fa..cb976a6 100755 (executable)
     ITDebugLog(@"Getting song title at index %i.", index);
     temp1 = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cTrk'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }",index] eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
     ITDebugLog(@"Getting song title at index %i done.", index);
-    return temp1;
+    return ( ([temp1 length]) ? temp1 : nil ) ;
 }
 
 - (int)currentAlbumTrackCount
     ITDebugLog(@"Getting current unique identifier.");
     temp1 = [NSString stringWithFormat:@"%i-%i", [self currentPlaylistIndex], [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pDID" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN]];
     ITDebugLog(@"Getting current unique identifier done.");
-    return temp1;
+    return ( ([temp1 length]) ? temp1 : nil ) ;
 }
 
 - (int)currentSongIndex
     ITDebugLog(@"Getting current song title.");
     temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pnam" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
     ITDebugLog(@"Getting current song title done.");
-    return temp1;
+    return ( ([temp1 length]) ? temp1 : nil ) ;
 }
 
 - (NSString *)currentSongArtist
     ITDebugLog(@"Getting current song artist.");
     temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pArt" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
     ITDebugLog(@"Getting current song artist done.");
-    return temp1;
+    return ( ([temp1 length]) ? temp1 : nil ) ;
 }
 
 - (NSString *)currentSongAlbum
     ITDebugLog(@"Getting current song album.");
     temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pAlb" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
     ITDebugLog(@"Getting current song album done.");
-    return temp1;
+    return ( ([temp1 length]) ? temp1 : nil ) ;
 }
 
 - (NSString *)currentSongGenre
     ITDebugLog(@"Getting current song genre.");
     temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pGen" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
     ITDebugLog(@"Getting current song genre done.");
-    return temp1;
+    return ( ([temp1 length]) ? temp1 : nil ) ;
 }
 
 - (NSString *)currentSongLength
index d2a54bb..2b0cd4b 100755 (executable)
Binary files a/libValidate.a and b/libValidate.a differ