Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
Spinner.h
1/***********************************************************************
2 created: 3/2/2005
3 author: Paul D Turner
4*************************************************************************/
5/***************************************************************************
6 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 ***************************************************************************/
27#ifndef _CEGUISpinner_h_
28#define _CEGUISpinner_h_
29
30#include "../Base.h"
31#include "../Window.h"
32
33#if defined(_MSC_VER)
34# pragma warning(push)
35# pragma warning(disable : 4251)
36#endif
37
38
39// Start of CEGUI namespace section
40namespace CEGUI
41{
50 class CEGUIEXPORT Spinner : public Window
51 {
52 public:
64
65 /*************************************************************************
66 Events system constants
67 *************************************************************************/
68 static const String WidgetTypeName;
69 static const String EventNamespace;
100
101 /*************************************************************************
102 Component widget name strings
103 *************************************************************************/
104 static const String EditboxName;
107
108 /*************************************************************************
109 Object Construction and Destruction
110 *************************************************************************/
115 Spinner(const String& type, const String& name);
116
121 virtual ~Spinner(void);
122
134
135
136 /*************************************************************************
137 Accessors
138 *************************************************************************/
146 double getCurrentValue(void) const;
147
156 double getStepSize(void) const;
157
165 double getMaximumValue(void) const;
166
174 double getMinimumValue(void) const;
175
185
186 /*************************************************************************
187 Manipulators
188 *************************************************************************/
199 void setCurrentValue(double value);
200
212 void setStepSize(double step);
213
225
237
250
251 protected:
252 /*************************************************************************
253 Constants
254 *************************************************************************/
255 static const String FloatValidator;
257 static const String HexValidator;
258 static const String OctalValidator;
259
260 /*************************************************************************
261 Protected Implementation Methods
262 *************************************************************************/
272 virtual double getValueFromText(void) const;
273
281 virtual String getTextFromValue(void) const;
282
295
308
320
321 /*************************************************************************
322 Overrides for Event handler methods
323 *************************************************************************/
327
328 /*************************************************************************
329 New Event handler methods
330 *************************************************************************/
342
354
366
378
390
391 /*************************************************************************
392 Internal event listener methods
393 *************************************************************************/
394 bool handleIncreaseButton(const EventArgs& e);
395 bool handleDecreaseButton(const EventArgs& e);
396 bool handleEditTextChange(const EventArgs& e);
397
398
399 /*************************************************************************
400 Data Fields
401 *************************************************************************/
402 double d_stepSize;
404 double d_maxValue;
405 double d_minValue;
407
408 private:
409 /*************************************************************************
410 Private Implementation Methods
411 *************************************************************************/
419 void addSpinnerProperties(void);
420 };
421
422
423
424template<>
425class PropertyHelper<Spinner::TextInputMode>
426{
427public:
432
433 static const String& getDataTypeName()
434 {
435 static String type("TextInputMode");
436
437 return type;
438 }
439
440 static return_type fromString(const String& str)
441 {
442 if (str == "FloatingPoint")
443 {
445 }
446 else if (str == "Hexadecimal")
447 {
449 }
450 else if (str == "Octal")
451 {
452 return Spinner::Octal;
453 }
454 else
455 {
456 return Spinner::Integer;
457 }
458 }
459
460 static string_return_type toString(pass_type val)
461 {
462 if (val == Spinner::Octal)
463 {
464 return "Octal";
465 }
466 else if (val == Spinner::FloatingPoint)
467 {
468 return "FloatingPoint";
469 }
470 else if (val == Spinner::Hexadecimal)
471 {
472 return "Hexadecimal";
473 }
474 else if (val == Spinner::Integer)
475 {
476 return "Integer";
477 }
478 else
479 {
480 assert(false && "Invalid Text Input Mode");
481 return "FloatingPoint";
482 }
483 }
484};
485
486
487
488} // End of CEGUI namespace section
489
490#if defined(_MSC_VER)
491# pragma warning(pop)
492#endif
493
494#endif // end of guard _CEGUISpinner_h_
EventArgs based class that is used for Activated and Deactivated window events.
Definition InputEvent.h:330
Base class for an Editbox widget.
Definition widgets/Editbox.h:70
Base class used as the argument to all subscribers Event object.
Definition EventArgs.h:51
Helper class used to convert various data types to and from the format expected in Property strings.
Definition ForwardRefs.h:84
Base class to provide logic for push button type widgets.
Definition PushButton.h:48
Base class for the Spinner widget.
Definition Spinner.h:51
static const String EventTextInputModeChanged
Definition Spinner.h:99
void setCurrentValue(double value)
Set the current spinner value.
void setTextInputMode(TextInputMode mode)
Set the spinner input / display mode.
static const String IntegerValidator
Validator regex used for decimal integer mode.
Definition Spinner.h:256
static const String EventValueChanged
Definition Spinner.h:75
void setStepSize(double step)
Set the current step value.
virtual double getValueFromText(void) const
Returns the numerical representation of the current editbox text.
static const String HexValidator
Validator regex used for hexadecimal mode.
Definition Spinner.h:257
PushButton * getIncreaseButton() const
Return a pointer to the 'increase' PushButtoncomponent widget for this Spinner.
double getStepSize(void) const
Return the current step value.
Spinner(const String &type, const String &name)
Constructor for Spinner objects.
double getCurrentValue(void) const
Return the current spinner value.
void initialiseComponents(void)
Initialises the Window based object ready for use.
static const String EventNamespace
Namespace for global events.
Definition Spinner.h:69
TextInputMode getTextInputMode(void) const
Return the current text input / display mode setting.
double d_stepSize
Step size value used y the increase & decrease buttons.
Definition Spinner.h:402
virtual void onTextChanged(WindowEventArgs &e)
Handler called when the window's text is changed.
TextInputMode
Enumerated type specifying possible input and/or display modes for the spinner.
Definition Spinner.h:58
@ FloatingPoint
Floating point decimal.
Definition Spinner.h:59
@ Hexadecimal
Hexadecimal.
Definition Spinner.h:61
@ Octal
Octal.
Definition Spinner.h:62
@ Integer
Integer decimal.
Definition Spinner.h:60
double d_currentValue
Numerical copy of the text in d_editbox.
Definition Spinner.h:403
static const String DecreaseButtonName
Widget name for the decrease button component.
Definition Spinner.h:106
double getMaximumValue(void) const
Return the current maximum limit value for the Spinner.
virtual void onMinimumValueChanged(WindowEventArgs &e)
Method called when the minimum value setting changes.
virtual void onMaximumValueChanged(WindowEventArgs &e)
Method called when the maximum value setting changes.
static const String EventMaximumValueChanged
Definition Spinner.h:87
void setMaximumValue(double maxValue)
Set the spinner maximum value.
virtual void onStepChanged(WindowEventArgs &e)
Method called when the step value changes.
virtual void onActivated(ActivationEventArgs &e)
Handler called when this window has become the active window.
TextInputMode d_inputMode
Current text display/input mode.
Definition Spinner.h:406
virtual ~Spinner(void)
Destructor for Spinner objects.
void setMinimumValue(double minVaue)
Set the spinner minimum value.
PushButton * getDecreaseButton() const
Return a pointer to the 'decrease' PushButton component widget for this Spinner.
double d_maxValue
Maximum value for spinner.
Definition Spinner.h:404
virtual void onTextInputModeChanged(WindowEventArgs &e)
Method called when the text input/display mode is changed.
static const String EventMinimumValueChanged
Definition Spinner.h:93
static const String IncreaseButtonName
Widget name for the increase button component.
Definition Spinner.h:105
double getMinimumValue(void) const
Return the current minimum limit value for the Spinner.
static const String WidgetTypeName
Window factory name.
Definition Spinner.h:68
virtual void onValueChanged(WindowEventArgs &e)
Method called when the spinner value changes.
static const String FloatValidator
Validator regex used for floating point mode.
Definition Spinner.h:255
static const String OctalValidator
Validator regex used for octal mode.
Definition Spinner.h:258
static const String EditboxName
Widget name for the editbox thumb component.
Definition Spinner.h:104
static const String EventStepChanged
Definition Spinner.h:81
double d_minValue
Minimum value for spinner.
Definition Spinner.h:405
virtual String getTextFromValue(void) const
Returns the textual representation of the current spinner value.
Editbox * getEditbox() const
Return a pointer to the Editbox component widget for this Spinner.
virtual void onFontChanged(WindowEventArgs &e)
Handler called when the window's font is changed.
String class used within the GUI system.
Definition String.h:64
base class for properties able to do native set/get
Definition TypedProperty.h:50
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition InputEvent.h:252
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition Window.h:151
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1