mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 06:00:37 +00:00
Added methods to handle ticks with a dummy implementation.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11291 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
18858f1cfe
commit
4796b2e906
4 changed files with 183 additions and 18 deletions
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include "gnustep/gui/config.h"
|
||||
|
||||
#include <AppKit/NSEvent.h>
|
||||
#include <AppKit/NSSlider.h>
|
||||
#include <AppKit/NSSliderCell.h>
|
||||
|
@ -123,6 +123,11 @@ static Class cellClass;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (double) altIncrementValue
|
||||
{
|
||||
return [_cell altIncrementValue];
|
||||
}
|
||||
|
||||
- (NSImage *) image
|
||||
{
|
||||
return [_cell image];
|
||||
|
@ -138,6 +143,11 @@ static Class cellClass;
|
|||
return [_cell knobThickness];
|
||||
}
|
||||
|
||||
- (void) setAltIncrementValue: (double)increment
|
||||
{
|
||||
[_cell setAltIncrementValue: increment];
|
||||
}
|
||||
|
||||
- (void) setImage: (NSImage *)backgroundImage
|
||||
{
|
||||
[_cell setImage: backgroundImage];
|
||||
|
@ -213,16 +223,58 @@ static Class cellClass;
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (void) drawRect: (NSRect)rect
|
||||
// ticks
|
||||
- (BOOL) allowsTickMarkValuesOnly
|
||||
{
|
||||
/*
|
||||
* Give the cell our bounds to draw in, not the rect - if we give it a rect
|
||||
* that represents an exposed part of this view, it will try to draw the
|
||||
* slider knob positioned in that rectangle ... which is wrong.
|
||||
*/
|
||||
[_cell drawWithFrame: _bounds inView: self];
|
||||
return [_cell allowsTickMarkValuesOnly];
|
||||
}
|
||||
|
||||
- (double) closestTickMarkValueToValue: (double)aValue
|
||||
{
|
||||
return [_cell closestTickMarkValueToValue: aValue];
|
||||
}
|
||||
|
||||
- (int) indexOfTickMarkAtPoint: (NSPoint)point;
|
||||
{
|
||||
return [_cell indexOfTickMarkAtPoint: point];
|
||||
}
|
||||
|
||||
- (int) numberOfTickMarks;
|
||||
{
|
||||
return [_cell numberOfTickMarks];
|
||||
}
|
||||
|
||||
- (NSRect) rectOfTickMarkAtIndex: (int)index;
|
||||
{
|
||||
return [_cell rectOfTickMarkAtIndex: index];
|
||||
}
|
||||
|
||||
- (void) setAllowsTickMarkValuesOnly: (BOOL)flag;
|
||||
{
|
||||
[_cell setAllowsTickMarkValuesOnly: flag];
|
||||
}
|
||||
|
||||
- (void) setNumberOfTickMarks: (int)numberOfTickMarks;
|
||||
{
|
||||
[_cell setNumberOfTickMarks: numberOfTickMarks];
|
||||
}
|
||||
|
||||
- (void) setTickMarkPosition: (NSTickMarkPosition)position;
|
||||
{
|
||||
[_cell setTickMarkPosition: position];
|
||||
}
|
||||
|
||||
- (NSTickMarkPosition) tickMarkPosition;
|
||||
{
|
||||
return [_cell tickMarkPosition];
|
||||
}
|
||||
|
||||
- (double) tickMarkValueAtIndex: (int)index;
|
||||
{
|
||||
return [_cell tickMarkValueAtIndex: index];
|
||||
}
|
||||
|
||||
|
||||
- (void) trackKnob: (NSEvent*)theEvent knobRect: (NSRect)knobRect
|
||||
{
|
||||
NSApplication *app = [NSApplication sharedApplication];
|
||||
|
@ -275,7 +327,7 @@ static Class cellClass;
|
|||
[_window flushWindow];
|
||||
if (isContinuous)
|
||||
{
|
||||
[target performSelector: action withObject: self];
|
||||
[self sendAction: action to: target];
|
||||
}
|
||||
oldFloatValue = floatValue;
|
||||
}
|
||||
|
@ -286,7 +338,7 @@ static Class cellClass;
|
|||
// If the control is not continuous send the action at the end of the drag
|
||||
if (!isContinuous)
|
||||
{
|
||||
[target performSelector: action withObject: self];
|
||||
[self sendAction: action to: target];
|
||||
}
|
||||
[NSEvent stopPeriodicEvents];
|
||||
}
|
||||
|
@ -311,7 +363,7 @@ static Class cellClass;
|
|||
[_cell setFloatValue: floatValue];
|
||||
if ([_cell isContinuous])
|
||||
{
|
||||
[[_cell target] performSelector: [_cell action] withObject: self];
|
||||
[self sendAction: [_cell action] to: [_cell target]];
|
||||
}
|
||||
[_cell drawWithFrame: _bounds inView: self];
|
||||
[_window flushWindow];
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "gnustep/gui/config.h"
|
||||
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
#include <AppKit/NSSliderCell.h>
|
||||
|
@ -281,6 +279,73 @@
|
|||
return aFloat;
|
||||
}
|
||||
|
||||
// ticks
|
||||
- (BOOL) allowsTickMarkValuesOnly
|
||||
{
|
||||
return _allowsTickMarkValuesOnly;
|
||||
}
|
||||
|
||||
- (double) closestTickMarkValueToValue: (double)aValue
|
||||
{
|
||||
if (aValue < _minValue)
|
||||
return _minValue;
|
||||
else if (aValue > _maxValue)
|
||||
return _maxValue;
|
||||
|
||||
if (_numberOfTickMarks == 0)
|
||||
return aValue;
|
||||
|
||||
// FIXME
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
- (int) indexOfTickMarkAtPoint: (NSPoint)point;
|
||||
{
|
||||
// FIXME
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (int) numberOfTickMarks;
|
||||
{
|
||||
return _numberOfTickMarks;
|
||||
}
|
||||
|
||||
- (NSRect) rectOfTickMarkAtIndex: (int)index;
|
||||
{
|
||||
// FIXME
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
- (void) setAllowsTickMarkValuesOnly: (BOOL)flag;
|
||||
{
|
||||
_allowsTickMarkValuesOnly = flag;
|
||||
}
|
||||
|
||||
- (void) setNumberOfTickMarks: (int)numberOfTickMarks;
|
||||
{
|
||||
_numberOfTickMarks = numberOfTickMarks;
|
||||
}
|
||||
|
||||
- (void) setTickMarkPosition: (NSTickMarkPosition)position;
|
||||
{
|
||||
_tickMarkPosition = position;
|
||||
}
|
||||
|
||||
- (NSTickMarkPosition) tickMarkPosition;
|
||||
{
|
||||
return _tickMarkPosition;
|
||||
}
|
||||
|
||||
- (double) tickMarkValueAtIndex: (int)index;
|
||||
{
|
||||
if (index >= _numberOfTickMarks)
|
||||
return _maxValue;
|
||||
if (index <= 0)
|
||||
return _minValue;
|
||||
|
||||
return _minValue + index * (_maxValue - _minValue) / _numberOfTickMarks;
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)decoder
|
||||
{
|
||||
self = [super initWithCoder: decoder];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue