mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-29 21:57:39 +00:00
* Headers/Additions/GNUstepGUI/GSTheme.h:
* Source/GSTheme.m: * Source/GSThemeDrawing.m: * Source/NSBox.m: Factor out -[NSBox drawRect:] to GSTheme method -drawBoxInClipRect:boxType:borderType:inView:. Add a tiles name GSBoxBorder for themeing the box border. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37188 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5cd9dd8b7e
commit
c63df23ba8
5 changed files with 106 additions and 57 deletions
|
@ -2913,4 +2913,85 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
[cell _setInEditing: NO];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawBoxInClipRect: (NSRect)clipRect
|
||||
boxType: (NSBoxType)boxType
|
||||
borderType: (NSBorderType)borderType
|
||||
inView: (NSBox *)box
|
||||
{
|
||||
NSColor *color;
|
||||
|
||||
if (boxType == NSBoxCustom)
|
||||
{
|
||||
if (![box isOpaque])
|
||||
{
|
||||
color = [NSColor clearColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
color = [box fillColor];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
color = [[box window] backgroundColor];
|
||||
}
|
||||
// Fill inside
|
||||
[color set];
|
||||
NSRectFill(clipRect);
|
||||
|
||||
// Draw border
|
||||
|
||||
GSDrawTiles *tiles = [[GSTheme theme] tilesNamed: GSBoxBorder state: GSThemeNormalState];
|
||||
if (tiles == nil
|
||||
|| borderType == NSNoBorder
|
||||
|| boxType == NSBoxSeparator
|
||||
|| boxType == NSBoxOldStyle
|
||||
|| boxType == NSBoxCustom)
|
||||
{
|
||||
switch (borderType)
|
||||
{
|
||||
case NSNoBorder:
|
||||
break;
|
||||
case NSLineBorder:
|
||||
if (boxType == NSBoxCustom)
|
||||
{
|
||||
[[box borderColor] set];
|
||||
NSFrameRectWithWidth([box borderRect], [box borderWidth]);
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSColor controlDarkShadowColor] set];
|
||||
NSFrameRect([box borderRect]);
|
||||
}
|
||||
break;
|
||||
case NSBezelBorder:
|
||||
[[GSTheme theme] drawDarkBezel: [box borderRect] withClip: clipRect];
|
||||
break;
|
||||
case NSGrooveBorder:
|
||||
[[GSTheme theme] drawGroove: [box borderRect] withClip: clipRect];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[[GSTheme theme] fillRect: [box borderRect]
|
||||
withTiles: tiles
|
||||
background: [NSColor clearColor]];
|
||||
}
|
||||
|
||||
// Draw title
|
||||
if ([box titlePosition] != NSNoTitle)
|
||||
{
|
||||
// If the title is on the border, clip a hole in the later
|
||||
if ((borderType != NSNoBorder)
|
||||
&& (([box titlePosition] == NSAtTop) || ([box titlePosition] == NSAtBottom)))
|
||||
{
|
||||
[color set];
|
||||
NSRectFill([box titleRect]);
|
||||
}
|
||||
[[box titleCell] drawWithFrame: [box titleRect] inView: box];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue