mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-22 12:12:19 +00:00
Add drawing methods for theming NSBrowserCell.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38690 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4213323979
commit
971a573445
5 changed files with 198 additions and 89 deletions
|
@ -40,6 +40,7 @@
|
|||
#import "AppKit/NSEvent.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
#import "GSGuiPrivate.h"
|
||||
#import "GNUstepGUI/GSTheme.h"
|
||||
|
||||
/*
|
||||
* Class variables
|
||||
|
@ -90,7 +91,7 @@ static NSFont *_leafFont;
|
|||
*/
|
||||
+ (NSImage*) branchImage
|
||||
{
|
||||
return _branch_image;
|
||||
return [[GSTheme theme] branchImage];
|
||||
}
|
||||
|
||||
/**<p>Returns the default hightlited branch image</p>
|
||||
|
@ -98,7 +99,7 @@ static NSFont *_leafFont;
|
|||
*/
|
||||
+ (NSImage*) highlightedBranchImage
|
||||
{
|
||||
return _highlight_image;
|
||||
return [[GSTheme theme] highlightedBranchImage];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -330,92 +331,14 @@ static NSFont *_leafFont;
|
|||
*/
|
||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||
{
|
||||
NSRect title_rect = cellFrame;
|
||||
NSImage *branch_image = nil;
|
||||
NSImage *cell_image = [self image];
|
||||
|
||||
if (_cell.is_highlighted || _cell.state)
|
||||
{
|
||||
if (!_browsercell_is_leaf)
|
||||
branch_image = [object_getClass(self) highlightedBranchImage];
|
||||
if (nil != [self alternateImage])
|
||||
cell_image = [self alternateImage];
|
||||
|
||||
// If we are highlighted, fill the background
|
||||
[[self highlightColorInView: controlView] setFill];
|
||||
NSRectFill(cellFrame);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_browsercell_is_leaf)
|
||||
branch_image = [object_getClass(self) branchImage];
|
||||
|
||||
// (Don't fill the background)
|
||||
}
|
||||
|
||||
// Draw the branch image if there is one
|
||||
if (branch_image)
|
||||
{
|
||||
NSRect imgRect;
|
||||
|
||||
imgRect.size = [branch_image size];
|
||||
imgRect.origin.x = MAX(NSMaxX(title_rect) - imgRect.size.width - 4.0, 0.);
|
||||
imgRect.origin.y = MAX(NSMidY(title_rect) - (imgRect.size.height/2.), 0.);
|
||||
|
||||
if (controlView != nil)
|
||||
{
|
||||
imgRect = [controlView centerScanRect: imgRect];
|
||||
}
|
||||
|
||||
[branch_image drawInRect: imgRect
|
||||
fromRect: NSZeroRect
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0
|
||||
respectFlipped: YES
|
||||
hints: nil];
|
||||
|
||||
title_rect.size.width -= imgRect.size.width + 8;
|
||||
}
|
||||
|
||||
// Skip 2 points from the left border
|
||||
title_rect.origin.x += 2;
|
||||
title_rect.size.width -= 2;
|
||||
|
||||
// Draw the cell image if there is one
|
||||
if (cell_image)
|
||||
{
|
||||
NSRect imgRect;
|
||||
|
||||
imgRect.size = [cell_image size];
|
||||
imgRect.origin.x = NSMinX(title_rect);
|
||||
imgRect.origin.y = MAX(NSMidY(title_rect) - (imgRect.size.height/2.),0.);
|
||||
|
||||
if (controlView != nil)
|
||||
{
|
||||
imgRect = [controlView centerScanRect: imgRect];
|
||||
}
|
||||
|
||||
[cell_image drawInRect: imgRect
|
||||
fromRect: NSZeroRect
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0
|
||||
respectFlipped: YES
|
||||
hints: nil];
|
||||
|
||||
title_rect.origin.x += imgRect.size.width + 4;
|
||||
title_rect.size.width -= imgRect.size.width + 4;
|
||||
}
|
||||
|
||||
// Draw the body of the cell
|
||||
if (_cell.in_editing)
|
||||
{
|
||||
[self _drawEditorWithFrame: cellFrame inView: controlView];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self _drawAttributedText: [self attributedStringValue]
|
||||
inFrame: title_rect];
|
||||
}
|
||||
[[GSTheme theme] drawBrowserInteriorWithFrame: cellFrame
|
||||
withCell: self
|
||||
inView: controlView
|
||||
withImage: [self image]
|
||||
alternateImage: [self alternateImage]
|
||||
isHighlighted: [self isHighlighted]
|
||||
state: [self state]
|
||||
isLeaf: [self isLeaf]];
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue