Optimizations

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5495 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 1999-12-13 19:47:03 +00:00
parent 47a548b69b
commit 8470145054

View file

@ -32,7 +32,6 @@
#include <gnustep/gui/config.h> #include <gnustep/gui/config.h>
#include <AppKit/NSBrowserCell.h> #include <AppKit/NSBrowserCell.h>
#include <AppKit/NSTextFieldCell.h>
#include <AppKit/NSColor.h> #include <AppKit/NSColor.h>
#include <AppKit/NSFont.h> #include <AppKit/NSFont.h>
#include <AppKit/NSImage.h> #include <AppKit/NSImage.h>
@ -46,23 +45,13 @@
static NSImage *_branch_image; static NSImage *_branch_image;
static NSImage *_highlight_image; static NSImage *_highlight_image;
static Class _cellClass;
static Class _colorClass; static Class _colorClass;
// Color is not used now, but the code is here // GNUstep user default to have NSBrowserCell in bold if non leaf
// in case in the future we want to use it again
static BOOL _gsFontifyCells = NO; static BOOL _gsFontifyCells = NO;
//static NSColor *_nonLeafColor;
static NSFont *_nonLeafFont; static NSFont *_nonLeafFont;
//static NSColor *_leafColor;
static NSFont *_leafFont; static NSFont *_leafFont;
/*****************************************************************************
*
* NSBrowserCell
*
*****************************************************************************/
@implementation NSBrowserCell @implementation NSBrowserCell
/* /*
@ -78,7 +67,6 @@ static NSFont *_leafFont;
/* /*
* Cache classes to avoid overheads of poor compiler implementation. * Cache classes to avoid overheads of poor compiler implementation.
*/ */
_cellClass = [NSCell class];
_colorClass = [NSColor class]; _colorClass = [NSColor class];
// A GNUstep experimental feature // A GNUstep experimental feature
@ -86,11 +74,7 @@ static NSFont *_leafFont;
boolForKey: @"GSBrowserCellFontify"]) boolForKey: @"GSBrowserCellFontify"])
{ {
_gsFontifyCells = YES; _gsFontifyCells = YES;
_cellClass = [NSTextFieldCell class];
//_nonLeafColor = RETAIN ([_colorClass colorWithCalibratedWhite: 0.222
// alpha: 1.0]);
_nonLeafFont = RETAIN ([NSFont boldSystemFontOfSize: 0]); _nonLeafFont = RETAIN ([NSFont boldSystemFontOfSize: 0]);
//_leafColor = RETAIN ([_colorClass blackColor]);
_leafFont = RETAIN ([NSFont systemFontOfSize: 0]); _leafFont = RETAIN ([NSFont systemFontOfSize: 0]);
} }
} }
@ -120,8 +104,6 @@ static NSFont *_leafFont;
- (id) initTextCell: (NSString *)aString - (id) initTextCell: (NSString *)aString
{ {
[super initTextCell: aString]; [super initTextCell: aString];
_branchImage = RETAIN([isa branchImage]);
_highlightBranchImage = RETAIN([isa highlightedBranchImage]);
_cell.is_editable = NO; _cell.is_editable = NO;
_cell.is_bordered = NO; _cell.is_bordered = NO;
_cell.text_align = NSLeftTextAlignment; _cell.text_align = NSLeftTextAlignment;
@ -143,8 +125,6 @@ static NSFont *_leafFont;
- (void) dealloc - (void) dealloc
{ {
RELEASE(_branchImage);
RELEASE(_highlightBranchImage);
TEST_RELEASE(_alternateImage); TEST_RELEASE(_alternateImage);
[super dealloc]; [super dealloc];
@ -154,10 +134,8 @@ static NSFont *_leafFont;
{ {
NSBrowserCell *c = [super copyWithZone: zone]; NSBrowserCell *c = [super copyWithZone: zone];
c->_branchImage = RETAIN(_branchImage);
if (_alternateImage) if (_alternateImage)
c->_alternateImage = RETAIN(_alternateImage); c->_alternateImage = RETAIN(_alternateImage);
c->_highlightBranchImage = RETAIN(_highlightBranchImage);
c->_browsercell_is_leaf = _browsercell_is_leaf; c->_browsercell_is_leaf = _browsercell_is_leaf;
c->_browsercell_is_loaded = _browsercell_is_loaded; c->_browsercell_is_loaded = _browsercell_is_loaded;
@ -253,14 +231,18 @@ static NSFont *_leafFont;
backColor = [_colorClass selectedControlColor]; backColor = [_colorClass selectedControlColor];
[backColor set]; [backColor set];
if (!_browsercell_is_leaf) if (!_browsercell_is_leaf)
image = _highlightBranchImage; image = [isa highlightedBranchImage];
else if (_alternateImage)
image = _alternateImage;
} }
else else
{ {
backColor = [cvWin backgroundColor]; backColor = [cvWin backgroundColor];
[backColor set]; [backColor set];
if (!_browsercell_is_leaf) if (!_browsercell_is_leaf)
image = _branchImage; image = [isa branchImage];
else if (_alternateImage)
image = _alternateImage;
} }
NSRectFill(cellFrame); // Clear the background NSRectFill(cellFrame); // Clear the background
@ -306,6 +288,7 @@ static NSFont *_leafFont;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
tmp = _browsercell_is_loaded; tmp = _browsercell_is_loaded;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
[aCoder encodeObject: _alternateImage];
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -317,8 +300,7 @@ static NSFont *_leafFont;
_browsercell_is_leaf = tmp; _browsercell_is_leaf = tmp;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp]; [aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_browsercell_is_loaded = tmp; _browsercell_is_loaded = tmp;
_branchImage = RETAIN([isa branchImage]); [aDecoder decodeValueOfObjCType: @encode(id) at: &_alternateImage];
_highlightBranchImage = RETAIN([isa highlightedBranchImage]);
return self; return self;
} }