____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"#include <slider.h>

Public Types | |
| enum | { HORIZONTAL = 0, VERTICAL } |
Public Member Functions | |
| Slider (double scaleEnd=1.0) | |
| Slider (double scaleStart, double scaleEnd) | |
| virtual | ~Slider () |
| virtual void | setScale (double scaleStart, double scaleEnd) |
| virtual double | getScaleStart () const |
| virtual void | setScaleStart (double scaleStart) |
| virtual double | getScaleEnd () const |
| virtual void | setScaleEnd (double scaleEnd) |
| virtual double | getValue () const |
| virtual void | setValue (double value) |
| virtual void | drawMarker (gcn::Graphics *graphics) |
| virtual void | setMarkerLength (int length) |
| virtual int | getMarkerLength () const |
| virtual void | setOrientation (unsigned int orientation) |
| virtual unsigned int | getOrientation () const |
| virtual void | setStepLength (double length) |
| virtual double | getStepLength () const |
| virtual void | draw (gcn::Graphics *graphics) |
| virtual void | drawBorder (gcn::Graphics *graphics) |
| virtual void | lostFocus () |
| virtual void | mousePress (int x, int y, int button) |
| virtual void | mouseRelease (int x, int y, int button) |
| virtual void | mouseMotion (int x, int y) |
| virtual bool | keyPress (const Key &key) |
Protected Member Functions | |
| virtual double | markerPositionToValue (int v) const |
| virtual int | valueToMarkerPosition (double value) const |
| virtual int | getMarkerPosition () const |
Protected Attributes | |
| bool | mMouseDrag |
| double | mValue |
| double | mStepLength |
| int | mMarkerLength |
| double | mScaleStart |
| double | mScaleEnd |
| unsigned int | mOrientation |
Definition at line 68 of file slider.h.
| anonymous enum |
| gcn::Slider::Slider | ( | double | scaleEnd = 1.0 |
) |
Constructor. Scale start is 0.
| scaleEnd | the end of the slider scale. |
Definition at line 64 of file slider.cpp.
References gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), HORIZONTAL, 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 83 of file slider.cpp.
References gcn::Widget::addKeyListener(), gcn::Widget::addMouseListener(), HORIZONTAL, mMouseDrag, mScaleEnd, mScaleStart, gcn::Widget::setBorderSize(), gcn::Widget::setFocusable(), setMarkerLength(), setOrientation(), setStepLength(), and setValue().
| virtual gcn::Slider::~Slider | ( | ) | [inline, virtual] |
| 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 101 of file slider.cpp.
References mScaleEnd, and mScaleStart.
| double gcn::Slider::getScaleStart | ( | ) | const [virtual] |
Gets the scale start.
Definition at line 107 of file slider.cpp.
References mScaleStart.
Referenced by markerPositionToValue(), setValue(), and valueToMarkerPosition().
| void gcn::Slider::setScaleStart | ( | double | scaleStart | ) | [virtual] |
Sets the scale start.
| scaleStart | the start of the scale. |
Definition at line 112 of file slider.cpp.
References mScaleStart.
| double gcn::Slider::getScaleEnd | ( | ) | const [virtual] |
Gets the scale end.
Definition at line 117 of file slider.cpp.
References mScaleEnd.
Referenced by markerPositionToValue(), setValue(), and valueToMarkerPosition().
| void gcn::Slider::setScaleEnd | ( | double | scaleEnd | ) | [virtual] |
Sets the scale end.
| scaleEnd | the end of the scale. |
Definition at line 122 of file slider.cpp.
References mScaleEnd.
| double gcn::Slider::getValue | ( | ) | const [virtual] |
Gets the current value.
Definition at line 280 of file slider.cpp.
References mValue.
Referenced by EditorPatchSliderListener::action(), EditorUnitSliderListener::action(), getMarkerPosition(), and keyPress().
| void gcn::Slider::setValue | ( | double | value | ) | [virtual] |
Sets the current value.
| value | a scale value. |
Definition at line 263 of file slider.cpp.
References getScaleEnd(), getScaleStart(), and mValue.
Referenced by keyPress(), mouseMotion(), mousePress(), and Slider().
| void gcn::Slider::drawMarker | ( | gcn::Graphics * | graphics | ) | [virtual] |
Draws the marker.
| graphics | a graphics object to draw with. |
Reimplemented in ImageSlider.
Definition at line 163 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::hasFocus(), HORIZONTAL, and gcn::Graphics::setColor().
Referenced by draw().
| void gcn::Slider::setMarkerLength | ( | int | length | ) | [virtual] |
Sets the length of the marker.
| length | new length for the marker. |
Definition at line 290 of file slider.cpp.
References mMarkerLength.
Referenced by ImageSlider::setMarkerImage(), and Slider().
| int gcn::Slider::getMarkerLength | ( | ) | const [virtual] |
Gets the length of the marker.
Definition at line 285 of file slider.cpp.
References mMarkerLength.
Referenced by ImageSlider::drawMarker(), drawMarker(), markerPositionToValue(), mouseMotion(), mousePress(), and valueToMarkerPosition().
| 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 332 of file slider.cpp.
References mOrientation.
Referenced by Slider().
| unsigned int gcn::Slider::getOrientation | ( | ) | const [virtual] |
Gets the orientation of the slider. Se the enum in this class.
Definition at line 337 of file slider.cpp.
References mOrientation.
Referenced by ImageSlider::drawMarker(), drawMarker(), keyPress(), markerPositionToValue(), mouseMotion(), mousePress(), and valueToMarkerPosition().
| 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 388 of file slider.cpp.
References mStepLength.
Referenced by Slider().
| double gcn::Slider::getStepLength | ( | ) | const [virtual] |
Gets the step length.
Definition at line 393 of file slider.cpp.
References mStepLength.
Referenced by keyPress().
| 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.
Reimplemented in ImageSlider.
Definition at line 127 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 a 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 139 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::lostFocus | ( | ) | [virtual] |
Called if the Widget loses focus.
Reimplemented from gcn::Widget.
Definition at line 240 of file slider.cpp.
References mMouseDrag.
| 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 211 of file slider.cpp.
References gcn::Widget::generateAction(), gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), gcn::Widget::getWidth(), HORIZONTAL, gcn::MouseInput::LEFT, 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 235 of file slider.cpp.
References mMouseDrag.
| 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 245 of file slider.cpp.
References gcn::Widget::generateAction(), gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), HORIZONTAL, markerPositionToValue(), mMouseDrag, gcn::Widget::setDirty(), and setValue().
| bool 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 295 of file slider.cpp.
References gcn::Key::DOWN, gcn::Widget::generateAction(), getOrientation(), getStepLength(), getValue(), gcn::Key::getValue(), HORIZONTAL, gcn::Key::LEFT, gcn::Key::RIGHT, setValue(), and gcn::Key::UP.
| double gcn::Slider::markerPositionToValue | ( | int | v | ) | const [protected, virtual] |
Converts a marker position to a value.
| v | the position to convert. |
Definition at line 342 of file slider.cpp.
References gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), getScaleEnd(), getScaleStart(), gcn::Widget::getWidth(), and HORIZONTAL.
Referenced by mouseMotion(), and mousePress().
| int gcn::Slider::valueToMarkerPosition | ( | double | value | ) | const [protected, virtual] |
Converts a value to a marker position.
| value | the value to convert. |
Definition at line 359 of file slider.cpp.
References gcn::Widget::getHeight(), getMarkerLength(), getOrientation(), getScaleEnd(), getScaleStart(), gcn::Widget::getWidth(), HORIZONTAL, and int().
Referenced by getMarkerPosition().
| int gcn::Slider::getMarkerPosition | ( | ) | const [protected, virtual] |
Gets the marker position for the current value.
Definition at line 398 of file slider.cpp.
References getValue(), and valueToMarkerPosition().
Referenced by ImageSlider::drawMarker(), and drawMarker().
bool gcn::Slider::mMouseDrag [protected] |
Definition at line 253 of file slider.h.
Referenced by lostFocus(), mouseMotion(), mousePress(), mouseRelease(), and Slider().
double gcn::Slider::mValue [protected] |
double gcn::Slider::mStepLength [protected] |
int gcn::Slider::mMarkerLength [protected] |
double gcn::Slider::mScaleStart [protected] |
Definition at line 257 of file slider.h.
Referenced by getScaleStart(), setScale(), setScaleStart(), and Slider().
double gcn::Slider::mScaleEnd [protected] |
Definition at line 258 of file slider.h.
Referenced by getScaleEnd(), setScale(), setScaleEnd(), and Slider().
unsigned int gcn::Slider::mOrientation [protected] |
1.5.6