ManaPlus
|
#include <slider.h>
Public Member Functions | |
Slider (Widget2 *const widget, const double scaleEnd, const double stepLength) | |
Slider (Widget2 *const widget, const double scaleStart, const double scaleEnd, const double stepLength) | |
~Slider () | |
void | updateAlpha () |
void | draw (Graphics *const graphics) |
void | safeDraw (Graphics *const graphics) |
void | mouseEntered (MouseEvent &event) |
void | mouseExited (MouseEvent &event) |
void | mousePressed (MouseEvent &event) |
void | mouseDragged (MouseEvent &event) |
void | mouseWheelMovedUp (MouseEvent &event) |
void | mouseWheelMovedDown (MouseEvent &event) |
void | keyPressed (KeyEvent &event) |
void | setScale (const double scaleStart, const double scaleEnd) |
double | getScaleStart () const |
void | setScaleStart (const double scaleStart) |
double | getScaleEnd () const |
void | setScaleEnd (const double scaleEnd) |
void | setValue (const double value) |
double | getValue () const |
int | getMarkerLength () const |
void | setMarkerLength (const int length) |
void | setOrientation (const OrientationT orientation) |
OrientationT | getOrientation () const |
void | setStepLength (const double length) |
double | getStepLength () const |
Public Member Functions inherited from Widget | |
Widget (const Widget2 *const widget) | |
~Widget () | |
virtual void | drawFrame (Graphics *graphics) |
virtual void | safeDrawFrame (Graphics *graphics) |
void | setFrameSize (const unsigned int frameSize) |
unsigned int | getFrameSize () const |
virtual void | logic () |
Widget * | getParent () const |
void | setWidth (const int width) |
int | getWidth () const |
void | setHeight (const int height) |
int | getHeight () const |
void | setSize (const int width, const int height) |
void | setX (const int x) |
int | getX () const |
void | setY (const int y) |
int | getY () const |
void | setPosition (const int x, const int y) |
void | setDimension (const Rect &dimension) |
const Rect & | getDimension () const |
void | setFocusable (const bool focusable) |
bool | isFocusable () const |
virtual bool | isFocused () const |
void | setEnabled (const bool enabled) |
bool | isEnabled () const |
void | setVisible (Visible visible) |
bool | isVisible () const |
void | setBaseColor (const Color &color) |
const Color & | getBaseColor () const |
void | setForegroundColor (const Color &color) |
const Color & | getForegroundColor () const |
void | setBackgroundColor (const Color &color) |
const Color & | getBackgroundColor () const |
virtual void | requestFocus () |
virtual void | requestMoveToTop () |
virtual void | requestMoveToBottom () |
virtual void | setFocusHandler (FocusHandler *const focusHandler) |
FocusHandler * | getFocusHandler () |
void | addActionListener (ActionListener *const actionListener) |
void | removeActionListener (ActionListener *const actionListener) |
void | addDeathListener (WidgetDeathListener *const deathListener) |
void | removeDeathListener (WidgetDeathListener *const deathListener) |
void | addMouseListener (MouseListener *const mouseListener) |
void | removeMouseListener (MouseListener *const mouseListener) |
void | addKeyListener (KeyListener *const keyListener) |
void | removeKeyListener (KeyListener *const keyListener) |
void | addFocusListener (FocusListener *const focusListener) |
void | removeFocusListener (FocusListener *const focusListener) |
void | addWidgetListener (WidgetListener *const widgetListener) |
void | removeWidgetListener (WidgetListener *const widgetListener) |
void | setActionEventId (const std::string &actionEventId) |
const std::string & | getActionEventId () const |
virtual void | getAbsolutePosition (int &x, int &y) const |
virtual void | setParent (Widget *parent) |
Font * | getFont () const |
void | setFont (Font *const font) |
virtual void | fontChanged () |
bool | isTabInEnabled () const |
void | setTabInEnabled (const bool enabled) |
bool | isTabOutEnabled () const |
void | setTabOutEnabled (const bool enabled) |
void | requestModalFocus () |
virtual void | requestModalMouseInputFocus () |
virtual void | releaseModalFocus () |
virtual void | releaseModalMouseInputFocus () |
virtual bool | isModalFocused () const |
virtual bool | isModalMouseInputFocused () const |
virtual Widget * | getWidgetAt (int x, int y) |
const std::list< MouseListener * > & | getMouseListeners () const A_CONST |
const std::list< KeyListener * > & | getKeyListeners () const A_CONST |
const std::list< FocusListener * > & | getFocusListeners () const A_CONST |
virtual Rect | getChildrenArea () |
virtual FocusHandler * | getInternalFocusHandler () |
void | setInternalFocusHandler (FocusHandler *const internalFocusHandler) |
virtual void | moveToTop (Widget *widget) |
virtual void | moveToBottom (Widget *widget) |
virtual void | focusNext () |
virtual void | focusPrevious () |
virtual void | showWidgetPart (Widget *const widget, const Rect &area) |
void | setId (const std::string &id) |
const std::string & | getId () const |
virtual void | showPart (const Rect &rectangle) |
bool | isAllowLogic () const |
void | setMouseConsume (const bool b) |
bool | isMouseConsume () const |
void | setRedraw (const bool b) |
virtual bool | isSelectable () const |
void | setSelectable (const bool selectable) |
void | windowResized () |
virtual void | postInit () |
Public Member Functions inherited from Widget2 | |
virtual | ~Widget2 () |
const Color & | getThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE |
const Color & | getThemeCharColor (const signed char c, bool &valid) const A_INLINE |
virtual void | setWidget2 (const Widget2 *const widget) |
void | setPalette (int palette) |
void | checkPalette () |
void | setForegroundColor2 (const Color &color) |
Widget * | getWindow () const |
virtual void | setWindow (Widget *const window) |
Public Member Functions inherited from MouseListener | |
virtual | ~MouseListener () |
virtual void | mouseReleased (MouseEvent &event) |
virtual void | mouseClicked (MouseEvent &event) |
virtual void | mouseMoved (MouseEvent &event) |
Public Member Functions inherited from KeyListener | |
virtual | ~KeyListener () |
virtual void | keyReleased (KeyEvent &event) |
Private Member Functions | |
void | init () |
double | markerPositionToValue (const int position) const |
int | valueToMarkerPosition (const double value) const |
int | getMarkerPosition () const |
Private Attributes | |
double | mValue |
double | mStepLength |
double | mScaleStart |
double | mScaleEnd |
OrientationT | mOrientation |
ImageCollection * | mVertexes |
int | mMarkerLength |
bool | mHasMouse |
Static Private Attributes | |
static ImageRect | buttons [2] |
static float | mAlpha = 1.0 |
static int | mInstances = 0 |
Slider widget. Same as the Guichan slider but with custom look.
Slider::Slider | ( | Widget2 *const | widget, |
const double | scaleEnd, | ||
const double | stepLength | ||
) |
Constructor with scale start equal to 0.
Definition at line 97 of file slider.cpp.
References init().
Slider::Slider | ( | Widget2 *const | widget, |
const double | scaleStart, | ||
const double | scaleEnd, | ||
const double | stepLength | ||
) |
Slider::~Slider | ( | ) |
Destructor.
Definition at line 134 of file slider.cpp.
References buttons, delete2, gui, mInstances, mVertexes, Gui::removeDragged(), and Theme::unloadRect().
|
virtual |
Draws the slider.
Implements Widget.
Definition at line 195 of file slider.cpp.
References BLOCK_END, BLOCK_START, buttons, Graphics::calcPattern(), Graphics::calcTileCollection(), ImageCollection::clear(), Graphics::drawTileCollection(), Graphics::finalize(), Widget::getHeight(), getMarkerPosition(), Graphics::getRedraw(), Widget::getWidth(), ImageRect::grid, Rect::height, SliderGrid::HEND, SliderGrid::HGRIP, SliderGrid::HMID, SliderGrid::HSTART, Widget::mDimension, mHasMouse, Widget::mRedraw, mVertexes, updateAlpha(), x, and y.
|
inline |
Gets the length of the marker.
Definition at line 213 of file slider.h.
References mMarkerLength.
|
inlineprivate |
Gets the marker position of the current selected value.
Definition at line 294 of file slider.h.
References getValue(), and valueToMarkerPosition().
Referenced by draw(), and safeDraw().
|
inline |
Gets the orientation of the slider. A slider can be drawn vertically or horizontally.
Definition at line 242 of file slider.h.
References mOrientation.
|
inline |
|
inline |
Gets the start value of the scale.
Definition at line 160 of file slider.h.
References mScaleStart.
Referenced by Setup_Video::action().
|
inline |
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 262 of file slider.h.
References mStepLength.
|
inline |
Gets the current selected value.
Definition at line 204 of file slider.h.
References mValue.
Referenced by SellDialog::action(), Setup_Colors::action(), Setup_Video::action(), BuyDialog::action(), ItemAmountWindow::action(), Setup_Video::apply(), SetupItemSlider::fromWidget(), SetupItemSlider2::fromWidget(), getMarkerPosition(), Setup_Colors::updateColor(), and SetupItemSlider2::updateLabel().
|
private |
Used to initialize instances.
Definition at line 148 of file slider.cpp.
References Widget::addKeyListener(), Widget::addMouseListener(), buttons, data, Widget::getWidth(), SliderGrid::HGRIP, Theme::loadRect(), Widget::mAllowLogic, mInstances, Widget::setFocusable(), Widget::setFrameSize(), setMarkerLength(), theme, and updateAlpha().
Referenced by Slider().
|
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.
event | Discribes the event. |
Reimplemented from KeyListener.
Definition at line 432 of file slider.cpp.
References Widget::distributeActionEvent(), InputAction::GUI_DOWN, InputAction::GUI_LEFT, InputAction::GUI_RIGHT, InputAction::GUI_UP, Orientation::HORIZONTAL, mOrientation, mStepLength, mValue, and setValue().
|
private |
Converts a marker position to a value in the scale.
position | The position to convert. |
Definition at line 487 of file slider.cpp.
References Rect::height, Orientation::HORIZONTAL, Widget::mDimension, mMarkerLength, mOrientation, mScaleEnd, mScaleStart, and Rect::width.
Referenced by mouseDragged(), and mousePressed().
|
virtual |
Called when the mouse has moved and the mouse has previously been pressed on the widget.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 401 of file slider.cpp.
References Widget::distributeActionEvent(), MouseEvent::getX(), MouseEvent::getY(), Rect::height, Orientation::HORIZONTAL, markerPositionToValue(), Widget::mDimension, mMarkerLength, mOrientation, and setValue().
|
virtual |
Called when the mouse enteres the widget area.
Reimplemented from MouseListener.
Definition at line 370 of file slider.cpp.
References mHasMouse, and Widget::mRedraw.
|
virtual |
Called when the mouse leaves the widget area.
Reimplemented from MouseListener.
Definition at line 376 of file slider.cpp.
References mHasMouse, and Widget::mRedraw.
|
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.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 382 of file slider.cpp.
References Widget::distributeActionEvent(), MouseEvent::getButton(), Rect::height, Orientation::HORIZONTAL, MouseButton::LEFT, markerPositionToValue(), Widget::mDimension, mMarkerLength, mOrientation, setValue(), Rect::width, x, and y.
|
virtual |
Called when the mouse wheel has moved down on the widget area.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 425 of file slider.cpp.
References Widget::distributeActionEvent(), mStepLength, mValue, and setValue().
|
virtual |
Called when the mouse wheel has moved up on the widget area.
event | Describes the event. |
Reimplemented from MouseListener.
Definition at line 418 of file slider.cpp.
References Widget::distributeActionEvent(), mStepLength, mValue, and setValue().
|
virtual |
Implements Widget.
Definition at line 296 of file slider.cpp.
References BLOCK_END, BLOCK_START, buttons, Graphics::drawImage(), Graphics::drawPattern(), Widget::getHeight(), getMarkerPosition(), Widget::getWidth(), ImageRect::grid, Rect::height, SliderGrid::HEND, SliderGrid::HGRIP, SliderGrid::HMID, SliderGrid::HSTART, Widget::mDimension, mHasMouse, updateAlpha(), x, and y.
|
inline |
Sets the length of the marker.
length | The length for the marker. |
Definition at line 222 of file slider.h.
References mMarkerLength.
Referenced by init().
|
inline |
Sets the orientation of the slider. A slider can be drawn vertically or horizontally.
orientation | The orientation of the slider. |
Definition at line 232 of file slider.h.
References mOrientation.
void Slider::setScale | ( | const double | scaleStart, |
const 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 468 of file slider.cpp.
References mScaleEnd, and mScaleStart.
Referenced by BuyDialog::updateSlider(), SellDialog::valueChanged(), Setup_Colors::valueChanged(), and BuyDialog::valueChanged().
|
inline |
Sets the end value of the scale.
scaleEnd | The end value of the scale. |
Definition at line 187 of file slider.h.
References mScaleEnd.
|
inline |
Sets the start value of the scale.
scaleStart | The start value of the scale. |
Definition at line 169 of file slider.h.
References mScaleStart.
|
inline |
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 252 of file slider.h.
References mStepLength.
void Slider::setValue | ( | const double | value | ) |
Sets the current selected value.
value | The current selected value. |
Definition at line 474 of file slider.cpp.
References CAST_S32, Widget::mRedraw, mScaleEnd, mScaleStart, mStepLength, and mValue.
Referenced by SellDialog::action(), Setup_Video::action(), BuyDialog::action(), ItemAmountWindow::action(), Setup_Colors::cancel(), Setup_Video::cancel(), SetupItemSlider::createControls(), SetupItemSlider2::createControls(), keyPressed(), ItemAmountWindow::keyReleased(), mouseDragged(), mousePressed(), mouseWheelMovedDown(), mouseWheelMovedUp(), SellDialog::reset(), BuyDialog::reset(), NpcSellDialog::sellOneItem(), Setup_Colors::setEntry(), Setup_Colors::Setup_Colors(), Setup_Video::Setup_Video(), SetupItemSlider::toWidget(), SetupItemSlider2::toWidget(), BuyDialog::updateSlider(), SellDialog::valueChanged(), Setup_Colors::valueChanged(), and BuyDialog::valueChanged().
void Slider::updateAlpha | ( | ) |
Update the alpha value to the graphic components.
Definition at line 176 of file slider.cpp.
References buttons, Theme::getMinimumOpacity(), ImageRect::grid, Settings::guiAlpha, mAlpha, settings, SliderGrid::SLIDER_MAX, and theme.
Referenced by draw(), init(), and safeDraw().
|
private |
Converts a value to a marker position.
value | The value to convert. |
Definition at line 499 of file slider.cpp.
References CAST_S32, Rect::height, Orientation::HORIZONTAL, Widget::mDimension, mMarkerLength, mOrientation, mScaleEnd, mScaleStart, and Rect::width.
Referenced by getMarkerPosition().
|
staticprivate |
Definition at line 297 of file slider.h.
Referenced by draw(), init(), safeDraw(), updateAlpha(), and ~Slider().
|
staticprivate |
Definition at line 298 of file slider.h.
Referenced by updateAlpha().
|
private |
Definition at line 335 of file slider.h.
Referenced by draw(), mouseEntered(), mouseExited(), and safeDraw().
|
staticprivate |
|
private |
Holds the length of the marker.
Definition at line 333 of file slider.h.
Referenced by getMarkerLength(), markerPositionToValue(), mouseDragged(), mousePressed(), setMarkerLength(), and valueToMarkerPosition().
|
private |
Holds the orientation of the slider. A slider can be drawn vertically or horizontally.
Definition at line 326 of file slider.h.
Referenced by getOrientation(), keyPressed(), markerPositionToValue(), mouseDragged(), mousePressed(), setOrientation(), and valueToMarkerPosition().
|
private |
Holds the end value of the scale.
Definition at line 320 of file slider.h.
Referenced by getScaleEnd(), markerPositionToValue(), setScale(), setScaleEnd(), setValue(), and valueToMarkerPosition().
|
private |
Holds the start value of the scale.
Definition at line 315 of file slider.h.
Referenced by getScaleStart(), markerPositionToValue(), setScale(), setScaleStart(), setValue(), and valueToMarkerPosition().
|
private |
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 310 of file slider.h.
Referenced by getStepLength(), keyPressed(), mouseWheelMovedDown(), mouseWheelMovedUp(), setStepLength(), and setValue().
|
private |
Holds the current selected value.
Definition at line 304 of file slider.h.
Referenced by getValue(), keyPressed(), mouseWheelMovedDown(), mouseWheelMovedUp(), and setValue().
|
private |