Planeshift
pawsspinbox.h
Go to the documentation of this file.
1 /*
2  * pawsspinbox.h
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 #ifndef PAWS_SPINBOX_HEADER
20 #define PAWS_SPINBOX_HEADER
21 
22 
23 #include "pawstextbox.h"
24 #include "pawsbutton.h"
25 #include <csutil/timer.h>
26 
27 
32 #define SPIN_INTERVAL 100
33 #define SPIN_START_DELAY 500
34 
35 #define SPIN_STOP 0
36 #define SPIN_UP 1
37 #define SPIN_DOWN 2
38 
39 struct SpinBoxTimerEvent;
40 
56 class pawsSpinBox : public pawsWidget
57 {
58 public:
59  pawsSpinBox();
60  virtual ~pawsSpinBox();
61  pawsSpinBox(const pawsSpinBox &origin);
62 
63  virtual bool Setup(iDocumentNode* node);
64  virtual bool ManualSetup(csString &value, float Min, float Max, float Inc, csString &pos);
65  virtual void SetRange(float Min, float Max, float Inc);
66 
67  virtual void SetValue(float value);
68  virtual float GetValue();
69 
70  virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
71  virtual bool OnButtonReleased(int button, int keyModifier, pawsWidget* widget);
72 
73  virtual void OnLostFocus();
74 
75  virtual bool Perform(iTimerEvent* ev);
76  virtual void Spin();
77 
78 private:
79  csRef<iEventTimer> globalTimer;
80  SpinBoxTimerEvent* timerEvent;
81 
82  int spinCounter;
83  int spinState;
84 
85  pawsButton* upButton;
86  pawsButton* downButton;
87  pawsEditTextBox* text;
88 
89  float max;
90  float min;
91  float inc;
92 };
94 
97 #endif
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
A combination widget that has up and down arrows and a text label.
Definition: pawsspinbox.h:56
virtual float GetValue()
virtual bool ManualSetup(csString &value, float Min, float Max, float Inc, csString &pos)
An edit box widget/.
Definition: pawstextbox.h:409
virtual void SetRange(float Min, float Max, float Inc)
virtual ~pawsSpinBox()
virtual void OnLostFocus()
Sets hasFocus false and notifys parent.
virtual void SetValue(float value)
virtual bool Setup(iDocumentNode *node)
Setup this widget.
A simple button widget.
Definition: pawsbutton.h:43
virtual bool Perform(iTimerEvent *ev)
virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget *widget)
Called whenever a button is pressed.
CREATE_PAWS_FACTORY(pawsSpinBox)
virtual bool OnButtonReleased(int button, int keyModifier, pawsWidget *widget)
Called whenever a button is released.
virtual void Spin()