#include <slider.hpp>
Inheritance diagram for gcn::Slider:

If the selected value is changed an action event will be sent to all action listeners of the slider.
Definition at line 74 of file slider.hpp.
Public Types | |
| enum | Orientation { HORIZONTAL = 0, VERTICAL } |
| Draw orientations for the slider. More... | |
Public Member Functions | |
| virtual void | draw (Graphics *graphics) |
| Draws the widget. | |
| int | getMarkerLength () const |
| Gets the length of the marker. | |
| Orientation | getOrientation () const |
| Gets the orientation of the slider. | |
| double | getScaleEnd () const |
| Gets the end value of the scale. | |
| double | getScaleStart () const |
| Gets the start value of the scale. | |
| double | getStepLength () const |
| Gets the step length. | |
| double | getValue () const |
| Gets the current selected value. | |
| virtual void | keyPressed (KeyEvent &keyEvent) |
| Called if a key is pressed when the widget has keyboard focus. | |
| virtual void | mouseDragged (MouseEvent &mouseEvent) |
| Called when the mouse has moved and the mouse has previously been pressed on the widget. | |
| virtual void | mousePressed (MouseEvent &mouseEvent) |
| Called when a mouse button has been pressed on the widget area. | |
| virtual void | mouseWheelMovedDown (MouseEvent &mouseEvent) |
| Called when the mouse wheel has moved down on the widget area. | |
| virtual void | mouseWheelMovedUp (MouseEvent &mouseEvent) |
| Called when the mouse wheel has moved up on the widget area. | |
| void | setMarkerLength (int length) |
| Sets the length of the marker. | |
| void | setOrientation (Orientation orientation) |
| Sets the orientation of the slider. | |
| void | setScale (double scaleStart, double scaleEnd) |
| Sets the scale of the slider. | |
| void | setScaleEnd (double scaleEnd) |
| Sets the end value of the scale. | |
| void | setScaleStart (double scaleStart) |
| Sets the start value of the scale. | |
| void | setStepLength (double length) |
| Sets the step length. | |
| void | setValue (double value) |
| Sets the current selected value. | |
| Slider (double scaleStart, double scaleEnd) | |
| Constructor. | |
| Slider (double scaleEnd=1.0) | |
| Constructor. | |
| virtual | ~Slider () |
| Destructor. | |
Protected Member Functions | |
| virtual void | drawMarker (gcn::Graphics *graphics) |
| Draws the marker. | |
| virtual int | getMarkerPosition () const |
| Gets the marker position of the current selected value. | |
| virtual double | markerPositionToValue (int position) const |
| Converts a marker position to a value in the scale. | |
| virtual int | valueToMarkerPosition (double value) const |
| Converts a value to a marker position. | |
Protected Attributes | |
| bool | mDragged |
| True if the slider is dragged, false otherwise. | |
| int | mMarkerLength |
| Holds the length of the marker. | |
| Orientation | mOrientation |
| Holds the orientation of the slider. | |
| double | mScaleEnd |
| Holds the end value of the scale. | |
| double | mScaleStart |
| Holds the start value of the scale. | |
| double | mStepLength |
| Holds the step length. | |
| double | mValue |
| Holds the current selected value. | |
Draw orientations for the slider.
A slider can be drawn vertically or horizontally.
Definition at line 85 of file slider.hpp.
| gcn::Slider::Slider | ( | double | scaleEnd = 1.0 |
) |
Constructor.
The default start value of the slider scale is zero.
| scaleEnd | The end value of the slider scale. |
Definition at line 69 of file slider.cpp.
References gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), HORIZONTAL, mDragged, mScaleEnd, mScaleStart, gcn::Widget::setFocusable(), gcn::Widget::setFrameSize(), setMarkerLength(), setOrientation(), setStepLength(), and setValue().
| gcn::Slider::Slider | ( | double | scaleStart, | |
| double | scaleEnd | |||
| ) |
Constructor.
| scaleStart | The start value of the slider scale. | |
| scaleEnd | The end value of the slider scale. |
Definition at line 87 of file slider.cpp.
References gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), HORIZONTAL, mDragged, mScaleEnd, mScaleStart, gcn::Widget::setFocusable(), gcn::Widget::setFrameSize(), setMarkerLength(), setOrientation(), setStepLength(), and setValue().
| void gcn::Slider::draw | ( | Graphics * | graphics | ) | [virtual] |
Draws the widget.
It is called by the parent widget when it is time for the widget to draw itself. The graphics object is set up so that all drawing is relative to the widget, i.e coordinate (0,0) is the top left corner of the widget. It is not possible to draw outside of a widget's dimension.
| graphics | aA graphics object to draw with. |
Implements gcn::Widget.
Definition at line 131 of file slider.cpp.
References gcn::Color::a, drawMarker(), gcn::Graphics::fillRectangle(), gcn::Widget::getBaseColor(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), and gcn::Graphics::setColor().
| void gcn::Slider::drawMarker | ( | gcn::Graphics * | graphics | ) | [protected, virtual] |
Draws the marker.
| graphics | A graphics object to draw with. |
Definition at line 143 of file slider.cpp.
References gcn::Color::a, gcn::Graphics::drawLine(), gcn::Graphics::drawRectangle(), gcn::Graphics::fillRectangle(), gcn::Widget::getBaseColor(), gcn::Widget::getForegroundColor(), gcn::Widget::getHeight(), getMarkerLength(), getMarkerPosition(), getOrientation(), gcn::Widget::getWidth(), HORIZONTAL, gcn::Widget::isFocused(), and gcn::Graphics::setColor().
Referenced by draw().
| int gcn::Slider::getMarkerLength | ( | ) | const |
Gets the length of the marker.
Definition at line 250 of file slider.cpp.
References mMarkerLength.
Referenced by drawMarker(), markerPositionToValue(), mouseDragged(), mousePressed(), and valueToMarkerPosition().
| int gcn::Slider::getMarkerPosition | ( | ) | const [protected, virtual] |
Gets the marker position of the current selected value.
Definition at line 362 of file slider.cpp.
References getValue(), and valueToMarkerPosition().
Referenced by drawMarker().
| Slider::Orientation gcn::Slider::getOrientation | ( | ) | const |
Gets the orientation of the slider.
A slider can be drawn vertically or horizontally.
Definition at line 301 of file slider.cpp.
References mOrientation.
Referenced by drawMarker(), keyPressed(), markerPositionToValue(), mouseDragged(), mousePressed(), and valueToMarkerPosition().
| double gcn::Slider::getScaleEnd | ( | ) | const |
Gets the end value of the scale.
Definition at line 121 of file slider.cpp.
References mScaleEnd.
Referenced by markerPositionToValue(), setValue(), and valueToMarkerPosition().
| double gcn::Slider::getScaleStart | ( | ) | const |
Gets the start value of the scale.
Definition at line 111 of file slider.cpp.
References mScaleStart.
Referenced by markerPositionToValue(), setValue(), and valueToMarkerPosition().
| double gcn::Slider::getStepLength | ( | ) | const |
Gets the step length.
The step length is used when the keys LEFT and RIGHT are pressed to step in the scale.
Definition at line 357 of file slider.cpp.
References mStepLength.
Referenced by keyPressed(), mouseWheelMovedDown(), and mouseWheelMovedUp().
| double gcn::Slider::getValue | ( | ) | const |
Gets the current selected value.
Definition at line 245 of file slider.cpp.
References mValue.
Referenced by getMarkerPosition(), keyPressed(), mouseWheelMovedDown(), and mouseWheelMovedUp().
| void gcn::Slider::keyPressed | ( | KeyEvent & | keyEvent | ) | [virtual] |
Called if a key is pressed when the widget has keyboard focus.
If a key is held down the widget will generate multiple key presses.
| keyEvent | Discribes the event. |
Reimplemented from gcn::KeyListener.
Definition at line 260 of file slider.cpp.
References gcn::InputEvent::consume(), gcn::Widget::distributeActionEvent(), gcn::Key::DOWN, gcn::KeyEvent::getKey(), getOrientation(), getStepLength(), getValue(), gcn::Key::getValue(), HORIZONTAL, gcn::Key::LEFT, gcn::Key::RIGHT, setValue(), and gcn::Key::UP.
| double gcn::Slider::markerPositionToValue | ( | int | position | ) | const [protected, virtual] |
Converts a marker position to a value in the scale.
| position | The position to convert. |
Definition at line 306 of file slider.cpp.
References gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), getScaleEnd(), getScaleStart(), gcn::Widget::getWidth(), and HORIZONTAL.
Referenced by mouseDragged(), and mousePressed().
| void gcn::Slider::mouseDragged | ( | MouseEvent & | mouseEvent | ) | [virtual] |
Called when the mouse has moved and the mouse has previously been pressed on the widget.
| mouseEvent | Describes the event. |
Reimplemented from gcn::MouseListener.
Definition at line 212 of file slider.cpp.
References gcn::InputEvent::consume(), gcn::Widget::distributeActionEvent(), gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), gcn::MouseEvent::getX(), gcn::MouseEvent::getY(), HORIZONTAL, markerPositionToValue(), and setValue().
| void gcn::Slider::mousePressed | ( | MouseEvent & | mouseEvent | ) | [virtual] |
Called when a mouse button has been pressed on the widget area.
NOTE: A mouse press is NOT equal to a mouse click. Use mouseClickMessage to check for mouse clicks.
| mouseEvent | Describes the event. |
Reimplemented from gcn::MouseListener.
Definition at line 191 of file slider.cpp.
References gcn::Widget::distributeActionEvent(), gcn::MouseEvent::getButton(), gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), gcn::Widget::getWidth(), gcn::MouseEvent::getX(), gcn::MouseEvent::getY(), HORIZONTAL, gcn::MouseEvent::LEFT, markerPositionToValue(), and setValue().
| void gcn::Slider::mouseWheelMovedDown | ( | MouseEvent & | mouseEvent | ) | [virtual] |
Called when the mouse wheel has moved down on the widget area.
| mousEvent | Describes the event. |
Reimplemented from gcn::MouseListener.
Definition at line 375 of file slider.cpp.
References gcn::InputEvent::consume(), gcn::Widget::distributeActionEvent(), getStepLength(), getValue(), and setValue().
| void gcn::Slider::mouseWheelMovedUp | ( | MouseEvent & | mouseEvent | ) | [virtual] |
Called when the mouse wheel has moved up on the widget area.
| mouseEvent | Describes the event. |
Reimplemented from gcn::MouseListener.
Definition at line 367 of file slider.cpp.
References gcn::InputEvent::consume(), gcn::Widget::distributeActionEvent(), getStepLength(), getValue(), and setValue().
| void gcn::Slider::setMarkerLength | ( | int | length | ) |
Sets the length of the marker.
| length | The length for the marker. |
Definition at line 255 of file slider.cpp.
References mMarkerLength.
Referenced by Slider().
| void gcn::Slider::setOrientation | ( | Orientation | orientation | ) |
Sets the orientation of the slider.
A slider can be drawn vertically or horizontally.
| orientation | The orientation of the slider. |
Definition at line 296 of file slider.cpp.
References mOrientation.
Referenced by Slider().
| void gcn::Slider::setScale | ( | double | scaleStart, | |
| double | scaleEnd | |||
| ) |
Sets the scale of the slider.
| scaleStart | The start value of the scale. | |
| scaleEnd | tThe end of value the scale. |
Definition at line 105 of file slider.cpp.
References mScaleEnd, and mScaleStart.
| void gcn::Slider::setScaleEnd | ( | double | scaleEnd | ) |
Sets the end value of the scale.
| scaleEnd | The end value of the scale. |
Definition at line 126 of file slider.cpp.
References mScaleEnd.
| void gcn::Slider::setScaleStart | ( | double | scaleStart | ) |
Sets the start value of the scale.
| scaleStart | The start value of the scale. |
Definition at line 116 of file slider.cpp.
References mScaleStart.
| void gcn::Slider::setStepLength | ( | double | length | ) |
Sets the step length.
The step length is used when the keys LEFT and RIGHT are pressed to step in the scale.
| length | The step length. |
Definition at line 352 of file slider.cpp.
References mStepLength.
Referenced by Slider().
| void gcn::Slider::setValue | ( | double | value | ) |
Sets the current selected value.
| value | The current selected value. |
Definition at line 228 of file slider.cpp.
References getScaleEnd(), getScaleStart(), and mValue.
Referenced by keyPressed(), mouseDragged(), mousePressed(), mouseWheelMovedDown(), mouseWheelMovedUp(), and Slider().
| int gcn::Slider::valueToMarkerPosition | ( | double | value | ) | const [protected, virtual] |
Converts a value to a marker position.
| value | The value to convert. |
Definition at line 323 of file slider.cpp.
References gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), getScaleEnd(), getScaleStart(), gcn::Widget::getWidth(), and HORIZONTAL.
Referenced by getMarkerPosition().
Orientation gcn::Slider::mOrientation [protected] |
Holds the orientation of the slider.
A slider can be drawn vertically or horizontally.
Definition at line 309 of file slider.hpp.
Referenced by getOrientation(), and setOrientation().
double gcn::Slider::mStepLength [protected] |
Holds the step length.
The step length is used when the keys LEFT and RIGHT are pressed to step in the scale.
Definition at line 288 of file slider.hpp.
Referenced by getStepLength(), and setStepLength().
1.5.2