* 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:
Eric Wasylishen 2013-10-03 19:52:05 +00:00
parent 5cd9dd8b7e
commit c63df23ba8
5 changed files with 106 additions and 57 deletions

View file

@ -1,3 +1,12 @@
2013-10-03 Eric Wasylishen <ewasylishen@gmail.com>
* 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.
2013-10-03 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSSliderCell.m: Support themeing the circular slider

View file

@ -217,6 +217,7 @@
#import <Foundation/NSObject.h>
#import <Foundation/NSGeometry.h>
#import <AppKit/NSBox.h>
#import <AppKit/NSCell.h>
// For gradient types
#import <AppKit/NSButtonCell.h>
@ -305,6 +306,9 @@ APPKIT_EXPORT NSString *GSColorWell;
APPKIT_EXPORT NSString *GSSliderHorizontalTrack;
APPKIT_EXPORT NSString *GSSliderVerticalTrack;
/* NSBox parts */
APPKIT_EXPORT NSString *GSBoxBorder;
/**
* Structure to describe the size of top/bottom/left/right margins inside
* a button
@ -1173,6 +1177,11 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
- (void) drawTableViewRow: (int)rowIndex
clipRect: (NSRect)clipRect
inView: (NSView *)view;
- (void) drawBoxInClipRect: (NSRect)clipRect
boxType: (NSBoxType)boxType
borderType: (NSBorderType)borderType
inView: (NSBox *)box;
@end
/**

View file

@ -109,6 +109,9 @@ NSString *GSColorWell = @"GSColorWell";
NSString *GSSliderHorizontalTrack = @"GSSliderHorizontalTrack";
NSString *GSSliderVerticalTrack = @"GSSliderVerticalTrack";
// NSBox parts
NSString *GSBoxBorder = @"GSBoxBorder";
NSString *GSThemeDidActivateNotification
= @"GSThemeDidActivateNotification";
NSString *GSThemeDidDeactivateNotification

View file

@ -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

View file

@ -452,65 +452,12 @@
//
- (void) drawRect: (NSRect)rect
{
NSColor *color;
rect = NSIntersectionRect(_bounds, rect);
if (_box_type == NSBoxCustom)
{
if (_transparent)
{
color = [NSColor clearColor];
}
else
{
color = _fill_color;
}
}
else
{
color = [_window backgroundColor];
}
// Fill inside
[color set];
NSRectFill(rect);
// Draw border
switch (_border_type)
{
case NSNoBorder:
break;
case NSLineBorder:
if (_box_type == NSBoxCustom)
{
[_border_color set];
NSFrameRectWithWidth(_border_rect, _border_width);
}
else
{
[[NSColor controlDarkShadowColor] set];
NSFrameRect(_border_rect);
}
break;
case NSBezelBorder:
[[GSTheme theme] drawDarkBezel: _border_rect withClip: rect];
break;
case NSGrooveBorder:
[[GSTheme theme] drawGroove: _border_rect withClip: rect];
break;
}
// Draw title
if (_title_position != NSNoTitle)
{
// If the title is on the border, clip a hole in the later
if ((_border_type != NSNoBorder)
&& ((_title_position == NSAtTop) || (_title_position == NSAtBottom)))
{
[color set];
NSRectFill(_title_rect);
}
[_cell drawWithFrame: _title_rect inView: self];
}
[[GSTheme theme] drawBoxInClipRect: rect
boxType: _box_type
borderType: _border_type
inView: self];
}
- (BOOL) isOpaque