| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.0 and later.
|
| Companion guide | |
| Declared in | NSSliderCell.h |
An NSSliderCell object controls the appearance and behavior of an NSSlider object, or of a single slider in an NSMatrix object.
You can customize an NSSliderCell to a certain degree, using its set... methods. If these methods do not allow you sufficient flexibility, you can create a subclass. In that subclass, you can override any of the following methods: knobRectFlipped:, drawBarInside:flipped:, drawKnob, and prefersTrackingUntilMouseUp.
– allowsTickMarkValuesOnly
– closestTickMarkValueToValue:
– indexOfTickMarkAtPoint:
– numberOfTickMarks
– rectOfTickMarkAtIndex:
– setAllowsTickMarkValuesOnly:
– setNumberOfTickMarks:
– setTickMarkPosition:
– tickMarkPosition
– tickMarkValueAtIndex:
Returns a Boolean value indicating whether the NSSliderCell continues to track the cursor until the next mouse up.
+ (BOOL)prefersTrackingUntilMouseUp
YES if the NSSliderCell continues to track the cursor even after the cursor leaves the cell's tracking rectangle; otherwise, NO. By default, this method returns YES.
If this method returns YES, this means that, once you take hold of a slider’s knob (by putting the cursor inside the cell’s frame rectangle and pressing the mouse button), you retain control of the knob until you release the mouse button, even if you drag the cursor clear to the other side of the screen.
Never call this method explicitly. Override it if you create a subclass of NSSliderCell that you want to track the mouse differently.
NSSliderCell.hReturns a Boolean value indicating whether the receiver fixes its values to those values represented by its tick marks.
- (BOOL)allowsTickMarkValuesOnly
YES if the slider's values are limited to those values represented by tick marks; otherwise, NO.
NSSliderCell.hReturns the amount by which the slider changes its value when the user drags with the Option key held down.
- (double)altIncrementValue
The amount by which the slider changes its value when the user drags the knob with the Option key held down. Unless you call setAltIncrementValue:, altIncrementValue returns –1.0, and the slider behaves no differently with the Option key down than with it up.
NSSliderCell.hReturns the value of the tick mark closest to the specified value.
- (double)closestTickMarkValueToValue:(double)aValue
The value for which to obtain the closest tick mark.
The value of the closest tick mark.
NSSliderCell.hDraws the slider’s bar—but not its bezel or knob—inside the specified rectangle.
- (void)drawBarInside:(NSRect)aRect flipped:(BOOL)flipped
The bounds of the slider's bar, not of its interior rectangle.
A Boolean value that indicates whether the cell’s control view—that is, the NSSlider or NSMatrix associated with the NSSliderCell—has a flipped coordinate system.
You should never invoke this method explicitly. It’s included so you can override it in a subclass.
NSSliderCell.hCalculates the rectangle in which the knob should be drawn, then invokes drawKnob: to actually draw the knob.
- (void)drawKnob
Before this message is sent, a lockFocus method must be sent to the cell’s control view.
You might invoke this method if you override one of the display methods belonging to NSControl or NSCell.
If you create a subclass of NSSliderCell, don’t override this method. Override drawKnob: instead.
NSSliderCell.hDraws the slider knob in the given rectangle.
- (void)drawKnob:(NSRect)knobRect
The rectangle in which to draw the slider knob.
Before this message is sent, a lockFocus message must be sent to the cell’s control view.
You should never invoke this method explicitly. It’s included so you can override it in a subclass.
NSSliderCell.h
Returns the index of the tick mark closest to the location of the slider represented by the specified point.
- (NSInteger)indexOfTickMarkAtPoint:(NSPoint)point
The point representing the slider location.
The index of the tick mark closest to the specified location.
If point is not within the bounding rectangle (plus an extra pixel of space) of any tick mark, the method returns NSNotFound. This method invokes rectOfTickMarkAtIndex: for each tick mark on the slider until it finds a tick mark containing point.
NSSliderCell.h
Returns an integer indicating the orientation (vertical or horizontal) of the slider.
- (NSInteger)isVertical
1 if the slider is vertical, 0 if it’s horizontal, and –1 if the orientation can’t be determined (for example, if the slider hasn’t been displayed yet). A slider is defined as vertical if its height is greater than its width.
NSSliderCell.hReturns the rectangle in which the slider knob is drawn.
- (NSRect)knobRectFlipped:(BOOL)flipped
YES if the coordinate system of the associated NSSlider or NSMatrix is flipped; otherwise NO. You can determine whether this is the case by sending the NSView message isFlipped message to the NSMatrix or NSSlider.
The rectangle in which the knob is drawn, specified in the coordinate system of the NSSlider or NSMatrix with which the receiver is associated.
The knob rectangle depends on where in the slider the knob belongs—that is, it depends on the receiver’s minimum and maximum values and on the value the position of the knob will represent.
You should never invoke this method explicitly. It’s included so you can override it in a subclass.
NSSliderCell.h
Returns the slider knob’s thickness, in pixels.
- (CGFloat)knobThickness
The thickness of the slider knob. The thickness is defined to be the extent of the knob along the long dimension of the bar. In a vertical slider, then, a knob’s thickness is its height; in a horizontal slider, its thickness is its width.
NSSliderCell.hReturns the maximum value the slider can send to its target.
- (double)maxValue
The maximum value of the slider. A horizontal slider sends its maximum value when the knob is at the right end of the slider; a vertical slider sends it when the knob is at the top. The maximum selectable value for a circular slider is just below maxValue; for example, if maxValue is 360, you can set the dial up to 359.999.
NSSliderCell.hReturns the minimum value the slider can send to its target.
- (double)minValue
The minimum value of the slider. A vertical slider sends this value when its knob is at the bottom; a horizontal slider sends it when its knob is all the way to the left; a circular slider sends it when its knob is at the top.
NSSliderCell.hReturns the number of tick marks associated with the slider.
- (NSInteger)numberOfTickMarks
The number of tick marks. The tick marks assigned to the minimum and maximum values are included.
NSSliderCell.hReturns the bounding rectangle of the tick mark at the specified index.
- (NSRect)rectOfTickMarkAtIndex:(NSInteger)index
The index of the tick mark for which to return the bounding rectangle. The minimum-value tick mark is at index 0.
The bounding rectangle of the specified tick mark.
If no tick mark is associated with index, the method raises NSRangeException.
NSSliderCell.hSets whether the receiver’s values are fixed to the values represented by the tick marks.
- (void)setAllowsTickMarkValuesOnly:(BOOL)flag
YES if the slider's values are fixed to the values represented by the slider's tick marks; otherwise NO. For example, if you specify YES for a slider that has a minimum value of 0, a maximum value of 100, and five markers, the allowable values are 0, 25, 50, 75, and 100. When users move the slider’s knob, it jumps to the tick mark nearest the cursor when the mouse button is released. This method has no effect if the slider has no tick marks.
NSSliderCell.hSets the amount by which the receiver modifies its value when the knob is Option-dragged.
- (void)setAltIncrementValue:(double)increment
The amount by which the receiver changes its value when the knob is Option-dragged. This number should t the range of values the slider can represent—for example, if the slider has a minimum value of 5 and a maximum value of 10, increment should be between 0 and 5.
If you don’t call this method, the slider behaves the same with the Option key down as with it up. This is also the result when you call setAltIncrementValue: with an increment of –1.
NSSliderCell.h
This method has been deprecated. Lets you set the knob’s thickness, measured in pixels.
- (void)setKnobThickness:(CGFloat)thickness
The knob's thickness. The thickness is defined to be the extent of the knob along the long dimension of the bar. In a vertical slider, then, a knob’s thickness is its height; in a horizontal slider, its thickness is its width.
NSSliderCell.h
Sets the maximum value the slider can send to its target.
- (void)setMaxValue:(double)aDouble
The slider's maximum value. A horizontal slider sends its maximum value when its knob is all the way to the right; a vertical slider sends its maximum value when its knob is at the top. The maximum selectable value for a circular slider is just below maxValue; for example, if maxValue is 360, you can set the dial up to 359.999.
NSSliderCell.h
Sets the minimum value the slider can send to its target.
- (void)setMinValue:(double)aDouble
The slider's minimum value. A horizontal slider sends its minimum value when its knob is all the way to the left; a vertical slider sends its minimum value when its knob is at the bottom; a circular slider sends it when its knob is at the top.
NSSliderCell.h
Sets the number of tick marks displayed by the receiver.
- (void)setNumberOfTickMarks:(NSInteger)numberOfTickMarks
The number of tick marks displayed by the slider, including those assigned to the minimum and maximum values. By default, this value is 0, and no tick marks appear. The number of tick marks assigned to a slider, along with the slider’s minimum and maximum values, determines the values associated with the tick marks.
NSSliderCell.hSets the type of slider to a bar or a dial.
- (void)setSliderType:(NSSliderType)sliderType
A constant indicating the type of the slider. Possible values are described in NSTickMarkPosition.
If sliderType is NSCircularSlider, then you get a fixed-size round slider. The minimum value (minValue) is at the top, and the value increases as you go clockwise around the dial. The maximum selectable value is just below maxValue; for example, if maxValue is 360, you can set the dial up to 359.999.
You can use the setNumberOfTickMarks: method to display tick marks, and you can use the setAllowsTickMarkValuesOnly: method to specify that values are limited to those values represented by tick marks. You can set this control to regular or small sizes; the mini size is not supported.
NSSliderCell.h
Sets where tick marks appear relative to the receiver.
- (void)setTickMarkPosition:(NSTickMarkPosition)position
A constant indicating the position of the tick marks. Possible values are described in NSTickMarkPosition.
This method has no effect if no tick marks have been assigned (that is, numberOfTickMarks returns 0).
NSSliderCell.hThis method has been deprecated. Sets the title in the bar behind the slider’s knob.
- (void)setTitle:(NSString *)title
The title.
NSSliderCell.h
This method has been deprecated. Sets the cell used to draw the slider’s title.
- (void)setTitleCell:(NSCell *)aCell
You only need to invoke this method if the default title cell, NSTextFieldCell, doesn’t suit your needs—that is, if you want to display the title in a manner that NSTextFieldCell doesn’t permit. When you do choose to override the default, aCell should be an instance of a subclass of NSTextFieldCell.
NSSliderCell.h
This method has been deprecated. Sets the color used to draw the slider’s title.
- (void)setTitleColor:(NSColor *)color
NSSliderCell.h
This method has been deprecated. Sets the font used to draw the slider’s title.
- (void)setTitleFont:(NSFont *)font
NSSliderCell.hReturns the slider type; either a bar or a dial.
- (NSSliderType)sliderType
A constant indicating the type of the slider. Possible return values are described in NSSliderType.
NSSliderCell.h
Returns the position of the tick marks relative to the receiver.
- (NSTickMarkPosition)tickMarkPosition
A constant indicating the position of the tick marks. Possible values are described in NSTickMarkPosition. The default alignments are NSTickMarkBelow and NSTickMarkLeft.
NSSliderCell.h
Returns the receiver’s value represented by the tick mark at the specified index.
- (double)tickMarkValueAtIndex:(NSInteger)index
The index of the tick mark for which to retrieve the value. The minimum-value tick mark has an index of 0.
The value represented by the specified tick mark.
NSSliderCell.hThis method has been deprecated. Returns the slider’s title.
- (NSString *)title
The title. The default title is the empty string (@"").
NSSliderCell.hThis method has been deprecated. Returns nil.
- (id)titleCell
NSSliderCell.h
This method has been deprecated. Returns nil.
- (NSColor *)titleColor
NSSliderCell.hThis method has been deprecated. Returns nil.
- (NSFont *)titleFont
NSSliderCell.hReturns the rectangle within which the cell tracks the cursor while the mouse button is down.
- (NSRect)trackRect
The tracking rectangle of the NSSliderCell. This rectangle includes the slider bar, but not the bezel.
NSSliderCell.hSpecify where the tick marks of an NSSliderCell object appear.
typedef enum _NSTickMarkPosition { NSTickMarkBelow = 0, NSTickMarkAbove = 1, NSTickMarkLeft = NSTickMarkAbove, NSTickMarkRight = NSTickMarkBelow } NSTickMarkPosition;
NSTickMarkBelowTick marks below (for horizontal sliders); the default for horizontal sliders.
Available in Mac OS X v10.0 and later.
Declared in NSSliderCell.h
NSTickMarkAboveTick marks above (for horizontal sliders).
Available in Mac OS X v10.0 and later.
Declared in NSSliderCell.h
NSTickMarkLeftTick marks to the left (for vertical sliders); the default. for vertical sliders
Available in Mac OS X v10.0 and later.
Declared in NSSliderCell.h
NSTickMarkRightTick marks to the right (for vertical sliders).
Available in Mac OS X v10.0 and later.
Declared in NSSliderCell.h
These constants are used in setTickMarkPosition: and tickMarkPosition.
NSSliderCell.hDefine the types of sliders, used by setSliderType: and sliderType.
typedef enum {
NSLinearSlider = 0,
NSCircularSlider = 1
} NSSliderType;
NSLinearSliderA bar-shaped slider.
Available in Mac OS X v10.3 and later.
Declared in NSSliderCell.h
NSCircularSliderA circular slider; that is, a dial.
Available in Mac OS X v10.3 and later.
Declared in NSSliderCell.h
NSSliderCell.h
Last updated: 2006-05-23