mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Improve color control for theming
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27546 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5fcaad0723
commit
aca8c4b62c
4 changed files with 78 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
|||
2009-01-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSTheme.m:
|
||||
* Source/GSThemeDrawing.m:
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
Add support for setting color of named parts.
|
||||
|
||||
2009-01-06 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSWindowDecorationView.m: No longer adjust the size of
|
||||
|
|
|
@ -337,6 +337,15 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
*/
|
||||
- (void) deactivate;
|
||||
|
||||
/**
|
||||
* Returns the extra color list defined by the receiver.<br />
|
||||
* This is a set of named colors to be used for particular parts of the
|
||||
* gui which have been named by the -setName:forElement:temporary:
|
||||
* method. The presence of a color in this list may override the default
|
||||
* system color for a control.
|
||||
*/
|
||||
- (NSColorList*) extraColors;
|
||||
|
||||
/**
|
||||
* Returns the theme's icon.
|
||||
*/
|
||||
|
|
|
@ -92,6 +92,7 @@ static NSMapTable *names = 0;
|
|||
typedef struct {
|
||||
NSBundle *bundle;
|
||||
NSColorList *colors;
|
||||
NSColorList *extraColors;
|
||||
NSMutableDictionary *images;
|
||||
NSMutableDictionary *normalTiles;
|
||||
NSMutableDictionary *highlightedTiles;
|
||||
|
@ -104,6 +105,7 @@ typedef struct {
|
|||
#define _internal ((internal*)_reserved)
|
||||
#define _bundle _internal->bundle
|
||||
#define _colors _internal->colors
|
||||
#define _extraColors _internal->extraColors
|
||||
#define _images _internal->images
|
||||
#define _normalTiles _internal->normalTiles
|
||||
#define _highlightedTiles _internal->highlightedTiles
|
||||
|
@ -286,6 +288,8 @@ typedef struct {
|
|||
*/
|
||||
[_colors release];
|
||||
_colors = nil;
|
||||
[_extraColors release];
|
||||
_extraColors = nil;
|
||||
|
||||
/*
|
||||
* We step through all the bundle image resources and load them in
|
||||
|
@ -495,6 +499,7 @@ typedef struct {
|
|||
{
|
||||
RELEASE(_bundle);
|
||||
RELEASE(_colors);
|
||||
RELEASE(_extraColors);
|
||||
RELEASE(_images);
|
||||
RELEASE(_normalTiles);
|
||||
RELEASE(_highlightedTiles);
|
||||
|
@ -507,6 +512,31 @@ typedef struct {
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSColorList*) extraColors
|
||||
{
|
||||
if (_extraColors == nil)
|
||||
{
|
||||
NSString *colorsPath;
|
||||
|
||||
colorsPath = [_bundle pathForResource: @"ThemeExtraColors"
|
||||
ofType: @"clr"];
|
||||
if (colorsPath == nil)
|
||||
{
|
||||
_extraColors = [null retain];
|
||||
}
|
||||
else
|
||||
{
|
||||
_extraColors = [[NSColorList alloc] initWithName: @"ThemeExtra"
|
||||
fromFile: colorsPath];
|
||||
}
|
||||
}
|
||||
if ((id)_extraColors == (id)null)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return _extraColors;
|
||||
}
|
||||
|
||||
- (NSImage*) icon
|
||||
{
|
||||
if (_icon == nil)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
|
||||
#import "GSThemePrivate.h"
|
||||
#import "AppKit/NSColorList.h"
|
||||
#import "AppKit/NSGraphics.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
|
||||
|
@ -41,6 +42,7 @@
|
|||
{
|
||||
GSDrawTiles *tiles = nil;
|
||||
NSColor *color = nil;
|
||||
NSColorList *extra = [self extraColors];
|
||||
NSString *name = [self nameForElement: cell];
|
||||
|
||||
if (name == nil)
|
||||
|
@ -50,15 +52,29 @@
|
|||
|
||||
if (state == GSThemeNormalState)
|
||||
{
|
||||
color = [NSColor controlBackgroundColor];
|
||||
color = [extra colorWithKey: name];
|
||||
if (color == nil)
|
||||
{
|
||||
color = [NSColor controlBackgroundColor];
|
||||
}
|
||||
}
|
||||
else if (state == GSThemeHighlightedState)
|
||||
{
|
||||
color = [NSColor selectedControlColor];
|
||||
color = [extra colorWithKey:
|
||||
[name stringByAppendingString: @"Highlighted"]];
|
||||
if (color == nil)
|
||||
{
|
||||
color = [NSColor selectedControlColor];
|
||||
}
|
||||
}
|
||||
else if (state == GSThemeSelectedState)
|
||||
{
|
||||
color = [NSColor selectedControlColor];
|
||||
color = [extra colorWithKey:
|
||||
[name stringByAppendingString: @"Selected"]];
|
||||
if (color == nil)
|
||||
{
|
||||
color = [NSColor selectedControlColor];
|
||||
}
|
||||
}
|
||||
|
||||
tiles = [self tilesNamed: name state: state cache: YES];
|
||||
|
@ -315,7 +331,7 @@
|
|||
[cell setImage: [NSImage imageNamed: @"common_ArrowUp"]];
|
||||
[cell setAlternateImage: [NSImage imageNamed: @"common_ArrowUpH"]];
|
||||
[cell setImagePosition: NSImageOnly];
|
||||
name = GSScrollerDownArrow;
|
||||
name = GSScrollerUpArrow;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -324,7 +340,7 @@
|
|||
[cell setImage: [NSImage imageNamed: @"common_ArrowDown"]];
|
||||
[cell setAlternateImage: [NSImage imageNamed: @"common_ArrowDownH"]];
|
||||
[cell setImagePosition: NSImageOnly];
|
||||
name = GSScrollerUpArrow;
|
||||
name = GSScrollerDownArrow;
|
||||
}
|
||||
}
|
||||
[self setName: name forElement: cell temporary: YES];
|
||||
|
@ -354,20 +370,29 @@
|
|||
|
||||
- (NSCell*) cellForScrollerKnobSlot: (BOOL)horizontal
|
||||
{
|
||||
NSButtonCell *cell;
|
||||
NSButtonCell *cell;
|
||||
NSColorList *extra = [self extraColors];
|
||||
NSColor *color;
|
||||
|
||||
cell = [NSButtonCell new];
|
||||
[cell setBordered: NO];
|
||||
[cell setStringValue: nil];
|
||||
[cell setBackgroundColor: [NSColor scrollBarColor]];
|
||||
|
||||
if (horizontal)
|
||||
{
|
||||
color = [extra colorWithKey: GSScrollerHorizontalSlot];
|
||||
[self setName: GSScrollerHorizontalSlot forElement: cell temporary: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
color = [extra colorWithKey: GSScrollerVerticalSlot];
|
||||
[self setName: GSScrollerVerticalSlot forElement: cell temporary: YES];
|
||||
}
|
||||
if (color == nil)
|
||||
{
|
||||
color = [NSColor scrollBarColor];
|
||||
}
|
||||
[cell setBackgroundColor: color];
|
||||
RELEASE(cell);
|
||||
return cell;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue