mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-04 00:10:41 +00:00
Move stepper drawing code into GSTheme.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28983 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e533cbec58
commit
6f96e84bc6
8 changed files with 137 additions and 104 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2009-11-09 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSControl.m,
|
||||||
|
* Headers/AppKit/NSStepper.h,
|
||||||
|
* Headers/AppKit/NSStepperCell.h,
|
||||||
|
* Source/NSStepper.m: White space changes and cleanup.
|
||||||
|
* Source/NSStepperCell.m,
|
||||||
|
* Headers/Additions/GNUstepGUI/GSTheme.h,
|
||||||
|
* Source/GSThemeDrawing.m: Move stepper drawing code into GSTheme.
|
||||||
|
|
||||||
2009-11-09 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-11-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSScroller.m: make offset of buttons inside scroller adjustable
|
* Source/NSScroller.m: make offset of buttons inside scroller adjustable
|
||||||
|
|
|
@ -652,26 +652,40 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
||||||
- (BOOL) toolbarIsOpaque;
|
- (BOOL) toolbarIsOpaque;
|
||||||
|
|
||||||
// Methods to deal with steppers..
|
// 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
|
* Draw light colored stepper using the border and clip rects
|
||||||
*/
|
*/
|
||||||
- (NSRect) drawStepperLightButton: (NSRect) border :(NSRect) clip;
|
- (NSRect) drawStepperLightButton: (NSRect)border : (NSRect)clip;
|
||||||
/**
|
/**
|
||||||
* Draw normal stepper up button.
|
* Draw normal stepper up button.
|
||||||
*/
|
*/
|
||||||
- (void) drawStepperUpButton: (NSRect) aRect;
|
- (void) drawStepperUpButton: (NSRect)aRect;
|
||||||
/**
|
/**
|
||||||
* Draw highlighted up stepper button.
|
* Draw highlighted up stepper button.
|
||||||
*/
|
*/
|
||||||
- (void) drawStepperHighlightUpButton: (NSRect) aRect;
|
- (void) drawStepperHighlightUpButton: (NSRect)aRect;
|
||||||
/**
|
/**
|
||||||
* Draw down button for stepper
|
* Draw down button for stepper
|
||||||
*/
|
*/
|
||||||
- (void) drawStepperDownButton: (NSRect) aRect;
|
- (void) drawStepperDownButton: (NSRect)aRect;
|
||||||
/**
|
/**
|
||||||
* Draw highlighted stepper down button
|
* Draw highlighted stepper down button
|
||||||
*/
|
*/
|
||||||
- (void) drawStepperHighlightDownButton: (NSRect) aRect;
|
- (void) drawStepperHighlightDownButton: (NSRect)aRect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In some themes it may be necessary to override the drawing
|
* In some themes it may be necessary to override the drawing
|
||||||
|
|
|
@ -30,18 +30,18 @@
|
||||||
#ifndef _GNUstep_H_NSStepper
|
#ifndef _GNUstep_H_NSStepper
|
||||||
#define _GNUstep_H_NSStepper
|
#define _GNUstep_H_NSStepper
|
||||||
|
|
||||||
#include <AppKit/NSControl.h>
|
#import <AppKit/NSControl.h>
|
||||||
|
|
||||||
@interface NSStepper : NSControl
|
@interface NSStepper : NSControl
|
||||||
{
|
{
|
||||||
// Attributes
|
// Attributes
|
||||||
}
|
}
|
||||||
- (double) maxValue;
|
- (double)maxValue;
|
||||||
- (void) setMaxValue: (double)maxValue;
|
- (void)setMaxValue: (double)maxValue;
|
||||||
- (double) minValue;
|
- (double)minValue;
|
||||||
- (void) setMinValue: (double)minValue;
|
- (void)setMinValue: (double)minValue;
|
||||||
- (double) increment;
|
- (double)increment;
|
||||||
- (void) setIncrement: (double)increment;
|
- (void)setIncrement: (double)increment;
|
||||||
|
|
||||||
- (BOOL)autorepeat;
|
- (BOOL)autorepeat;
|
||||||
- (void)setAutorepeat: (BOOL)autorepeat;
|
- (void)setAutorepeat: (BOOL)autorepeat;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#ifndef _GNUstep_H_NSStepperCell
|
#ifndef _GNUstep_H_NSStepperCell
|
||||||
#define _GNUstep_H_NSStepperCell
|
#define _GNUstep_H_NSStepperCell
|
||||||
|
|
||||||
#include <AppKit/NSActionCell.h>
|
#import <AppKit/NSActionCell.h>
|
||||||
|
|
||||||
@interface NSStepperCell : NSActionCell
|
@interface NSStepperCell : NSActionCell
|
||||||
{
|
{
|
||||||
|
|
|
@ -483,7 +483,50 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect) drawStepperLightButton: (NSRect) border :(NSRect) clip
|
// NSStepperCell drawing
|
||||||
|
// Hard coded values for button sizes
|
||||||
|
#define STEPPER_WIDTH 15
|
||||||
|
#define STEPPER_HEIGHT 11
|
||||||
|
|
||||||
|
- (NSRect) stepperUpButtonRectWithFrame: (NSRect)frame
|
||||||
|
{
|
||||||
|
NSRect upRect;
|
||||||
|
|
||||||
|
upRect.size.width = STEPPER_WIDTH;
|
||||||
|
upRect.size.height = STEPPER_HEIGHT;
|
||||||
|
upRect.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1;
|
||||||
|
upRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) + 1;
|
||||||
|
return upRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSRect) stepperDownButtonRectWithFrame: (NSRect)frame
|
||||||
|
{
|
||||||
|
NSRect downRect;
|
||||||
|
|
||||||
|
downRect.size.width = STEPPER_WIDTH;
|
||||||
|
downRect.size.height = STEPPER_HEIGHT;
|
||||||
|
downRect.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1;
|
||||||
|
downRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) - STEPPER_HEIGHT + 1;
|
||||||
|
return downRect;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) drawStepperBorder: (NSRect)frame
|
||||||
|
{
|
||||||
|
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge};
|
||||||
|
NSColor *black = [NSColor controlDarkShadowColor];
|
||||||
|
NSColor *grays[] = {black, black};
|
||||||
|
NSRect twoButtons;
|
||||||
|
|
||||||
|
twoButtons.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1;
|
||||||
|
twoButtons.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) - STEPPER_HEIGHT;
|
||||||
|
twoButtons.size.width = STEPPER_WIDTH + 1;
|
||||||
|
twoButtons.size.height = 2 * STEPPER_HEIGHT + 1;
|
||||||
|
|
||||||
|
NSDrawColorTiledRects(twoButtons, NSZeroRect,
|
||||||
|
up_sides, grays, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSRect) drawStepperLightButton: (NSRect)border : (NSRect)clip
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
NSRect highlightRect = NSInsetRect(border, 1., 1.);
|
NSRect highlightRect = NSInsetRect(border, 1., 1.);
|
||||||
|
@ -509,9 +552,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawStepperUpButton: (NSRect) aRect
|
- (void) drawStepperUpButton: (NSRect)aRect
|
||||||
{
|
{
|
||||||
NSRect unHighlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
|
NSRect unHighlightRect = [self drawStepperLightButton: aRect : NSZeroRect];
|
||||||
[[NSColor controlBackgroundColor] set];
|
[[NSColor controlBackgroundColor] set];
|
||||||
NSRectFill(unHighlightRect);
|
NSRectFill(unHighlightRect);
|
||||||
|
|
||||||
|
@ -530,9 +573,9 @@
|
||||||
PSstroke();
|
PSstroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawStepperHighlightUpButton: (NSRect) aRect
|
- (void) drawStepperHighlightUpButton: (NSRect)aRect
|
||||||
{
|
{
|
||||||
NSRect highlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
|
NSRect highlightRect = [self drawStepperLightButton: aRect : NSZeroRect];
|
||||||
[[NSColor selectedControlColor] set];
|
[[NSColor selectedControlColor] set];
|
||||||
NSRectFill(highlightRect);
|
NSRectFill(highlightRect);
|
||||||
|
|
||||||
|
@ -551,9 +594,9 @@
|
||||||
PSstroke();
|
PSstroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawStepperDownButton: (NSRect) aRect
|
- (void) drawStepperDownButton: (NSRect)aRect
|
||||||
{
|
{
|
||||||
NSRect unHighlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
|
NSRect unHighlightRect = [self drawStepperLightButton: aRect : NSZeroRect];
|
||||||
[[NSColor controlBackgroundColor] set];
|
[[NSColor controlBackgroundColor] set];
|
||||||
NSRectFill(unHighlightRect);
|
NSRectFill(unHighlightRect);
|
||||||
|
|
||||||
|
@ -572,9 +615,9 @@
|
||||||
PSstroke();
|
PSstroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawStepperHighlightDownButton: (NSRect) aRect
|
- (void) drawStepperHighlightDownButton: (NSRect)aRect
|
||||||
{
|
{
|
||||||
NSRect highlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
|
NSRect highlightRect = [self drawStepperLightButton: aRect : NSZeroRect];
|
||||||
[[NSColor selectedControlColor] set];
|
[[NSColor selectedControlColor] set];
|
||||||
NSRectFill(highlightRect);
|
NSRectFill(highlightRect);
|
||||||
|
|
||||||
|
@ -593,6 +636,31 @@
|
||||||
PSstroke();
|
PSstroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) drawStepperCell: (NSCell*)cell
|
||||||
|
withFrame: (NSRect)cellFrame
|
||||||
|
inView: (NSView*)controlView
|
||||||
|
highlightUp: (BOOL)highlightUp
|
||||||
|
highlightDown: (BOOL)highlightDown
|
||||||
|
{
|
||||||
|
NSRect upRect;
|
||||||
|
NSRect downRect;
|
||||||
|
|
||||||
|
[self drawStepperBorder: cellFrame];
|
||||||
|
|
||||||
|
upRect = [self stepperUpButtonRectWithFrame: cellFrame];
|
||||||
|
downRect = [self stepperDownButtonRectWithFrame: cellFrame];
|
||||||
|
|
||||||
|
if (highlightUp)
|
||||||
|
[self drawStepperHighlightUpButton: upRect];
|
||||||
|
else
|
||||||
|
[self drawStepperUpButton: upRect];
|
||||||
|
|
||||||
|
if (highlightDown)
|
||||||
|
[self drawStepperHighlightDownButton: downRect];
|
||||||
|
else
|
||||||
|
[self drawStepperDownButton: downRect];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) drawImage: (NSImage *)image
|
- (void) drawImage: (NSImage *)image
|
||||||
inButtonCell: (NSButtonCell *) cell
|
inButtonCell: (NSButtonCell *) cell
|
||||||
withFrame: (NSRect) aRect
|
withFrame: (NSRect) aRect
|
||||||
|
|
|
@ -828,12 +828,12 @@ static NSNotificationCenter *nc;
|
||||||
[_cell performClickWithFrame: [self bounds] inView: self];
|
[_cell performClickWithFrame: [self bounds] inView: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)refusesFirstResponder
|
- (BOOL) refusesFirstResponder
|
||||||
{
|
{
|
||||||
return [[self selectedCell] refusesFirstResponder];
|
return [[self selectedCell] refusesFirstResponder];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRefusesFirstResponder:(BOOL)flag
|
- (void) setRefusesFirstResponder:(BOOL)flag
|
||||||
{
|
{
|
||||||
[[self selectedCell] setRefusesFirstResponder: flag];
|
[[self selectedCell] setRefusesFirstResponder: flag];
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,14 +26,9 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <Foundation/NSDebug.h>
|
#import "AppKit/NSStepper.h"
|
||||||
#include <Foundation/NSException.h>
|
#import "AppKit/NSEvent.h"
|
||||||
#include "AppKit/NSStepper.h"
|
#import "AppKit/NSStepperCell.h"
|
||||||
#include "AppKit/NSControl.h"
|
|
||||||
#include "AppKit/NSEvent.h"
|
|
||||||
#include "AppKit/NSWindow.h"
|
|
||||||
#include "AppKit/NSApplication.h"
|
|
||||||
#include "AppKit/NSStepperCell.h"
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// class variables
|
// class variables
|
||||||
|
|
|
@ -28,20 +28,13 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "AppKit/NSApplication.h"
|
#import "AppKit/NSApplication.h"
|
||||||
#include "AppKit/NSColor.h"
|
#import "AppKit/NSControl.h"
|
||||||
#include "AppKit/NSControl.h"
|
#import "AppKit/NSEvent.h"
|
||||||
#include "AppKit/NSEvent.h"
|
#import "AppKit/NSStepperCell.h"
|
||||||
#include "AppKit/NSGraphics.h"
|
#import "AppKit/NSWindow.h"
|
||||||
#include "AppKit/NSGraphicsContext.h"
|
|
||||||
#include "AppKit/NSStepperCell.h"
|
|
||||||
#include "AppKit/NSWindow.h"
|
|
||||||
#include "GNUstepGUI/GSTheme.h"
|
#include "GNUstepGUI/GSTheme.h"
|
||||||
|
|
||||||
// Hard coded values for button sizes
|
|
||||||
#define STEPPER_WIDTH 15
|
|
||||||
#define STEPPER_HEIGHT 11
|
|
||||||
|
|
||||||
@interface NSStepperCell (Private)
|
@interface NSStepperCell (Private)
|
||||||
- (void) _increment;
|
- (void) _increment;
|
||||||
- (void) _decrement;
|
- (void) _decrement;
|
||||||
|
@ -49,8 +42,6 @@
|
||||||
upButton: (BOOL)upButton
|
upButton: (BOOL)upButton
|
||||||
withFrame: (NSRect)frame
|
withFrame: (NSRect)frame
|
||||||
inView: (NSView*)controlView;
|
inView: (NSView*)controlView;
|
||||||
- (NSRect) upButtonRectWithFrame: (NSRect)frame;
|
|
||||||
- (NSRect) downButtonRectWithFrame: (NSRect)frame;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSStepperCell
|
@implementation NSStepperCell
|
||||||
|
@ -74,6 +65,8 @@
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
if (!self)
|
||||||
|
return nil;
|
||||||
|
|
||||||
[self setIntValue: 0];
|
[self setIntValue: 0];
|
||||||
[self setAlignment: NSRightTextAlignment];
|
[self setAlignment: NSRightTextAlignment];
|
||||||
|
@ -120,22 +113,22 @@
|
||||||
_increment = increment;
|
_increment = increment;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)autorepeat
|
- (BOOL) autorepeat
|
||||||
{
|
{
|
||||||
return _autorepeat;
|
return _autorepeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setAutorepeat: (BOOL)autorepeat
|
- (void) setAutorepeat: (BOOL)autorepeat
|
||||||
{
|
{
|
||||||
_autorepeat = autorepeat;
|
_autorepeat = autorepeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)valueWraps
|
- (BOOL) valueWraps
|
||||||
{
|
{
|
||||||
return _valueWraps;
|
return _valueWraps;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setValueWraps: (BOOL)valueWraps
|
- (void) setValueWraps: (BOOL)valueWraps
|
||||||
{
|
{
|
||||||
_valueWraps = valueWraps;
|
_valueWraps = valueWraps;
|
||||||
}
|
}
|
||||||
|
@ -143,36 +136,11 @@
|
||||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame
|
- (void) drawInteriorWithFrame: (NSRect)cellFrame
|
||||||
inView: (NSView*)controlView
|
inView: (NSView*)controlView
|
||||||
{
|
{
|
||||||
NSRect upRect;
|
[[GSTheme theme] drawStepperCell: self
|
||||||
NSRect downRect;
|
withFrame: cellFrame
|
||||||
NSRect twoButtons;
|
inView: controlView
|
||||||
|
highlightUp: highlightUp
|
||||||
upRect = [self upButtonRectWithFrame: cellFrame];
|
highlightDown: highlightDown];
|
||||||
downRect = [self downButtonRectWithFrame: cellFrame];
|
|
||||||
|
|
||||||
twoButtons = downRect;
|
|
||||||
twoButtons.origin.y--;
|
|
||||||
twoButtons.size.width++;
|
|
||||||
twoButtons.size.height = 2 * STEPPER_HEIGHT + 1;
|
|
||||||
|
|
||||||
if (highlightUp)
|
|
||||||
[[GSTheme theme] drawStepperHighlightUpButton: upRect];
|
|
||||||
else
|
|
||||||
[[GSTheme theme] drawStepperUpButton: upRect];
|
|
||||||
|
|
||||||
if (highlightDown)
|
|
||||||
[[GSTheme theme] drawStepperHighlightDownButton: downRect];
|
|
||||||
else
|
|
||||||
[[GSTheme theme] drawStepperDownButton: downRect];
|
|
||||||
|
|
||||||
{
|
|
||||||
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge};
|
|
||||||
NSColor *black = [NSColor controlDarkShadowColor];
|
|
||||||
NSColor *grays[] = {black, black};
|
|
||||||
|
|
||||||
NSDrawColorTiledRects(twoButtons, NSZeroRect,
|
|
||||||
up_sides, grays, 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getPeriodicDelay: (float*)delay interval: (float*)interval
|
- (void) getPeriodicDelay: (float*)delay interval: (float*)interval
|
||||||
|
@ -214,8 +182,8 @@
|
||||||
if ([theEvent type] != NSLeftMouseDown)
|
if ([theEvent type] != NSLeftMouseDown)
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
upRect = [self upButtonRectWithFrame: cellFrame];
|
upRect = [[GSTheme theme] stepperUpButtonRectWithFrame: cellFrame];
|
||||||
downRect = [self downButtonRectWithFrame: cellFrame];
|
downRect = [[GSTheme theme] stepperDownButtonRectWithFrame: cellFrame];
|
||||||
|
|
||||||
// Did the mouse go down in the up or in the down part?
|
// Did the mouse go down in the up or in the down part?
|
||||||
if (NSMouseInRect(point, upRect, NO))
|
if (NSMouseInRect(point, upRect, NO))
|
||||||
|
@ -475,26 +443,4 @@
|
||||||
[controlView setNeedsDisplayInRect: frame];
|
[controlView setNeedsDisplayInRect: frame];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect) upButtonRectWithFrame: (NSRect)frame
|
|
||||||
{
|
|
||||||
NSRect upRect;
|
|
||||||
|
|
||||||
upRect.size.width = STEPPER_WIDTH;
|
|
||||||
upRect.size.height = STEPPER_HEIGHT;
|
|
||||||
upRect.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1;
|
|
||||||
upRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) + 1;
|
|
||||||
return upRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSRect) downButtonRectWithFrame: (NSRect)frame
|
|
||||||
{
|
|
||||||
NSRect downRect;
|
|
||||||
|
|
||||||
downRect.size.width = STEPPER_WIDTH;
|
|
||||||
downRect.size.height = STEPPER_HEIGHT;
|
|
||||||
downRect.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1;
|
|
||||||
downRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) - STEPPER_HEIGHT + 1;
|
|
||||||
return downRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue