mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 02:04:20 +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
c0913a5c74
commit
3bfc5beceb
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>
|
||||
|
||||
* Source/NSScroller.m: make offset of buttons inside scroller adjustable
|
||||
|
|
|
@ -652,26 +652,40 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
- (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;
|
||||
- (NSRect) drawStepperLightButton: (NSRect)border : (NSRect)clip;
|
||||
/**
|
||||
* Draw normal stepper up button.
|
||||
*/
|
||||
- (void) drawStepperUpButton: (NSRect) aRect;
|
||||
- (void) drawStepperUpButton: (NSRect)aRect;
|
||||
/**
|
||||
* Draw highlighted up stepper button.
|
||||
*/
|
||||
- (void) drawStepperHighlightUpButton: (NSRect) aRect;
|
||||
- (void) drawStepperHighlightUpButton: (NSRect)aRect;
|
||||
/**
|
||||
* Draw down button for stepper
|
||||
*/
|
||||
- (void) drawStepperDownButton: (NSRect) aRect;
|
||||
- (void) drawStepperDownButton: (NSRect)aRect;
|
||||
/**
|
||||
* Draw highlighted stepper down button
|
||||
*/
|
||||
- (void) drawStepperHighlightDownButton: (NSRect) aRect;
|
||||
- (void) drawStepperHighlightDownButton: (NSRect)aRect;
|
||||
|
||||
/**
|
||||
* In some themes it may be necessary to override the drawing
|
||||
|
|
|
@ -30,18 +30,18 @@
|
|||
#ifndef _GNUstep_H_NSStepper
|
||||
#define _GNUstep_H_NSStepper
|
||||
|
||||
#include <AppKit/NSControl.h>
|
||||
#import <AppKit/NSControl.h>
|
||||
|
||||
@interface NSStepper : NSControl
|
||||
{
|
||||
// Attributes
|
||||
}
|
||||
- (double) maxValue;
|
||||
- (void) setMaxValue: (double)maxValue;
|
||||
- (double) minValue;
|
||||
- (void) setMinValue: (double)minValue;
|
||||
- (double) increment;
|
||||
- (void) setIncrement: (double)increment;
|
||||
- (double)maxValue;
|
||||
- (void)setMaxValue: (double)maxValue;
|
||||
- (double)minValue;
|
||||
- (void)setMinValue: (double)minValue;
|
||||
- (double)increment;
|
||||
- (void)setIncrement: (double)increment;
|
||||
|
||||
- (BOOL)autorepeat;
|
||||
- (void)setAutorepeat: (BOOL)autorepeat;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#ifndef _GNUstep_H_NSStepperCell
|
||||
#define _GNUstep_H_NSStepperCell
|
||||
|
||||
#include <AppKit/NSActionCell.h>
|
||||
#import <AppKit/NSActionCell.h>
|
||||
|
||||
@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.);
|
||||
|
@ -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];
|
||||
NSRectFill(unHighlightRect);
|
||||
|
||||
|
@ -530,9 +573,9 @@
|
|||
PSstroke();
|
||||
}
|
||||
|
||||
- (void) drawStepperHighlightUpButton: (NSRect) aRect
|
||||
- (void) drawStepperHighlightUpButton: (NSRect)aRect
|
||||
{
|
||||
NSRect highlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
|
||||
NSRect highlightRect = [self drawStepperLightButton: aRect : NSZeroRect];
|
||||
[[NSColor selectedControlColor] set];
|
||||
NSRectFill(highlightRect);
|
||||
|
||||
|
@ -551,9 +594,9 @@
|
|||
PSstroke();
|
||||
}
|
||||
|
||||
- (void) drawStepperDownButton: (NSRect) aRect
|
||||
- (void) drawStepperDownButton: (NSRect)aRect
|
||||
{
|
||||
NSRect unHighlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
|
||||
NSRect unHighlightRect = [self drawStepperLightButton: aRect : NSZeroRect];
|
||||
[[NSColor controlBackgroundColor] set];
|
||||
NSRectFill(unHighlightRect);
|
||||
|
||||
|
@ -572,9 +615,9 @@
|
|||
PSstroke();
|
||||
}
|
||||
|
||||
- (void) drawStepperHighlightDownButton: (NSRect) aRect
|
||||
- (void) drawStepperHighlightDownButton: (NSRect)aRect
|
||||
{
|
||||
NSRect highlightRect = [self drawStepperLightButton: aRect :NSZeroRect];
|
||||
NSRect highlightRect = [self drawStepperLightButton: aRect : NSZeroRect];
|
||||
[[NSColor selectedControlColor] set];
|
||||
NSRectFill(highlightRect);
|
||||
|
||||
|
@ -593,6 +636,31 @@
|
|||
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
|
||||
inButtonCell: (NSButtonCell *) cell
|
||||
withFrame: (NSRect) aRect
|
||||
|
|
|
@ -828,12 +828,12 @@ static NSNotificationCenter *nc;
|
|||
[_cell performClickWithFrame: [self bounds] inView: self];
|
||||
}
|
||||
|
||||
- (BOOL)refusesFirstResponder
|
||||
- (BOOL) refusesFirstResponder
|
||||
{
|
||||
return [[self selectedCell] refusesFirstResponder];
|
||||
}
|
||||
|
||||
- (void)setRefusesFirstResponder:(BOOL)flag
|
||||
- (void) setRefusesFirstResponder:(BOOL)flag
|
||||
{
|
||||
[[self selectedCell] setRefusesFirstResponder: flag];
|
||||
}
|
||||
|
|
|
@ -26,14 +26,9 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include "AppKit/NSStepper.h"
|
||||
#include "AppKit/NSControl.h"
|
||||
#include "AppKit/NSEvent.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
#include "AppKit/NSApplication.h"
|
||||
#include "AppKit/NSStepperCell.h"
|
||||
#import "AppKit/NSStepper.h"
|
||||
#import "AppKit/NSEvent.h"
|
||||
#import "AppKit/NSStepperCell.h"
|
||||
|
||||
//
|
||||
// class variables
|
||||
|
|
|
@ -28,20 +28,13 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include "AppKit/NSApplication.h"
|
||||
#include "AppKit/NSColor.h"
|
||||
#include "AppKit/NSControl.h"
|
||||
#include "AppKit/NSEvent.h"
|
||||
#include "AppKit/NSGraphics.h"
|
||||
#include "AppKit/NSGraphicsContext.h"
|
||||
#include "AppKit/NSStepperCell.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
#import "AppKit/NSApplication.h"
|
||||
#import "AppKit/NSControl.h"
|
||||
#import "AppKit/NSEvent.h"
|
||||
#import "AppKit/NSStepperCell.h"
|
||||
#import "AppKit/NSWindow.h"
|
||||
#include "GNUstepGUI/GSTheme.h"
|
||||
|
||||
// Hard coded values for button sizes
|
||||
#define STEPPER_WIDTH 15
|
||||
#define STEPPER_HEIGHT 11
|
||||
|
||||
@interface NSStepperCell (Private)
|
||||
- (void) _increment;
|
||||
- (void) _decrement;
|
||||
|
@ -49,8 +42,6 @@
|
|||
upButton: (BOOL)upButton
|
||||
withFrame: (NSRect)frame
|
||||
inView: (NSView*)controlView;
|
||||
- (NSRect) upButtonRectWithFrame: (NSRect)frame;
|
||||
- (NSRect) downButtonRectWithFrame: (NSRect)frame;
|
||||
@end
|
||||
|
||||
@implementation NSStepperCell
|
||||
|
@ -74,6 +65,8 @@
|
|||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
if (!self)
|
||||
return nil;
|
||||
|
||||
[self setIntValue: 0];
|
||||
[self setAlignment: NSRightTextAlignment];
|
||||
|
@ -120,22 +113,22 @@
|
|||
_increment = increment;
|
||||
}
|
||||
|
||||
- (BOOL)autorepeat
|
||||
- (BOOL) autorepeat
|
||||
{
|
||||
return _autorepeat;
|
||||
}
|
||||
|
||||
- (void)setAutorepeat: (BOOL)autorepeat
|
||||
- (void) setAutorepeat: (BOOL)autorepeat
|
||||
{
|
||||
_autorepeat = autorepeat;
|
||||
}
|
||||
|
||||
- (BOOL)valueWraps
|
||||
- (BOOL) valueWraps
|
||||
{
|
||||
return _valueWraps;
|
||||
}
|
||||
|
||||
- (void)setValueWraps: (BOOL)valueWraps
|
||||
- (void) setValueWraps: (BOOL)valueWraps
|
||||
{
|
||||
_valueWraps = valueWraps;
|
||||
}
|
||||
|
@ -143,36 +136,11 @@
|
|||
- (void) drawInteriorWithFrame: (NSRect)cellFrame
|
||||
inView: (NSView*)controlView
|
||||
{
|
||||
NSRect upRect;
|
||||
NSRect downRect;
|
||||
NSRect twoButtons;
|
||||
|
||||
upRect = [self upButtonRectWithFrame: cellFrame];
|
||||
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);
|
||||
}
|
||||
[[GSTheme theme] drawStepperCell: self
|
||||
withFrame: cellFrame
|
||||
inView: controlView
|
||||
highlightUp: highlightUp
|
||||
highlightDown: highlightDown];
|
||||
}
|
||||
|
||||
- (void) getPeriodicDelay: (float*)delay interval: (float*)interval
|
||||
|
@ -214,8 +182,8 @@
|
|||
if ([theEvent type] != NSLeftMouseDown)
|
||||
return NO;
|
||||
|
||||
upRect = [self upButtonRectWithFrame: cellFrame];
|
||||
downRect = [self downButtonRectWithFrame: cellFrame];
|
||||
upRect = [[GSTheme theme] stepperUpButtonRectWithFrame: cellFrame];
|
||||
downRect = [[GSTheme theme] stepperDownButtonRectWithFrame: cellFrame];
|
||||
|
||||
// Did the mouse go down in the up or in the down part?
|
||||
if (NSMouseInRect(point, upRect, NO))
|
||||
|
@ -475,26 +443,4 @@
|
|||
[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
|
||||
|
|
Loading…
Reference in a new issue