$treeview $search $mathjax
Stratagus  2.2.7
$projectbrief
$projectbrief
$searchbox
-->
         _________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

gcn::Slider Class Reference

#include <slider.h>

Inheritance diagram for gcn::Slider:

gcn::Widget gcn::MouseListener gcn::KeyListener ImageSlider

List of all members.


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

Detailed Description

A slider able to slide between different values. You can set the scale of the slider yourself so that it ranges between, for example, -1.0 and 2.0.

Member Enumeration Documentation

anonymous enum

Draw orientations for the slider. It can be drawn verticaly or horizontaly.

Enumerator:
HORIZONTAL 
VERTICAL 


Constructor & Destructor Documentation

gcn::Slider::Slider ( double  scaleEnd = 1.0  ) 

Constructor. Scale start is 0.

Parameters:
scaleEnd the end of the slider scale.

gcn::Slider::Slider ( double  scaleStart,
double  scaleEnd 
)

Constructor.

Parameters:
scaleStart the start of the scale.
scaleEnd the end of the scale.

virtual gcn::Slider::~Slider (  )  [inline, virtual]

Destructor.


Member Function Documentation

void gcn::Slider::setScale ( double  scaleStart,
double  scaleEnd 
) [virtual]

Sets the scale.

Parameters:
scaleStart the start of the scale.
scaleEnd the end of the scale.

double gcn::Slider::getScaleStart (  )  const [virtual]

Gets the scale start.

Returns:
the scale start.

void gcn::Slider::setScaleStart ( double  scaleStart  )  [virtual]

Sets the scale start.

Parameters:
scaleStart the start of the scale.

double gcn::Slider::getScaleEnd (  )  const [virtual]

Gets the scale end.

Returns:
the scale end.

void gcn::Slider::setScaleEnd ( double  scaleEnd  )  [virtual]

Sets the scale end.

Parameters:
scaleEnd the end of the scale.

double gcn::Slider::getValue (  )  const [virtual]

Gets the current value.

Returns:
the current value.

void gcn::Slider::setValue ( double  value  )  [virtual]

Sets the current value.

Parameters:
value a scale value.

void gcn::Slider::drawMarker ( gcn::Graphics graphics  )  [virtual]

Draws the marker.

Parameters:
graphics a graphics object to draw with.

Reimplemented in ImageSlider.

void gcn::Slider::setMarkerLength ( int  length  )  [virtual]

Sets the length of the marker.

Parameters:
length new length for the marker.

int gcn::Slider::getMarkerLength (  )  const [virtual]

Gets the length of the marker.

Returns:
the length of the marker.

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.

Parameters:
orientation the orientation.

unsigned int gcn::Slider::getOrientation (  )  const [virtual]

Gets the orientation of the slider. Se the enum in this class.

Returns:
the orientation of the slider.

void gcn::Slider::setStepLength ( double  length  )  [virtual]

Sets the step length. Step length is used when the keys left and right are pressed.

Parameters:
length the step length.

double gcn::Slider::getStepLength (  )  const [virtual]

Gets the step length.

Returns:
the step length.

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.

Parameters:
graphics a Graphics object to draw with.

Implements gcn::Widget.

Reimplemented in ImageSlider.

void gcn::Slider::drawBorder ( gcn::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.

Parameters:
graphics a Graphics object to draw with.

Reimplemented from gcn::Widget.

void gcn::Slider::lostFocus (  )  [virtual]

Called if the Widget loses focus.

Reimplemented from gcn::Widget.

void gcn::Slider::mousePress ( int  ,
int  ,
int   
) [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.

Parameters:
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.

void gcn::Slider::mouseRelease ( int  ,
int  ,
int   
) [virtual]

Called when a mouse button is released when the mouse is in the Widget area or if the Widget has focus.

Parameters:
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.

void gcn::Slider::mouseMotion ( int  ,
int   
) [virtual]

Called when the mouse moves and the mouse is in the Widget area or if the Widget has focus.

Parameters:
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.

bool gcn::Slider::keyPress ( const 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.

Parameters:
key the key pressed.

Reimplemented from gcn::KeyListener.

double gcn::Slider::markerPositionToValue ( int  v  )  const [protected, virtual]

Converts a marker position to a value.

Parameters:
v the position to convert.
Returns:
the value corresponding to the position.

int gcn::Slider::valueToMarkerPosition ( double  value  )  const [protected, virtual]

Converts a value to a marker position.

Parameters:
value the value to convert.
Returns:
the position corresponding to the value.

int gcn::Slider::getMarkerPosition (  )  const [protected, virtual]

Gets the marker position for the current value.

Returns:
the marker position for the current value.


Member Data Documentation

bool gcn::Slider::mMouseDrag [protected]

double gcn::Slider::mValue [protected]

double gcn::Slider::mStepLength [protected]

int gcn::Slider::mMarkerLength [protected]

double gcn::Slider::mScaleStart [protected]

double gcn::Slider::mScaleEnd [protected]

unsigned int gcn::Slider::mOrientation [protected]


The documentation for this class was generated from the following files:
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.