mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:20:47 +00:00
Tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3942 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ce7ebf5f45
commit
23dee081a5
2 changed files with 218 additions and 202 deletions
|
@ -7,14 +7,14 @@
|
||||||
Date: September 1997
|
Date: September 1997
|
||||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||||
Date: August 1998
|
Date: August 1998
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public
|
modify it under the terms of the GNU Library General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2 of the License, or (at your option) any later version.
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
@ -37,254 +37,268 @@
|
||||||
|
|
||||||
static Class cellClass;
|
static Class cellClass;
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (self == [NSSlider class])
|
if (self == [NSSlider class])
|
||||||
{
|
{
|
||||||
// Initial version
|
// Initial version
|
||||||
[self setVersion:1];
|
[self setVersion: 1];
|
||||||
|
|
||||||
// Set our cell class to NSSliderCell
|
// Set our cell class to NSSliderCell
|
||||||
[self setCellClass:[NSSliderCell class]];
|
[self setCellClass: [NSSliderCell class]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void)setCellClass:(Class)class { cellClass = class; }
|
+ (void) setCellClass: (Class)class
|
||||||
+ (Class)cellClass { return cellClass; }
|
{
|
||||||
|
cellClass = class;
|
||||||
|
}
|
||||||
|
|
||||||
- initWithFrame:(NSRect)frameRect
|
+ (Class) cellClass
|
||||||
|
{
|
||||||
|
return cellClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
{
|
{
|
||||||
NSSliderCell* theCell = [[[isa cellClass] new] autorelease];
|
NSSliderCell* theCell = [[[isa cellClass] new] autorelease];
|
||||||
|
|
||||||
[super initWithFrame:frameRect];
|
[super initWithFrame: frameRect];
|
||||||
|
|
||||||
// set our cell
|
// set our cell
|
||||||
[self setCell:theCell];
|
[self setCell: theCell];
|
||||||
[theCell setState:1];
|
[theCell setState: 1];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSImage *)image
|
- (NSImage *) image
|
||||||
{
|
{
|
||||||
return [[self cell] image];
|
return [[self cell] image];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (int)isVertical
|
- (int) isVertical
|
||||||
{
|
{
|
||||||
return [[self cell] isVertical];
|
return [[self cell] isVertical];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)knobThickness
|
- (float) knobThickness
|
||||||
{
|
{
|
||||||
return [[self cell] knobThickness];
|
return [[self cell] knobThickness];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setImage:(NSImage *)backgroundImage
|
- (void) setImage: (NSImage *)backgroundImage
|
||||||
{
|
{
|
||||||
[[self cell] setImage:backgroundImage];
|
[[self cell] setImage: backgroundImage];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKnobThickness:(float)aFloat
|
- (void) setKnobThickness: (float)aFloat
|
||||||
{
|
{
|
||||||
[[self cell] setKnobThickness:aFloat];
|
[[self cell] setKnobThickness: aFloat];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTitle:(NSString *)aString
|
- (void) setTitle: (NSString *)aString
|
||||||
{
|
{
|
||||||
[[self cell] setTitle:aString];
|
[[self cell] setTitle: aString];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTitleCell:(NSCell *)aCell
|
- (void) setTitleCell: (NSCell *)aCell
|
||||||
{
|
{
|
||||||
[[self cell] setTitleCell:aCell];
|
[[self cell] setTitleCell: aCell];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTitleColor:(NSColor *)aColor
|
- (void) setTitleColor: (NSColor *)aColor
|
||||||
{
|
{
|
||||||
[[self cell] setTitleColor:aColor];
|
[[self cell] setTitleColor: aColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTitleFont:(NSFont *)fontObject
|
- (void) setTitleFont: (NSFont *)fontObject
|
||||||
{
|
{
|
||||||
[[self cell] setTitleFont:fontObject];
|
[[self cell] setTitleFont: fontObject];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)title
|
- (NSString *) title
|
||||||
{
|
{
|
||||||
return [[self cell] title];
|
return [[self cell] title];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)titleCell
|
- (id) titleCell
|
||||||
{
|
{
|
||||||
return [[self cell] titleCell];
|
return [[self cell] titleCell];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSColor *)titleColor
|
- (NSColor *) titleColor
|
||||||
{
|
{
|
||||||
return [[self cell] titleColor];
|
return [[self cell] titleColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSFont *)titleFont
|
- (NSFont *) titleFont
|
||||||
{
|
{
|
||||||
return [[self cell] titleFont];
|
return [[self cell] titleFont];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (double)maxValue
|
- (double) maxValue
|
||||||
{
|
{
|
||||||
return [[self cell] maxValue];
|
return [[self cell] maxValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (double)minValue
|
- (double) minValue
|
||||||
{
|
{
|
||||||
return [[self cell] minValue];
|
return [[self cell] minValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMaxValue:(double)aDouble
|
- (void) setMaxValue: (double)aDouble
|
||||||
{
|
{
|
||||||
[[self cell] setMaxValue:aDouble];
|
[[self cell] setMaxValue: aDouble];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMinValue:(double)aDouble
|
- (void) setMinValue: (double)aDouble
|
||||||
{
|
{
|
||||||
[[self cell] setMinValue:aDouble];
|
[[self cell] setMinValue: aDouble];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void) drawRect: (NSRect)rect
|
||||||
{
|
{
|
||||||
[[self cell] drawWithFrame:rect inView:self];
|
[[self cell] drawWithFrame: rect inView: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)_floatValueForMousePoint:(NSPoint)point knobRect:(NSRect)knobRect
|
- (float)_floatValueForMousePoint: (NSPoint)point knobRect: (NSRect)knobRect
|
||||||
{
|
{
|
||||||
NSSliderCell* theCell = [self cell];
|
NSSliderCell* theCell = [self cell];
|
||||||
NSRect slotRect = [theCell trackRect];
|
NSRect slotRect = [theCell trackRect];
|
||||||
BOOL isVertical = [theCell isVertical];
|
BOOL isVertical = [theCell isVertical];
|
||||||
float minValue = [theCell minValue];
|
float minValue = [theCell minValue];
|
||||||
float maxValue = [theCell maxValue];
|
float maxValue = [theCell maxValue];
|
||||||
float floatValue = 0;
|
float floatValue = 0;
|
||||||
float position;
|
float position;
|
||||||
|
|
||||||
if (isVertical)
|
// Adjust the point to lie inside the knob slot. We don't
|
||||||
{ // Adjust the point to lie inside the knob slot. We don't
|
// have to worry whether the view is flipped or not.
|
||||||
// have to worry whether the view is flipped or not.
|
if (isVertical)
|
||||||
if (point.y < slotRect.origin.y + knobRect.size.height / 2)
|
{
|
||||||
position = slotRect.origin.y + knobRect.size.height / 2;
|
if (point.y < slotRect.origin.y + knobRect.size.height / 2)
|
||||||
else
|
{
|
||||||
if (point.y > slotRect.origin.y + slotRect.size.height
|
position = slotRect.origin.y + knobRect.size.height / 2;
|
||||||
- knobRect.size.height / 2)
|
}
|
||||||
position = slotRect.origin.y + slotRect.size.height
|
else if (point.y > slotRect.origin.y + slotRect.size.height
|
||||||
- knobRect.size.height / 2;
|
- knobRect.size.height / 2)
|
||||||
else
|
{
|
||||||
position = point.y;
|
position = slotRect.origin.y + slotRect.size.height
|
||||||
// Compute the float value
|
- knobRect.size.height / 2;
|
||||||
floatValue = (position - (slotRect.origin.y + knobRect.size.height/2))
|
}
|
||||||
/ (slotRect.size.height - knobRect.size.height);
|
else
|
||||||
if ([self isFlipped])
|
position = point.y;
|
||||||
floatValue = 1 - floatValue;
|
// Compute the float value
|
||||||
}
|
floatValue = (position - (slotRect.origin.y + knobRect.size.height/2))
|
||||||
else
|
/ (slotRect.size.height - knobRect.size.height);
|
||||||
{ // Adjust the point to lie inside the knob slot
|
if ([self isFlipped])
|
||||||
if (point.x < slotRect.origin.x + knobRect.size.width / 2)
|
floatValue = 1 - floatValue;
|
||||||
position = slotRect.origin.x + knobRect.size.width / 2;
|
}
|
||||||
else
|
else
|
||||||
if (point.x > slotRect.origin.x + slotRect.size.width
|
{
|
||||||
- knobRect.size.width / 2)
|
if (point.x < slotRect.origin.x + knobRect.size.width / 2)
|
||||||
position = slotRect.origin.x + slotRect.size.width
|
{
|
||||||
- knobRect.size.width / 2;
|
position = slotRect.origin.x + knobRect.size.width / 2;
|
||||||
else
|
}
|
||||||
position = point.x;
|
else if (point.x > slotRect.origin.x + slotRect.size.width
|
||||||
// Compute the float value
|
- knobRect.size.width / 2)
|
||||||
// given the knob size
|
{
|
||||||
floatValue = (position - (slotRect.origin.x + knobRect.size.width / 2))
|
position = slotRect.origin.x + slotRect.size.width
|
||||||
/ (slotRect.size.width - knobRect.size.width);
|
- knobRect.size.width / 2;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
position = point.x;
|
||||||
|
|
||||||
return floatValue * (maxValue - minValue) + minValue;
|
// Compute the float value given the knob size
|
||||||
|
floatValue = (position - (slotRect.origin.x + knobRect.size.width / 2))
|
||||||
|
/ (slotRect.size.width - knobRect.size.width);
|
||||||
|
}
|
||||||
|
|
||||||
|
return floatValue * (maxValue - minValue) + minValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)trackKnob:(NSEvent*)theEvent knobRect:(NSRect)knobRect
|
- (void) trackKnob: (NSEvent*)theEvent knobRect: (NSRect)knobRect
|
||||||
{
|
{
|
||||||
NSApplication *app = [NSApplication sharedApplication];
|
NSApplication *app = [NSApplication sharedApplication];
|
||||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||||
| NSLeftMouseDraggedMask | NSMouseMovedMask
|
| NSLeftMouseDraggedMask | NSMouseMovedMask
|
||||||
| NSPeriodicMask;
|
| NSPeriodicMask;
|
||||||
NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
|
NSPoint point = [self convertPoint: [theEvent locationInWindow] fromView: nil];
|
||||||
NSEventType eventType = [theEvent type];
|
NSEventType eventType = [theEvent type];
|
||||||
BOOL isContinuous = [self isContinuous];
|
BOOL isContinuous = [self isContinuous];
|
||||||
NSSliderCell* theCell = [self cell];
|
NSSliderCell* theCell = [self cell];
|
||||||
float oldFloatValue = [theCell floatValue];
|
float oldFloatValue = [theCell floatValue];
|
||||||
id target = [theCell target];
|
id target = [theCell target];
|
||||||
SEL action = [theCell action];
|
SEL action = [theCell action];
|
||||||
|
|
||||||
[NSEvent startPeriodicEventsAfterDelay:0.05 withPeriod:0.05];
|
[NSEvent startPeriodicEventsAfterDelay: 0.05 withPeriod: 0.05];
|
||||||
[[NSRunLoop currentRunLoop] limitDateForMode:NSEventTrackingRunLoopMode];
|
[[NSRunLoop currentRunLoop] limitDateForMode: NSEventTrackingRunLoopMode];
|
||||||
|
|
||||||
while (eventType != NSLeftMouseUp)
|
while (eventType != NSLeftMouseUp)
|
||||||
|
{
|
||||||
|
theEvent = [app nextEventMatchingMask: eventMask
|
||||||
|
untilDate: [NSDate distantFuture]
|
||||||
|
inMode: NSEventTrackingRunLoopMode
|
||||||
|
dequeue: YES];
|
||||||
|
eventType = [theEvent type];
|
||||||
|
|
||||||
|
if (eventType != NSPeriodic)
|
||||||
|
point = [self convertPoint: [theEvent locationInWindow]
|
||||||
|
fromView: nil];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (point.x != knobRect.origin.x || point.y != knobRect.origin.y)
|
||||||
|
{
|
||||||
|
float floatValue = [self _floatValueForMousePoint: point
|
||||||
|
knobRect: knobRect];
|
||||||
|
|
||||||
|
if (floatValue != oldFloatValue)
|
||||||
{
|
{
|
||||||
theEvent = [app nextEventMatchingMask:eventMask
|
[theCell setFloatValue: floatValue];
|
||||||
untilDate:[NSDate distantFuture]
|
[theCell drawWithFrame: [self bounds] inView: self];
|
||||||
inMode:NSEventTrackingRunLoopMode
|
[window flushWindow];
|
||||||
dequeue:YES];
|
if (isContinuous)
|
||||||
eventType = [theEvent type];
|
[target performSelector: action withObject: self];
|
||||||
|
oldFloatValue = floatValue;
|
||||||
if (eventType != NSPeriodic)
|
}
|
||||||
point = [self convertPoint:[theEvent locationInWindow]
|
knobRect.origin = point;
|
||||||
fromView:nil];
|
}
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
if (point.x != knobRect.origin.x || point.y != knobRect.origin.y)
|
// If the control is not continuous send the action at the end of the drag
|
||||||
{
|
if (!isContinuous)
|
||||||
float floatValue = [self _floatValueForMousePoint:point
|
[target performSelector: action withObject: self];
|
||||||
knobRect:knobRect];
|
[NSEvent stopPeriodicEvents];
|
||||||
|
|
||||||
if (floatValue != oldFloatValue)
|
|
||||||
{
|
|
||||||
[theCell setFloatValue:floatValue];
|
|
||||||
[theCell drawWithFrame:[self bounds] inView:self];
|
|
||||||
[window flushWindow];
|
|
||||||
if (isContinuous)
|
|
||||||
[target performSelector:action withObject:self];
|
|
||||||
oldFloatValue = floatValue;
|
|
||||||
}
|
|
||||||
knobRect.origin = point;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If the control is not continuous send
|
|
||||||
if (!isContinuous) // the action at the end of the drag
|
|
||||||
[target performSelector:action withObject:self];
|
|
||||||
[NSEvent stopPeriodicEvents];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDown:(NSEvent *)theEvent
|
- (void) mouseDown: (NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
NSPoint location = [self convertPoint:[theEvent locationInWindow]fromView:nil];
|
NSPoint location = [self convertPoint: [theEvent locationInWindow]fromView: nil];
|
||||||
NSSliderCell* theCell = [self cell];
|
NSSliderCell* theCell = [self cell];
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
|
||||||
[self lockFocus];
|
[self lockFocus];
|
||||||
|
|
||||||
rect = [theCell knobRectFlipped:[self isFlipped]];
|
rect = [theCell knobRectFlipped: [self isFlipped]];
|
||||||
if (![self mouse:location inRect:rect])
|
if (![self mouse: location inRect: rect])
|
||||||
{ // Mouse is not on the knob, move
|
{
|
||||||
// the knob to the mouse position
|
// Mouse is not on the knob, move the knob to the mouse position
|
||||||
float floatValue = [self _floatValueForMousePoint:location
|
float floatValue = [self _floatValueForMousePoint: location
|
||||||
knobRect:rect];
|
knobRect: rect];
|
||||||
|
|
||||||
[theCell setFloatValue:floatValue];
|
[theCell setFloatValue: floatValue];
|
||||||
if ([self isContinuous])
|
if ([self isContinuous])
|
||||||
[[theCell target] performSelector:[theCell action]
|
[[theCell target] performSelector: [theCell action]
|
||||||
withObject:self];
|
withObject: self];
|
||||||
[theCell drawWithFrame:[self bounds] inView:self];
|
[theCell drawWithFrame: [self bounds] inView: self];
|
||||||
[window flushWindow];
|
[window flushWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self trackKnob:theEvent knobRect:rect];
|
[self trackKnob: theEvent knobRect: rect];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -37,30 +37,35 @@
|
||||||
|
|
||||||
@implementation NSSliderCell
|
@implementation NSSliderCell
|
||||||
|
|
||||||
- init
|
- (id) init
|
||||||
{
|
{
|
||||||
[self initImageCell:nil];
|
[self initImageCell: nil];
|
||||||
_altIncrementValue = -1;
|
_altIncrementValue = -1;
|
||||||
_isVertical = -1;
|
_isVertical = -1;
|
||||||
_minValue = 0;
|
_minValue = 0;
|
||||||
_maxValue = 1;
|
_maxValue = 1;
|
||||||
_floatValue = 0;
|
_floatValue = 0;
|
||||||
[self setBordered:YES];
|
[self setBordered: YES];
|
||||||
[self setBezeled:YES];
|
[self setBezeled: YES];
|
||||||
|
|
||||||
_knobCell = [NSCell new];
|
_knobCell = [NSCell new];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[_titleCell release];
|
[_titleCell release];
|
||||||
[_knobCell release];
|
[_knobCell release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFloatValue:(float)aFloat
|
- (BOOL) isFliped
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setFloatValue: (float)aFloat
|
||||||
{
|
{
|
||||||
if (aFloat < _minValue)
|
if (aFloat < _minValue)
|
||||||
_floatValue = _minValue;
|
_floatValue = _minValue;
|
||||||
|
@ -70,16 +75,13 @@
|
||||||
_floatValue = aFloat;
|
_floatValue = aFloat;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped
|
- (void) drawBarInside: (NSRect)rect flipped: (BOOL)flipped
|
||||||
{ // not per spec FIX ME
|
{
|
||||||
if ([self image])
|
[[NSColor scrollBarColor] set];
|
||||||
return;
|
NSRectFill(rect);
|
||||||
|
|
||||||
[[NSColor darkGrayColor] set];
|
|
||||||
NSRectFill(rect); // draw the bar
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSRect)knobRectFlipped:(BOOL)flipped
|
- (NSRect) knobRectFlipped: (BOOL)flipped
|
||||||
{
|
{
|
||||||
NSImage* image = [_knobCell image];
|
NSImage* image = [_knobCell image];
|
||||||
NSSize size;
|
NSSize size;
|
||||||
|
@ -107,17 +109,17 @@
|
||||||
return NSMakeRect (origin.x, origin.y, size.width, size.height);
|
return NSMakeRect (origin.x, origin.y, size.width, size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawKnob
|
- (void) drawKnob
|
||||||
{
|
{
|
||||||
[self drawKnob:[self knobRectFlipped:[[self controlView] isFlipped]]];
|
[self drawKnob: [self knobRectFlipped: [[self controlView] isFlipped]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawKnob:(NSRect)knobRect
|
- (void) drawKnob: (NSRect)knobRect
|
||||||
{
|
{
|
||||||
[_knobCell drawInteriorWithFrame:knobRect inView:[self controlView]];
|
[_knobCell drawInteriorWithFrame: knobRect inView: [self controlView]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
|
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||||
{
|
{
|
||||||
BOOL vertical = (cellFrame.size.height > cellFrame.size.width);
|
BOOL vertical = (cellFrame.size.height > cellFrame.size.width);
|
||||||
NSImage* image;
|
NSImage* image;
|
||||||
|
@ -125,16 +127,16 @@
|
||||||
|
|
||||||
if (vertical != _isVertical) {
|
if (vertical != _isVertical) {
|
||||||
if (vertical) {
|
if (vertical) {
|
||||||
image = [NSImage imageNamed:@"common_SliderVert"];
|
image = [NSImage imageNamed: @"common_SliderVert"];
|
||||||
size = [image size];
|
size = [image size];
|
||||||
[_knobCell setImage:image];
|
[_knobCell setImage: image];
|
||||||
[image setSize:NSMakeSize (cellFrame.size.width, size.height)];
|
[image setSize: NSMakeSize (cellFrame.size.width, size.height)];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
image = [NSImage imageNamed:@"common_SliderHoriz"];
|
image = [NSImage imageNamed: @"common_SliderHoriz"];
|
||||||
size = [image size];
|
size = [image size];
|
||||||
[_knobCell setImage:image];
|
[_knobCell setImage: image];
|
||||||
[image setSize:NSMakeSize (size.width, cellFrame.size.height)];
|
[image setSize: NSMakeSize (size.width, cellFrame.size.height)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_isVertical = vertical;
|
_isVertical = vertical;
|
||||||
|
@ -142,13 +144,13 @@
|
||||||
_trackRect = cellFrame;
|
_trackRect = cellFrame;
|
||||||
|
|
||||||
if (_titleCell)
|
if (_titleCell)
|
||||||
[_titleCell drawInteriorWithFrame:cellFrame inView:controlView];
|
[_titleCell drawInteriorWithFrame: cellFrame inView: controlView];
|
||||||
|
|
||||||
[self drawBarInside:cellFrame flipped:[controlView isFlipped]];
|
[self drawBarInside: cellFrame flipped: [controlView isFlipped]];
|
||||||
[self drawKnob];
|
[self drawKnob];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)knobThickness
|
- (float) knobThickness
|
||||||
{
|
{
|
||||||
NSImage* image = [_knobCell image];
|
NSImage* image = [_knobCell image];
|
||||||
NSSize size = [image size];
|
NSSize size = [image size];
|
||||||
|
@ -156,7 +158,7 @@
|
||||||
return _isVertical ? size.height : size.width;
|
return _isVertical ? size.height : size.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKnobThickness:(float)thickness
|
- (void) setKnobThickness: (float)thickness
|
||||||
{
|
{
|
||||||
NSImage* image = [_knobCell image];
|
NSImage* image = [_knobCell image];
|
||||||
NSSize size = [image size];
|
NSSize size = [image size];
|
||||||
|
@ -166,48 +168,48 @@
|
||||||
else
|
else
|
||||||
size.width = thickness;
|
size.width = thickness;
|
||||||
|
|
||||||
[image setSize:size];
|
[image setSize: size];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setAltIncrementValue:(double)increment
|
- (void) setAltIncrementValue: (double)increment
|
||||||
{
|
{
|
||||||
_altIncrementValue = increment;
|
_altIncrementValue = increment;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMinValue:(double)aDouble
|
- (void) setMinValue: (double)aDouble
|
||||||
{
|
{
|
||||||
_minValue = aDouble;
|
_minValue = aDouble;
|
||||||
if (_floatValue < _minValue)
|
if (_floatValue < _minValue)
|
||||||
_floatValue = _minValue;
|
_floatValue = _minValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMaxValue:(double)aDouble
|
- (void) setMaxValue: (double)aDouble
|
||||||
{
|
{
|
||||||
_maxValue = aDouble;
|
_maxValue = aDouble;
|
||||||
if (_floatValue > _maxValue)
|
if (_floatValue > _maxValue)
|
||||||
_floatValue = _maxValue;
|
_floatValue = _maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)titleCell { return _titleCell; }
|
- (id) titleCell { return _titleCell; }
|
||||||
- (NSColor*)titleColor { return [_titleCell textColor]; }
|
- (NSColor*) titleColor { return [_titleCell textColor]; }
|
||||||
- (NSFont*)titleFont { return [_titleCell font]; }
|
- (NSFont*) titleFont { return [_titleCell font]; }
|
||||||
- (void)setTitle:(NSString*)title { [_titleCell setStringValue:title]; }
|
- (void) setTitle: (NSString*)title { [_titleCell setStringValue: title]; }
|
||||||
- (NSString*)title { return [_titleCell stringValue]; }
|
- (NSString*) title { return [_titleCell stringValue]; }
|
||||||
- (void)setTitleCell:(NSCell*)aCell { ASSIGN(_titleCell, aCell); }
|
- (void) setTitleCell: (NSCell*)aCell { ASSIGN(_titleCell, aCell); }
|
||||||
- (void)setTitleColor:(NSColor*)color { [_titleCell setTextColor:color]; }
|
- (void) setTitleColor: (NSColor*)color { [_titleCell setTextColor: color]; }
|
||||||
- (void)setTitleFont:(NSFont*)font { [_titleCell setFont:font]; }
|
- (void) setTitleFont: (NSFont*)font { [_titleCell setFont: font]; }
|
||||||
- (int)isVertical { return _isVertical; }
|
- (int) isVertical { return _isVertical; }
|
||||||
- (double)altIncrementValue { return _altIncrementValue; }
|
- (double) altIncrementValue { return _altIncrementValue; }
|
||||||
+ (BOOL)prefersTrackingUntilMouseUp { return YES; }
|
+ (BOOL) prefersTrackingUntilMouseUp { return YES; }
|
||||||
- (NSRect)trackRect { return _trackRect; }
|
- (NSRect) trackRect { return _trackRect; }
|
||||||
- (double)minValue { return _minValue; }
|
- (double) minValue { return _minValue; }
|
||||||
- (double)maxValue { return _maxValue; }
|
- (double) maxValue { return _maxValue; }
|
||||||
- (float)floatValue { return _floatValue; }
|
- (float) floatValue { return _floatValue; }
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)decoder
|
- (id) initWithCoder: (NSCoder*)decoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: decoder];
|
self = [super initWithCoder: decoder];
|
||||||
[decoder decodeValuesOfObjCTypes:"ffff",
|
[decoder decodeValuesOfObjCTypes: "ffff",
|
||||||
&_minValue, &_maxValue, &_floatValue, &_altIncrementValue];
|
&_minValue, &_maxValue, &_floatValue, &_altIncrementValue];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +217,7 @@
|
||||||
- (void) encodeWithCoder: (NSCoder*)coder
|
- (void) encodeWithCoder: (NSCoder*)coder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder: coder];
|
[super encodeWithCoder: coder];
|
||||||
[coder encodeValuesOfObjCTypes:"ffff",
|
[coder encodeValuesOfObjCTypes: "ffff",
|
||||||
&_minValue, &_maxValue, &_floatValue, &_altIncrementValue];
|
&_minValue, &_maxValue, &_floatValue, &_altIncrementValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue