Merge in some theming changes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24120 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-11-17 08:54:20 +00:00
parent f15b15d1ba
commit dffc79cdfb
5 changed files with 84 additions and 21 deletions

View file

@ -1,3 +1,11 @@
2006-11-17 Richard Frith-Macdoanld <rfm@gnu.org>
* Source/GSTheme.m:
* Source/NSButtonCell.m:
* Source/NSScrollView.m:
* Headers/Additions/GNUstepGUI/GSTheme.h:
Merge in theme changes for scrollviews and cleaner button drawing api.
2006-11-16 Adam Fedor <fedor@gnu.org>
* Model/GMAppKit.m ([NSImage +createObjectForModelUnarchiver:]):

View file

@ -162,6 +162,17 @@ typedef enum {
} GSThemeFillStyle;
/**
* 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).
*/
typedef enum {
GSThemeNormalState, /** A control in its normal state */
GSThemeHighlightedState, /** A control which is highlighted */
GSThemeSelectedState, /** A control which is selected */
} GSThemeControlState;
/** Notification sent when a theme has just become active.
*/
APPKIT_EXPORT NSString *GSThemeDidActivateNotification;
@ -374,7 +385,7 @@ APPKIT_EXPORT NSString *GSThemeDidDeactivateNotification;
in: (NSButtonCell*)cell
view: (NSView*)view
style: (int)style
state: (int)state;
state: (GSThemeControlState)state;
/** Draws the indicator (normally a dotted rectangle) to show that
* the view currently has keyboard focus.

View file

@ -672,23 +672,23 @@ static NSNull *null = nil;
in: (NSButtonCell*)cell
view: (NSView*)view
style: (int)style
state: (int)state
state: (GSThemeControlState)state
{
GSDrawTiles *tiles = nil;
NSColor *color = nil;
NSRect interiorFrame;
if (state == 0) /* default state, unpressed */
if (state == GSThemeNormalState)
{
tiles = [self tilesNamed: @"NSButtonNormal" cache: YES];
color = [NSColor controlBackgroundColor];
}
else if (state == 1) /* highlighted state */
else if (state == GSThemeHighlightedState)
{
tiles = [self tilesNamed: @"NSButtonHighlighted" cache: YES];
color = [NSColor selectedControlColor];
}
else if (state == 2) /* pushed state */
else if (state == GSThemeSelectedState)
{
tiles = [self tilesNamed: @"NSButtonPushed" cache: YES];
color = [NSColor selectedControlColor];
@ -700,15 +700,15 @@ static NSNull *null = nil;
[color set];
NSRectFill(frame);
if (state == 0) /* default state, unpressed */
if (state == GSThemeNormalState)
{
[self drawButton: frame withClip: NSZeroRect];
}
else if (state == 1) /* highlighted state */
else if (state == GSThemeHighlightedState)
{
[self drawGrayBezel: frame withClip: NSZeroRect];
}
else if (state == 2) /* pushed state */
else if (state == GSThemeSelectedState)
{
[self drawGrayBezel: frame withClip: NSZeroRect];
interiorFrame

View file

@ -836,8 +836,8 @@ typedef struct _GSButtonCellFlags
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
unsigned mask;
int buttonState = 0;
unsigned mask;
GSThemeControlState buttonState = GSThemeNormalState;
// Save last view drawn to
if (_control_view != controlView)
@ -876,14 +876,14 @@ typedef struct _GSButtonCellFlags
/* Determine the background color. */
if (mask & (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
{
buttonState = 1; /* highlighted state */
buttonState = GSThemeHighlightedState;
}
}
/* Pushed in buttons contents are displaced to the bottom right 1px. */
if (_cell.is_bordered && (mask & NSPushInCellMask))
{
buttonState = 2; // pushed button
buttonState = GSThemeSelectedState;
}
// draw the border if needed

View file

@ -25,15 +25,18 @@
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.
*/
#include <Foundation/NSDebug.h>
#include <Foundation/NSException.h>
#include <Foundation/NSNotification.h>
#include "AppKit/NSScroller.h"
#include "AppKit/NSColor.h"
#include "AppKit/NSCell.h"
#include "AppKit/NSClipView.h"
#include "AppKit/NSInterfaceStyle.h"
#include "AppKit/NSScrollView.h"
#include "AppKit/NSRulerView.h"
#include "AppKit/NSTableHeaderView.h"
@ -63,6 +66,10 @@ typedef struct _scrollViewFlags
#endif
} GSScrollViewFlags;
@interface NSScrollView (GSPrivate)
- (void) _themeDidActivate: (NSNotification*)notification;
@end
@implementation NSScrollView
/*
@ -169,6 +176,11 @@ static float scrollerWidth;
[self setHasHorizontalRuler: YES];
[self tile];
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(_themeDidActivate:)
name: GSThemeDidActivateNotification
object: nil];
return self;
}
@ -179,6 +191,8 @@ static float scrollerWidth;
- (void) dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
DESTROY(_horizScroller);
DESTROY(_vertScroller);
DESTROY(_horizRuler);
@ -866,15 +880,24 @@ static float scrollerWidth;
if (_hasVertScroller)
{
NSRect vertScrollerRect;
NSRectEdge edge = NSMinXEdge;
NSInterfaceStyle style;
style = NSInterfaceStyleForKey(@"NSScrollViewInterfaceStyle", nil);
if (style == NSMacintoshInterfaceStyle
|| style == NSWindows95InterfaceStyle)
{
edge = NSMaxXEdge;
}
NSDivideRect (contentRect, &vertScrollerRect, &contentRect,
scrollerWidth, NSMinXEdge);
scrollerWidth, edge);
[_vertScroller setFrame: vertScrollerRect];
/* Substract 1 for the line that separates the vertical scroller
* from the clip view (and eventually the horizontal scroller). */
NSDivideRect (contentRect, NULL, &contentRect, 1, NSMinXEdge);
NSDivideRect (contentRect, NULL, &contentRect, 1, edge);
}
/* Prepare the horizontal scroller. */
@ -883,7 +906,7 @@ static float scrollerWidth;
NSRect horizScrollerRect;
NSDivideRect (contentRect, &horizScrollerRect, &contentRect,
scrollerWidth, bottomEdge);
scrollerWidth, bottomEdge);
[_horizScroller setFrame: horizScrollerRect];
@ -918,7 +941,7 @@ static float scrollerWidth;
NSRect horizRulerRect;
NSDivideRect (contentRect, &horizRulerRect, &contentRect,
[_horizRuler requiredThickness], topEdge);
[_horizRuler requiredThickness], topEdge);
[_horizRuler setFrame: horizRulerRect];
}
@ -927,7 +950,7 @@ static float scrollerWidth;
NSRect vertRulerRect;
NSDivideRect (contentRect, &vertRulerRect, &contentRect,
[_vertRuler requiredThickness], NSMinXEdge);
[_vertRuler requiredThickness], NSMinXEdge);
[_vertRuler setFrame: vertRulerRect];
}
}
@ -964,8 +987,20 @@ static float scrollerWidth;
if (_hasVertScroller)
{
DPSmoveto(ctxt, [_vertScroller frame].origin.x + scrollerWidth,
[_vertScroller frame].origin.y - 1);
NSInterfaceStyle style;
style = NSInterfaceStyleForKey(@"NSScrollViewInterfaceStyle", nil);
if (style == NSMacintoshInterfaceStyle
|| style == NSWindows95InterfaceStyle)
{
DPSmoveto(ctxt, [_vertScroller frame].origin.x - 1,
[_vertScroller frame].origin.y - 1);
}
else
{
DPSmoveto(ctxt, [_vertScroller frame].origin.x + scrollerWidth,
[_vertScroller frame].origin.y - 1);
}
DPSrlineto(ctxt, 0, [_vertScroller frame].size.height + 1);
DPSstroke(ctxt);
}
@ -1348,7 +1383,8 @@ static float scrollerWidth;
{
_hasHeaderView = YES;
_hasCornerView = YES;
ASSIGN(_headerClipView, [aDecoder decodeObjectForKey: @"NSHeaderClipView"]);
ASSIGN(_headerClipView,
[aDecoder decodeObjectForKey: @"NSHeaderClipView"]);
}
[self tile];
@ -1470,3 +1506,11 @@ static float scrollerWidth;
}
@end
@implementation NSScrollView (GSPrivate)
- (void) _themeDidActivate: (NSNotification*)notification
{
[self tile];
}
@end