#if OS_API_VERSION(GS_API_NONE,GS_API_NONE)
@class NSArray;
@class NSBundle;
@class NSBrowserCell;
@class NSDictionary;
@class NSButton;
@class NSColor;
@class NSColorList;
@class NSColorWell;
@class NSImage;
@class NSMenuItemCell;
@class NSPopUpButtonCell;
@class NSMenuView;
@class NSProgressIndicator;
@class NSTableHeaderCell;
@class NSTabViewItem;
@class GSDrawTiles;
@class GSTitleView;
APPKIT_EXPORT NSString *GSSwitch;
APPKIT_EXPORT NSString *GSRadio;
/* First, declare names used for obtaining colors and/or tiles for specific
* controls and parts of controls.
*/
/* Names for the component parts of a scroller,
* allowing tiles and/or colors to be set for them.
*/
APPKIT_EXPORT NSString *GSScrollerDownArrow;
APPKIT_EXPORT NSString *GSScrollerHorizontalKnob;
APPKIT_EXPORT NSString *GSScrollerHorizontalSlot;
APPKIT_EXPORT NSString *GSScrollerLeftArrow;
APPKIT_EXPORT NSString *GSScrollerRightArrow;
APPKIT_EXPORT NSString *GSScrollerUpArrow;
APPKIT_EXPORT NSString *GSScrollerVerticalKnob;
APPKIT_EXPORT NSString *GSScrollerVerticalSlot;
/* Names for table view parts */
APPKIT_EXPORT NSString *GSTableHeader;
APPKIT_EXPORT NSString *GSTableCorner;
/*
* Browser part names.
*/
APPKIT_EXPORT NSString *GSBrowserHeader;
/*
* Menu part names.
*/
APPKIT_EXPORT NSString *GSMenuHorizontalBackground;
APPKIT_EXPORT NSString *GSMenuVerticalBackground;
APPKIT_EXPORT NSString *GSMenuTitleBackground;
APPKIT_EXPORT NSString *GSMenuHorizontalItem;
APPKIT_EXPORT NSString *GSMenuVerticalItem;
APPKIT_EXPORT NSString *GSMenuSeparatorItem;
/* NSPopUpButton parts */
APPKIT_EXPORT NSString *GSPopUpButton;
/*
* Progress Indicator part names.
*/
APPKIT_EXPORT NSString *GSProgressIndicatorBezel;
APPKIT_EXPORT NSString *GSProgressIndicatorBarDeterminate;
/*
* Color well part names.
*/
APPKIT_EXPORT NSString *GSColorWell;
APPKIT_EXPORT NSString *GSColorWellInnerBorder;
/* NSSliderCell parts */
APPKIT_EXPORT NSString *GSSliderHorizontalTrack;
APPKIT_EXPORT NSString *GSSliderVerticalTrack;
/* NSBox parts */
APPKIT_EXPORT NSString *GSBoxBorder;
/* NSTabView parts */
APPKIT_EXPORT NSString *GSTabViewSelectedTabFill;
APPKIT_EXPORT NSString *GSTabViewUnSelectedTabFill;
APPKIT_EXPORT NSString *GSTabViewBackgroundTabFill;
APPKIT_EXPORT NSString *GSTabViewBottomSelectedTabFill;
APPKIT_EXPORT NSString *GSTabViewBottomUnSelectedTabFill;
APPKIT_EXPORT NSString *GSTabViewBottomBackgroundTabFill;
APPKIT_EXPORT NSString *GSTabViewLeftSelectedTabFill;
APPKIT_EXPORT NSString *GSTabViewLeftUnSelectedTabFill;
APPKIT_EXPORT NSString *GSTabViewLeftBackgroundTabFill;
APPKIT_EXPORT NSString *GSTabViewRightSelectedTabFill;
APPKIT_EXPORT NSString *GSTabViewRightUnSelectedTabFill;
APPKIT_EXPORT NSString *GSTabViewRightBackgroundTabFill;
/**
* Structure to describe the size of top/bottom/left/right margins inside
* a button
*/
typedef struct GSThemeMargins
{
CGFloat left;
CGFloat right;
CGFloat top;
CGFloat bottom;
} GSThemeMargins;
/**
* 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 = 0, /** CM image is not drawn */
GSThemeFillStyleScale = 1, /** CM image is scaled to fit */
GSThemeFillStyleRepeat = 2, /** CM image is tiled from bottom left */
GSThemeFillStyleCenter = 3, /** CM image is tiled from the center */
GSThemeFillStyleMatrix = 4, /** a matrix of nine separated images */
GSThemeFillStyleScaleAll = 5 /** All 'stretchable' images (i.e. not
the four corners) are scaled to fill
their area, instead of being repeated */
} GSThemeFillStyle;
/** Function to convert a fill style enumeration value to a string.
* Returns nil on failure.
*/
extern NSString *
GSThemeStringFromFillStyle(GSThemeFillStyle s);
/** Function to convert a string to a fill style enumeration value.
* Returns GSThemeFillStyleNone if the string is not a valid name.
*/
extern GSThemeFillStyle
GSThemeFillStyleFromString(NSString *s);
/**
* This enumeration provides constants for informing drawing methods
* what state a control is in (and consequently how the display element
* being drawn should be presented).
* NB. GSThemeNormalState must be 0 and GSThemeSelectedState must be the
* last state, in order to allow code to iterate through all the states.
*/
typedef enum {
GSThemeNormalState = 0, /** A control in its normal state */
GSThemeFirstResponderState,
GSThemeDisabledState, /** A control which is disabled */
GSThemeHighlightedFirstResponderState,
GSThemeHighlightedState, /** A control which is highlighted */
GSThemeSelectedFirstResponderState,
GSThemeSelectedState /** A control which is selected */
} GSThemeControlState;
/** Notification sent when a theme has just become active.
* The notification is posted by the -activate method.
* This is primarily for internal use by AppKit controls which
* need to readjust how they are displayed when a new theme is in use.
* Theme subclasses must ensure that the theme is ready for use by the
* time this notification is posted (which generally means that
* they should have finished putting all resources in place in
* response to a GSThemeWillActivateNotification).
*/
APPKIT_EXPORT NSString *GSThemeDidActivateNotification;
/** Notification sent when a theme has just become inactive.
* The notification is posted by the -deactivate method.
* This is primarily for use by subclasses of GSTheme which need to perform
* additional cleanup after the theme stops being used.
*/
APPKIT_EXPORT NSString *GSThemeDidDeactivateNotification;
/** Notification sent when a theme is about to become active.
* The notification is posted by the -activate method.
* This is for use by subclasses of GSTheme which need to perform
* additional setup before the theme starts being used by AppKit controls.
* At the point when this notification is called, the color, image, and
* defaults information from the theme will have been installed and the
* theme subclass may perform final adjustments.
*/
APPKIT_EXPORT NSString *GSThemeWillActivateNotification;
/** Notification sent when a theme is about to become inactive.
* The notification is posted by the -deactivate method.
* This allows code to make preparatory changes before the current theme
* is deactivated, but subclasses should not make the theme unusable
* at this point as the AppKit may be doing its own cleanup in response
* to the notification.
*/
APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
/**
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 as 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
void *_reserved;
}
/**
* Loads a theme from a theme bundle of the specified name, which may be
* either a full path name of the theme bundle, or a simple theme name
* (in which case the standard directories are searched for it) or nil
* (in which case the default GNUstep theme is returned).
* Returns the loaded theme but does not make it the current theme,
* to do that you will need to call the +setTheme: method.
*/
+ (GSTheme*) loadThemeNamed: (NSString*)themeName;
/**
* 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, however, the method is not
* really intended to be overridden, and subclasses should generally
* handle activation work in response to the GSThemeWillActivatenotification
* posted by this method.
*
* The base implementation handles setup and caching of the system
* color list, standard image information, tiling information,
* and user defaults.
* It then sends a GSThemeWillActivateNotification to allow subclasses to
* perform further activation work, and a GSThemeDidActivateNotification
* to allow other parts of the GUI library to update themselves from the
* new theme.
*
* Finally, this method marks all windows in the application as needing
* update ... so they will draw themselves with the new theme information.
*
* NB. If a GSTheme subclass is integrating to an external native theming
* mechanism in order to make GNUstep apps look like native apps, then the
* external theme may change dynamically and the GSTheme subclass may need
* to change the GNUstep application to reflect this change. When this
* happens, the update should be handled by the subclass calling -deactivate
* and then -activate to make the changes 'live'.
*
*/
- (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;
/**
* Returns the class used by the theme for loading color lists. The default
* implementation returns the NSColorList class, but a subclass may override
* this to return a color list class whose values change dynamically in
* response to changes of a native theming API for instance.
* The class returned by this method should be NSColorList or one of its
* subclasses. Subclasses should note that GSTheme will initialise the
* instances of the class using the [NSColerList-initWithName:fromFile:]
* method.
*/
- (Class) colorClass;
/** Removes the name from the color cache forcing it to be re-created next
* time the named color is required.
* Passing nil for aName removes all named colors.
* 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
* for the particular combination of item name and state, the method
* returns nil.
* The standard names used for the parts of various controls are declared
* in GSTheme.h
* See also the -tilesNamed:state: method.
*/
- (NSColor*) colorNamed: (NSString*)aName
state: (GSThemeControlState)elementState;
/**
* Returns the system color list defined by the receiver.
* The default implementation returns the color list provided in the
* theme bundle (if any) or the default system color list.
*/
- (NSColorList*) colors;
/**
* 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 it is preferred for subclasses to perform
* their own deactivation in response to a GSThemeWillDeactivateNotification.
*
* The base implementation sends a GSThemeWillDeactivateNotification to
* allow subclasses to perform cleanup, then restores image, color and default
* information to the state before the theme was activates, and finally
* sends a GSThemeDidDeactivateNotification to allow other parts of the
* GUI library to update themselves.
*
* NB. If a GSTheme subclass is integrating to an external native theming
* mechanism in order to make GNUstep apps look like native apps, then the
* external theme may change dynamically and the GSTheme subclass may need
* to change the GNUstep application to reflect this change. When this
* happens, the update should be handled by the subclass calling -deactivate
* and then -activate to make the changes 'live'.
*
*/
- (void) deactivate;
/**
* Returns the theme's icon.
*/
- (NSImage*) icon;
/**
* Returns the class used by the theme for loading images. The default
* implementation returns the NSImage class, but a subclass may override
* this to return an image class whose instances dynamically alter what
* they draw in response to changes of a native theming API for instance.
* This method must return the NSImage class or one of its subclasses.
* Subclass implementations should note that instances will be initialised
* using the [NSImage-initWithContentsOfFile:] method and will use the
* [NSImage-imageFileTypes] method to determine which image files can be
* loaded.
*/
- (Class) imageClass;
/**
* 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 stored.
*
* HorizontalDivision
* The offset along the X-axis used to divide the image into
* columns of tiles.
*
* VerticalDivision
* The offer along the Y-axis used to divide the image into
* rows of tiles.
*
*
*
*
*/
- (NSDictionary*) infoDictionary;
/**
* Return the theme's name.
*/
- (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 this method
* returns nil.
*/
- (NSString*) nameForElement: (id)anObject;
/** Returns the original implementation of a method overridden by this
* theme, or zero if the method was not overridden.
*
* A theme may override a method of another class by implementing a method
* whose name is '_overrideXXXMethod_YYY' where 'XXX' is the name of the
* class whose method is to be overridden, and 'YYY' is the normal name of
* the method in that class.
* eg. _overrideNSScrollerMethod_drawRect:
*
* NB. The overriding method may not access instance variable directly and
* must cast all uses of 'self' to be the correct class.
*
*/
- (IMP) overriddenMethod: (SEL)selector for: (id)receiver;
/** 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. 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.
* Supplying a nil value for aString simply removes any name setting for
* anObject.
* Supplying nil for anObject is illegal (raises an exception) unless
* the value of aString is also nil (and the method does nothing).
* Any control which uses this method to set names for subsidiary elements
* must also make sure to remove the name mapping before that element is
* deallocated, unless the takeOwnership option is YES, in which case
* anObject is retained, the name mapping lasts only until the receiver
* is deactivated, and at that point anObject is released.
*/
- (void) setName: (NSString*)aString
forElement: (id)anObject
temporary: (BOOL)takeOwnership;
/**
* 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 re-parented into another window for display
* on screen.
*
*/
- (NSWindow*) themeInspector;
/** Removes the name tile images from cache, forcing re-creation next
* time the named tiles are required.
* Passing nil for aName removes all named tiles.
* 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.
* The standard names used for the parts of various controls are declared
* in GSTheme.h
* 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 elementState argument specifies the state for which tiles are
* requested.
* See the -colorNamed:state: method for determining colors to be
* used for drawing specific GUI elements.
*/
- (GSDrawTiles*) tilesNamed: (NSString*)aName
state: (GSThemeControlState)elementState;
/**
* Return the theme's version string.
*/
- (NSString*) versionString;
/**
* Return the theme's license.
*/
- (NSString*) license;
@end
/**
* Theme drawing methods.
* Methods which return information/resources are generally expected
* (ie unless explicitly documented otherwise) to be returning something
* which persists until the method is called again or until the current
* theme is deactivated (whichever comes first).
* This means that drawing code should not need to
* retain/release any returned object (the theme is responsible for
* retaining the object), and should also be able to cache size information
* etc for later drawing.
* This simple rule means that drawing code can be written to be as
* efficient as possible while keeping caching strategies simple and
* uniform.
* To facilitate this within the theme code itsself, it is recommended
* that you make use of the -setName:forElement:temporary: method to
* retain any vended object until deactivation.
*/
@interface GSTheme (Drawing)
/**
* Allows the theme to set an image or set attributes for drawing the
* button differently based on the key equivalent which is set.
*/
- (void) setKeyEquivalent: (NSString *)key
forButtonCell: (NSButtonCell *)cell;
/**
* Draws a button frame and background (not its content) for the specified
* cell and view.
*/
- (void) drawButton: (NSRect)frame
in: (NSCell*)cell
view: (NSView*)view
style: (int)style
state: (GSThemeControlState)state;
/**
* Amount by which the button is inset by the border.
*/
- (GSThemeMargins) buttonMarginsForCell: (NSCell*)cell
style: (int)style
state: (GSThemeControlState)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;
/**
* Draw a border of the specified border type.
*/
- (void) drawBorderType: (NSBorderType)aType
frame: (NSRect)frame
view: (NSView*)view;
/**
* Determine the size for the specified border type .
*/
- (NSSize) sizeForBorderType: (NSBorderType)aType;
/**
* Draw a border of the specified frame style.
*/
- (void) drawBorderForImageFrameStyle: (NSImageFrameStyle)frameStyle
frame: (NSRect)frame
view: (NSView*)view;
/**
* Determine the size for the specified frame style.
*/
- (NSSize) sizeForImageFrameStyle: (NSImageFrameStyle)frameStyle;
/**
* Return YES if the scroller arrows are at the same end.
* Return NO to get one scroller arrow at each end of the scroller.
*
* The default implementation first checks the default GSScrollerArrowsSameEnd
* and if that is not set, delegates to the NSInterfaceStyle.
*/
- (BOOL) scrollerArrowsSameEndForScroller: (NSScroller *)aScroller;
/**
* Returns YES if clicking in the scroller slot should scroll by one page,
* NO if the scroller should jump to the location clicked.
*
* The default implementation first checks the default GSScrollerScrollsByPage
* and if that is not set, delegates to the NSInterfaceStyle.
*/
- (BOOL) scrollerScrollsByPageForScroller: (NSScroller *)aScroller;
/**
* Creates and returns the cell to be used to draw a scroller arrow of the
* specified type and orientation.
* The theme instance is responsible for ensuring that the cell continues
* to exist until the theme is deactivated (the default implementation does
* this by naming the cell using the -setName:forElement:temporary:
* method, which also provides a name for the cell color and image).
*/
- (NSButtonCell*) cellForScrollerArrow: (NSScrollerArrow)part
horizontal: (BOOL)horizontal;
/**
* Creates and returns the cell to be used to draw a scroller knob of the
* specified orientation.
* The theme instance is responsible for ensuring that the cell continues
* to exist until the theme is deactivated (the default implementation does
* this by naming the cell using the -setName:forElement:temporary:
* method).
*/
- (NSCell*) cellForScrollerKnob: (BOOL)horizontal;
/**
* Creates and returns the cell to be used to draw a scroller slot of the
* specified orientation.
* The theme instance is responsible for ensuring that the cell continues
* to exist until the theme is deactivated (the default implementation does
* this by naming the cell using the -setName:forElement:temporary:
* method).
*/
- (NSCell*) cellForScrollerKnobSlot: (BOOL)horizontal;
/** Returns the width which should be allowed for a scroller within the
* current theme. Drawing code is entitled to assume that this value will
* remain constant until the theme is deactivated.
*/
- (float) defaultScrollerWidth;
/**
* If YES, instructs NSScrollView to leave an empty square space where
* the horizontal and vertical scrollers meet.
*
* Controlled by user default GSScrollViewUseBottomCorner; default YES.
*/
- (BOOL) scrollViewUseBottomCorner;
/**
* If YES, instructs NSScrollView to make the scrollers overlap the border.
* The scroll view border is drawn using the NSScrollView part, which
* must be provided by the theme if this method returns YES.
*
* Controlled by user default GSScrollViewScrollersOverlapBorders; default NO;
*/
- (BOOL) scrollViewScrollersOverlapBorders;
/**
* Method for toolbar theming.
*/
- (NSColor *) toolbarBackgroundColor;
- (NSColor *) toolbarBorderColor;
- (void) drawToolbarRect: (NSRect)aRect
frame: (NSRect)viewFrame
borderMask: (unsigned int)borderMask;
- (BOOL) toolbarIsOpaque;
// Methods to deal with steppers..
/**
* Draw a stepper cell
*/
- (void) drawStepperCell: (NSCell*)cell
withFrame: (NSRect)cellFrame
inView: (NSView*)controlView
highlightUp: (BOOL)highlightUp
highlightDown: (BOOL)highlightDown;
// Stepper cell helper methods
- (NSRect) stepperUpButtonRectWithFrame: (NSRect)frame;
- (NSRect) stepperDownButtonRectWithFrame: (NSRect)frame;
- (void) drawStepperBorder: (NSRect)frame;
/**
* Draw light colored stepper using the border and clip rects
*/
- (NSRect) drawStepperLightButton: (NSRect)border : (NSRect)clip;
/**
* Draw normal stepper up button.
*/
- (void) drawStepperUpButton: (NSRect)aRect;
/**
* Draw highlighted up stepper button.
*/
- (void) drawStepperHighlightUpButton: (NSRect)aRect;
/**
* Draw down button for stepper
*/
- (void) drawStepperDownButton: (NSRect)aRect;
/**
* Draw highlighted stepper down button
*/
- (void) drawStepperHighlightDownButton: (NSRect)aRect;
// NSSegmentedControl drawing methods
- (void) drawSegmentedControlSegment: (NSCell *)cell
withFrame: (NSRect)cellFrame
inView: (NSView *)controlView
style: (NSSegmentStyle)style
state: (GSThemeControlState)state
roundedLeft: (BOOL)roundedLeft
roundedRight: (BOOL)roundedRight;
/**
* Returns the color used to draw a menu view background.
*
* By default, looks up the color named menuBackgroundColor,
* otherwise returns the window background color.
*
* The returned color is used by
* -drawBackgroundForMenuView:withFrame:dirtyRect:horizontal:
*
* Can be overridden in subclasses to return a custom color.
*/
- (NSColor *) menuBackgroundColor;
/**
* Returns the color used to draw a menu item background.
*
* The menu item background is drawn atop the menu background.
*
* By default, looks up the color named menuItemBackgroundColor,
* otherwise returns the control background color.
* When selected or highlighted, the background color is provided by
* [NSColor+selectedMenuItemColor].
*
* The returned value used by
* -drawBorderAndBackgroundForMenuItemCell:withFrame:inView:state:isHorizontal:
* and [NSMenuItemCell-backgroundColor].
*
* Can be overridden in subclasses to return a custom color.
*/
- (NSColor *) menuItemBackgroundColor;
- (NSColor *) menuBarBackgroundColor;
- (NSColor *) menuBarBorderColor;
/**
* Returns the color used to draw a menu view border.
*
* By default, looks up the color named menuBorderColor,
* otherwise returns the dark gray color.
*
* The returned color is used by
* -drawBackgroundForMenuView:withFrame:dirtyRect:horizontal:
*
* Can be overridden in subclasses to return a custom color.
*/
- (NSColor *) menuBorderColor;
/**
* Returns a color to draw each edge in a menu view border.
*
* By default, returns -menuBorderColor for the upper and left edges of a
* vertical menu, or for the bottom edge of a horizontal one.
*
* The returned edge color is used by
* -drawBackgroundForMenuView:withFrame:dirtyRect:horizontal:
*
* Can be overridden in subclasses to return a custom color per edge.
*/
- (NSColor *) menuBorderColorForEdge: (NSRectEdge)edge
isHorizontal: (BOOL)horizontal;
- (void) drawBackgroundForMenuView: (NSMenuView*)menuView
withFrame: (NSRect)bounds
dirtyRect: (NSRect)dirtyRect
horizontal: (BOOL)horizontal;
/**
* Returns whether the menu item border should be drawn or not.
*
* By default, returns [NSMenuItemCell-isBordered] value. The value is NO
* when the menu is horizontal, YES when vertical.
*
* The returned value used by
* -drawBorderAndBackgroundForMenuItemCell:withFrame:inView:state:isHorizontal:
*
* Can be overridden in subclasses.
*/
- (BOOL) drawsBorderForMenuItemCell: (NSMenuItemCell *)cell
state: (GSThemeControlState)state
isHorizontal: (BOOL)horizontal;
// menu item cell drawing method
- (void) drawBorderAndBackgroundForMenuItemCell: (NSMenuItemCell *)cell
withFrame: (NSRect)cellFrame
inView: (NSView *)controlView
state: (GSThemeControlState)state
isHorizontal: (BOOL)isHorizontal;
/**
* Draws the menu item title.
*
* Can be overridden to customize the text font, size and position.
* You can use [[cell menuItem] title]
to get the title.
*
* The title color is mapped to the theme state as described below:
*
* GSThemeSelectedState
* [NSColor+selectedMenuItemTextColor]
* GSThemeDisabledState
* [NSColor+controlTextColor] or
* [NSColor+disabledControlTextColor]
*
*/
- (void) drawTitleForMenuItemCell: (NSMenuItemCell *)cell
withFrame: (NSRect)cellFrame
inView: (NSView *)controlView
state: (GSThemeControlState)state
isHorizontal: (BOOL)isHorizontal;
/**
* Returns the color used to draw a separator line in a menu.
*
* By default, looks up the color named menuSeparatorColor,
* otherwise returns nil.
*
* The returned color is used by
* -drawSeparatorItemForMenuItemCell:withFrame:inView:isHorizontal:
*
* Can be overridden in subclasses to return a custom color.
*/
- (NSColor *) menuSeparatorColor;
/**
* Returns the left and right inset used to draw a separator line in a
* menu.
*
* By default, returns 3.0.
*
* The returned color is used by
* -drawSeparatorItemForMenuItemCell:withFrame:inView:isHorizontal:
*
* Can be overridden in subclasses to return a custom value.
*/
- (CGFloat) menuSeparatorInset;
/**
* Amount that submenus overlap their parent menu by, horizontally.
* (i.e. applies to vertical menus)
*
* Controlled by GSMenuSubmenuHorizontalOverlap default
*/
- (CGFloat) menuSubmenuHorizontalOverlap;
/**
* Amount that submenus overlap the horizontal menu bar by, vertically.
*
* Controlled by GSMenuSubmenuVerticalOverlap default
*/
- (CGFloat) menuSubmenuVerticalOverlap;
/**
* Draws a separator between normal menu items in a menu.
*
* Each separator corresponds to a menu item that returns YES to
* -isSeparatorItem
*
* You can provide an image tile named GSMenuSeparatorItem to
* draw the separator.
* Can be overridden in subclasses to customize the drawing.
*
* See also -menuSeparatorColor and -menuSeparatorInset
*/
- (void) drawSeparatorItemForMenuItemCell: (NSMenuItemCell *)cell
withFrame: (NSRect)cellFrame
inView: (NSView *)controlView
isHorizontal: (BOOL)isHorizontal;
/**
* Returns the class used to create the title bar in the given menu view.
*
* By default, returns GSTitleView.
* A subclass can be returned to customize the title view look and behavior.
*/
- (Class) titleViewClassForMenuView: (NSMenuView *)aMenuView;
- (NSRect) drawMenuTitleBackground: (GSTitleView *)aTitleView
withBounds: (NSRect)bounds
withClip: (NSRect)clipRect;
- (CGFloat) menuBarHeight;
- (CGFloat) menuItemHeight;
- (CGFloat) menuSeparatorHeight;
// NSColorWell drawing method
- (NSRect) drawColorWellBorder: (NSColorWell*)well
withBounds: (NSRect)bounds
withClip: (NSRect)clipRect;
// progress indicator drawing methods
- (void) drawProgressIndicator: (NSProgressIndicator*)progress
withBounds: (NSRect)bounds
withClip: (NSRect)rect
atCount: (int)count
forValue: (double)val;
- (NSRect) drawProgressIndicatorBezel: (NSRect)bounds withClip: (NSRect) rect;
- (void) drawProgressIndicatorBarDeterminate: (NSRect)bounds;
// Table drawing methods
- (NSColor *) tableHeaderTextColorForState: (GSThemeControlState)state;
- (void) drawTableCornerView: (NSView*)cornerView
withClip: (NSRect)aRect;
- (void) drawTableHeaderCell: (NSTableHeaderCell *)cell
withFrame: (NSRect)cellFrame
inView: (NSView *)controlView
state: (GSThemeControlState)state;
- (float) titlebarHeight;
- (float) resizebarHeight;
- (float) titlebarButtonSize;
- (float) titlebarPaddingRight;
- (float) titlebarPaddingTop;
- (float) titlebarPaddingLeft;
- (void) drawWindowBorder: (NSRect)rect
withFrame: (NSRect)frame
forStyleMask: (unsigned int)styleMask
state: (int)inputState
andTitle: (NSString*)title;
- (NSColor *) browserHeaderTextColor;
- (void) drawBrowserHeaderCell: (NSTableHeaderCell*)cell
withFrame: (NSRect)rect
inView: (NSView*)view;
- (NSRect) browserHeaderDrawingRectForCell: (NSTableHeaderCell*)cell
withFrame: (NSRect)rect;
- (NSRect) tabViewContentRectForBounds: (NSRect)aRect
tabViewType: (NSTabViewType)type
tabView: (NSTabView *)view;
- (void) drawTabViewRect: (NSRect)rect
inView: (NSView *)view
withItems: (NSArray *)items
selectedItem: (NSTabViewItem *)item;
- (void) drawScrollerRect: (NSRect)rect
inView: (NSView *)view
hitPart: (NSScrollerPart)hitPart
isHorizontal: (BOOL)isHorizontal;
- (void) drawBrowserRect: (NSRect)rect
inView: (NSView *)view
withScrollerRect: (NSRect)scrollerRect
columnSize: (NSSize)columnSize;
- (CGFloat) browserColumnSeparation;
- (CGFloat) browserVerticalPadding;
- (BOOL) browserUseBezels;
- (void) drawMenuRect: (NSRect)rect
inView: (NSView *)view
isHorizontal: (BOOL)horizontal
itemCells: (NSArray *)itemCells;
- (void) drawScrollViewRect: (NSRect)rect
inView: (NSView *)view;
- (void) drawSliderBorderAndBackground: (NSBorderType)aType
frame: (NSRect)cellFrame
inCell: (NSCell *)cell
isHorizontal: (BOOL)horizontal;
- (void) drawBarInside: (NSRect)rect
inCell: (NSCell *)cell
flipped: (BOOL)flipped;
- (void) drawKnobInCell: (NSCell *)cell;
- (NSRect) tableHeaderCellDrawingRectForBounds: (NSRect)theRect;
- (void) drawTableHeaderRect: (NSRect)aRect
inView: (NSView *)view;
- (void) drawPopUpButtonCellInteriorWithFrame: (NSRect)cellFrame
withCell: (NSCell *)cell
inView: (NSView *)controlView;
- (void) drawTableViewBackgroundInClipRect: (NSRect)clipRect
inView: (NSView *)view
withBackgroundColor: (NSColor *)backgroundColor;
- (void) drawTableViewRect: (NSRect)aRect
inView: (NSView *)view;
- (void) drawTableViewGridInClipRect: (NSRect)aRect
inView: (NSView *)view;
- (void) highlightTableViewSelectionInClipRect: (NSRect)clipRect
inView: (NSView *)view
selectingColumns: (BOOL)selectingColumns;
- (void) drawTableViewRow: (int)rowIndex
clipRect: (NSRect)clipRect
inView: (NSView *)view;
- (void) drawBoxInClipRect: (NSRect)clipRect
boxType: (NSBoxType)boxType
borderType: (NSBorderType)borderType
inView: (NSBox *)box;
@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 gray 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 drawing 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.
* The rect argument is the rectangle to be filled.
* The image argument is the data to fill with.
* The source argument is the rectangle within the image which is used.
* The flipped argument specifies what sort of coordinate system is in
* use in the view where we are drawing.
*/
- (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 a group of up to nine tile images.
* The GSDrawTiles object encapsulates the tile images and information
* about what parts of each image are used for tiling.
* This draws the left, right, top and bottom borders by tiling the
* images at left, right, top and bottom. 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 to fill the center where
* style is FillStyleNone.
* The return value is the central rectangle (inside the border images).
*/
- (NSRect) fillRect: (NSRect)rect
withTiles: (GSDrawTiles*)tiles
background: (NSColor*)color
fillStyle: (GSThemeFillStyle)style;
/**
* Method to tile a rectangle given a group of up to nine tile images.
* The GSDrawTiles object encapsulates the tile images and information
* about what parts of each image are used for tiling.
* This draws the left, right, top and bottom borders by tiling the
* images at left, right, top and bottom. It then draws the four corner
* images and finally deals with the remaining space in the middle according
* to the default style set for the GSDrawTiles object used.
* The background color specified is used to fill the center where
* style is FillStyleNone.
* The return value is the central rectangle (inside the border images).
*/
- (NSRect) fillRect: (NSRect)rect
withTiles: (GSDrawTiles*)tiles
background: (NSColor*)color;
- (NSRect) fillRect: (NSRect)rect
withTiles: (GSDrawTiles*)tiles;
/**
* Method to tile the supplied image to fill the vertical rectangle.
* The rect argument is the rectangle to be filled.
* The image argument is the data to fill with.
* The source argument is the rectangle within the image which is used.
* The flipped argument specifies what sort of coordinate system is in
* use in the view where we are drawing.
*/
- (void) fillVerticalRect: (NSRect)rect
withImage: (NSImage*)image
fromRect: (NSRect)source
flipped: (BOOL)flipped;
@end
@interface GSTheme (Menus)
/**
* This method sets the menu for the window using the current theme
* In the default theme this calls the setMenu: method on the window
* giving the menu parameter as the argument.
*/
- (void) setMenu: (NSMenu *)menu forWindow: (NSWindow *)window;
/**
* Display the context menu when the right mouse button is pressed.
*/
- (void) rightMouseDisplay: (NSMenu *)menu
forEvent: (NSEvent *)theEvent;
/**
* Display popup menu item.
*/
- (void) displayPopUpMenu: (NSMenuView *)mr
withCellFrame: (NSRect)cellFrame
controlViewWindow: (NSWindow *)cvWin
preferredEdge: (NSRectEdge)edge
selectedItem: (int)selectedItem;
/**
* Process events for popups.
*/
- (BOOL) doesProcessEventsForPopUpMenu;
/**
* Display the menu icon in the application.
*/
- (BOOL) menuShouldShowIcon;
/**
* Processes menu events for the theme. The default implementation
* does nothing.
*/
- (void) processCommand: (void *)context;
/**
* Calculate the height of the menu for in-window menus. The default
* implementation returns [NSMenuView menuBarHeight];
*/
- (float) menuHeightForWindow: (NSWindow *)window;
/**
* Update the menu for the window. This refreshes the menu contents.
* The default implementation of this method does nothing.
*/
- (void) updateMenu: (NSMenu *)menu forWindow: (NSWindow *)window;
- (void) updateAllWindowsWithMenu: (NSMenu *) menu;
@end
@interface GSTheme (OpenSavePanels)
/**
* This method returns the open panel class needed by the
* native environment.
*/
- (Class) openPanelClass;
/**
* This method returns the open panel class needed by the
* native environment.
*/
- (Class) savePanelClass;
@end
// Panels which can be overridden by the theme...
@interface GSPrintPanel : NSPrintPanel
@end
@interface GSPageLayout : NSPageLayout
@end
@interface GSTheme (PrintPanels)
/**
* This method returns the print panel class needed by the
* native environment.
*/
- (Class) printPanelClass;
/**
* This method returns the page layout class needed by the
* native environment.
*/
- (Class) pageLayoutClass;
@end
@interface GSTheme (NSWindow)
/**
* This method returns the standard window button for the
* given mask for the current theme.
*/
- (NSButton *) standardWindowButton: (NSWindowButton)button
forStyleMask: (NSUInteger) mask;
/**
* This method does any additional setup after the default
* cell is set.
*/
- (void) didSetDefaultButtonCell: (NSButtonCell *)aCell;
@end
@interface GSTheme (NSBrowserCell)
/**
* Draw editor in cell
*/
- (void) drawEditorForCell: (NSCell *)cell
withFrame: (NSRect)cellFrame
inView: (NSView *)view;
/**
* Draw attributed text in cell
*/
- (void) drawInCell: (NSCell *)cell
attributedText: (NSAttributedString *)stringValue
inFrame: (NSRect)cellFrame;
/**
* Draw the interior of the browser cell
*/
- (void) drawBrowserInteriorWithFrame: (NSRect)cellFrame
withCell: (NSBrowserCell *)cell
inView: (NSView *)controlView
withImage: (NSImage *)theImage
alternateImage: (NSImage *)alternateImage
isHighlighted: (BOOL)isHighlighted
state: (int)state
isLeaf: (BOOL)isLeaf;
/**
* This method returns the branch image
*/
- (NSImage *) branchImage;
/**
* This method returns the highlighted version of
* the branch image
*/
- (NSImage *) highlightedBranchImage;
@end
#endif /* OS_API_VERSION */
#endif /* _GNUstep_H_GSTheme */