00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _CEGUISpinner_h_
00025 #define _CEGUISpinner_h_
00026
00027 #include "CEGUIBase.h"
00028 #include "CEGUIWindow.h"
00029 #include "elements/CEGUISpinnerProperties.h"
00030
00031 #if defined(_MSC_VER)
00032 # pragma warning(push)
00033 # pragma warning(disable : 4251)
00034 #endif
00035
00036
00037
00038 namespace CEGUI
00039 {
00048 class CEGUIEXPORT Spinner : public Window
00049 {
00050 public:
00055 enum TextInputMode
00056 {
00057 FloatingPoint,
00058 Integer,
00059 Hexadecimal,
00060 Octal
00061 };
00062
00063
00064
00065
00066 static const String EventNamespace;
00067 static const String EventValueChanged;
00068 static const String EventStepChanged;
00069 static const String EventMaximumValueChanged;
00070 static const String EventMinimumValueChanged;
00071 static const String EventTextInputModeChanged;
00072
00073
00074
00075
00080 Spinner(const String& type, const String& name);
00081
00086 virtual ~Spinner(void);
00087
00098 void initialise(void);
00099
00100
00101
00102
00103
00111 float getCurrentValue(void) const;
00112
00121 float getStepSize(void) const;
00122
00130 float getMaximumValue(void) const;
00131
00139 float getMinimumValue(void) const;
00140
00149 TextInputMode getTextInputMode(void) const;
00150
00151
00152
00153
00164 void setCurrentValue(float value);
00165
00177 void setStepSize(float step);
00178
00189 void setMaximumValue(float maxValue);
00190
00201 void setMinimumValue(float minVaue);
00202
00214 void setTextInputMode(TextInputMode mode);
00215
00216 protected:
00217
00218
00219
00220 static const String FloatValidator;
00221 static const String IntegerValidator;
00222 static const String HexValidator;
00223 static const String OctalValidator;
00224
00225
00226
00227
00235 void addSpinnerEvents(void);
00236
00246 virtual float getValueFromText(void) const;
00247
00255 virtual String getTextFromValue(void) const;
00256
00257
00268 virtual bool testClassName_impl(const String& class_name) const
00269 {
00270 if (class_name==(const utf8*)"Spinner") return true;
00271 return Window::testClassName_impl(class_name);
00272 }
00273
00274
00275
00276
00277
00286 virtual PushButton* createIncreaseButton(const String& name) const = 0;
00287
00296 virtual PushButton* createDecreaseButton(const String& name) const = 0;
00297
00306 virtual Editbox* createEditbox(const String& name) const = 0;
00307
00308
00309
00310
00311 virtual void onFontChanged(WindowEventArgs& e);
00312 virtual void onTextChanged(WindowEventArgs& e);
00313 virtual void onActivated(ActivationEventArgs& e);
00314
00315
00316
00317
00328 virtual void onValueChanged(WindowEventArgs& e);
00329
00340 virtual void onStepChanged(WindowEventArgs& e);
00341
00352 virtual void onMaximumValueChanged(WindowEventArgs& e);
00353
00364 virtual void onMinimumValueChanged(WindowEventArgs& e);
00365
00376 virtual void onTextInputModeChanged(WindowEventArgs& e);
00377
00378
00379
00380
00381 bool handleIncreaseButton(const EventArgs& e);
00382 bool handleDecreaseButton(const EventArgs& e);
00383 bool handleEditTextChange(const EventArgs& e);
00384
00385
00386
00387
00388
00389 PushButton* d_increaseButton;
00390 PushButton* d_decreaseButton;
00391 Editbox* d_editbox;
00392
00393 float d_stepSize;
00394 float d_currentValue;
00395 float d_maxValue;
00396 float d_minValue;
00397 TextInputMode d_inputMode;
00398
00399 private:
00400
00401
00402
00403 static SpinnerProperties::CurrentValue d_currentValueProperty;
00404 static SpinnerProperties::StepSize d_stepSizeProperty;
00405 static SpinnerProperties::MaximumValue d_maxValueProperty;
00406 static SpinnerProperties::MinimumValue d_minValueProperty;
00407 static SpinnerProperties::TextInputMode d_textInputModeProperty;
00408
00409
00410
00411
00419 void addSpinnerProperties(void);
00420 };
00421
00422 }
00423
00424
00425 #endif // end of guard _CEGUISpinner_h_