merge in some theme branch changes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24017 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-11-02 19:42:42 +00:00
parent 67bbe5ea4b
commit c7ab9084e8
3 changed files with 78 additions and 32 deletions

View file

@ -170,6 +170,7 @@ new_label (NSString *value)
NSString *url = nil;
NSString *copyright = nil;
NSString *copyrightDescription = nil;
NSString *theme = nil;
/* GUI Objects used to show the Info */
NSButton *iconButton;
@ -181,6 +182,7 @@ new_label (NSString *value)
NSTextField *urlLabel = nil;
NSTextField *copyrightLabel;
NSTextField *copyrightDescriptionLabel = nil;
NSTextField *themeLabel = nil;
NSFont *smallFont;
/* Minimum size we use for the panel */
@ -400,6 +402,12 @@ new_label (NSString *value)
[copyrightDescriptionLabel sizeToFit];
}
theme = [NSString stringWithFormat: @"%@: %@",
_(@"Current theme"), [[GSTheme theme] name]];
themeLabel = new_label (theme);
[themeLabel setFont: smallFont];
[themeLabel sizeToFit];
/*
* Compute width and height of the panel
*/
@ -452,6 +460,10 @@ new_label (NSString *value)
width = tmp_A;
}
tmp_A = [themeLabel frame].size.width;
if (tmp_A > width)
width = tmp_A;
/* height */
/* Warning: we implicitly assume icon height is approx of the
standard height of 48. The code tries to be nice so that 50 or
@ -481,6 +493,9 @@ new_label (NSString *value)
tmp_A += [copyrightDescriptionLabel frame].size.height;
}
tmp_A += 5;
tmp_A += [themeLabel frame].size.height;
if (tmp_A > height)
height = tmp_A;
@ -592,18 +607,17 @@ new_label (NSString *value)
[copyrightDescriptionLabel setFrame: f];
}
f = [themeLabel frame];
f.origin.x = (width - f.size.width) / 2;
f.origin.y = tmp_b - 25 - f.size.height;
tmp_b = f.origin.y;
[cv addSubview: themeLabel];
[themeLabel setFrame: f];
[themeLabel setTarget: [GSTheme class]];
[themeLabel setAction: @selector(orderFrontSharedThemePanel:)];
[self center];
return self;
}
- (void) mouseDown: (NSEvent*)theEvent
{
/*
* Mouse down on window background ... we could do different things in
* different regions of the window, but for now we just use this to
* activate the theme panel.
*/
[GSTheme orderFrontSharedThemePanel: self];
}
@end

View file

@ -668,40 +668,62 @@ static NSNull *null = nil;
@implementation GSTheme (Drawing)
- (NSRect) drawButton: (NSRect) frame
in: (NSButtonCell*) cell
view: (NSView*) view
style: (int) style
state: (int) state
- (NSRect) drawButton: (NSRect)frame
in: (NSButtonCell*)cell
view: (NSView*)view
style: (int)style
state: (int)state
{
/* computes the interior frame rect */
NSRect interiorFrame = [cell drawingRectForBounds: frame];
/* Draw the button background */
GSDrawTiles *tiles = nil;
NSColor *color = nil;
NSRect interiorFrame;
if (state == 0) /* default state, unpressed */
{
[[NSColor controlBackgroundColor] set];
NSRectFill(frame);
[self drawButton: frame withClip: NSZeroRect];
tiles = [self tilesNamed: @"NSButtonNormal" cache: YES];
color = [NSColor controlBackgroundColor];
}
else if (state == 1) /* highlighted state */
{
[[NSColor selectedControlColor] set];
NSRectFill(frame);
[self drawGrayBezel: frame withClip: NSZeroRect];
tiles = [self tilesNamed: @"NSButtonHighlighted" cache: YES];
color = [NSColor selectedControlColor];
}
else if (state == 2) /* pushed state */
{
[[NSColor selectedControlColor] set];
NSRectFill(frame);
[self drawGrayBezel: frame withClip: NSZeroRect];
interiorFrame
= NSOffsetRect(interiorFrame, 1.0, [view isFlipped] ? 1.0 : -1.0);
tiles = [self tilesNamed: @"NSButtonPushed" cache: YES];
color = [NSColor selectedControlColor];
}
/* returns the interior frame rect */
if (tiles == nil)
{
interiorFrame = [cell drawingRectForBounds: frame];
[color set];
NSRectFill(frame);
if (state == 0) /* default state, unpressed */
{
[self drawButton: frame withClip: NSZeroRect];
}
else if (state == 1) /* highlighted state */
{
[self drawGrayBezel: frame withClip: NSZeroRect];
}
else if (state == 2) /* pushed state */
{
[self drawGrayBezel: frame withClip: NSZeroRect];
interiorFrame
= NSOffsetRect(interiorFrame, 1.0, [view isFlipped] ? 1.0 : -1.0);
}
}
else
{
/* Use tiles to draw button border with central part filled with color
*/
interiorFrame = [self fillRect: frame
withTiles: tiles
background: color
fillStyle: GSThemeFillStyleNone];
}
return interiorFrame;
}