#include <slider.hpp>
Inheritance diagram for gcn::Slider:
You can set the scale of the slider yourself so that it ranges between, for example, -1.0 and 2.0.
Definition at line 72 of file slider.hpp.
Public Types | |
HORIZONTAL = 0 | |
VERTICAL | |
enum | { HORIZONTAL = 0, VERTICAL } |
Draw orientations for the slider. More... | |
Public Member Functions | |
Slider (double scaleEnd=1.0) | |
Constructor. | |
Slider (double scaleStart, double scaleEnd) | |
Constructor. | |
virtual | ~Slider () |
Destructor. | |
virtual void | setScale (double scaleStart, double scaleEnd) |
Sets the scale. | |
virtual double | getScaleStart () const |
Gets the scale start. | |
virtual void | setScaleStart (double scaleStart) |
Sets the scale start. | |
virtual double | getScaleEnd () const |
Gets the scale end. | |
virtual void | setScaleEnd (double scaleEnd) |
Sets the scale end. | |
virtual double | getValue () const |
Gets the current value. | |
virtual void | setValue (double value) |
Sets the current value. | |
virtual void | drawMarker (gcn::Graphics *graphics) |
Draws the marker. | |
virtual void | setMarkerLength (int length) |
Sets the length of the marker. | |
virtual int | getMarkerLength () const |
Gets the length of the marker. | |
virtual void | setOrientation (unsigned int orientation) |
Sets the orientation of the slider. | |
virtual unsigned int | getOrientation () const |
Gets the orientation of the slider. | |
virtual void | setStepLength (double length) |
Sets the step length. | |
virtual double | getStepLength () const |
Gets the step length. | |
virtual void | draw (gcn::Graphics *graphics) |
Draws the Widget. | |
virtual void | drawBorder (gcn::Graphics *graphics) |
Draws the Widget border. | |
virtual void | lostFocus () |
Called if the Widget looses focus. | |
virtual void | mousePress (int x, int y, int button) |
Called when a mouse button is pressed when the mouse is in the Widget area or if the Widget has focus. | |
virtual void | mouseRelease (int x, int y, int button) |
Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus. | |
virtual void | mouseMotion (int x, int y) |
Called when the mouse moves and the mouse is in the Widget area or if the Widget has focus. | |
virtual void | Slider::mouseWheelUp (int x, int y) |
virtual void | Slider::mouseWheelDown (int x, int y) |
virtual void | keyPress (const Key &key) |
Called if a key is pressed when the widget has keyboard focus. | |
Protected Member Functions | |
virtual double | markerPositionToValue (int v) const |
Converts a marker position to a value. | |
virtual int | valueToMarkerPosition (double value) const |
Converts a value to a marker position. | |
virtual int | getMarkerPosition () const |
Gets the marker position for the current value. | |
Protected Attributes | |
bool | mMouseDrag |
double | mValue |
double | mStepLength |
int | mMarkerLength |
double | mScaleStart |
double | mScaleEnd |
unsigned int | mOrientation |
anonymous enum |
Draw orientations for the slider.
It can be drawn verticaly or horizontaly.
Definition at line 231 of file slider.hpp.
gcn::Slider::Slider | ( | double | scaleEnd = 1.0 |
) |
Constructor.
Scale start is 0.
scaleEnd | the end of the slider scale. |
Definition at line 69 of file slider.cpp.
References gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), mMouseDrag, mScaleEnd, mScaleStart, gcn::Widget::setBorderSize(), gcn::Widget::setFocusable(), setMarkerLength(), setOrientation(), setStepLength(), and setValue().
gcn::Slider::Slider | ( | double | scaleStart, | |
double | scaleEnd | |||
) |
Constructor.
scaleStart | the start of the scale. | |
scaleEnd | the end of the scale. |
Definition at line 88 of file slider.cpp.
References gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), mMouseDrag, mScaleEnd, mScaleStart, gcn::Widget::setBorderSize(), gcn::Widget::setFocusable(), setMarkerLength(), setOrientation(), setStepLength(), and setValue().
void gcn::Slider::draw | ( | gcn::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 Widgets dimension.
graphics | a Graphics object to draw with. |
Implements gcn::Widget.
Definition at line 132 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::drawBorder | ( | gcn::Graphics * | graphics | ) | [virtual] |
Draws the Widget border.
A border is drawn around a Widget. The width and height of the border is therefore the Widgets height+2*bordersize. Think of a painting that has a certain size, the border surrounds the painting.
graphics | a Graphics object to draw with. |
Reimplemented from gcn::Widget.
Definition at line 144 of file slider.cpp.
References gcn::Color::a, gcn::Graphics::drawLine(), gcn::Widget::getBaseColor(), gcn::Widget::getBorderSize(), gcn::Widget::getHeight(), gcn::Widget::getWidth(), and gcn::Graphics::setColor().
void gcn::Slider::drawMarker | ( | gcn::Graphics * | graphics | ) | [virtual] |
Draws the marker.
graphics | a graphics object to draw with. |
Definition at line 168 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(), gcn::Widget::isFocused(), and gcn::Graphics::setColor().
Referenced by draw().
int gcn::Slider::getMarkerLength | ( | ) | const [virtual] |
Gets the length of the marker.
Definition at line 289 of file slider.cpp.
References mMarkerLength.
Referenced by drawMarker(), markerPositionToValue(), mouseMotion(), mousePress(), and valueToMarkerPosition().
int gcn::Slider::getMarkerPosition | ( | ) | const [protected, virtual] |
Gets the marker position for the current value.
Definition at line 395 of file slider.cpp.
References getValue(), and valueToMarkerPosition().
Referenced by drawMarker().
unsigned int gcn::Slider::getOrientation | ( | ) | const [virtual] |
Gets the orientation of the slider.
Se the enum in this class.
Definition at line 334 of file slider.cpp.
References mOrientation.
Referenced by drawMarker(), keyPress(), markerPositionToValue(), mouseMotion(), mousePress(), and valueToMarkerPosition().
double gcn::Slider::getScaleEnd | ( | ) | const [virtual] |
Gets the scale end.
Definition at line 122 of file slider.cpp.
References mScaleEnd.
Referenced by markerPositionToValue(), setValue(), and valueToMarkerPosition().
double gcn::Slider::getScaleStart | ( | ) | const [virtual] |
Gets the scale start.
Definition at line 112 of file slider.cpp.
References mScaleStart.
Referenced by markerPositionToValue(), setValue(), and valueToMarkerPosition().
double gcn::Slider::getStepLength | ( | ) | const [virtual] |
Gets the step length.
Definition at line 390 of file slider.cpp.
References mStepLength.
Referenced by keyPress().
double gcn::Slider::getValue | ( | ) | const [virtual] |
Gets the current value.
Definition at line 284 of file slider.cpp.
References mValue.
Referenced by getMarkerPosition(), and keyPress().
void gcn::Slider::keyPress | ( | const Key & | key | ) | [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.
key | the key pressed. |
Reimplemented from gcn::KeyListener.
Definition at line 299 of file slider.cpp.
References gcn::Widget::generateAction(), getOrientation(), getStepLength(), getValue(), gcn::Key::getValue(), and setValue().
double gcn::Slider::markerPositionToValue | ( | int | v | ) | const [protected, virtual] |
Converts a marker position to a value.
v | the position to convert. |
Definition at line 339 of file slider.cpp.
References gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), getScaleEnd(), getScaleStart(), and gcn::Widget::getWidth().
Referenced by mouseMotion(), and mousePress().
void gcn::Slider::mouseMotion | ( | int | x, | |
int | y | |||
) | [virtual] |
Called when the mouse moves and the mouse is in the Widget area or if the Widget has focus.
x | the x coordinate of the mouse relative to the Widget itself. | |
y | the y coordinate of the mouse relative to the Widget itself. |
Reimplemented from gcn::MouseListener.
Definition at line 250 of file slider.cpp.
References gcn::Widget::generateAction(), gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), markerPositionToValue(), mMouseDrag, and setValue().
void gcn::Slider::mousePress | ( | int | x, | |
int | y, | |||
int | button | |||
) | [virtual] |
Called when a mouse button is pressed when the mouse is in the Widget area or if the Widget has focus.
NOTE: A mouse press is NOT equal to a mouse click. Use mouseClickMessage to check for mouse clicks.
x | the x coordinate of the mouse relative to the Widget itself. | |
y | the y coordinate of the mouse relative to the Widget itself. | |
button | the button pressed. |
Reimplemented from gcn::MouseListener.
Definition at line 216 of file slider.cpp.
References gcn::Widget::generateAction(), gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), gcn::Widget::getWidth(), markerPositionToValue(), mMouseDrag, and setValue().
void gcn::Slider::mouseRelease | ( | int | x, | |
int | y, | |||
int | button | |||
) | [virtual] |
Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus.
x | the x coordinate of the mouse relative to the Widget itself. | |
y | the y coordinate of the mouse relative to the Widget itself. | |
button | the button released. |
Reimplemented from gcn::MouseListener.
Definition at line 240 of file slider.cpp.
References mMouseDrag.
void gcn::Slider::setMarkerLength | ( | int | length | ) | [virtual] |
Sets the length of the marker.
length | new length for the marker. |
Definition at line 294 of file slider.cpp.
References mMarkerLength.
Referenced by Slider().
void gcn::Slider::setOrientation | ( | unsigned int | orientation | ) | [virtual] |
Sets the orientation of the slider.
A slider can be drawn verticaly or horizontaly. For orientation, see the enum in this class.
orientation | the orientation. |
Definition at line 329 of file slider.cpp.
References mOrientation.
Referenced by Slider().
void gcn::Slider::setScale | ( | double | scaleStart, | |
double | scaleEnd | |||
) | [virtual] |
Sets the scale.
scaleStart | the start of the scale. | |
scaleEnd | the end of the scale. |
Definition at line 106 of file slider.cpp.
References mScaleEnd, and mScaleStart.
void gcn::Slider::setScaleEnd | ( | double | scaleEnd | ) | [virtual] |
Sets the scale end.
scaleEnd | the end of the scale. |
Definition at line 127 of file slider.cpp.
References mScaleEnd.
void gcn::Slider::setScaleStart | ( | double | scaleStart | ) | [virtual] |
Sets the scale start.
scaleStart | the start of the scale. |
Definition at line 117 of file slider.cpp.
References mScaleStart.
void gcn::Slider::setStepLength | ( | double | length | ) | [virtual] |
Sets the step length.
Step length is used when the keys left and right are pressed.
length | the step length. |
Definition at line 385 of file slider.cpp.
References mStepLength.
Referenced by Slider().
void gcn::Slider::setValue | ( | double | value | ) | [virtual] |
Sets the current value.
value | a scale value. |
Definition at line 267 of file slider.cpp.
References getScaleEnd(), getScaleStart(), and mValue.
Referenced by keyPress(), mouseMotion(), mousePress(), 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 356 of file slider.cpp.
References gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), getScaleEnd(), getScaleStart(), and gcn::Widget::getWidth().
Referenced by getMarkerPosition().