Revision: 7487
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7487&view=rev
Author:   hofman
Date:     2011-09-10 12:09:15 +0000 (Sat, 10 Sep 2011)
Log Message:
-----------
use textfieldcell for drawing background of linewell and fontwell, so we get a 
consistent look also on Lion

Modified Paths:
--------------
    trunk/SKFontWell.h
    trunk/SKFontWell.m
    trunk/SKLineWell.h
    trunk/SKLineWell.m

Modified: trunk/SKFontWell.h
===================================================================
--- trunk/SKFontWell.h  2011-09-09 13:13:27 UTC (rev 7486)
+++ trunk/SKFontWell.h  2011-09-10 12:09:15 UTC (rev 7487)
@@ -63,6 +63,7 @@
 
 
 @interface SKFontWellCell : NSButtonCell {
+    NSTextFieldCell *bgCell;
     NSColor *textColor;
     BOOL hasTextColor;
 }

Modified: trunk/SKFontWell.m
===================================================================
--- trunk/SKFontWell.m  2011-09-09 13:13:27 UTC (rev 7486)
+++ trunk/SKFontWell.m  2011-09-10 12:09:15 UTC (rev 7487)
@@ -441,6 +441,8 @@
 @synthesize textColor, hasTextColor;
 
 - (void)commonInit {
+    bgCell = [[NSTextFieldCell alloc] initTextCell:@""];
+    [bgCell setBezeled:YES];
     if (textColor == nil)
         [self setTextColor:[NSColor blackColor]];
     [self setBezelStyle:NSShadowlessSquareBezelStyle]; // this is mainly to 
make it selectable
@@ -473,33 +475,23 @@
 }
 
 - (void)dealloc {
+    SKDESTROY(bgCell);
     SKDESTROY(textColor);
     [super dealloc];
 }
 
 - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView *)controlView {
-    [NSGraphicsContext saveGraphicsState];
+    [bgCell drawWithFrame:frame inView:controlView];
     
-    NSColor *bgColor = [self state] == NSOnState ? [NSColor 
selectedControlColor] : [NSColor controlBackgroundColor];
-    NSColor *edgeColor = [NSColor colorWithCalibratedWhite:0 alpha:[self 
isHighlighted] ? 0.33 : .11];
-    
-    [bgColor setFill];
-    NSRectFill(frame);
-    
-    [edgeColor setStroke];
-    [[NSBezierPath bezierPathWithRect:NSInsetRect(frame, 0.5, 0.5)] stroke];
-    
-    NSBezierPath *path = [NSBezierPath bezierPathWithRect:frame];
-    [path appendBezierPathWithRect:NSInsetRect(frame, -2.0, -2.0)];
-    [path setWindingRule:NSEvenOddWindingRule];
-    NSShadow *shadow1 = [[NSShadow new] autorelease];
-    [shadow1 setShadowBlurRadius:2.0];
-    [shadow1 setShadowOffset:NSMakeSize(0.0, -1.0)];
-    [shadow1 setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.7]];
-    [shadow1 set];
-    [[NSColor blackColor] setFill];
-    [path fill];
-    
+    [NSGraphicsContext saveGraphicsState];
+    if ([self state] == NSOnState) {
+        [[NSColor selectedControlColor] setFill];
+        NSRectFillUsingOperation(frame, NSCompositePlusDarker);
+    }
+    if ([self isHighlighted]) {
+        [[NSColor colorWithCalibratedWhite:0.0 alpha:0.1] setFill];
+        NSFrameRectWithWidthUsingOperation(frame, 1.0, NSCompositePlusDarker);
+    }
     [NSGraphicsContext restoreGraphicsState];
     
     if ([self refusesFirstResponder] == NO && [NSApp isActive] && 
[[controlView window] isKeyWindow] && [[controlView window] firstResponder] == 
controlView) {

Modified: trunk/SKLineWell.h
===================================================================
--- trunk/SKLineWell.h  2011-09-09 13:13:27 UTC (rev 7486)
+++ trunk/SKLineWell.h  2011-09-10 12:09:15 UTC (rev 7487)
@@ -61,6 +61,7 @@
     NSArray *dashPattern;
     PDFLineStyle startLineStyle;
     PDFLineStyle endLineStyle;
+    NSTextFieldCell *bgCell;
     
     struct _lwFlags {
         unsigned int displayStyle:2;

Modified: trunk/SKLineWell.m
===================================================================
--- trunk/SKLineWell.m  2011-09-09 13:13:27 UTC (rev 7486)
+++ trunk/SKLineWell.m  2011-09-10 12:09:15 UTC (rev 7487)
@@ -78,6 +78,9 @@
 }
 
 - (void)commonInit {
+    bgCell = [[NSTextFieldCell alloc] initTextCell:@""];
+    [bgCell setBezeled:YES];
+    
     lwFlags.canActivate = 1;
     lwFlags.highlighted = 0;
     lwFlags.existsActiveLineWell = 0;
@@ -142,6 +145,7 @@
     [self unbind:SKLineWellEndLineStyleKey];
     if (lwFlags.active)
         [self deactivate];
+    SKDESTROY(bgCell);
     SKDESTROY(dashPattern);
     [super dealloc];
 }
@@ -254,30 +258,21 @@
 }
 
 - (void)drawRect:(NSRect)rect {
-    [NSGraphicsContext saveGraphicsState];
-    
     NSRect bounds = [self bounds];
-    NSColor *bgColor = [self isActive] ? [NSColor selectedControlColor] : 
[NSColor controlBackgroundColor];
-    NSColor *edgeColor = [NSColor colorWithCalibratedWhite:0 alpha:[self 
isHighlighted] ? 0.33 : .11];
     
-    [bgColor setFill];
-    NSRectFill(bounds);
+    [bgCell drawWithFrame:bounds inView:self];
     
-    [edgeColor setStroke];
-    [[NSBezierPath bezierPathWithRect:NSInsetRect(bounds, 0.5, 0.5)] stroke];
-    
-    NSBezierPath *path = [NSBezierPath bezierPathWithRect:bounds];
-    [path appendBezierPathWithRect:NSInsetRect(bounds, -2.0, -2.0)];
-    [path setWindingRule:NSEvenOddWindingRule];
-    NSShadow *shadow1 = [[NSShadow new] autorelease];
-    [shadow1 setShadowBlurRadius:2.0];
-    [shadow1 setShadowOffset:NSMakeSize(0.0, -1.0)];
-    [shadow1 setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.7]];
-    [shadow1 set];
-    [[NSColor blackColor] setFill];
-    [path fill];
-    
+    [NSGraphicsContext saveGraphicsState];
+    if ([self isActive]) {
+        [[NSColor selectedControlColor] setFill];
+        NSRectFillUsingOperation(bounds, NSCompositePlusDarker);
+    }
+    if ([self isHighlighted]) {
+        [[NSColor colorWithCalibratedWhite:0.0 alpha:0.1] setFill];
+        NSFrameRectWithWidthUsingOperation(bounds, 1.0, NSCompositePlusDarker);
+    }
     [NSGraphicsContext restoreGraphicsState];
+    
     [NSGraphicsContext saveGraphicsState];
     
     [[NSBezierPath bezierPathWithRect:NSInsetRect(bounds, 2.0, 2.0)] addClip];

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


------------------------------------------------------------------------------
Malware Security Report: Protecting Your Business, Customers, and the 
Bottom Line. Protect your business and customers by understanding the 
threat from malware and how it can impact your online business. 
http://www.accelacomm.com/jaw/sfnl/114/51427462/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to