A scrollbar component. More...
Inherits Component, AsyncUpdater, and Timer.
Public Types | |
| enum | ColourIds { backgroundColourId = 0x1000300, thumbColourId = 0x1000400, trackColourId = 0x1000401 } |
A set of colour IDs to use to change the colour of various aspects of the component. More... | |
Public Member Functions | |
| ScrollBar (bool isVertical, bool buttonsAreVisible=true) | |
| Creates a Scrollbar. | |
| ~ScrollBar () | |
| Destructor. | |
| bool | isVertical () const throw () |
| Returns true if the scrollbar is vertical, false if it's horizontal. | |
| void | setOrientation (bool shouldBeVertical) |
| Changes the scrollbar's direction. | |
| void | setButtonVisibility (bool buttonsAreVisible) |
| Shows or hides the scrollbar's buttons. | |
| void | setAutoHide (bool shouldHideWhenFullRange) |
| Tells the scrollbar whether to make itself invisible when not needed. | |
| bool | autoHides () const throw () |
| Returns true if this scrollbar is set to auto-hide when its thumb is as big as its maximum range. | |
| void | setRangeLimits (const Range< double > &newRangeLimit) |
| Sets the minimum and maximum values that the bar will move between. | |
| void | setRangeLimits (double minimum, double maximum) |
| Sets the minimum and maximum values that the bar will move between. | |
| const Range< double > | getRangeLimit () const throw () |
| Returns the current limits on the thumb position. | |
| double | getMinimumRangeLimit () const throw () |
| Returns the lower value that the thumb can be set to. | |
| double | getMaximumRangeLimit () const throw () |
| Returns the upper value that the thumb can be set to. | |
| void | setCurrentRange (const Range< double > &newRange) |
| Changes the position of the scrollbar's 'thumb'. | |
| void | setCurrentRange (double newStart, double newSize) |
| Changes the position of the scrollbar's 'thumb'. | |
| void | setCurrentRangeStart (double newStart) |
| Moves the bar's thumb position. | |
| const Range< double > | getCurrentRange () const throw () |
| Returns the current thumb range. | |
| double | getCurrentRangeStart () const throw () |
| Returns the position of the top of the thumb. | |
| double | getCurrentRangeSize () const throw () |
| Returns the current size of the thumb. | |
| void | setSingleStepSize (double newSingleStepSize) |
| Sets the amount by which the up and down buttons will move the bar. | |
| void | moveScrollbarInSteps (int howManySteps) |
| Moves the scrollbar by a number of single-steps. | |
| void | moveScrollbarInPages (int howManyPages) |
| Moves the scroll bar up or down in pages. | |
| void | scrollToTop () |
| Scrolls to the top (or left). | |
| void | scrollToBottom () |
| Scrolls to the bottom (or right). | |
| void | setButtonRepeatSpeed (int initialDelayInMillisecs, int repeatDelayInMillisecs, int minimumDelayInMillisecs=-1) |
| Changes the delay before the up and down buttons autorepeat when they are held down. | |
| void | addListener (ScrollBarListener *listener) |
| Registers a listener that will be called when the scrollbar is moved. | |
| void | removeListener (ScrollBarListener *listener) |
| Deregisters a previously-registered listener. | |
| bool | keyPressed (const KeyPress &key) |
| void | mouseWheelMove (const MouseEvent &e, float wheelIncrementX, float wheelIncrementY) |
| void | lookAndFeelChanged () |
| void | handleAsyncUpdate () |
| void | mouseDown (const MouseEvent &e) |
| void | mouseDrag (const MouseEvent &e) |
| void | mouseUp (const MouseEvent &e) |
| void | paint (Graphics &g) |
| void | resized () |
A scrollbar component.
To use a scrollbar, set up its total range using the setRangeLimits() method - this sets the range of values it can represent. Then you can use setCurrentRange() to change the position and size of the scrollbar's 'thumb'.
Registering a ScrollBarListener with the scrollbar will allow you to find out when the user moves it, and you can use the getCurrentRangeStart() to find out where they moved it to.
The scrollbar will adjust its own visibility according to whether its thumb size allows it to actually be scrolled.
For most purposes, it's probably easier to use a ViewportContainer or ListBox instead of handling a scrollbar directly.
| enum ScrollBar::ColourIds |
A set of colour IDs to use to change the colour of various aspects of the component.
These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.
| ScrollBar::ScrollBar | ( | bool | isVertical, | |
| bool | buttonsAreVisible = true | |||
| ) |
Creates a Scrollbar.
| isVertical | whether it should be a vertical or horizontal bar | |
| buttonsAreVisible | whether to show the up/down or left/right buttons |
| ScrollBar::~ScrollBar | ( | ) |
Destructor.
| bool ScrollBar::isVertical | ( | ) | const throw () |
Returns true if the scrollbar is vertical, false if it's horizontal.
| void ScrollBar::setOrientation | ( | bool | shouldBeVertical | ) |
Changes the scrollbar's direction.
You'll also need to resize the bar appropriately - this just changes its internal layout.
| shouldBeVertical | true makes it vertical; false makes it horizontal. |
| void ScrollBar::setButtonVisibility | ( | bool | buttonsAreVisible | ) |
Shows or hides the scrollbar's buttons.
| void ScrollBar::setAutoHide | ( | bool | shouldHideWhenFullRange | ) |
Tells the scrollbar whether to make itself invisible when not needed.
The default behaviour is for a scrollbar to become invisible when the thumb fills the whole of its range (i.e. when it can't be moved). Setting this value to false forces the bar to always be visible.
| bool ScrollBar::autoHides | ( | ) | const throw () |
Returns true if this scrollbar is set to auto-hide when its thumb is as big as its maximum range.
| void ScrollBar::setRangeLimits | ( | const Range< double > & | newRangeLimit | ) |
Sets the minimum and maximum values that the bar will move between.
The bar's thumb will always be constrained so that the entire thumb lies within this range.
| void ScrollBar::setRangeLimits | ( | double | minimum, | |
| double | maximum | |||
| ) |
Sets the minimum and maximum values that the bar will move between.
The bar's thumb will always be constrained so that the entire thumb lies within this range.
| const Range<double> ScrollBar::getRangeLimit | ( | ) | const throw () |
Returns the current limits on the thumb position.
| double ScrollBar::getMinimumRangeLimit | ( | ) | const throw () |
Returns the lower value that the thumb can be set to.
This is the value set by setRangeLimits().
| double ScrollBar::getMaximumRangeLimit | ( | ) | const throw () |
Returns the upper value that the thumb can be set to.
This is the value set by setRangeLimits().
| void ScrollBar::setCurrentRange | ( | const Range< double > & | newRange | ) |
Changes the position of the scrollbar's 'thumb'.
If this method call actually changes the scrollbar's position, it will trigger an asynchronous call to ScrollBarListener::scrollBarMoved() for all the listeners that are registered.
| void ScrollBar::setCurrentRange | ( | double | newStart, | |
| double | newSize | |||
| ) |
Changes the position of the scrollbar's 'thumb'.
This sets both the position and size of the thumb - to just set the position without changing the size, you can use setCurrentRangeStart().
If this method call actually changes the scrollbar's position, it will trigger an asynchronous call to ScrollBarListener::scrollBarMoved() for all the listeners that are registered.
| newStart | the top (or left) of the thumb, in the range getMinimumRangeLimit() <= newStart <= getMaximumRangeLimit(). If the value is beyond these limits, it will be clipped. | |
| newSize | the size of the thumb, such that getMinimumRangeLimit() <= newStart + newSize <= getMaximumRangeLimit(). If the size is beyond these limits, it will be clipped. |
| void ScrollBar::setCurrentRangeStart | ( | double | newStart | ) |
Moves the bar's thumb position.
This will move the thumb position without changing the thumb size. Note that the maximum thumb start position is (getMaximumRangeLimit() - getCurrentRangeSize()).
If this method call actually changes the scrollbar's position, it will trigger an asynchronous call to ScrollBarListener::scrollBarMoved() for all the listeners that are registered.
| const Range<double> ScrollBar::getCurrentRange | ( | ) | const throw () |
Returns the current thumb range.
| double ScrollBar::getCurrentRangeStart | ( | ) | const throw () |
Returns the position of the top of the thumb.
| double ScrollBar::getCurrentRangeSize | ( | ) | const throw () |
Returns the current size of the thumb.
| void ScrollBar::setSingleStepSize | ( | double | newSingleStepSize | ) |
Sets the amount by which the up and down buttons will move the bar.
The value here is in terms of the total range, and is added or subtracted from the thumb position when the user clicks an up/down (or left/right) button.
| void ScrollBar::moveScrollbarInSteps | ( | int | howManySteps | ) |
Moves the scrollbar by a number of single-steps.
This will move the bar by a multiple of its single-step interval (as specified using the setSingleStepSize() method).
A positive value here will move the bar down or to the right, a negative value moves it up or to the left.
| void ScrollBar::moveScrollbarInPages | ( | int | howManyPages | ) |
Moves the scroll bar up or down in pages.
This will move the bar by a multiple of its current thumb size, effectively doing a page-up or down.
A positive value here will move the bar down or to the right, a negative value moves it up or to the left.
| void ScrollBar::scrollToTop | ( | ) |
Scrolls to the top (or left).
This is the same as calling setCurrentRangeStart (getMinimumRangeLimit());
| void ScrollBar::scrollToBottom | ( | ) |
Scrolls to the bottom (or right).
This is the same as calling setCurrentRangeStart (getMaximumRangeLimit() - getCurrentRangeSize());
| void ScrollBar::setButtonRepeatSpeed | ( | int | initialDelayInMillisecs, | |
| int | repeatDelayInMillisecs, | |||
| int | minimumDelayInMillisecs = -1 | |||
| ) |
Changes the delay before the up and down buttons autorepeat when they are held down.
For an explanation of what the parameters are for, see Button::setRepeatSpeed().
| void ScrollBar::addListener | ( | ScrollBarListener * | listener | ) |
Registers a listener that will be called when the scrollbar is moved.
| void ScrollBar::removeListener | ( | ScrollBarListener * | listener | ) |
Deregisters a previously-registered listener.
| bool ScrollBar::keyPressed | ( | const KeyPress & | key | ) | [virtual] |
For internal use only.
Reimplemented from Component.
| void ScrollBar::mouseWheelMove | ( | const MouseEvent & | e, | |
| float | wheelIncrementX, | |||
| float | wheelIncrementY | |||
| ) | [virtual] |
For internal use only.
Reimplemented from Component.
| void ScrollBar::lookAndFeelChanged | ( | ) | [virtual] |
For internal use only.
Reimplemented from Component.
| void ScrollBar::handleAsyncUpdate | ( | ) | [virtual] |
For internal use only.
Implements AsyncUpdater.
| void ScrollBar::mouseDown | ( | const MouseEvent & | e | ) | [virtual] |
For internal use only.
Reimplemented from Component.
| void ScrollBar::mouseDrag | ( | const MouseEvent & | e | ) | [virtual] |
For internal use only.
Reimplemented from Component.
| void ScrollBar::mouseUp | ( | const MouseEvent & | e | ) | [virtual] |
For internal use only.
Reimplemented from Component.
| void ScrollBar::paint | ( | Graphics & | g | ) | [virtual] |
For internal use only.
Reimplemented from Component.
| void ScrollBar::resized | ( | ) | [virtual] |
For internal use only.
Reimplemented from Component.
1.6.3