// For gradient types
#include "AppKit/NSButtonCell.h"
#if OS_API_VERSION(GS_API_NONE,GS_API_NONE)
@class NSArray;
@class NSBundle;
@class NSColor;
@class NSDictionary;
@class NSImage;
@class GSDrawTiles;
/**
* This defines how the values in a tile array should be used when
* drawing a rectangle. Mostly this just effects the center, middle
* image of the rectangle.
* FillStyleMatrix is provided for the use of theme editors wishing
* to display the tile.
*/
typedef enum {
GSThemeFillStyleNone, /** CM image is not drawn */
GSThemeFillStyleScale, /** CM image is scaled to fit */
GSThemeFillStyleRepeat, /** CM image is tiled from bottom left */
GSThemeFillStyleCenter, /** CM image is tiled from the center */
GSThemeFillStyleMatrix /** a matrix of nine separated images */
} GSThemeFillStyle;
/** Notification sent when a theme has just become active.
*/
APPKIT_EXPORT NSString *GSThemeDidActivateNotification;
/** Notification sent when a theme has become inactive.
*/
APPKIT_EXPORT NSString *GSThemeDidDeactivateNotification;
/**
This interface is HIGHLY unstable
and incomplete at present.
This is a class used for 'theming', which is mostly a matter of
encapsulating common drawing behaviors so that GUI appearance can
be easily modified, but also includes mechanisms for altering
some GUI behavior (such mas orientation and position of menus).
Methods in this class standardize drawing of buttons, borders
and other common GUI elements, so that all other classes within
the GUI will provide a consistent appearance by using these
methods.
The default implementation uses the standard configurable colors
defined in NSColor, such as controlLightHighlightColor
,
controlShadowColor
and controlDarkShadowColor
.
Themes are expected to override the default system color list with their
own versions, and this class cooperates with [NSColor] and [NSColorList]
to establish the correct system color list when a theme is activated.
The class provides a mechanism for automatic loading of theme bundles
consisting of resources used to define how drawing is done, plus an
optional binary subclass of this class (to replace/extend the drawing
methods this class provides).
In future this class should provide mechanisms to draw controls by
tiling of images, and provide control over GUI behavior by controlling
the values returned by NSInterfaceStyleForKey() so that controls
use the appropriate behavior.
*/
@interface GSTheme : NSObject
{
@private
NSBundle *_bundle;
NSMutableArray *_images;
NSMutableDictionary *_tiles;
NSImage *_icon;
}
/**
* Creates and displays a panel allowing selection of different themes
* and display of the current theme inspector.
*/
+ (void) orderFrontSharedThemePanel: (id)sender;
/**
* Set the currently active theme to be the instance specified.
* You do not normally need to call this method as it is called
* automatically when the user default which specifies the current
* theme (GSTheme) is updated.
*/
+ (void) setTheme: (GSTheme*)theme;
/**
* Returns the currently active theme instance. This is the value most
* recently set using +setTheme: or (if none has been set) is a default
* instance of the base class.
*/
+ (GSTheme*) theme;
/**
* This method is called automatically when the receiver is made into
* the currently active theme by the +setTheme: method. Subclasses may
* override it to perform startup operations, but should call the super
* class implementation after doing their own thing.
*
* The base implementation handles setup and caching of the system
* color list, standard image information, tiling information,
* and user defaults.
* It then sends a GSThemeDidActivateNotification to allow other
* parts of the GUI library to update themselves from the new theme.
* If the theme sets an alternative system color list, the notification
* userInfo dictionary will contain that list keyed on Colors.
*
* Finally, this method marks all windows in the application as needing
* update ... so they will draw themselves with the new theme information.
*
*/
- (void) activate;
/**
* Returns the names of the theme's authors.
*/
- (NSArray*) authors;
/**
* Return the bundle containing the resources used by the current theme.
*/
- (NSBundle*) bundle;
/**
* This method is called automatically when the receiver is stopped from
* being the currently active theme by the use of the +setTheme: method
* to make another theme active. Subclasses may override it to perform
* shutdown operations, but should call the super class implementation
* after their own.
*
* The base implementation handles some cleanup and then sends a
* GSThemeDidDeactivateNotification to allow other parts of the GUI library
* to update themselves.
*
*/
- (void) deactivate;
/**
* Returns the theme's icon.
*/
- (NSImage*) icon;
/**
* Initialise an instance of a theme with the specified resource bundle.
* You don't need to call this method directly, but if you are subclassing
* you may need to override this to provide additional initialisation.
*/
- (id) initWithBundle: (NSBundle*)bundle;
/**
* Returns the info dictionary for this theme. In the base class
* implementation this is simply the info dictionary of the theme
* bundle, but subclasses may override this method to return extra
* or different information.
*
* Keys found in this dictionary include:
*
*
* GSThemeDomain
* A dictionary whose key/value pairs are used to set up new values
* in the GSThemeDomain domain of the user defaults system, and hence
* define values for these unless overridden by values set explicitly by
* the user.
*
* GSThemeTiles
* A dictionary keyed on tile names and containing the following:
*
* FileName
* Name of the file (within the GSThemeTiles directory in the
* bundle) in which the image for this tile is tored.
*
* HorizontalDivision
* The offet along the X-axis used to divide the image into
* columns of tiles.
*
* VerticalDivision
* The offet along the Y-axis used to divide the image into
* rows of tiles.
*
*
*
*
*/
- (NSDictionary*) infoDictionary;
/**
* Return the theme's name.
*/
- (NSString*) name;
/**
* Provides a standard inspector window used to display information about
* the receiver. The default implementation displays the icon, the name,
* and the authors of the theme.
*
* The code managing this object (if any) must be prepared to have the
* content view of the window reparented into another window for display
* on screen.
*
*/
- (NSWindow*) themeInspector;
/**
* Returns the tile image information for a particular image name,
* or nil if there is no such information.
* The GUI library uses this internally to handling tiling of image
* information to draw user interface elements. The tile information
* returned by this method can be passed to the
* -fillRect:withTiles:background:fillStyle: method.
* The useCache argument controls whether the information is retrieved
* from cache or regenerated from information in the theme bundle.
*/
- (GSDrawTiles*) tilesNamed: (NSString*)aName cache: (BOOL)useCache;
@end
/**
* Theme drawing methods
*/
@interface GSTheme (Drawing)
/**
* Draws a button frame and background (not its content) for the specified
* cell and view.
* Returns the rectangle into which the cell contents should be drawn.
*/
- (NSRect) drawButton: (NSRect)frame
in: (NSButtonCell*)cell
view: (NSView*)view
style: (int)style
state: (int)state;
/** Draws the indicator (normally a dotted rectangle) to show that
* the view currently has keyboard focus.
*/
- (void) drawFocusFrame: (NSRect)frame view: (NSView*)view;
/**
* Draws the background of a window ... normally a simple fill with the
* the window's background color.
*/
- (void) drawWindowBackground: (NSRect)frame view: (NSView*)view;
@end
/**
* Helper functions for drawing standard items.
*/
@interface GSTheme (MidLevelDrawing)
/** Draw a standard button */
- (NSRect) drawButton: (NSRect)border withClip: (NSRect)clip;
/** Draw a dark bezel border */
- (NSRect) drawDarkBezel: (NSRect)border withClip: (NSRect)clip;
/** Draw a "dark" button border (used in tableviews) */
- (NSRect) drawDarkButton: (NSRect)border withClip: (NSRect)clip;
/** Draw a frame photo border. Used in NSImageView. */
- (NSRect) drawFramePhoto: (NSRect)border withClip: (NSRect)clip;
/** Draw a gradient border. */
- (NSRect) drawGradientBorder: (NSGradientType)gradientType
inRect: (NSRect)border
withClip: (NSRect)clip;
/** Draw a grey bezel border */
- (NSRect) drawGrayBezel: (NSRect)border withClip: (NSRect)clip;
/** Draw a groove border */
- (NSRect) drawGroove: (NSRect)border withClip: (NSRect)clip;
/** Draw a light bezel border */
- (NSRect) drawLightBezel: (NSRect)border withClip: (NSRect)clip;
/** Draw a white bezel border */
- (NSRect) drawWhiteBezel: (NSRect)border withClip: (NSRect)clip;
@end
/**
* Low level drawiong methods ... themes may use these for drawing,
* but should not normally override them.
*/
@interface GSTheme (LowLevelDrawing)
/**
* Method to tile the supplied image to fill the horizontal rectangle.
*/
- (void) fillHorizontalRect: (NSRect)rect
withImage: (NSImage*)image
fromRect: (NSRect)source
flipped: (BOOL)flipped;
/**
* Tile rect with image. The tiling starts with the origin of the
* first copy of the image at the bottom left corner of the rect
* unless center is YES, in which case the image is centered in rect
* and tiled outwards from that.
*/
- (void) fillRect: (NSRect)rect
withRepeatedImage: (NSImage*)image
fromRect: (NSRect)source
center: (BOOL)center;
/**
* Method to tile a rectangle given an array of nine tile images.
* This draws the left, right, top and bottom borders by tiling the
* images at TileCL, TileCR, TileTM and TileBM respectively. It then
* draws the four corner images and finally deals with the remaining
* space in the middle according to the specified style.
* The background color specified is used where style is FillStyleNone.
*/
- (void) fillRect: (NSRect)rect
withTiles: (GSDrawTiles*)tiles
background: (NSColor*)color
fillStyle: (GSThemeFillStyle)style;
/**
* Method to tile the supplied image to fill the vertical rectangle.
*/
- (void) fillVerticalRect: (NSRect)rect
withImage: (NSImage*)image
fromRect: (NSRect)source
flipped: (BOOL)flipped;
@end
#endif /* OS_API_VERSION */
#endif /* _GNUstep_H_GSTheme */