mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:50:48 +00:00
Some code for scroller theming
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27498 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3b1331a973
commit
5d35bfee59
5 changed files with 241 additions and 79 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2009-01-02 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSButtonCell.m: Fix to use the backgroundColor method when
|
||||||
|
drawing a borderless button.
|
||||||
|
* Source/NSScroller.m:
|
||||||
|
* Source/GSThemeDrawing.m:
|
||||||
|
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||||
|
Add in slightly modified version of Christopher Armstrong's code for
|
||||||
|
theming for NSScroller.
|
||||||
|
|
||||||
2009-01-02 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-01-02 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||||
|
|
|
@ -135,19 +135,24 @@
|
||||||
|
|
||||||
#include <Foundation/NSObject.h>
|
#include <Foundation/NSObject.h>
|
||||||
#include <Foundation/NSGeometry.h>
|
#include <Foundation/NSGeometry.h>
|
||||||
#include "AppKit/NSCell.h"
|
#include <AppKit/NSCell.h>
|
||||||
// For gradient types
|
// For gradient types
|
||||||
#include "AppKit/NSButtonCell.h"
|
#include <AppKit/NSButtonCell.h>
|
||||||
// For image frame style
|
// For image frame style
|
||||||
#include "AppKit/NSImageCell.h"
|
#include <AppKit/NSImageCell.h>
|
||||||
|
// For scroller constants
|
||||||
|
#include <AppKit/NSScroller.h>
|
||||||
|
|
||||||
#if OS_API_VERSION(GS_API_NONE,GS_API_NONE)
|
#if OS_API_VERSION(GS_API_NONE,GS_API_NONE)
|
||||||
@class NSArray;
|
@class NSArray;
|
||||||
@class NSBundle;
|
@class NSBundle;
|
||||||
|
@class NSButton;
|
||||||
@class NSColor;
|
@class NSColor;
|
||||||
@class NSColorList;
|
@class NSColorList;
|
||||||
@class NSDictionary;
|
@class NSDictionary;
|
||||||
@class NSImage;
|
@class NSImage;
|
||||||
|
@class NSMenuItemCell;
|
||||||
|
@class NSMenuView;
|
||||||
@class GSDrawTiles;
|
@class GSDrawTiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,7 +219,7 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
||||||
This is a class used for 'theming', which is mostly a matter of
|
This is a class used for 'theming', which is mostly a matter of
|
||||||
encapsulating common drawing behaviors so that GUI appearance can
|
encapsulating common drawing behaviors so that GUI appearance can
|
||||||
be easily modified, but also includes mechanisms for altering
|
be easily modified, but also includes mechanisms for altering
|
||||||
some GUI behavior (such mas orientation and position of menus).
|
some GUI behavior (such as orientation and position of menus).
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Methods in this class standardize drawing of buttons, borders
|
Methods in this class standardize drawing of buttons, borders
|
||||||
|
@ -459,6 +464,14 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
||||||
*/
|
*/
|
||||||
- (NSSize) sizeForImageFrameStyle: (NSImageFrameStyle)frameStyle;
|
- (NSSize) sizeForImageFrameStyle: (NSImageFrameStyle)frameStyle;
|
||||||
|
|
||||||
|
|
||||||
|
/** Methods for scroller theming.
|
||||||
|
*/
|
||||||
|
- (NSButtonCell*) cellForScrollerArrow: (NSScrollerArrow)part
|
||||||
|
horizontal: (BOOL)horizontal;
|
||||||
|
- (NSCell*) cellForScrollerKnob: (BOOL)horizontal;
|
||||||
|
- (NSCell*) cellForScrollerKnobSlot: (BOOL)horizontal;
|
||||||
|
- (float) defaultScrollerWidth;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#import "GSThemePrivate.h"
|
#import "GSThemePrivate.h"
|
||||||
#import "AppKit/NSGraphics.h"
|
#import "AppKit/NSGraphics.h"
|
||||||
|
#import "AppKit/NSImage.h"
|
||||||
|
|
||||||
|
|
||||||
@implementation GSTheme (Drawing)
|
@implementation GSTheme (Drawing)
|
||||||
|
@ -275,5 +276,82 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* NSScroller themeing.
|
||||||
|
*/
|
||||||
|
- (NSButtonCell*) cellForScrollerArrow: (NSScrollerArrow)arrow
|
||||||
|
horizontal: (BOOL)horizontal
|
||||||
|
{
|
||||||
|
NSButtonCell *cell;
|
||||||
|
|
||||||
|
cell = [NSButtonCell new];
|
||||||
|
if (horizontal)
|
||||||
|
{
|
||||||
|
if (arrow == NSScrollerDecrementArrow)
|
||||||
|
{
|
||||||
|
[cell setHighlightsBy:
|
||||||
|
NSChangeBackgroundCellMask | NSContentsCellMask];
|
||||||
|
[cell setImage: [NSImage imageNamed: @"common_ArrowLeft"]];
|
||||||
|
[cell setAlternateImage: [NSImage imageNamed: @"common_ArrowLeftH"]];
|
||||||
|
[cell setImagePosition: NSImageOnly];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[cell setHighlightsBy:
|
||||||
|
NSChangeBackgroundCellMask | NSContentsCellMask];
|
||||||
|
[cell setImage: [NSImage imageNamed: @"common_ArrowRight"]];
|
||||||
|
[cell setAlternateImage: [NSImage imageNamed: @"common_ArrowRightH"]];
|
||||||
|
[cell setImagePosition: NSImageOnly];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (arrow == NSScrollerDecrementArrow)
|
||||||
|
{
|
||||||
|
[cell setHighlightsBy:
|
||||||
|
NSChangeBackgroundCellMask | NSContentsCellMask];
|
||||||
|
[cell setImage: [NSImage imageNamed: @"common_ArrowUp"]];
|
||||||
|
[cell setAlternateImage: [NSImage imageNamed: @"common_ArrowUpH"]];
|
||||||
|
[cell setImagePosition: NSImageOnly];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[cell setHighlightsBy:
|
||||||
|
NSChangeBackgroundCellMask | NSContentsCellMask];
|
||||||
|
[cell setImage: [NSImage imageNamed: @"common_ArrowDown"]];
|
||||||
|
[cell setAlternateImage: [NSImage imageNamed: @"common_ArrowDownH"]];
|
||||||
|
[cell setImagePosition: NSImageOnly];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AUTORELEASE(cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSCell*) cellForScrollerKnob: (BOOL)horizontal
|
||||||
|
{
|
||||||
|
NSButtonCell *knobCell;
|
||||||
|
|
||||||
|
knobCell = [NSButtonCell new];
|
||||||
|
[knobCell setButtonType: NSMomentaryChangeButton];
|
||||||
|
[knobCell setImage: [NSImage imageNamed: @"common_Dimple"]];
|
||||||
|
[knobCell setImagePosition: NSImageOnly];
|
||||||
|
return knobCell;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSCell*) cellForScrollerKnobSlot: (BOOL)horizontal
|
||||||
|
{
|
||||||
|
NSButtonCell *cell;
|
||||||
|
|
||||||
|
cell = [NSButtonCell new];
|
||||||
|
[cell setBordered: NO];
|
||||||
|
[cell setStringValue: nil];
|
||||||
|
[cell setBackgroundColor: [NSColor scrollBarColor]];
|
||||||
|
return AUTORELEASE(cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (float) defaultScrollerWidth
|
||||||
|
{
|
||||||
|
return 18.0;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ typedef struct _GSButtonCellFlags
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
[self initTextCell: @"Button"];
|
self = [self initTextCell: @"Button"];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -314,8 +314,8 @@ typedef struct _GSButtonCellFlags
|
||||||
|
|
||||||
[super setFont: fontObject];
|
[super setFont: fontObject];
|
||||||
|
|
||||||
if ((_keyEquivalentFont != nil) && (fontObject != nil) &&
|
if ((_keyEquivalentFont != nil) && (fontObject != nil)
|
||||||
((size = [fontObject pointSize]) != [_keyEquivalentFont pointSize]))
|
&& ((size = [fontObject pointSize]) != [_keyEquivalentFont pointSize]))
|
||||||
{
|
{
|
||||||
[self setKeyEquivalentFont: [_keyEquivalentFont fontName]
|
[self setKeyEquivalentFont: [_keyEquivalentFont fontName]
|
||||||
size: size];
|
size: size];
|
||||||
|
@ -923,6 +923,21 @@ typedef struct _GSButtonCellFlags
|
||||||
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
|
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
|
||||||
inView: (NSView*)controlView
|
inView: (NSView*)controlView
|
||||||
{
|
{
|
||||||
|
/* The background color is used for borderless cells (the MacOS-X
|
||||||
|
* documentation of the NSButtonCell -backgroundColor method says
|
||||||
|
* it's only used for borderless cells).
|
||||||
|
*/
|
||||||
|
if (!_cell.is_bordered)
|
||||||
|
{
|
||||||
|
NSColor *c = [self backgroundColor];
|
||||||
|
|
||||||
|
if (c != nil)
|
||||||
|
{
|
||||||
|
[c set];
|
||||||
|
NSRectFill(cellFrame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw gradient
|
// Draw gradient
|
||||||
if (!_cell.is_highlighted)
|
if (!_cell.is_highlighted)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
#include "AppKit/NSScrollView.h"
|
#include "AppKit/NSScrollView.h"
|
||||||
#include "AppKit/NSWindow.h"
|
#include "AppKit/NSWindow.h"
|
||||||
|
|
||||||
|
#include "GNUstepGUI/GSTheme.h"
|
||||||
|
|
||||||
/**<p>TODO Description</p>
|
/**<p>TODO Description</p>
|
||||||
*/
|
*/
|
||||||
@implementation NSScroller
|
@implementation NSScroller
|
||||||
|
@ -54,17 +56,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* button cells used by scroller instances to draw scroller buttons and knob. */
|
/* button cells used by scroller instances to draw scroller buttons and knob. */
|
||||||
static NSButtonCell* upCell = nil;
|
static NSButtonCell *upCell = nil;
|
||||||
static NSButtonCell* downCell = nil;
|
static NSButtonCell *downCell = nil;
|
||||||
static NSButtonCell* leftCell = nil;
|
static NSButtonCell *leftCell = nil;
|
||||||
static NSButtonCell* rightCell = nil;
|
static NSButtonCell *rightCell = nil;
|
||||||
static NSButtonCell* knobCell = nil;
|
static NSCell *horizontalKnobCell = nil;
|
||||||
|
static NSCell *verticalKnobCell = nil;
|
||||||
|
static NSCell *horizontalKnobSlotCell = nil;
|
||||||
|
static NSCell *verticalKnobSlotCell = nil;
|
||||||
|
|
||||||
static const float scrollerWidth = 18;
|
|
||||||
static const float buttonsOffset = 2; // buttonsWidth = sw - buttonsOffset
|
static const float buttonsOffset = 2; // buttonsWidth = sw - buttonsOffset
|
||||||
|
|
||||||
static NSColor *scrollBarColor = nil;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class methods
|
* Class methods
|
||||||
*/
|
*/
|
||||||
|
@ -73,7 +75,6 @@ static NSColor *scrollBarColor = nil;
|
||||||
if (self == [NSScroller class])
|
if (self == [NSScroller class])
|
||||||
{
|
{
|
||||||
[self setVersion: 1];
|
[self setVersion: 1];
|
||||||
ASSIGN (scrollBarColor, [NSColor scrollBarColor]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ static NSColor *scrollBarColor = nil;
|
||||||
*/
|
*/
|
||||||
+ (float) scrollerWidth
|
+ (float) scrollerWidth
|
||||||
{
|
{
|
||||||
return scrollerWidth;
|
return [[GSTheme theme] defaultScrollerWidth];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) isFlipped
|
- (BOOL) isFlipped
|
||||||
|
@ -254,7 +255,8 @@ static NSColor *scrollBarColor = nil;
|
||||||
|
|
||||||
_hitPart = NSScrollerNoPart;
|
_hitPart = NSScrollerNoPart;
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_arrowsPosition];
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
|
||||||
|
at: &_arrowsPosition];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isEnabled];
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isEnabled];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_target];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_target];
|
||||||
// Undo RETAIN by decoder
|
// Undo RETAIN by decoder
|
||||||
|
@ -323,54 +325,41 @@ static NSColor *scrollBarColor = nil;
|
||||||
*/
|
*/
|
||||||
- (void) drawParts
|
- (void) drawParts
|
||||||
{
|
{
|
||||||
/*
|
GSTheme *theme = [GSTheme theme] ;
|
||||||
* Create the class variable button cells if they do not yet exist.
|
|
||||||
*/
|
if (upCell)
|
||||||
if (knobCell)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
upCell = [NSButtonCell new];
|
upCell = RETAIN([theme cellForScrollerArrow:
|
||||||
[upCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask];
|
NSScrollerDecrementArrow horizontal:NO]);
|
||||||
[upCell setImage: [NSImage imageNamed: @"common_ArrowUp"]];
|
downCell = RETAIN([theme cellForScrollerArrow:
|
||||||
[upCell setAlternateImage: [NSImage imageNamed: @"common_ArrowUpH"]];
|
NSScrollerIncrementArrow horizontal:NO]);
|
||||||
[upCell setImagePosition: NSImageOnly];
|
leftCell = RETAIN([theme cellForScrollerArrow:
|
||||||
[upCell setContinuous: YES];
|
NSScrollerDecrementArrow horizontal:YES]);
|
||||||
[upCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
rightCell = RETAIN([theme cellForScrollerArrow:
|
||||||
[upCell setPeriodicDelay: 0.3 interval: 0.03];
|
NSScrollerIncrementArrow horizontal:YES]);
|
||||||
|
verticalKnobCell = RETAIN([theme cellForScrollerKnob: NO]);
|
||||||
|
horizontalKnobCell = RETAIN([theme cellForScrollerKnob: YES]);
|
||||||
|
verticalKnobSlotCell = RETAIN([theme cellForScrollerKnobSlot: NO]);
|
||||||
|
horizontalKnobSlotCell = RETAIN([theme cellForScrollerKnobSlot: YES]);
|
||||||
|
|
||||||
downCell = [NSButtonCell new];
|
|
||||||
[downCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask];
|
|
||||||
[downCell setImage: [NSImage imageNamed: @"common_ArrowDown"]];
|
|
||||||
[downCell setAlternateImage: [NSImage imageNamed: @"common_ArrowDownH"]];
|
|
||||||
[downCell setImagePosition: NSImageOnly];
|
|
||||||
[downCell setContinuous: YES];
|
[downCell setContinuous: YES];
|
||||||
[downCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
[downCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
||||||
[downCell setPeriodicDelay: 0.3 interval: 0.03];
|
[downCell setPeriodicDelay: 0.3 interval: 0.03];
|
||||||
|
|
||||||
leftCell = [NSButtonCell new];
|
|
||||||
[leftCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask];
|
|
||||||
[leftCell setImage: [NSImage imageNamed: @"common_ArrowLeft"]];
|
|
||||||
[leftCell setAlternateImage: [NSImage imageNamed: @"common_ArrowLeftH"]];
|
|
||||||
[leftCell setImagePosition: NSImageOnly];
|
|
||||||
[leftCell setContinuous: YES];
|
[leftCell setContinuous: YES];
|
||||||
[leftCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
[leftCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
||||||
[leftCell setPeriodicDelay: 0.3 interval: 0.03];
|
[leftCell setPeriodicDelay: 0.3 interval: 0.03];
|
||||||
|
|
||||||
rightCell = [NSButtonCell new];
|
|
||||||
[rightCell setHighlightsBy: NSChangeBackgroundCellMask | NSContentsCellMask];
|
|
||||||
[rightCell setImage: [NSImage imageNamed: @"common_ArrowRight"]];
|
|
||||||
[rightCell setAlternateImage: [NSImage imageNamed: @"common_ArrowRightH"]];
|
|
||||||
[rightCell setImagePosition: NSImageOnly];
|
|
||||||
[rightCell setContinuous: YES];
|
[rightCell setContinuous: YES];
|
||||||
[rightCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
[rightCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
||||||
[rightCell setPeriodicDelay: 0.3 interval: 0.03];
|
[rightCell setPeriodicDelay: 0.3 interval: 0.03];
|
||||||
|
|
||||||
knobCell = [NSButtonCell new];
|
[upCell setContinuous: YES];
|
||||||
[knobCell setButtonType: NSMomentaryChangeButton];
|
[upCell sendActionOn: (NSLeftMouseDownMask | NSPeriodicMask)];
|
||||||
[knobCell setImage: [NSImage imageNamed: @"common_Dimple"]];
|
[upCell setPeriodicDelay: 0.3 interval: 0.03];
|
||||||
[knobCell setImagePosition: NSImageOnly];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _setTargetAndActionToCells
|
- (void) _setTargetAndActionToCells
|
||||||
{
|
{
|
||||||
[upCell setTarget: _target];
|
[upCell setTarget: _target];
|
||||||
|
@ -385,8 +374,11 @@ static NSColor *scrollBarColor = nil;
|
||||||
[rightCell setTarget: _target];
|
[rightCell setTarget: _target];
|
||||||
[rightCell setAction: _action];
|
[rightCell setAction: _action];
|
||||||
|
|
||||||
[knobCell setTarget: _target];
|
[horizontalKnobCell setTarget: _target];
|
||||||
[knobCell setAction: _action];
|
[horizontalKnobCell setAction: _action];
|
||||||
|
|
||||||
|
[verticalKnobCell setTarget:_target];
|
||||||
|
[horizontalKnobCell setTarget:_target];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) checkSpaceForParts
|
- (void) checkSpaceForParts
|
||||||
|
@ -948,7 +940,10 @@ static NSColor *scrollBarColor = nil;
|
||||||
*/
|
*/
|
||||||
- (void) drawKnob
|
- (void) drawKnob
|
||||||
{
|
{
|
||||||
[knobCell drawWithFrame: [self rectForPart: NSScrollerKnob] inView: self];
|
if (_isHorizontal)
|
||||||
|
[horizontalKnobCell drawWithFrame: [self rectForPart: NSScrollerKnob] inView: self];
|
||||||
|
else
|
||||||
|
[verticalKnobCell drawWithFrame: [self rectForPart: NSScrollerKnob] inView: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) drawKnobSlot
|
- (void) drawKnobSlot
|
||||||
|
@ -960,8 +955,10 @@ static NSColor *scrollBarColor = nil;
|
||||||
rect = [self rectForPart: NSScrollerKnobSlot];
|
rect = [self rectForPart: NSScrollerKnobSlot];
|
||||||
}
|
}
|
||||||
|
|
||||||
[scrollBarColor set];
|
if (_isHorizontal)
|
||||||
NSRectFill (rect);
|
[horizontalKnobSlotCell drawWithFrame:rect inView:self];
|
||||||
|
else
|
||||||
|
[verticalKnobSlotCell drawWithFrame:rect inView:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**<p>Highlights the button whose under the mouse. Does nothing if the mouse
|
/**<p>Highlights the button whose under the mouse. Does nothing if the mouse
|
||||||
|
@ -991,11 +988,31 @@ static NSColor *scrollBarColor = nil;
|
||||||
- (NSRect) rectForPart: (NSScrollerPart)partCode
|
- (NSRect) rectForPart: (NSScrollerPart)partCode
|
||||||
{
|
{
|
||||||
NSRect scrollerFrame = _frame;
|
NSRect scrollerFrame = _frame;
|
||||||
float x = 1, y = 1;
|
float x, y;
|
||||||
float width, height;
|
float width, height;
|
||||||
float buttonsWidth = ([isa scrollerWidth] - buttonsOffset);
|
float buttonsWidth;
|
||||||
float buttonsSize = 2 * buttonsWidth + 2;
|
float buttonsSize;
|
||||||
NSUsableScrollerParts usableParts;
|
NSUsableScrollerParts usableParts;
|
||||||
|
|
||||||
|
NSInterfaceStyle interfaceStyle = NSInterfaceStyleForKey(@"NSScrollerInterfaceStyle",self);
|
||||||
|
|
||||||
|
|
||||||
|
/* We use the button offset if we in the NeXTstep interface style. */
|
||||||
|
if (interfaceStyle == NSNextStepInterfaceStyle
|
||||||
|
|| interfaceStyle == GSWindowMakerInterfaceStyle)
|
||||||
|
{
|
||||||
|
buttonsWidth = ([isa scrollerWidth] - buttonsOffset);
|
||||||
|
x = y = 1.0;
|
||||||
|
buttonsSize = 2 * buttonsWidth + 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buttonsWidth = [isa scrollerWidth];
|
||||||
|
x = y = 1.0;
|
||||||
|
buttonsSize = 2 * buttonsWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the scroller is disabled then the scroller buttons and the
|
* If the scroller is disabled then the scroller buttons and the
|
||||||
* knob are not displayed at all.
|
* knob are not displayed at all.
|
||||||
|
@ -1045,7 +1062,7 @@ static NSColor *scrollBarColor = nil;
|
||||||
|
|
||||||
/* calc the slot Height */
|
/* calc the slot Height */
|
||||||
slotHeight = height - (_arrowsPosition == NSScrollerArrowsNone
|
slotHeight = height - (_arrowsPosition == NSScrollerArrowsNone
|
||||||
? 0 : buttonsSize);
|
? 0 : buttonsSize);
|
||||||
knobHeight = _knobProportion * slotHeight;
|
knobHeight = _knobProportion * slotHeight;
|
||||||
knobHeight = (float)floor(knobHeight);
|
knobHeight = (float)floor(knobHeight);
|
||||||
if (knobHeight < buttonsWidth)
|
if (knobHeight < buttonsWidth)
|
||||||
|
@ -1057,11 +1074,22 @@ static NSColor *scrollBarColor = nil;
|
||||||
|
|
||||||
|
|
||||||
/* calc actual position */
|
/* calc actual position */
|
||||||
y += knobPosition + ((_arrowsPosition == NSScrollerArrowsMaxEnd
|
if (interfaceStyle == NSNextStepInterfaceStyle
|
||||||
|| _arrowsPosition == NSScrollerArrowsNone)
|
|| interfaceStyle == GSWindowMakerInterfaceStyle)
|
||||||
? 0 : buttonsSize);
|
{
|
||||||
|
y += knobPosition + ((_arrowsPosition == NSScrollerArrowsMaxEnd
|
||||||
|
|| _arrowsPosition == NSScrollerArrowsNone)
|
||||||
|
? 0 : buttonsSize);
|
||||||
|
width = buttonsWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
y += knobPosition + ((_arrowsPosition == NSScrollerArrowsNone)
|
||||||
|
? 0 : buttonsWidth);
|
||||||
|
width = buttonsWidth ;
|
||||||
|
}
|
||||||
|
|
||||||
height = knobHeight;
|
height = knobHeight;
|
||||||
width = buttonsWidth;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1076,11 +1104,19 @@ static NSColor *scrollBarColor = nil;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
height -= buttonsSize;
|
height -= buttonsSize;
|
||||||
if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
if ( (interfaceStyle == NSNextStepInterfaceStyle ||
|
||||||
|
interfaceStyle == GSWindowMakerInterfaceStyle)
|
||||||
|
&& _arrowsPosition == NSScrollerArrowsMinEnd)
|
||||||
{
|
{
|
||||||
y += buttonsSize;
|
y += buttonsSize;
|
||||||
}
|
}
|
||||||
break;
|
else if (interfaceStyle != NSNextStepInterfaceStyle
|
||||||
|
&& interfaceStyle != GSWindowMakerInterfaceStyle)
|
||||||
|
{
|
||||||
|
y += buttonsWidth;
|
||||||
|
width = buttonsWidth;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case NSScrollerDecrementLine:
|
case NSScrollerDecrementLine:
|
||||||
case NSScrollerDecrementPage:
|
case NSScrollerDecrementPage:
|
||||||
|
@ -1089,7 +1125,9 @@ static NSColor *scrollBarColor = nil;
|
||||||
{
|
{
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
}
|
}
|
||||||
else if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
else if ((interfaceStyle == NSNextStepInterfaceStyle
|
||||||
|
|| interfaceStyle == GSWindowMakerInterfaceStyle)
|
||||||
|
&& _arrowsPosition == NSScrollerArrowsMaxEnd)
|
||||||
{
|
{
|
||||||
y += (height - buttonsSize + 1);
|
y += (height - buttonsSize + 1);
|
||||||
}
|
}
|
||||||
|
@ -1104,14 +1142,22 @@ static NSColor *scrollBarColor = nil;
|
||||||
{
|
{
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
}
|
}
|
||||||
else if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
else if (interfaceStyle == NSNextStepInterfaceStyle
|
||||||
{
|
|| interfaceStyle == GSWindowMakerInterfaceStyle)
|
||||||
y += (height - buttonsWidth);
|
{
|
||||||
}
|
if (_arrowsPosition == NSScrollerArrowsMaxEnd)
|
||||||
else if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
{
|
||||||
{
|
y += (height - buttonsWidth);
|
||||||
y += (buttonsWidth + 1);
|
}
|
||||||
}
|
else if (_arrowsPosition == NSScrollerArrowsMinEnd)
|
||||||
|
{
|
||||||
|
y += (buttonsWidth + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
y += (height - buttonsWidth);
|
||||||
|
}
|
||||||
height = buttonsWidth;
|
height = buttonsWidth;
|
||||||
width = buttonsWidth;
|
width = buttonsWidth;
|
||||||
break;
|
break;
|
||||||
|
@ -1133,7 +1179,7 @@ static NSColor *scrollBarColor = nil;
|
||||||
+ (float) scrollerWidthForControlSize: (NSControlSize)controlSize
|
+ (float) scrollerWidthForControlSize: (NSControlSize)controlSize
|
||||||
{
|
{
|
||||||
// FIXME
|
// FIXME
|
||||||
return scrollerWidth;
|
return [self scrollerWidth];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setControlSize: (NSControlSize)controlSize
|
- (void) setControlSize: (NSControlSize)controlSize
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue