mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 05:01:00 +00:00
Optimized by removing the auxiliary cell. Removed some old methods.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5458 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5bcfbc4a80
commit
9c1de96be4
1 changed files with 56 additions and 129 deletions
|
@ -8,6 +8,9 @@
|
||||||
Author: Scott Christley <scottc@net-community.com>
|
Author: Scott Christley <scottc@net-community.com>
|
||||||
Date: 1996
|
Date: 1996
|
||||||
|
|
||||||
|
Author: Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
Date: December 1999
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
|
@ -40,48 +43,19 @@
|
||||||
/*
|
/*
|
||||||
* Class variables
|
* Class variables
|
||||||
*/
|
*/
|
||||||
static NSImage *branch_image;
|
static NSImage *_branch_image;
|
||||||
static NSImage *highlight_image;
|
static NSImage *_highlight_image;
|
||||||
|
|
||||||
static Class cellClass;
|
static Class _cellClass;
|
||||||
static Class colorClass;
|
static Class _colorClass;
|
||||||
|
|
||||||
// Color is not used now, but the code is here
|
// Color is not used now, but the code is here
|
||||||
// in case in the future we want to use it again
|
// in case in the future we want to use it again
|
||||||
static BOOL gsFontifyCells = NO;
|
static BOOL _gsFontifyCells = NO;
|
||||||
//static NSColor *nonLeafColor;
|
//static NSColor *_nonLeafColor;
|
||||||
static NSFont *nonLeafFont;
|
static NSFont *_nonLeafFont;
|
||||||
//static NSColor *leafColor;
|
//static NSColor *_leafColor;
|
||||||
static NSFont *leafFont;
|
static NSFont *_leafFont;
|
||||||
|
|
||||||
/*
|
|
||||||
* Private methods
|
|
||||||
*/
|
|
||||||
@interface NSBrowserCell (Private)
|
|
||||||
- (void) setBranchImageCell: aCell;
|
|
||||||
- (void) setHighlightBranchImageCell: aCell;
|
|
||||||
- (void) setTextFieldCell: aCell;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSBrowserCell (Private)
|
|
||||||
|
|
||||||
- (void) setTextFieldCell: aCell
|
|
||||||
{
|
|
||||||
ASSIGN(_browserText, aCell);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setBranchImageCell: aCell
|
|
||||||
{
|
|
||||||
ASSIGN(_branchImage, aCell);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setHighlightBranchImageCell: aCell
|
|
||||||
{
|
|
||||||
ASSIGN(_highlightBranchImage, aCell);
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
|
@ -99,25 +73,25 @@ static NSFont *leafFont;
|
||||||
if (self == [NSBrowserCell class])
|
if (self == [NSBrowserCell class])
|
||||||
{
|
{
|
||||||
[self setVersion: 1];
|
[self setVersion: 1];
|
||||||
ASSIGN(branch_image, [NSImage imageNamed: @"common_3DArrowRight"]);
|
ASSIGN(_branch_image, [NSImage imageNamed: @"common_3DArrowRight"]);
|
||||||
ASSIGN(highlight_image, [NSImage imageNamed: @"common_3DArrowRightH"]);
|
ASSIGN(_highlight_image, [NSImage imageNamed: @"common_3DArrowRightH"]);
|
||||||
/*
|
/*
|
||||||
* Cache classes to avoid overheads of poor compiler implementation.
|
* Cache classes to avoid overheads of poor compiler implementation.
|
||||||
*/
|
*/
|
||||||
cellClass = [NSCell class];
|
_cellClass = [NSCell class];
|
||||||
colorClass = [NSColor class];
|
_colorClass = [NSColor class];
|
||||||
|
|
||||||
// A GNUstep experimental feature
|
// A GNUstep experimental feature
|
||||||
if ([[NSUserDefaults standardUserDefaults]
|
if ([[NSUserDefaults standardUserDefaults]
|
||||||
boolForKey: @"GSBrowserCellFontify"])
|
boolForKey: @"GSBrowserCellFontify"])
|
||||||
{
|
{
|
||||||
gsFontifyCells = YES;
|
_gsFontifyCells = YES;
|
||||||
cellClass = [NSTextFieldCell class];
|
_cellClass = [NSTextFieldCell class];
|
||||||
//nonLeafColor = RETAIN ([colorClass colorWithCalibratedWhite: 0.222
|
//_nonLeafColor = RETAIN ([_colorClass colorWithCalibratedWhite: 0.222
|
||||||
// alpha: 1.0]);
|
// alpha: 1.0]);
|
||||||
nonLeafFont = RETAIN ([NSFont boldSystemFontOfSize: 0]);
|
_nonLeafFont = RETAIN ([NSFont boldSystemFontOfSize: 0]);
|
||||||
//leafColor = RETAIN ([colorClass blackColor]);
|
//_leafColor = RETAIN ([_colorClass blackColor]);
|
||||||
leafFont = RETAIN ([NSFont systemFontOfSize: 0]);
|
_leafFont = RETAIN ([NSFont systemFontOfSize: 0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,12 +101,12 @@ static NSFont *leafFont;
|
||||||
*/
|
*/
|
||||||
+ (NSImage*) branchImage
|
+ (NSImage*) branchImage
|
||||||
{
|
{
|
||||||
return branch_image;
|
return _branch_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSImage*) highlightedBranchImage
|
+ (NSImage*) highlightedBranchImage
|
||||||
{
|
{
|
||||||
return highlight_image;
|
return _highlight_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -146,23 +120,24 @@ static NSFont *leafFont;
|
||||||
- (id) initTextCell: (NSString *)aString
|
- (id) initTextCell: (NSString *)aString
|
||||||
{
|
{
|
||||||
[super initTextCell: aString];
|
[super initTextCell: aString];
|
||||||
// create image cells
|
|
||||||
_branchImage = RETAIN([isa branchImage]);
|
_branchImage = RETAIN([isa branchImage]);
|
||||||
_highlightBranchImage = RETAIN([isa highlightedBranchImage]);
|
_highlightBranchImage = RETAIN([isa highlightedBranchImage]);
|
||||||
// create the text cell
|
_cell.is_editable = NO;
|
||||||
_browserText = [[cellClass alloc] initTextCell: aString];
|
_cell.is_bordered = NO;
|
||||||
[_browserText setEditable: NO];
|
_text_align = NSLeftTextAlignment;
|
||||||
[_browserText setBordered: NO];
|
|
||||||
[_browserText setAlignment: NSLeftTextAlignment];
|
|
||||||
|
|
||||||
_alternateImage = nil;
|
_alternateImage = nil;
|
||||||
|
if (_gsFontifyCells)
|
||||||
|
{
|
||||||
// To make the [self setLeaf: NO] effective
|
// To make the [self setLeaf: NO] effective
|
||||||
_isLeaf = YES;
|
_isLeaf = YES;
|
||||||
[self setLeaf: NO];
|
[self setLeaf: NO];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_isLeaf = NO;
|
||||||
|
}
|
||||||
_isLoaded = NO;
|
_isLoaded = NO;
|
||||||
|
|
||||||
[self setEditable: NO];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +146,6 @@ static NSFont *leafFont;
|
||||||
RELEASE(_branchImage);
|
RELEASE(_branchImage);
|
||||||
RELEASE(_highlightBranchImage);
|
RELEASE(_highlightBranchImage);
|
||||||
TEST_RELEASE(_alternateImage);
|
TEST_RELEASE(_alternateImage);
|
||||||
RELEASE(_browserText);
|
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -184,7 +158,6 @@ static NSFont *leafFont;
|
||||||
if (_alternateImage)
|
if (_alternateImage)
|
||||||
c->_alternateImage = RETAIN(_alternateImage);
|
c->_alternateImage = RETAIN(_alternateImage);
|
||||||
c->_highlightBranchImage = RETAIN(_highlightBranchImage);
|
c->_highlightBranchImage = RETAIN(_highlightBranchImage);
|
||||||
c->_browserText = [_browserText copyWithZone: zone]; // Copy the text cell
|
|
||||||
c->_isLeaf = _isLeaf;
|
c->_isLeaf = _isLeaf;
|
||||||
c->_isLoaded = _isLoaded;
|
c->_isLoaded = _isLoaded;
|
||||||
|
|
||||||
|
@ -219,17 +192,15 @@ static NSFont *leafFont;
|
||||||
|
|
||||||
_isLeaf = flag;
|
_isLeaf = flag;
|
||||||
|
|
||||||
if (gsFontifyCells)
|
if (_gsFontifyCells)
|
||||||
{
|
{
|
||||||
if (_isLeaf)
|
if (_isLeaf)
|
||||||
{
|
{
|
||||||
[(NSTextFieldCell *)_browserText setFont: leafFont];
|
ASSIGN (_cell_font, _leafFont);
|
||||||
//[(NSTextFieldCell *)_browserText setTextColor: leafColor];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[(NSTextFieldCell *)_browserText setFont: nonLeafFont];
|
ASSIGN (_cell_font, _nonLeafFont);
|
||||||
//[(NSTextFieldCell *)_browserText setTextColor: nonLeafColor];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,57 +223,14 @@ static NSFont *leafFont;
|
||||||
*/
|
*/
|
||||||
- (void) reset
|
- (void) reset
|
||||||
{
|
{
|
||||||
cell_highlighted = NO;
|
_cell.is_highlighted = NO;
|
||||||
cell_state = NO;
|
_cell_state = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) set
|
- (void) set
|
||||||
{
|
{
|
||||||
cell_highlighted = YES;
|
_cell.is_highlighted = YES;
|
||||||
cell_state = YES;
|
_cell_state = YES;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Setting and accessing the NSCell's Value
|
|
||||||
*/
|
|
||||||
- (double) doubleValue
|
|
||||||
{
|
|
||||||
return [_browserText doubleValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (float) floatValue
|
|
||||||
{
|
|
||||||
return [_browserText floatValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (int) intValue
|
|
||||||
{
|
|
||||||
return [_browserText intValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString*) stringValue
|
|
||||||
{
|
|
||||||
return [_browserText stringValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setIntValue: (int)anInt
|
|
||||||
{
|
|
||||||
[_browserText setIntValue: anInt];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setDoubleValue: (double)aDouble
|
|
||||||
{
|
|
||||||
[_browserText setDoubleValue: aDouble];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setFloatValue: (float)aFloat
|
|
||||||
{
|
|
||||||
[_browserText setFloatValue: aFloat];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setStringValue: (NSString*)aString
|
|
||||||
{
|
|
||||||
[_browserText setStringValue: aString];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -313,25 +241,28 @@ static NSFont *leafFont;
|
||||||
NSRect title_rect = cellFrame;
|
NSRect title_rect = cellFrame;
|
||||||
NSImage *image = nil;
|
NSImage *image = nil;
|
||||||
NSColor *backColor;
|
NSColor *backColor;
|
||||||
|
NSWindow *cvWin = [controlView window];
|
||||||
|
|
||||||
control_view = controlView; // remember last view cell was drawn in
|
if (!cvWin)
|
||||||
if (![controlView window])
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[controlView lockFocus];
|
[controlView lockFocus];
|
||||||
if (cell_highlighted || cell_state)
|
|
||||||
|
if (_cell.is_highlighted || _cell_state)
|
||||||
{
|
{
|
||||||
backColor = [colorClass selectedControlColor];
|
backColor = [_colorClass selectedControlColor];
|
||||||
[backColor set];
|
[backColor set];
|
||||||
if (!_isLeaf)
|
if (!_isLeaf)
|
||||||
image = _highlightBranchImage;
|
image = _highlightBranchImage;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
backColor = [[controlView window] backgroundColor];
|
backColor = [cvWin backgroundColor];
|
||||||
[backColor set];
|
[backColor set];
|
||||||
if (!_isLeaf)
|
if (!_isLeaf)
|
||||||
image = _branchImage;
|
image = _branchImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSRectFill(cellFrame); // Clear the background
|
NSRectFill(cellFrame); // Clear the background
|
||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
|
@ -348,13 +279,13 @@ static NSFont *leafFont;
|
||||||
* Images are always drawn with their bottom-left corner at the origin
|
* Images are always drawn with their bottom-left corner at the origin
|
||||||
* so we must adjust the position to take account of a flipped view.
|
* so we must adjust the position to take account of a flipped view.
|
||||||
*/
|
*/
|
||||||
if ([control_view isFlipped])
|
if ([controlView isFlipped])
|
||||||
image_rect.origin.y += image_rect.size.height;
|
image_rect.origin.y += image_rect.size.height;
|
||||||
[image compositeToPoint: image_rect.origin operation: NSCompositeCopy];
|
[image compositeToPoint: image_rect.origin operation: NSCompositeCopy];
|
||||||
|
|
||||||
title_rect.size.width -= image_rect.size.width + 8;
|
title_rect.size.width -= image_rect.size.width + 8;
|
||||||
}
|
}
|
||||||
[_browserText drawWithFrame: title_rect inView: controlView];
|
[super drawInteriorWithFrame: title_rect inView: controlView];
|
||||||
[controlView unlockFocus];
|
[controlView unlockFocus];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,9 +301,6 @@ static NSFont *leafFont;
|
||||||
{
|
{
|
||||||
[super encodeWithCoder: aCoder];
|
[super encodeWithCoder: aCoder];
|
||||||
|
|
||||||
[aCoder encodeObject: _browserText];
|
|
||||||
[aCoder encodeObject: _branchImage];
|
|
||||||
[aCoder encodeObject: _highlightBranchImage];
|
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
||||||
}
|
}
|
||||||
|
@ -381,11 +309,10 @@ static NSFont *leafFont;
|
||||||
{
|
{
|
||||||
[super initWithCoder: aDecoder];
|
[super initWithCoder: aDecoder];
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_browserText];
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_branchImage];
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_highlightBranchImage];
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLeaf];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
|
||||||
|
_branchImage = RETAIN([isa branchImage]);
|
||||||
|
_highlightBranchImage = RETAIN([isa highlightedBranchImage]);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue