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

slider.h
Go to the documentation of this file.
1 /* _______ __ __ __ ______ __ __ _______ __ __
2  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
3  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
4  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
5  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
6  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
7  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
8  *
9  * Copyright (c) 2004, 2005 darkbits Js_./
10  * Per Larsson a.k.a finalman _RqZ{a<^_aa
11  * Olof Naess�n a.k.a jansem/yakslem _asww7!uY`> )\a//
12  * _Qhm`] _f "'c 1!5m
13  * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
14  * .)j(] .d_/ '-( P . S
15  * License: (BSD) <Td/Z <fP"5(\"??"\a. .L
16  * Redistribution and use in source and _dV>ws?a-?' ._/L #'
17  * binary forms, with or without )4d[#7r, . ' )d`)[
18  * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam'
19  * that the following conditions are met: j<<WP+k/);. _W=j f
20  * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$
21  * retain the above copyright notice, ]E.pYY(Q]>. a J@\
22  * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a
23  * following disclaimer. 4'_uomm\. )L);-4 (3=
24  * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[
25  * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m
26  * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/
27  * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m
28  * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]'
29  * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W"
30  * 3. Neither the name of Guichan nor the :$we` _! + _/ . j?
31  * names of its contributors may be used =3)= _f (_yQmWW$#( "
32  * to endorse or promote products derived - W, sQQQQmZQ#Wwa]..
33  * from this software without specific (js, \[QQW$QWW#?!V"".
34  * prior written permission. ]y:.<\.. .
35  * -]n w/ ' [.
36  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ !
37  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , '
38  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- %
39  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r
40  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La
41  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a
43  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'.,
44  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?"
45  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. .
46  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _,
47  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
49  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
51  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
52  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53  */
54 
55 #ifndef GCN_SLIDER_HPP
56 #define GCN_SLIDER_HPP
57 
58 #include "guichan/platform.h"
59 #include "guichan/widget.h"
60 
61 namespace gcn
62 {
69  public Widget,
70  public MouseListener,
71  public KeyListener
72  {
73  public:
74 
80  Slider(double scaleEnd = 1.0);
81 
88  Slider(double scaleStart, double scaleEnd);
89 
93  virtual ~Slider() { }
94 
101  virtual void setScale(double scaleStart, double scaleEnd);
102 
108  virtual double getScaleStart() const;
109 
115  virtual void setScaleStart(double scaleStart);
116 
122  virtual double getScaleEnd() const;
123 
129  virtual void setScaleEnd(double scaleEnd);
130 
136  virtual double getValue() const;
137 
143  virtual void setValue(double value);
144 
150  virtual void drawMarker(gcn::Graphics* graphics);
151 
157  virtual void setMarkerLength(int length);
158 
164  virtual int getMarkerLength() const;
165 
172  virtual void setOrientation(unsigned int orientation);
173 
179  virtual unsigned int getOrientation() const;
180 
187  virtual void setStepLength(double length);
188 
194  virtual double getStepLength() const;
195 
196 
197  // Inherited from Widget
198 
199  virtual void draw(gcn::Graphics* graphics);
200 
201  virtual void drawBorder(gcn::Graphics* graphics);
202 
203  virtual void lostFocus();
204 
205 
206  // Inherited from MouseListener.
207 
208  virtual void mousePress(int x, int y, int button);
209 
210  virtual void mouseRelease(int x, int y, int button);
211 
212  virtual void mouseMotion(int x, int y);
213 
214 
215  // Inherited from KeyListener
216 
217  virtual bool keyPress(const Key& key);
218 
223  enum
224  {
225  HORIZONTAL = 0,
226  VERTICAL
227  };
228 
229  protected:
236  virtual double markerPositionToValue(int v) const;
237 
244  virtual int valueToMarkerPosition(double value) const;
245 
251  virtual int getMarkerPosition() const;
252 
254  double mValue;
255  double mStepLength;
257  double mScaleStart;
258  double mScaleEnd;
259  unsigned int mOrientation;
260  };
261 }
262 
263 #endif // end GCN_SLIDER_HPP
gcn::KeyListener
Definition: keylistener.h:74
GCN_CORE_DECLSPEC
#define GCN_CORE_DECLSPEC
Definition: platform.h:59
gcn::Graphics
Definition: graphics.h:97
gcn::Slider::mMarkerLength
int mMarkerLength
Definition: slider.h:256
gcn::Slider::mOrientation
unsigned int mOrientation
Definition: slider.h:259
gcn::MouseListener
Definition: mouselistener.h:72
gcn::Slider::mScaleEnd
double mScaleEnd
Definition: slider.h:258
gcn
Definition: cliprectangle.cpp:61
widget.h
gcn::Slider::~Slider
virtual ~Slider()
Definition: slider.h:93
gcn::Slider
Definition: slider.h:68
platform.h
gcn::Key
Definition: key.h:67
gcn::Slider::mScaleStart
double mScaleStart
Definition: slider.h:257
gcn::Slider::mMouseDrag
bool mMouseDrag
Definition: slider.h:253
gcn::Slider::mValue
double mValue
Definition: slider.h:254
gcn::Widget
Definition: widget.h:93
gcn::Slider::mStepLength
double mStepLength
Definition: slider.h:255
(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.