mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:11:18 +00:00
Some theme integration work
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23585 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1e779eacaf
commit
c7ab1a2a90
14 changed files with 1550 additions and 432 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
|||
2006-09-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSWindowDecorationView.m: Merge in theme branch changes.
|
||||
* Source/NSColorList.m: Cooperate with NSColor to change system
|
||||
color list when a new theme is activated.
|
||||
* Source/GSDrawFunctions.m: Merge in theme branch changes.
|
||||
Reorganize, add theme loading functionality, add image tiling
|
||||
methods.
|
||||
* Source/NSButtonCell.m: Merge in theme branch changes.
|
||||
* Source/NSColor.m: Take notice of themes changing the system
|
||||
color list and interface with NSColorList to make the chanes and
|
||||
then send out the notification to tell all observers.
|
||||
* Source/GSTitleView.m: call instance method rather than class method
|
||||
* Source/DocMakefile: Document theme changes
|
||||
* Source/NSTabView.m: call instance method rather than class method
|
||||
* Documentation/GuiAdditions.gsdoc: link to theme documentation
|
||||
* Documentation/General/GNUmakefile: make theme documentation
|
||||
* Headers/AppKit/NSWindow.h: improve comments
|
||||
* Headers/Additions/GNUstepGUI/GSDrawFunctions.h: reorganize
|
||||
|
||||
2006-09-21 Matt Rice <ratmice@yahoo.com>
|
||||
|
||||
* Source/NSTextFieldCell.m (-setEnabled:): Revert previous patch.
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02111 USA.
|
||||
|
||||
# Install into the system root by default
|
||||
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02111 USA
|
||||
#
|
||||
|
||||
# Install into the system root by default
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
</p>
|
||||
<list>
|
||||
<item><uref url="GSDisplayServer.html">GSDisplayServer</uref></item>
|
||||
<item><uref url="GSDrawFunctions.html">GSDrawFunctions</uref></item>
|
||||
<item><uref url="GSHbox.html">GSHbox</uref></item>
|
||||
<item><uref url="GSTable.html">GSTable</uref></item>
|
||||
<item><uref url="GSVbox.html">GSVbox</uref></item>
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
<abstract>Useful/configurable drawing functions</abstract>
|
||||
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004-2006 Free Software Foundation, Inc.
|
||||
|
||||
Author: Adam Fedor <fedor@gnu.org>
|
||||
Author: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
Date: Jan 2004
|
||||
|
||||
This file is part of the GNU Objective C User interface library.
|
||||
|
@ -21,7 +22,8 @@
|
|||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _GNUstep_H_GSDrawFunctions
|
||||
|
@ -31,39 +33,277 @@
|
|||
// For gradient types
|
||||
#include "AppKit/NSButtonCell.h"
|
||||
|
||||
@class NSBundle;
|
||||
@class NSColor;
|
||||
@class GSDrawTiles;
|
||||
|
||||
/**
|
||||
* This defines how the center middle image in a tile array should be
|
||||
* used when drawing a rectangle.
|
||||
*/
|
||||
typedef enum {
|
||||
FillStyleNone, /** The image is not drawn */
|
||||
FillStyleScale, /** The image is scaled to fit */
|
||||
FillStyleRepeat, /** The image is tiled from bottom left */
|
||||
FillStyleCenter /** The image is tiled from the center */
|
||||
} GSDrawFunctionsFillStyle;
|
||||
|
||||
|
||||
/** 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;
|
||||
|
||||
|
||||
/**
|
||||
<p><em>This interface is <strong>HIGHLY</strong> unstable
|
||||
and incomplete at present.</em>
|
||||
</p>
|
||||
<p>
|
||||
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).
|
||||
</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
The default implementation uses the standard configurable colors
|
||||
defined in NSColor, such as <code>controlLightHighlightColor</code>,
|
||||
<code>controlShadowColor</code> and <code>controlDarkShadowColor</code>.<br />
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
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).
|
||||
</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
*/
|
||||
@interface GSDrawFunctions : NSObject
|
||||
{
|
||||
@private
|
||||
NSBundle *_bundle;
|
||||
NSMutableArray *_images;
|
||||
NSMutableDictionary *_tiles;
|
||||
}
|
||||
|
||||
+ (id) theme;
|
||||
+ (void) setTheme: (id)theme;
|
||||
/**
|
||||
* Set the currently active theme to be the instance specified.<br />
|
||||
* 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: (GSDrawFunctions*)theme;
|
||||
|
||||
+ (NSRect) drawButton: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawDarkButton: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawDarkBezel: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawLightBezel: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawGrayBezel: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawWhiteBezel: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawGroove: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawFramePhoto: (NSRect)border : (NSRect)clip;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
+ (GSDrawFunctions*) theme;
|
||||
|
||||
+ (NSRect) drawGradientBorder: (NSGradientType)gradientType
|
||||
inRect: (NSRect)border
|
||||
withClip: (NSRect)clip;
|
||||
/**
|
||||
* <p>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 before doing their own thing.
|
||||
* </p>
|
||||
* <p>The base implementation handles setup and caching of certain image
|
||||
* information and then sends a GSThemeDidActivateNotification to allow
|
||||
* other parts of the GUI library to update themselves from the new theme.<br />
|
||||
* If the theme sets an alternative system color list, the notification
|
||||
* userInfo dictionary will contain that list keyed on <em>Colors</em>.
|
||||
* </p>
|
||||
*/
|
||||
- (void) activate;
|
||||
|
||||
- (NSRect) drawButton: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawDarkButton: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawDarkBezel: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawLightBezel: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawGrayBezel: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawWhiteBezel: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawGroove: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawFramePhoto: (NSRect)border : (NSRect)clip;
|
||||
/**
|
||||
* Return the bundle containing the resources used by the current theme.
|
||||
*/
|
||||
- (NSBundle*) bundle;
|
||||
|
||||
- (NSRect) drawGradientBorder: (NSGradientType)gradientType
|
||||
inRect: (NSRect)border
|
||||
withClip: (NSRect)clip;
|
||||
/**
|
||||
* <p>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.
|
||||
* </p>
|
||||
* <p>The base implementation handles some cleanup and then sends a
|
||||
* GSThemeDidDeactivateNotification to allow other parts of the GUI library
|
||||
* to update themselves.
|
||||
* </p>
|
||||
*/
|
||||
- (void) deactivate;
|
||||
|
||||
/** <init />
|
||||
* Initialise an instance of a theme with the specified resource bundle.<br />
|
||||
* 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 tile image information for a particular image name,
|
||||
* or nil if there is no such information.<br />
|
||||
* 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.
|
||||
*/
|
||||
- (GSDrawTiles*) tilesNamed: (NSString*)aName;
|
||||
@end
|
||||
|
||||
/**
|
||||
* Theme drawing methods
|
||||
*/
|
||||
@interface GSDrawFunctions (Drawing)
|
||||
|
||||
/**
|
||||
* Draws a button frame and background (not its content) for the specified
|
||||
* cell and view.<br />
|
||||
* 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 GSDrawFunctions (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 GSDrawFunctions (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.<br />
|
||||
* 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.<br />
|
||||
* The background color specified is used where style is FillStyleNone.
|
||||
*/
|
||||
- (void) fillRect: (NSRect)rect
|
||||
withTiles: (GSDrawTiles*)tiles
|
||||
background: (NSColor*)color
|
||||
fillStyle: (GSDrawFunctionsFillStyle)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
|
||||
|
||||
|
||||
/**
|
||||
* Deprecated methods ... do not use
|
||||
*/
|
||||
@interface GSDrawFunctions (deprecated)
|
||||
+ (NSRect) drawButton: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawDarkBezel: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawDarkButton: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawLightBezel: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawGradientBorder: (NSGradientType)gradientType
|
||||
inRect: (NSRect)border
|
||||
withClip: (NSRect)clip;
|
||||
+ (NSRect) drawGrayBezel: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawGroove: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawFramePhoto: (NSRect)border : (NSRect)clip;
|
||||
+ (NSRect) drawWhiteBezel: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawButton: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawDarkBezel: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawDarkButton: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawFramePhoto: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawGrayBezel: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawGroove: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawLightBezel: (NSRect)border : (NSRect)clip;
|
||||
- (NSRect) drawWhiteBezel: (NSRect)border : (NSRect)clip;
|
||||
@end
|
||||
|
||||
#endif /* _GNUstep_H_GSDrawFunctions */
|
||||
|
|
|
@ -111,7 +111,7 @@ APPKIT_EXPORT NSSize NSTokenSize;
|
|||
* <p>A window has a <em>frame</em>. This is the frame of the <em>entire</em>
|
||||
* window on the screen, including all decorations and borders. The origin
|
||||
* of the frame represents its bottom left corner and the frame is expressed
|
||||
* in screen coordinates (see [NSScreen]).<br />
|
||||
* in screen coordinates (see [NSScreen]).
|
||||
* </p>
|
||||
* <p>When a window is created, it has a <em>private</em> [NSView] instance
|
||||
* which fills the entire window frame and whose coordinate system is the
|
||||
|
@ -122,7 +122,7 @@ APPKIT_EXPORT NSSize NSTokenSize;
|
|||
* draw window decorations if the backend library is not handling the
|
||||
* window decorations.
|
||||
* </p>
|
||||
* <p>A window always contains a <em>content view<em> which is the highest
|
||||
* <p>A window always contains a <em>content view</em> which is the highest
|
||||
* level view available for public (application) use. This view fills the
|
||||
* area of the window inside any decoration/border.<br />
|
||||
* This is the only part of the window that application programmers are
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02111 USA
|
||||
#
|
||||
|
||||
MAKEFILE_NAME = DocMakefile
|
||||
|
@ -147,6 +148,7 @@ NSWorkspace.h
|
|||
|
||||
AUTOGSDOC_HEADERS_GUIADD = \
|
||||
GSDisplayServer.h \
|
||||
GSDrawFunctions.h \
|
||||
GSFusedSilica.h \
|
||||
GSTable.h \
|
||||
GSHbox.h \
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -195,6 +195,7 @@
|
|||
|
||||
- (void) drawRect: (NSRect)rect
|
||||
{
|
||||
GSDrawFunctions *theme = [GSDrawFunctions theme];
|
||||
NSRect workRect = [self bounds];
|
||||
NSSize titleSize;
|
||||
NSRectEdge top_left[] = {NSMinXEdge, NSMaxYEdge};
|
||||
|
@ -213,7 +214,7 @@
|
|||
|
||||
// Rectangle 2
|
||||
// Draw the title box's button.
|
||||
[GSDrawFunctions drawButton: workRect :workRect];
|
||||
[theme drawButton: workRect withClip: workRect];
|
||||
|
||||
// Overdraw white top and left lines with light gray lines for window title
|
||||
workRect.origin.y += 1;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "AppKit/NSColor.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
#include "GNUstepGUI/GSDisplayServer.h"
|
||||
#include "GNUstepGUI/GSDrawFunctions.h"
|
||||
|
||||
|
||||
struct NSWindow_struct
|
||||
|
@ -215,12 +216,9 @@ struct NSWindow_struct
|
|||
|
||||
- (void) drawRect: (NSRect)rect
|
||||
{
|
||||
NSColor *c = [_window backgroundColor];
|
||||
|
||||
if (NSIntersectsRect(rect, contentRect))
|
||||
{
|
||||
[c set];
|
||||
NSRectFill(contentRect);
|
||||
[[GSDrawFunctions theme] drawWindowBackground: contentRect view: self];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -836,6 +836,9 @@ typedef struct _GSButtonCellFlags
|
|||
|
||||
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||
{
|
||||
unsigned mask;
|
||||
int buttonState = 0;
|
||||
|
||||
// Save last view drawn to
|
||||
if (_control_view != controlView)
|
||||
_control_view = controlView;
|
||||
|
@ -848,22 +851,59 @@ typedef struct _GSButtonCellFlags
|
|||
if (NSIsEmptyRect(cellFrame))
|
||||
return;
|
||||
|
||||
// draw the border if needed
|
||||
if ((_cell.is_bordered) &&
|
||||
(!_shows_border_only_while_mouse_inside || _mouse_inside))
|
||||
// set the mask
|
||||
if (_cell.is_highlighted)
|
||||
{
|
||||
// FIXME Should check the bezel and gradient style
|
||||
if (_cell.is_highlighted && (_highlightsByMask & NSPushInCellMask))
|
||||
mask = _highlightsByMask;
|
||||
if (_cell.state)
|
||||
{
|
||||
[GSDrawFunctions drawGrayBezel: cellFrame : NSZeroRect];
|
||||
}
|
||||
else
|
||||
mask &= ~_showAltStateMask;
|
||||
}
|
||||
}
|
||||
else if (_cell.state)
|
||||
mask = _showAltStateMask;
|
||||
else
|
||||
mask = NSNoCellMask;
|
||||
|
||||
/* Draw the cell's background color.
|
||||
We draw when there is a border or when highlightsByMask
|
||||
is NSChangeBackgroundCellMask or NSChangeGrayCellMask,
|
||||
as required by our nextstep-like look and feel. */
|
||||
if (_cell.is_bordered
|
||||
|| (_highlightsByMask & NSChangeBackgroundCellMask)
|
||||
|| (_highlightsByMask & NSChangeGrayCellMask))
|
||||
{
|
||||
/* Determine the background color. */
|
||||
if (mask & (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
|
||||
{
|
||||
[GSDrawFunctions drawButton: cellFrame : NSZeroRect];
|
||||
buttonState = 1; /* highlighted state */
|
||||
}
|
||||
}
|
||||
|
||||
/* Pushed in buttons contents are displaced to the bottom right 1px. */
|
||||
if (_cell.is_bordered && (mask & NSPushInCellMask))
|
||||
{
|
||||
buttonState = 2; // pushed button
|
||||
}
|
||||
|
||||
// draw the border if needed
|
||||
if ((_cell.is_bordered)
|
||||
&& (!_shows_border_only_while_mouse_inside || _mouse_inside))
|
||||
{
|
||||
cellFrame = [[GSDrawFunctions theme]
|
||||
drawButton: cellFrame in: self view: controlView
|
||||
style: _bezel_style
|
||||
state: buttonState];
|
||||
}
|
||||
|
||||
[self drawInteriorWithFrame: cellFrame inView: controlView];
|
||||
|
||||
// Draw first responder
|
||||
if (_cell.shows_first_responder
|
||||
&& [[controlView window] firstResponder] == controlView)
|
||||
{
|
||||
[[GSDrawFunctions theme] drawFocusFrame: cellFrame view: controlView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawGradientWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||
|
@ -884,47 +924,47 @@ typedef struct _GSButtonCellFlags
|
|||
|
||||
switch (_gradient_type)
|
||||
{
|
||||
case NSGradientNone:
|
||||
return;
|
||||
break;
|
||||
case NSGradientNone:
|
||||
return;
|
||||
break;
|
||||
|
||||
case NSGradientConcaveWeak:
|
||||
[gray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [gray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexWeak:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [gray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConcaveStrong:
|
||||
[lightGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [darkGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexStrong:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [darkGray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
case NSGradientConcaveWeak:
|
||||
[gray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [gray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexWeak:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [gray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConcaveStrong:
|
||||
[lightGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [darkGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexStrong:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [darkGray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
white = start_white;
|
||||
white_step = fabs(start_white - end_white)/
|
||||
(cellFrame.size.width + cellFrame.size.height);
|
||||
white_step = fabs(start_white - end_white)
|
||||
/ (cellFrame.size.width + cellFrame.size.height);
|
||||
|
||||
// Start from top left
|
||||
p1 = NSMakePoint(cellFrame.origin.x,
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
p1 = NSMakePoint(cellFrame.origin.x,
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
p2 = NSMakePoint(cellFrame.origin.x,
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
|
||||
// Move by Y
|
||||
while (p1.y > cellFrame.origin.y)
|
||||
|
@ -974,7 +1014,6 @@ typedef struct _GSButtonCellFlags
|
|||
NSRect titleRect;
|
||||
NSSize imageSize = {0, 0};
|
||||
NSSize titleSize = {0, 0};
|
||||
NSColor *backgroundColor = nil;
|
||||
BOOL flippedView = [controlView isFlipped];
|
||||
NSCellImagePosition ipos = _cell.image_position;
|
||||
|
||||
|
@ -998,38 +1037,6 @@ typedef struct _GSButtonCellFlags
|
|||
else
|
||||
mask = NSNoCellMask;
|
||||
|
||||
/* Pushed in buttons contents are displaced to the bottom right 1px. */
|
||||
if (_cell.is_bordered && (mask & NSPushInCellMask))
|
||||
{
|
||||
cellFrame = NSOffsetRect(cellFrame, 1., flippedView ? 1. : -1.);
|
||||
}
|
||||
|
||||
/* Draw the cell's background color.
|
||||
We draw when there is a border or when highlightsByMask
|
||||
is NSChangeBackgroundCellMask or NSChangeGrayCellMask,
|
||||
as required by our nextstep-like look and feel. */
|
||||
if (_cell.is_bordered
|
||||
|| (_highlightsByMask & NSChangeBackgroundCellMask)
|
||||
|| (_highlightsByMask & NSChangeGrayCellMask))
|
||||
{
|
||||
/* Determine the background color. */
|
||||
if (mask & (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
|
||||
{
|
||||
backgroundColor = [NSColor selectedControlColor];
|
||||
}
|
||||
else if (_cell.is_bordered)
|
||||
{
|
||||
backgroundColor = [NSColor controlBackgroundColor];
|
||||
}
|
||||
|
||||
if (backgroundColor != nil)
|
||||
{
|
||||
[backgroundColor set];
|
||||
NSRectFill (cellFrame);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the image and the title that will be
|
||||
* displayed. If the NSContentsCellMask is set the
|
||||
|
@ -1195,7 +1202,8 @@ typedef struct _GSButtonCellFlags
|
|||
imageRect.origin.x = cellFrame.origin.x;
|
||||
imageRect.origin.y = cellFrame.origin.y;
|
||||
imageRect.size.width = cellFrame.size.width;
|
||||
imageRect.size.height = titleRect.origin.y - GSCellTextImageYDist - imageRect.origin.y;
|
||||
imageRect.size.height
|
||||
= titleRect.origin.y - GSCellTextImageYDist - imageRect.origin.y;
|
||||
|
||||
if (_cell.is_bordered || _cell.is_bezeled)
|
||||
{
|
||||
|
@ -1229,7 +1237,9 @@ typedef struct _GSButtonCellFlags
|
|||
// Draw image
|
||||
if (imageToDisplay != nil)
|
||||
{
|
||||
[self _drawImage: imageToDisplay inFrame: imageRect isFlipped: flippedView];
|
||||
[self _drawImage: imageToDisplay
|
||||
inFrame: imageRect
|
||||
isFlipped: flippedView];
|
||||
}
|
||||
|
||||
// Draw title
|
||||
|
@ -1237,13 +1247,6 @@ typedef struct _GSButtonCellFlags
|
|||
{
|
||||
[self _drawAttributedText: titleToDisplay inFrame: titleRect];
|
||||
}
|
||||
|
||||
// Draw first responder
|
||||
if (_cell.shows_first_responder
|
||||
&& [[controlView window] firstResponder] == controlView)
|
||||
{
|
||||
NSDottedFrameRect(cellFrame);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSSize) cellSize
|
||||
|
|
|
@ -45,9 +45,19 @@
|
|||
#include "AppKit/NSImage.h"
|
||||
#include "AppKit/NSGraphics.h"
|
||||
#include "AppKit/PSOperators.h"
|
||||
#include "GNUstepGUI/GSDrawFunctions.h"
|
||||
|
||||
static Class NSColorClass;
|
||||
|
||||
/* This interface must be provided in NSColorList to let us manage
|
||||
* system colors.
|
||||
*/
|
||||
@interface NSColorList (GNUstepPrivate)
|
||||
+ (void) _setDefaultSystemColorList: (NSColorList*)aList;
|
||||
+ (void) _setThemeSystemColorList: (NSColorList*)aList;
|
||||
@end
|
||||
|
||||
|
||||
@interface GSNamedColor : NSColor
|
||||
{
|
||||
NSString *_catalog_name;
|
||||
|
@ -153,12 +163,14 @@ static Class NSColorClass;
|
|||
|
||||
+ (NSColor*) colorFromString: (NSString*)string;
|
||||
+ (void) defaultsDidChange: (NSNotification*)notification;
|
||||
+ (void) themeDidActivate: (NSNotification*)notification;
|
||||
|
||||
@end
|
||||
|
||||
// Class variables
|
||||
static BOOL gnustep_gui_ignores_alpha = YES;
|
||||
static NSColorList *systemColors = nil;
|
||||
static NSColorList *defaultSystemColors = nil;
|
||||
static NSMutableDictionary *colorStrings = nil;
|
||||
static NSMutableDictionary *systemDict = nil;
|
||||
|
||||
|
@ -224,9 +236,11 @@ void initSystemColors(void)
|
|||
nil];
|
||||
|
||||
systemColors = [NSColorList colorListNamed: @"System"];
|
||||
defaultSystemColors = [[NSColorList alloc] initWithName: @"System"];
|
||||
[NSColorList _setDefaultSystemColorList: defaultSystemColors];
|
||||
if (systemColors == nil)
|
||||
{
|
||||
systemColors = [[NSColorList alloc] initWithName: @"System"];
|
||||
ASSIGN(systemColors, defaultSystemColors);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -240,24 +254,24 @@ void initSystemColors(void)
|
|||
|
||||
while ((key = (NSString *)[enumerator nextObject]))
|
||||
{
|
||||
NSString *aColorString;
|
||||
NSColor *color;
|
||||
|
||||
if ([systemColors colorWithKey: key])
|
||||
continue;
|
||||
if ((color = [systemColors colorWithKey: key]) == nil)
|
||||
{
|
||||
NSString *aColorString;
|
||||
|
||||
aColorString = [colorStrings objectForKey: key];
|
||||
color = [NSColorClass colorFromString: aColorString];
|
||||
aColorString = [colorStrings objectForKey: key];
|
||||
color = [NSColorClass colorFromString: aColorString];
|
||||
|
||||
NSCAssert1(color, @"couldn't get default system color %@", key);
|
||||
|
||||
[systemColors setColor: color forKey: key];
|
||||
|
||||
changed = YES;
|
||||
NSCAssert1(color, @"couldn't get default system color %@", key);
|
||||
[systemColors setColor: color forKey: key];
|
||||
changed = YES;
|
||||
}
|
||||
if (defaultSystemColors != systemColors)
|
||||
{
|
||||
[defaultSystemColors setColor: color forKey: key];
|
||||
}
|
||||
}
|
||||
|
||||
if (changed)
|
||||
[systemColors writeToFile: nil];
|
||||
}
|
||||
|
||||
systemDict = [NSMutableDictionary new];
|
||||
|
@ -309,6 +323,12 @@ systemColorWithName(NSString *name)
|
|||
selector: @selector(defaultsDidChange:)
|
||||
name: NSUserDefaultsDidChangeNotification
|
||||
object: nil];
|
||||
// watch for themes which may provide new system color lists
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(themeDidActivate:)
|
||||
name: GSThemeDidActivateNotification
|
||||
object: nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1636,6 +1656,35 @@ systemColorWithName(NSString *name)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle activation of a new theme ... look for a 'System' color list
|
||||
* in the theme bundle and use it instead of the default system color
|
||||
* list if it is present.
|
||||
*/
|
||||
+ (void) themeDidActivate: (NSNotification*)notification
|
||||
{
|
||||
NSDictionary *userInfo = [notification userInfo];
|
||||
NSColorList *list = [userInfo objectForKey: @"Colors"];
|
||||
|
||||
if (list == nil)
|
||||
{
|
||||
list = defaultSystemColors;
|
||||
}
|
||||
NSAssert([[list name] isEqual: @"System"], NSInvalidArgumentException);
|
||||
[NSColorList _setThemeSystemColorList: list];
|
||||
|
||||
/* We always update the system dictionary and send a notification, since
|
||||
* the theme may have gicen us a pre-existing color list, but have changed
|
||||
* one or more of the colors in it.
|
||||
*/
|
||||
list = [NSColorList colorListNamed: @"System"];
|
||||
ASSIGN(systemColors, list);
|
||||
[systemDict removeAllObjects];
|
||||
NSLog(@"Theme activation with control background %@", [self controlBackgroundColor]);
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSSystemColorsDidChangeNotification object: nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSNotificationQueue.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSArchiver.h>
|
||||
|
@ -43,82 +44,51 @@
|
|||
#include "AppKit/NSColor.h"
|
||||
#include "AppKit/AppKitExceptions.h"
|
||||
|
||||
// The list of available color lists is created only once -- this has
|
||||
// a drawback, that you need to restart your program to get the color
|
||||
// lists read again.
|
||||
static NSMutableArray *_gnustep_available_color_lists = nil;
|
||||
static NSLock *_gnustep_color_list_lock = nil;
|
||||
// The list of available color lists is cached and re-loaded only
|
||||
// after a time.
|
||||
static NSMutableArray *_availableColorLists = nil;
|
||||
static NSLock *_colorListLock = nil;
|
||||
|
||||
static NSColorList *defaultSystemColorList = nil;
|
||||
static NSColorList *themeColorList = nil;
|
||||
|
||||
@interface NSColorList (GNUstepPrivate)
|
||||
|
||||
/* Loads the available color lists from standard directories.<br />
|
||||
* If called with a nil argument, this will check to see if the
|
||||
* lists have already been loaded, and only load if they haven't been.
|
||||
*/
|
||||
+ (void) _loadAvailableColorLists: (NSNotification*)aNotification;
|
||||
|
||||
/* Set the default system color list ... to be used if no system color
|
||||
* list has been loaded from file. This should always be the last of
|
||||
* the array of available color lists even though it has noit been
|
||||
* written to file.
|
||||
*/
|
||||
+ (void) _setDefaultSystemColorList: (NSColorList*)aList;
|
||||
|
||||
/* Set the theme system color list ... if this is not nil, it is placed
|
||||
* at the start of the array of available lists and is used as the system
|
||||
* color list.
|
||||
*/
|
||||
+ (void) _setThemeSystemColorList: (NSColorList*)aList;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSColorList
|
||||
|
||||
//
|
||||
// Class methods
|
||||
//
|
||||
+ (void)initialize
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [NSColorList class])
|
||||
{
|
||||
[self setVersion: 2];
|
||||
_colorListLock = [NSRecursiveLock new];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Private Method which loads the color lists.
|
||||
* Invoke if _gnustep_available_color_lists == nil
|
||||
* before any operation with that object or its lock.
|
||||
*
|
||||
* The aim is to defer reading the available color lists
|
||||
* till we really need to, so that only programs which really use
|
||||
* this feature get the overhead.
|
||||
*/
|
||||
+ (void) _loadAvailableColorLists
|
||||
{
|
||||
NSString *dir;
|
||||
NSString *file;
|
||||
NSEnumerator *e;
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSDirectoryEnumerator *de;
|
||||
NSColorList *newList;
|
||||
|
||||
// Create the global array of color lists
|
||||
_gnustep_available_color_lists = [[NSMutableArray alloc] init];
|
||||
|
||||
/*
|
||||
* Load color lists found in standard paths into the array
|
||||
* FIXME: Check exactly where in the directory tree we should scan.
|
||||
*/
|
||||
e = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
|
||||
NSAllDomainsMask, YES) objectEnumerator];
|
||||
|
||||
while ((dir = (NSString *)[e nextObject]))
|
||||
{
|
||||
BOOL flag;
|
||||
|
||||
dir = [dir stringByAppendingPathComponent: @"Colors"];
|
||||
if (![fm fileExistsAtPath: dir isDirectory: &flag] || !flag)
|
||||
{
|
||||
// Only process existing directories
|
||||
continue;
|
||||
}
|
||||
|
||||
de = [fm enumeratorAtPath: dir];
|
||||
while ((file = [de nextObject]))
|
||||
{
|
||||
if ([[file pathExtension] isEqualToString: @"clr"])
|
||||
{
|
||||
NSString *name = [file stringByDeletingPathExtension];
|
||||
newList = [[NSColorList alloc] initWithName: name
|
||||
fromFile: [dir stringByAppendingPathComponent: file]];
|
||||
[_gnustep_available_color_lists addObject: newList];
|
||||
RELEASE(newList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// And create its access lock
|
||||
_gnustep_color_list_lock = [[NSLock alloc] init];
|
||||
}
|
||||
|
||||
/*
|
||||
* Getting All Color Lists
|
||||
*/
|
||||
|
@ -126,15 +96,11 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
{
|
||||
NSArray *a;
|
||||
|
||||
if (_gnustep_available_color_lists == nil)
|
||||
[NSColorList _loadAvailableColorLists];
|
||||
|
||||
// Serialize access to color list
|
||||
[_gnustep_color_list_lock lock];
|
||||
|
||||
a = [NSArray arrayWithArray: _gnustep_available_color_lists];
|
||||
|
||||
[_gnustep_color_list_lock unlock];
|
||||
[_colorListLock lock];
|
||||
[NSColorList _loadAvailableColorLists: nil];
|
||||
a = [NSArray arrayWithArray: _availableColorLists];
|
||||
[_colorListLock unlock];
|
||||
|
||||
return a;
|
||||
}
|
||||
|
@ -146,31 +112,25 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
{
|
||||
NSColorList *r;
|
||||
NSEnumerator *e;
|
||||
BOOL found = NO;
|
||||
|
||||
if (_gnustep_available_color_lists == nil)
|
||||
[NSColorList _loadAvailableColorLists];
|
||||
|
||||
// Serialize access to color list
|
||||
[_gnustep_color_list_lock lock];
|
||||
[_colorListLock lock];
|
||||
|
||||
e = [_gnustep_available_color_lists objectEnumerator];
|
||||
[NSColorList _loadAvailableColorLists: nil];
|
||||
e = [_availableColorLists objectEnumerator];
|
||||
|
||||
while ((r = (NSColorList *)[e nextObject]))
|
||||
while ((r = (NSColorList *)[e nextObject]) != nil)
|
||||
{
|
||||
if ([[r name] isEqualToString: name])
|
||||
{
|
||||
found = YES;
|
||||
RETAIN(r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[_gnustep_color_list_lock unlock];
|
||||
[_colorListLock unlock];
|
||||
|
||||
if (found)
|
||||
return r;
|
||||
else
|
||||
return nil;
|
||||
return AUTORELEASE(r);
|
||||
}
|
||||
|
||||
|
||||
|
@ -371,6 +331,8 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
key: (NSString *)key
|
||||
atIndex: (unsigned)location
|
||||
{
|
||||
NSNotification *n;
|
||||
|
||||
if (_is_editable == NO)
|
||||
[NSException raise: NSColorListNotEditableException
|
||||
format: @"Color list cannot be edited\n"];
|
||||
|
@ -379,13 +341,20 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
[_orderedColorKeys removeObject: key];
|
||||
[_orderedColorKeys insertObject: key atIndex: location];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSColorListChangedNotification
|
||||
object: self];
|
||||
n = [NSNotification notificationWithName: NSColorListChangedNotification
|
||||
object: self
|
||||
userInfo: nil];
|
||||
[[NSNotificationQueue defaultQueue]
|
||||
enqueueNotification: n
|
||||
postingStyle: NSPostASAP
|
||||
coalesceMask: NSNotificationCoalescingOnSender
|
||||
forModes: nil];
|
||||
}
|
||||
|
||||
- (void) removeColorWithKey: (NSString *)key
|
||||
{
|
||||
NSNotification *n;
|
||||
|
||||
if (_is_editable == NO)
|
||||
[NSException raise: NSColorListNotEditableException
|
||||
format: @"Color list cannot be edited\n"];
|
||||
|
@ -393,14 +362,21 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
[_colorDictionary removeObjectForKey: key];
|
||||
[_orderedColorKeys removeObject: key];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSColorListChangedNotification
|
||||
object: self];
|
||||
n = [NSNotification notificationWithName: NSColorListChangedNotification
|
||||
object: self
|
||||
userInfo: nil];
|
||||
[[NSNotificationQueue defaultQueue]
|
||||
enqueueNotification: n
|
||||
postingStyle: NSPostASAP
|
||||
coalesceMask: NSNotificationCoalescingOnSender
|
||||
forModes: nil];
|
||||
}
|
||||
|
||||
- (void) setColor: (NSColor *)aColor
|
||||
forKey: (NSString *)key
|
||||
{
|
||||
NSNotification *n;
|
||||
|
||||
if (_is_editable == NO)
|
||||
[NSException raise: NSColorListNotEditableException
|
||||
format: @"Color list cannot be edited\n"];
|
||||
|
@ -410,9 +386,14 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
if ([_orderedColorKeys containsObject: key] == NO)
|
||||
[_orderedColorKeys addObject: key];
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName: NSColorListChangedNotification
|
||||
object: self];
|
||||
n = [NSNotification notificationWithName: NSColorListChangedNotification
|
||||
object: self
|
||||
userInfo: nil];
|
||||
[[NSNotificationQueue defaultQueue]
|
||||
enqueueNotification: n
|
||||
postingStyle: NSPostASAP
|
||||
coalesceMask: NSNotificationCoalescingOnSender
|
||||
forModes: nil];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -438,8 +419,7 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
* We need to initialize before saving, to avoid the new file being
|
||||
* counted as a different list thus making us appear twice
|
||||
*/
|
||||
if (_gnustep_available_color_lists == nil)
|
||||
[NSColorList _loadAvailableColorLists];
|
||||
[NSColorList _loadAvailableColorLists: nil];
|
||||
|
||||
if (path == nil || ([fm fileExistsAtPath: path isDirectory: &isDir] == NO))
|
||||
{
|
||||
|
@ -513,10 +493,10 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
|
||||
if (success && path_is_standard)
|
||||
{
|
||||
[_gnustep_color_list_lock lock];
|
||||
if ([_gnustep_available_color_lists containsObject: self] == NO)
|
||||
[_gnustep_available_color_lists addObject: self];
|
||||
[_gnustep_color_list_lock unlock];
|
||||
[_colorListLock lock];
|
||||
if ([_availableColorLists containsObject: self] == NO)
|
||||
[_availableColorLists addObject: self];
|
||||
[_colorListLock unlock];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -532,12 +512,9 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
handler: nil];
|
||||
|
||||
// Remove the color list from the global list of colors
|
||||
if (_gnustep_available_color_lists == nil)
|
||||
[NSColorList _loadAvailableColorLists];
|
||||
|
||||
[_gnustep_color_list_lock lock];
|
||||
[_gnustep_available_color_lists removeObject: self];
|
||||
[_gnustep_color_list_lock unlock];
|
||||
[_colorListLock lock];
|
||||
[_availableColorLists removeObject: self];
|
||||
[_colorListLock unlock];
|
||||
|
||||
// Reset file name
|
||||
_fullFileName = nil;
|
||||
|
@ -562,3 +539,117 @@ static NSLock *_gnustep_color_list_lock = nil;
|
|||
|
||||
@end
|
||||
|
||||
@implementation NSColorList (GNUstepPrivate)
|
||||
|
||||
+ (void) _loadAvailableColorLists: (NSNotification*)aNotification
|
||||
{
|
||||
[_colorListLock lock];
|
||||
/* FIXME ... we should ensure that we get housekeeping notifications */
|
||||
if (_availableColorLists != nil && aNotification == nil)
|
||||
{
|
||||
// Nothing to do ... already loaded
|
||||
[_colorListLock unlock];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *dir;
|
||||
NSString *file;
|
||||
NSEnumerator *e;
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSDirectoryEnumerator *de;
|
||||
NSColorList *newList;
|
||||
|
||||
if (_availableColorLists == nil)
|
||||
{
|
||||
// Create the global array of color lists
|
||||
_availableColorLists = [[NSMutableArray alloc] init];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_availableColorLists removeAllObjects];
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep any pre-loaded system color list.
|
||||
*/
|
||||
if (themeColorList != nil)
|
||||
{
|
||||
[_availableColorLists addObject: themeColorList];
|
||||
}
|
||||
|
||||
/*
|
||||
* Load color lists found in standard paths into the array
|
||||
* FIXME: Check exactly where in the directory tree we should scan.
|
||||
*/
|
||||
e = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
|
||||
NSAllDomainsMask, YES) objectEnumerator];
|
||||
|
||||
while ((dir = (NSString *)[e nextObject]))
|
||||
{
|
||||
BOOL flag;
|
||||
|
||||
dir = [dir stringByAppendingPathComponent: @"Colors"];
|
||||
if (![fm fileExistsAtPath: dir isDirectory: &flag] || !flag)
|
||||
{
|
||||
// Only process existing directories
|
||||
continue;
|
||||
}
|
||||
|
||||
de = [fm enumeratorAtPath: dir];
|
||||
while ((file = [de nextObject]))
|
||||
{
|
||||
if ([[file pathExtension] isEqualToString: @"clr"])
|
||||
{
|
||||
NSString *name;
|
||||
|
||||
name = [file stringByDeletingPathExtension];
|
||||
newList = [[NSColorList alloc] initWithName: name
|
||||
fromFile: [dir stringByAppendingPathComponent: file]];
|
||||
[_availableColorLists addObject: newList];
|
||||
RELEASE(newList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultSystemColorList != nil)
|
||||
{
|
||||
[_availableColorLists addObject: defaultSystemColorList];
|
||||
}
|
||||
[_colorListLock unlock];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void) _setDefaultSystemColorList: (NSColorList*)aList
|
||||
{
|
||||
[_colorListLock lock];
|
||||
if (defaultSystemColorList != aList)
|
||||
{
|
||||
if (defaultSystemColorList != nil
|
||||
&& [_availableColorLists lastObject] == defaultSystemColorList)
|
||||
{
|
||||
[_availableColorLists removeLastObject];
|
||||
}
|
||||
ASSIGN(defaultSystemColorList, aList);
|
||||
[_availableColorLists addObject: aList];
|
||||
}
|
||||
[_colorListLock unlock];
|
||||
}
|
||||
|
||||
+ (void) _setThemeSystemColorList: (NSColorList*)aList
|
||||
{
|
||||
[_colorListLock lock];
|
||||
if (themeColorList != aList)
|
||||
{
|
||||
if (themeColorList != nil && [_availableColorLists count] > 0
|
||||
&& [_availableColorLists objectAtIndex: 0] == themeColorList)
|
||||
{
|
||||
[_availableColorLists removeObjectAtIndex: 0];
|
||||
}
|
||||
ASSIGN(themeColorList, aList);
|
||||
[_availableColorLists insertObject: aList atIndex: 0];
|
||||
}
|
||||
[_colorListLock unlock];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -365,6 +365,7 @@
|
|||
- (void) drawRect: (NSRect)rect
|
||||
{
|
||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||
GSDrawFunctions *theme = [GSDrawFunctions theme];
|
||||
int howMany = [_items count];
|
||||
int i;
|
||||
NSRect previousRect = NSMakeRect(0, 0, 0, 0);
|
||||
|
@ -378,18 +379,18 @@
|
|||
default:
|
||||
case NSTopTabsBezelBorder:
|
||||
aRect.size.height -= 16;
|
||||
[GSDrawFunctions drawButton: aRect : NSZeroRect];
|
||||
[theme drawButton: aRect withClip: NSZeroRect];
|
||||
break;
|
||||
|
||||
case NSBottomTabsBezelBorder:
|
||||
aRect.size.height -= 16;
|
||||
aRect.origin.y += 16;
|
||||
[GSDrawFunctions drawButton: aRect : rect];
|
||||
[theme drawButton: aRect withClip: rect];
|
||||
aRect.origin.y -= 16;
|
||||
break;
|
||||
|
||||
case NSNoTabsBezelBorder:
|
||||
[GSDrawFunctions drawButton: aRect : rect];
|
||||
[theme drawButton: aRect withClip: rect];
|
||||
break;
|
||||
|
||||
case NSNoTabsLineBorder:
|
||||
|
|
Loading…
Reference in a new issue