Revision: 2988
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2988&view=rev
Author:   hofman
Date:     2007-09-25 09:49:34 -0700 (Tue, 25 Sep 2007)

Log Message:
-----------
Convenience category method to draw an image flipped.

Modified Paths:
--------------
    trunk/BDSKHeaderPopUpButtonCell.m
    trunk/NSImage_SKExtensions.h
    trunk/NSImage_SKExtensions.m
    trunk/SKTextWithIconCell.m
    trunk/Skim.xcodeproj/project.pbxproj

Modified: trunk/BDSKHeaderPopUpButtonCell.m
===================================================================
--- trunk/BDSKHeaderPopUpButtonCell.m   2007-09-25 15:18:30 UTC (rev 2987)
+++ trunk/BDSKHeaderPopUpButtonCell.m   2007-09-25 16:49:34 UTC (rev 2988)
@@ -37,6 +37,7 @@
  */
 
 #import "BDSKHeaderPopUpButtonCell.h"
+#import "NSImage_SKExtensions.h"
 
 @implementation BDSKHeaderPopUpButtonCell
 
@@ -151,22 +152,7 @@
                
         indicatorRect = BDSKCenterRect(indicatorRect, indicatorSize, 
[controlView isFlipped]);
                
-               if ([controlView isFlipped]) {
-            // from NSImage-OAExtensions drawFlippedInRect...
-            NSRect rectToDraw = indicatorRect;
-            CGContextRef context;
-            
-            context = [[NSGraphicsContext currentContext] graphicsPort];
-            CGContextSaveGState(context); {
-                CGContextTranslateCTM(context, 0, NSMaxY(rectToDraw));
-                CGContextScaleCTM(context, 1, -1);
-                
-                rectToDraw.origin.y = 0; // We've translated the image so it's 
zero
-                [indicatorImage drawInRect:rectToDraw fromRect:NSZeroRect 
operation:NSCompositeSourceOver fraction:1.0];
-            } CGContextRestoreGState(context);
-               } else {
-                       [indicatorImage drawInRect:indicatorRect 
fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
-        }
+        [indicatorImage drawFlipped:[controlView isFlipped] 
inRect:indicatorRect fromRect:NSZeroRect operation:NSCompositeSourceOver 
fraction:1.0];
        }
        
        // Two little arrows. We could also use some image here

Modified: trunk/NSImage_SKExtensions.h
===================================================================
--- trunk/NSImage_SKExtensions.h        2007-09-25 15:18:30 UTC (rev 2987)
+++ trunk/NSImage_SKExtensions.h        2007-09-25 16:49:34 UTC (rev 2988)
@@ -40,7 +40,13 @@
 
 
 @interface NSImage (SKExtensions)
+
 + (void)makeAdornImages;
+
 + (NSImage *)iconWithSize:(NSSize)iconSize forToolboxCode:(OSType)code;
 + (NSImage *)imageWithIconForToolboxCode:(OSType)code;
+
+- (void)drawFlippedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect 
operation:(NSCompositingOperation)op fraction:(float)delta;
+- (void)drawFlipped:(BOOL)isFlipped inRect:(NSRect)dstRect 
fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op 
fraction:(float)delta;
+
 @end

Modified: trunk/NSImage_SKExtensions.m
===================================================================
--- trunk/NSImage_SKExtensions.m        2007-09-25 15:18:30 UTC (rev 2987)
+++ trunk/NSImage_SKExtensions.m        2007-09-25 16:49:34 UTC (rev 2988)
@@ -571,4 +571,22 @@
     return [self iconWithSize:NSMakeSize(32,32) forToolboxCode:code];
 }
 
+- (void)drawFlippedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect 
operation:(NSCompositingOperation)op fraction:(float)delta {
+    [NSGraphicsContext saveGraphicsState];
+    NSAffineTransform *transform = [NSAffineTransform transform];
+    [transform translateXBy:0.0 yBy:NSMaxY(dstRect)];
+    [transform scaleXBy:1.0 yBy:-1.0];
+    [transform translateXBy:0.0 yBy:-NSMinY(dstRect)];
+    [transform concat];
+    [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
+    [NSGraphicsContext restoreGraphicsState];
+}
+
+- (void)drawFlipped:(BOOL)isFlipped inRect:(NSRect)dstRect 
fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op 
fraction:(float)delta {
+    if (isFlipped)
+        [self drawFlippedInRect:dstRect fromRect:srcRect operation:op 
fraction:delta];
+    else
+        [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
+}
+
 @end

Modified: trunk/SKTextWithIconCell.m
===================================================================
--- trunk/SKTextWithIconCell.m  2007-09-25 15:18:30 UTC (rev 2987)
+++ trunk/SKTextWithIconCell.m  2007-09-25 16:49:34 UTC (rev 2988)
@@ -37,6 +37,7 @@
  */
 
 #import "SKTextWithIconCell.h"
+#import "NSImage_SKExtensions.h"
 
 // Almost all of this code is copy-and-paste from 
OmniAppKit/OATextWithIconCell, with some simplifications for features we're not 
interested in
 
@@ -102,16 +103,7 @@
     imageRect.origin.y += 0.5 * (NSHeight(imageRect) - imageSize.height);
     imageRect.origin.y = [controlView isFlipped] ? ceilf(NSMinY(imageRect))  : 
floorf(NSMinY(imageRect));
     imageRect.size = imageSize;
-    [NSGraphicsContext saveGraphicsState];
-    if ([controlView isFlipped]) {
-        NSAffineTransform *transform = [NSAffineTransform transform];
-        [transform translateXBy:0.0 yBy:NSMaxY(imageRect)];
-        [transform scaleXBy:1.0 yBy:-1.0];
-        [transform translateXBy:0.0 yBy:-NSMinY(imageRect)];
-        [transform concat];
-    }
-    [[self icon] drawInRect:imageRect fromRect:NSZeroRect 
operation:NSCompositeSourceOver fraction:1.0];
-       [NSGraphicsContext restoreGraphicsState];
+    [[self icon] drawFlipped:[controlView isFlipped] inRect:imageRect 
fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
 }
 
 - (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView 
editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart 
length:(int)selLength {

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2007-09-25 15:18:30 UTC (rev 
2987)
+++ trunk/Skim.xcodeproj/project.pbxproj        2007-09-25 16:49:34 UTC (rev 
2988)
@@ -1495,12 +1495,15 @@
                                "$(SRCROOT)/Italian.lproj/Skim 
Help/version.texi",
                                "$(SRCROOT)/French.lproj/Skim Help/skim.texi",
                                "$(SRCROOT)/French.lproj/Skim 
Help/version.texi",
+                               "$(SRCROOT)/Spanish.lproj/Skim Help/skim.texi",
+                               "$(SRCROOT)/Spanish.lproj/Skim 
Help/version.texi",
                        );
                        outputPaths = (
                                "$(DERIVED_FILE_DIR)/Skim 
Help/English.lproj/Skim Help/Skim Help.html",
                                "$(DERIVED_FILE_DIR)/Skim Help/Dutch.lproj/Skim 
Help/Skim Help.html",
                                "$(DERIVED_FILE_DIR)/Skim 
Help/Italian.lproj/Skim Help/Skim Help.html",
                                "$(DERIVED_FILE_DIR)/Skim 
Help/French.lproj/Skim Help/Skim Help.html",
+                               "$(DERIVED_FILE_DIR)/Skim 
Help/Spanish.lproj/Skim Help/Skim Help.html",
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to