Revision: 5819
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5819&view=rev
Author:   hofman
Date:     2009-09-27 11:52:32 +0000 (Sun, 27 Sep 2009)

Log Message:
-----------
show note type icon in status bar of note edit window

Modified Paths:
--------------
    trunk/SKNoteWindowController.m
    trunk/SKStatusBar.h
    trunk/SKStatusBar.m

Modified: trunk/SKNoteWindowController.m
===================================================================
--- trunk/SKNoteWindowController.m      2009-09-27 11:15:37 UTC (rev 5818)
+++ trunk/SKNoteWindowController.m      2009-09-27 11:52:32 UTC (rev 5819)
@@ -177,8 +177,12 @@
         [[self window] setFrame:frame display:NO];
     }
     
+    SKAnnotationTypeImageCell *cell = [[[SKAnnotationTypeImageCell alloc] 
initImageCell:nil] autorelease];
+    [cell setObjectValue:[NSDictionary dictionaryWithObjectsAndKeys:[note 
type], SKAnnotationTypeImageCellTypeKey, nil]];
+    
     [statusBar setLeftAction:@selector(statusBarClicked:)];
     [statusBar setLeftTarget:self];
+    [statusBar setIconCell:cell];
     
     [self updateStatusMessage];
     

Modified: trunk/SKStatusBar.h
===================================================================
--- trunk/SKStatusBar.h 2009-09-27 11:15:37 UTC (rev 5818)
+++ trunk/SKStatusBar.h 2009-09-27 11:52:32 UTC (rev 5819)
@@ -49,6 +49,7 @@
 @interface SKStatusBar : NSControl {
        id leftCell;
        id rightCell;
+    id iconCell;
        NSProgressIndicator *progressIndicator;
     NSTrackingRectTag leftTrackingRectTag;
     NSTrackingRectTag rightTrackingRectTag;
@@ -97,6 +98,9 @@
 - (NSFont *)font;
 - (void)setFont:(NSFont *)fontObject;
 
+- (id)iconCell;
+- (void)setIconCell:(id)newIconCell;
+
 - (NSProgressIndicator *)progressIndicator;
 
 - (SKProgressIndicatorStyle)progressIndicatorStyle;

Modified: trunk/SKStatusBar.m
===================================================================
--- trunk/SKStatusBar.m 2009-09-27 11:15:37 UTC (rev 5818)
+++ trunk/SKStatusBar.m 2009-09-27 11:52:32 UTC (rev 5819)
@@ -44,6 +44,7 @@
 #define SEPARATION          2.0
 #define VERTICAL_OFFSET     1.0
 #define PROGRESSBAR_WIDTH   100.0
+#define ICON_HEIGHT_OFFSET  2.0
 
 
 @interface SKStatusTextFieldCell : NSTextFieldCell {
@@ -84,6 +85,7 @@
         [rightCell setAlignment:NSRightTextAlignment];
         [rightCell setControlView:self];
         [rightCell setBackgroundStyle:NSBackgroundStyleRaised];
+        iconCell = nil;
                progressIndicator = nil;
         leftTrackingRectTag = 0;
         rightTrackingRectTag = 0;
@@ -94,6 +96,7 @@
 - (void)dealloc {
        [leftCell release];
        [rightCell release];
+       [iconCell release];
        [super dealloc];
 }
 
@@ -105,10 +108,13 @@
     CGFloat leftWidth = [[leftCell stringValue] length] ? [leftCell 
cellSize].width : 0.0;
     CGFloat rightWidth = [[rightCell stringValue] length] ? [rightCell 
cellSize].width : 0.0;
     NSRect ignored, rect = [self bounds];
+    CGFloat leftMargin = LEFT_MARGIN;
     CGFloat rightMargin = RIGHT_MARGIN;
+    if (iconCell)
+        leftMargin += NSHeight([self bounds]) - ICON_HEIGHT_OFFSET + 
SEPARATION;
     if (progressIndicator)
         rightMargin += NSWidth([progressIndicator frame]) + SEPARATION;
-    NSDivideRect(rect, &ignored, &rect, LEFT_MARGIN, NSMinXEdge);
+    NSDivideRect(rect, &ignored, &rect, leftMargin, NSMinXEdge);
     NSDivideRect(rect, &ignored, &rect, rightMargin, NSMaxXEdge);
     if (rightFrame != NULL)
         NSDivideRect(rect, rightFrame, &ignored, rightWidth, NSMaxXEdge);
@@ -122,13 +128,17 @@
     
     [gradient drawInRect:bounds angle:90.0];
     
-    NSRect textRect, ignored;
+    NSRect textRect, iconRect, ignored;
     CGFloat rightMargin = RIGHT_MARGIN;
+    CGFloat iconHeight = NSHeight(bounds) - ICON_HEIGHT_OFFSET;
     
     if (progressIndicator)
         rightMargin += NSWidth([progressIndicator frame]) + SEPARATION;
     NSDivideRect(bounds, &ignored, &textRect, LEFT_MARGIN, NSMinXEdge);
-    NSDivideRect(textRect, &ignored, &textRect, rightMargin, NSMaxXEdge);
+    if (iconCell) {
+        NSDivideRect(textRect, &iconRect, &textRect, iconHeight, NSMinXEdge);
+        NSDivideRect(textRect, &ignored, &textRect, SEPARATION, NSMaxXEdge);
+    }
        
        if (textRect.size.width < 0.0)
                textRect.size.width = 0.0;
@@ -139,6 +149,12 @@
     
        [leftCell drawWithFrame:textRect inView:self];
        [rightCell drawWithFrame:textRect inView:self];
+    
+    if (iconCell) {
+        iconRect = SKCenterRectVertically(iconRect, iconHeight, NO);
+        iconRect.origin.y += VERTICAL_OFFSET;
+        [iconCell drawWithFrame:iconRect inView:self];
+    }
 }
 
 - (BOOL)isVisible {
@@ -315,6 +331,19 @@
     [self setRightState:newState];
 }
 
+- (id)iconCell {
+    return iconCell;
+}
+
+- (void)setIconCell:(id)newIconCell {
+    if (iconCell != newIconCell) {
+        [iconCell release];
+        iconCell = [newIconCell retain];
+        [[self superview] setNeedsDisplayInRect:[self frame]];
+        [self resetCursorRects];
+    }
+}
+
 #pragma mark Progress indicator
 
 - (NSProgressIndicator *)progressIndicator {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to