File:  [mozdev] / chimera / NSImageAdditions.m
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Tue Feb 26 11:49:01 2002 UTC (17 years, 8 months ago) by macserv
Branches: MAIN
CVS tags: HEAD
Checking in the underlying prefs structure, and a prefPane, also fir structural integrity.  Also including a couple categories to extend a couple Cocoa objects, and some project changes to support building with the bundled prefPanes.  Also, added a contrib directory to house user contributed artifacts.  To come soon: more prefPanes, and the colorized icon store, with pref-generated notifications to be picked up by toolbars.

    1: #import "NSImageAdditions.h"
    2: #import <Cocoa/Cocoa.h>
    3: 
    4: @implementation NSImage (NSImageAdditions)
    5: - (void) drawFlippedInRect:(NSRect) rect operation:(NSCompositingOperation) op fraction:(float) delta {
    6: 	CGContextRef context;
    7: 
    8: 	context = [[NSGraphicsContext currentContext] graphicsPort];
    9: 	CGContextSaveGState( context ); {
   10: 		CGContextTranslateCTM( context, 0, NSMaxY( rect ) );
   11: 		CGContextScaleCTM( context, 1, -1 );
   12: 
   13: 		rect.origin.y = 0;
   14: 		[self drawInRect:rect fromRect:NSZeroRect operation:op fraction:delta];
   15: 	} CGContextRestoreGState( context );
   16: }
   17: 
   18: - (void) drawFlippedInRect:(NSRect) rect operation:(NSCompositingOperation) op {
   19:     [self drawFlippedInRect:rect operation:op fraction:1.0];
   20: }
   21: 
   22: - (void)applyBadge:(NSImage*)badge withAlpha:(float)alpha scale:(float)scale
   23: {
   24:     if (!badge)
   25:         return;
   26:     
   27:     [badge setScalesWhenResized:YES];
   28:     [badge setSize:NSMakeSize([self size].width * scale,[self size].height * scale)];
   29:     
   30:     [self lockFocus];
   31:     [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
   32:     [badge dissolveToPoint:NSMakePoint([self size].width - [badge size].width,0) fraction:alpha];
   33:     [self unlockFocus];
   34: }
   35: 
   36: @end

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>