git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4362 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-06-05 05:47:41 +00:00
parent f6d03c0dc7
commit e48c6ddbdc
2 changed files with 34 additions and 18 deletions

View file

@ -1,3 +1,7 @@
Sat Jun 5 7:05:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* NSCell.m: Some minor drawing optimisations.
1999-06-03 Adam Fedor <fedor@gnu.org> 1999-06-03 Adam Fedor <fedor@gnu.org>
* Source/NSGraphicsContext.m (GSCurrentContext): Insert = (patch * Source/NSGraphicsContext.m (GSCurrentContext): Insert = (patch

View file

@ -48,6 +48,12 @@
#include <AppKit/PSOperators.h> #include <AppKit/PSOperators.h>
static NSColor *bgCol;
static NSColor *hbgCol;
static NSColor *txtCol;
static NSColor *dtxtCol;
static NSColor *clearCol = nil;
@implementation NSCell @implementation NSCell
@ -93,6 +99,15 @@ static Class imageClass;
cell_float_right = 0; cell_float_right = 0;
action_mask = NSLeftMouseUpMask; action_mask = NSLeftMouseUpMask;
if (clearCol == nil)
{
bgCol = RETAIN([NSColor controlBackgroundColor]);
hbgCol = RETAIN([NSColor selectedControlColor]);
txtCol = RETAIN([NSColor controlTextColor]);
dtxtCol = RETAIN([NSColor disabledControlTextColor]);
clearCol = RETAIN([NSColor clearColor]);
}
return self; return self;
} }
@ -111,9 +126,9 @@ static Class imageClass;
NSInvalidArgumentException); NSInvalidArgumentException);
cell_type = NSImageCellType; cell_type = NSImageCellType;
cell_image = [anImage retain]; cell_image = RETAIN(anImage);
image_position = NSImageOnly; image_position = NSImageOnly;
cell_font = [[NSFont userFontOfSize: 0] retain]; cell_font = RETAIN([NSFont userFontOfSize: 0]);
return self; return self;
} }
@ -124,8 +139,8 @@ static Class imageClass;
[self _init]; [self _init];
cell_font = [[NSFont userFontOfSize: 0] retain]; cell_font = RETAIN([NSFont userFontOfSize: 0]);
contents = [aString retain]; contents = RETAIN(aString);
cell_type = NSTextCellType; cell_type = NSTextCellType;
text_align = NSCenterTextAlignment; text_align = NSCenterTextAlignment;
cell_float_autorange = YES; cell_float_autorange = YES;
@ -136,13 +151,10 @@ static Class imageClass;
- (void) dealloc - (void) dealloc
{ {
if (contents) TEST_RELEASE(contents);
[contents release]; TEST_RELEASE(cell_image);
if (cell_image) TEST_RELEASE(cell_font);
[cell_image release]; TEST_RELEASE(represented_object);
[cell_font release];
if (represented_object)
[represented_object release];
[super dealloc]; [super dealloc];
} }
@ -555,9 +567,9 @@ static Class imageClass;
- (NSColor*) textColor - (NSColor*) textColor
{ {
if ([self isEnabled]) if ([self isEnabled])
return [NSColor controlTextColor]; return txtCol;
else else
return [NSColor disabledControlTextColor]; return dtxtCol;
} }
- (void) _drawText: (NSString *) title inFrame: (NSRect) cellFrame - (void) _drawText: (NSString *) title inFrame: (NSRect) cellFrame
@ -654,15 +666,15 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
NSColor *bg; NSColor *bg;
if (cell_highlighted) if (cell_highlighted)
bg = [NSColor selectedControlColor]; bg = hbgCol;
else else
bg = [NSColor controlBackgroundColor]; bg = bgCol;
[bg set]; [bg set];
[[self image] setBackgroundColor: bg]; [cell_image setBackgroundColor: bg];
NSRectFill(cellFrame); NSRectFill(cellFrame);
} }
else else
[[self image] setBackgroundColor: [NSColor clearColor]]; [cell_image setBackgroundColor: clearCol];
switch ([self type]) switch ([self type])
{ {
@ -670,7 +682,7 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
[self _drawText: [self stringValue] inFrame: cellFrame]; [self _drawText: [self stringValue] inFrame: cellFrame];
break; break;
case NSImageCellType: case NSImageCellType:
[self _drawImage: [self image] inFrame: cellFrame]; [self _drawImage: cell_image inFrame: cellFrame];
break; break;
case NSNullCellType: case NSNullCellType:
break; break;