mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
api cleanup
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29039 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
38cd3d8edb
commit
f2a8d1d58c
6 changed files with 129 additions and 39 deletions
|
@ -1,3 +1,12 @@
|
|||
2009-11-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSTheme.m:
|
||||
* Source/NSMenuItemCell.m:
|
||||
* Source/GSThemeDrawing.m:
|
||||
* Source/NSScrollView.m:
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
Separate cache control from normal fetching of tiles and colors.
|
||||
|
||||
2009-11-19 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
|
|
|
@ -458,6 +458,14 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
*/
|
||||
- (Class) colorClass;
|
||||
|
||||
/** Removes the name from the color cache forcing it to be re-created next
|
||||
* time the named color is required.<br />
|
||||
* Passing nil for aName removes all named colors.<br />
|
||||
* Passing a negative value for elementState applies to all caches.
|
||||
*/
|
||||
- (void) colorFlush: (NSString*)aName
|
||||
state: (GSThemeControlState)elementState;
|
||||
|
||||
/**
|
||||
* This returns the color for drawing the item whose name is aName in
|
||||
* the specified state. If aName is nil or if there is no color defined
|
||||
|
@ -465,14 +473,10 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
* returns nil.<br />
|
||||
* The standard names used for the parts of various controls are declared
|
||||
* in GSTheme.h<br />
|
||||
* See also the -tilesNamed:state:cache: method.<br />
|
||||
* The useCache argument controls whether the information is retrieved
|
||||
* from cache or regenerated from information in the theme bundle, and
|
||||
* should normally be YES.
|
||||
* See also the -tilesNamed:state: method.
|
||||
*/
|
||||
- (NSColor*) colorNamed: (NSString*)aName
|
||||
state: (GSThemeControlState)elementState
|
||||
cache: (BOOL)useCache;
|
||||
state: (GSThemeControlState)elementState;
|
||||
|
||||
/**
|
||||
* Returns the system color list defined by the receiver.<br />
|
||||
|
@ -611,6 +615,14 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
*/
|
||||
- (NSWindow*) themeInspector;
|
||||
|
||||
/** Removes the name tile images from cahce, forcing re-creation next
|
||||
* time the named tiles are required.<br />
|
||||
* Passing nil for aName removes all named tiles.<br />
|
||||
* Passing a negative value for elementState applies to all caches.
|
||||
*/
|
||||
- (void) tilesFlush: (NSString*)aName
|
||||
state: (GSThemeControlState)elementState;
|
||||
|
||||
/**
|
||||
* Returns the tile image information for a particular image name,
|
||||
* or nil if there is no such information or the name is nil.<br />
|
||||
|
@ -621,16 +633,13 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
* returned by this method can be passed to the
|
||||
* -fillRect:withTiles:background:fillStyle: method.<br />
|
||||
* The elementState argument specifies the state for which tiles are
|
||||
* requested.<br />
|
||||
* The useCache argument controls whether the information is retrieved
|
||||
* from cache or regenerated from information in the theme bundle, and
|
||||
* should normally be YES.<br />
|
||||
* See the -colorNamed:state:cache: method for determining colors to be
|
||||
* requested.
|
||||
* See the -colorNamed:state: method for determining colors to be
|
||||
* used for drawing specific gui elements.
|
||||
*/
|
||||
- (GSDrawTiles*) tilesNamed: (NSString*)aName
|
||||
state: (GSThemeControlState)elementState
|
||||
cache: (BOOL)useCache;
|
||||
state: (GSThemeControlState)elementState;
|
||||
|
||||
/**
|
||||
* Return the theme's version string.
|
||||
*/
|
||||
|
|
102
Source/GSTheme.m
102
Source/GSTheme.m
|
@ -37,6 +37,7 @@
|
|||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSUserDefaults.h>
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "GNUstepGUI/GSTheme.h"
|
||||
#import "AppKit/NSApplication.h"
|
||||
#import "AppKit/NSButton.h"
|
||||
|
@ -421,11 +422,6 @@ typedef struct {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We could cache tile info here, but it's probably better for the
|
||||
* tilesNamed:state:cache: method to do it lazily.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Use the GSThemeDomain key in the info dictionary of the theme to
|
||||
* set a defaults domain which will establish user defaults values
|
||||
|
@ -517,21 +513,44 @@ typedef struct {
|
|||
return [NSColorList class];
|
||||
}
|
||||
|
||||
- (void) colorFlush: (NSString*)aName
|
||||
state: (GSThemeControlState)elementState
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
||||
NSAssert(elementState <= GSThemeSelectedState, NSInvalidArgumentException);
|
||||
if (elementState < 0)
|
||||
{
|
||||
pos = 0;
|
||||
end = GSThemeSelectedState;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = elementState;
|
||||
end = elementState;
|
||||
}
|
||||
while (pos <= end)
|
||||
{
|
||||
if (_extraColors[pos] != nil)
|
||||
{
|
||||
[_extraColors[pos] release];
|
||||
_extraColors[pos] = nil;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSColor*) colorNamed: (NSString*)aName
|
||||
state: (GSThemeControlState)elementState
|
||||
cache: (BOOL)useCache
|
||||
{
|
||||
NSColor *c = nil;
|
||||
|
||||
NSAssert(elementState <= GSThemeSelectedState, NSInvalidArgumentException);
|
||||
NSAssert(elementState >= 0, NSInvalidArgumentException);
|
||||
|
||||
if (aName != nil)
|
||||
{
|
||||
if (useCache == NO)
|
||||
{
|
||||
[_extraColors[elementState] release];
|
||||
_extraColors[elementState] = nil;
|
||||
}
|
||||
if (_extraColors[elementState] == nil)
|
||||
{
|
||||
NSString *colorsPath;
|
||||
|
@ -754,6 +773,29 @@ typedef struct {
|
|||
return [_bundle infoDictionary];
|
||||
}
|
||||
|
||||
- (void) mapMethod: (SEL)src toMethod: (SEL)dst ofClass: (Class)c
|
||||
{
|
||||
GSMethod method;
|
||||
BOOL instance = YES;
|
||||
|
||||
method = GSGetMethod([self class], src, instance, NO);
|
||||
if (method == 0)
|
||||
{
|
||||
instance = NO;
|
||||
method = GSGetMethod([self class], src, instance, NO);
|
||||
}
|
||||
if (method != 0)
|
||||
{
|
||||
GSMethodList list;
|
||||
|
||||
list = GSAllocMethodList(1);
|
||||
GSAppendMethodToList(list,
|
||||
dst, method->method_types, method->method_imp, YES);
|
||||
GSAddMethodList(c, list, instance);
|
||||
GSFlushMethodCacheForClass(c);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString*) name
|
||||
{
|
||||
if (self == defaultTheme)
|
||||
|
@ -820,20 +862,53 @@ typedef struct {
|
|||
return [GSThemeInspector sharedThemeInspector];
|
||||
}
|
||||
|
||||
- (void) tilesFlush: (NSString*)aName
|
||||
state: (GSThemeControlState)elementState
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
||||
NSAssert(elementState <= GSThemeSelectedState, NSInvalidArgumentException);
|
||||
if (elementState < 0)
|
||||
{
|
||||
pos = 0;
|
||||
end = GSThemeSelectedState;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = elementState;
|
||||
end = elementState;
|
||||
}
|
||||
while (pos <= end)
|
||||
{
|
||||
NSMutableDictionary *cache;
|
||||
|
||||
cache = _tiles[pos++];
|
||||
if (aName == nil)
|
||||
{
|
||||
return [cache removeAllObjects];
|
||||
}
|
||||
else
|
||||
{
|
||||
[cache removeObjectForKey: aName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (GSDrawTiles*) tilesNamed: (NSString*)aName
|
||||
state: (GSThemeControlState)elementState
|
||||
cache: (BOOL)useCache
|
||||
{
|
||||
GSDrawTiles *tiles;
|
||||
NSMutableDictionary *cache;
|
||||
|
||||
NSAssert(elementState <= GSThemeSelectedState, NSInvalidArgumentException);
|
||||
NSAssert(elementState >= 0, NSInvalidArgumentException);
|
||||
if (aName == nil)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
cache = _tiles[elementState];
|
||||
tiles = (useCache == YES) ? [cache objectForKey: aName] : nil;
|
||||
tiles = [cache objectForKey: aName];
|
||||
if (tiles == nil)
|
||||
{
|
||||
NSDictionary *info;
|
||||
|
@ -959,6 +1034,7 @@ typedef struct {
|
|||
{
|
||||
return [[self infoDictionary] objectForKey: @"GSThemeVersion"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GSTheme (Private)
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
name = @"NSButton";
|
||||
}
|
||||
|
||||
color = [self colorNamed: name state: state cache: YES];
|
||||
color = [self colorNamed: name state: state];
|
||||
if (color == nil)
|
||||
{
|
||||
if (state == GSThemeNormalState)
|
||||
|
@ -81,7 +81,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
tiles = [self tilesNamed: name state: state cache: YES];
|
||||
tiles = [self tilesNamed: name state: state];
|
||||
if (tiles == nil)
|
||||
{
|
||||
switch (style)
|
||||
|
@ -159,7 +159,7 @@
|
|||
name = @"NSButton";
|
||||
}
|
||||
|
||||
tiles = [self tilesNamed: name state: state cache: YES];
|
||||
tiles = [self tilesNamed: name state: state];
|
||||
if (tiles == nil)
|
||||
{
|
||||
switch (style)
|
||||
|
@ -385,15 +385,13 @@
|
|||
if (horizontal)
|
||||
{
|
||||
color = [self colorNamed: GSScrollerHorizontalSlot
|
||||
state: GSThemeNormalState
|
||||
cache: YES];
|
||||
state: GSThemeNormalState];
|
||||
[self setName: GSScrollerHorizontalSlot forElement: cell temporary: YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
color = [self colorNamed: GSScrollerVerticalSlot
|
||||
state: GSThemeNormalState
|
||||
cache: YES];
|
||||
state: GSThemeNormalState];
|
||||
[self setName: GSScrollerVerticalSlot forElement: cell temporary: YES];
|
||||
}
|
||||
if (color == nil)
|
||||
|
@ -415,8 +413,7 @@
|
|||
NSColor *color;
|
||||
|
||||
color = [self colorNamed: @"toolbarBackgroundColor"
|
||||
state: GSThemeNormalState
|
||||
cache: YES];
|
||||
state: GSThemeNormalState];
|
||||
if (color == nil)
|
||||
{
|
||||
color = [NSColor clearColor];
|
||||
|
@ -429,8 +426,7 @@
|
|||
NSColor *color;
|
||||
|
||||
color = [self colorNamed: @"toolbarBorderColor"
|
||||
state: GSThemeNormalState
|
||||
cache: YES];
|
||||
state: GSThemeNormalState];
|
||||
if (color == nil)
|
||||
{
|
||||
color = [NSColor grayColor];
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
state = GSThemeSelectedState;
|
||||
}
|
||||
|
||||
color = [[GSTheme theme] colorNamed: @"NSMenuItem" state: state cache: YES];
|
||||
color = [[GSTheme theme] colorNamed: @"NSMenuItem" state: state];
|
||||
if (color == nil)
|
||||
{
|
||||
if ((state == GSThemeHighlightedState) || (state == GSThemeSelectedState))
|
||||
|
|
|
@ -1154,7 +1154,7 @@ static float scrollerWidth;
|
|||
{
|
||||
name = @"NSScrollView";
|
||||
}
|
||||
color = [theme colorNamed: name state: GSThemeNormalState cache: YES];
|
||||
color = [theme colorNamed: name state: GSThemeNormalState];
|
||||
if (color == nil)
|
||||
{
|
||||
color = [NSColor controlDarkShadowColor];
|
||||
|
|
Loading…
Reference in a new issue