mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Add names for gui elements within a larger control.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27517 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b8033adbb3
commit
99adecef26
3 changed files with 57 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
2009-01-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
* Source/GSTheme.m:
|
||||
Add methods to name specific elements in the gui so that we can
|
||||
locate resources for them and so that override methods can handle
|
||||
them specially.
|
||||
|
||||
2009-01-04 18:32-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/GSToolbarView.m: Use ASSIGN as suggested. This corrects
|
||||
|
|
|
@ -378,10 +378,26 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
*/
|
||||
- (NSString*) name;
|
||||
|
||||
/** Returns the name used to locate theming resources for a particular gui
|
||||
* element. If no name has been set for the particular object, the name
|
||||
* for the class of object is returned.
|
||||
*/
|
||||
- (NSString*) nameForElement: (id)anObject;
|
||||
|
||||
/** Set the name of this theme ... used for testing by Thematic.app
|
||||
*/
|
||||
- (void) setName: (NSString*)aString;
|
||||
|
||||
/** Set the name that is used to identify theming resources for a particular
|
||||
* control or other gui element. The name set for a specific element will
|
||||
* override the default (the name of the class of the element), and this is
|
||||
* used so that where an element is part of a control, it can be displayed
|
||||
* differently from the same class of element used outside that control.<br />
|
||||
* Supplying a nil value for aString simply removes any name setting for
|
||||
* anObject.
|
||||
*/
|
||||
- (void) setName: (NSString*)aString forElement: (id)anObject;
|
||||
|
||||
/**
|
||||
* <p>Provides a standard inspector window used to display information about
|
||||
* the receiver. The default implementation displays the icon, the name,
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#import "Foundation/NSBundle.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSFileManager.h"
|
||||
#import "Foundation/NSMapTable.h"
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSNull.h"
|
||||
#import "Foundation/NSPathUtilities.h"
|
||||
|
@ -73,6 +74,7 @@ static NSString *currentThemeName = nil;
|
|||
static GSTheme *theTheme = nil;
|
||||
static NSMutableDictionary *themes = nil;
|
||||
static NSNull *null = nil;
|
||||
static NSMapTable *names = 0;
|
||||
|
||||
typedef struct {
|
||||
NSBundle *bundle;
|
||||
|
@ -119,6 +121,8 @@ typedef struct {
|
|||
defaultTheme = [[self alloc] initWithBundle: nil];
|
||||
ASSIGN(theTheme, defaultTheme);
|
||||
ASSIGN(currentThemeName, [defaultTheme name]);
|
||||
names = NSCreateMapTable(NSNonOwnedPointerMapKeyCallBacks,
|
||||
NSIntMapValueCallBacks, 0);
|
||||
}
|
||||
/* Establish the theme specified by the user defaults (if any);
|
||||
*/
|
||||
|
@ -531,6 +535,17 @@ typedef struct {
|
|||
return _name;
|
||||
}
|
||||
|
||||
- (NSString*) nameForElement: (id)anObject
|
||||
{
|
||||
NSString *name = (NSString*)NSMapGet(names, (void*)anObject);
|
||||
|
||||
if (name == nil)
|
||||
{
|
||||
name = NSStringFromClass([anObject class]);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
- (void) setName: (NSString*)aString
|
||||
{
|
||||
if (self != defaultTheme)
|
||||
|
@ -539,6 +554,24 @@ typedef struct {
|
|||
}
|
||||
}
|
||||
|
||||
- (void) setName: (NSString*)aString forElement: (id)anObject
|
||||
{
|
||||
if (anObject == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[%@-%@] nil object supplied",
|
||||
NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
|
||||
}
|
||||
if (aString == nil)
|
||||
{
|
||||
NSMapRemove(names, (void*)anObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMapInsert(names, (void*)anObject, (void*)aString);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSWindow*) themeInspector
|
||||
{
|
||||
return [GSThemeInspector sharedThemeInspector];
|
||||
|
|
Loading…
Reference in a new issue