IGUISpinBox.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Copyright (C) 2006-2012 Michael Zeilfelder
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef IRR_I_GUI_SPIN_BOX_H_INCLUDED
  5. #define IRR_I_GUI_SPIN_BOX_H_INCLUDED
  6. #include "IGUIElement.h"
  7. namespace irr
  8. {
  9. namespace gui
  10. {
  11. class IGUIEditBox;
  12. //! Enumeration bitflag for when to validate the text typed into the spinbox
  13. //! Default used by Irrlicht is: (EGUI_SBV_ENTER|EGUI_SBV_LOSE_FOCUS)
  14. enum EGUI_SPINBOX_VALIDATION
  15. {
  16. //! Does not validate typed text, probably a bad idea setting this usually.
  17. EGUI_SBV_NEVER = 0,
  18. //! Validate on each change. Was default up to Irrlicht 1.8
  19. EGUI_SBV_CHANGE = 1,
  20. //! Validate when enter was pressed
  21. EGUI_SBV_ENTER = 2,
  22. //! Validate when the editbox loses the focus
  23. EGUI_SBV_LOSE_FOCUS = 4
  24. };
  25. //! Single line edit box + spin buttons
  26. /** \par This element can create the following events of type EGUI_EVENT_TYPE:
  27. \li EGET_SPINBOX_CHANGED
  28. */
  29. class IGUISpinBox : public IGUIElement
  30. {
  31. public:
  32. //! constructor
  33. IGUISpinBox(IGUIEnvironment* environment, IGUIElement* parent,
  34. s32 id, core::rect<s32> rectangle)
  35. : IGUIElement(EGUIET_SPIN_BOX, environment, parent, id, rectangle) {}
  36. //! Access the edit box used in the spin control
  37. virtual IGUIEditBox* getEditBox() const = 0;
  38. //! set the current value of the spinbox
  39. /** \param val: value to be set in the spinbox */
  40. virtual void setValue(f32 val) = 0;
  41. //! Get the current value of the spinbox
  42. virtual f32 getValue() const = 0;
  43. //! Get the value the spinbox would have for the given text
  44. /** Note: There is no rounding for decimal places going on here
  45. The reason is that so far spinbox doesn't restrict entering longer
  46. numbers (or any other text) (TODO)*/
  47. virtual f32 getValueFor(const wchar_t* text) const = 0;
  48. //! set the range of values which can be used in the spinbox
  49. /** \param min: minimum value
  50. \param max: maximum value */
  51. virtual void setRange(f32 min, f32 max) = 0;
  52. //! get the minimum value which can be used in the spinbox
  53. virtual f32 getMin() const = 0;
  54. //! get the maximum value which can be used in the spinbox
  55. virtual f32 getMax() const = 0;
  56. //! Step size by which values are changed when pressing the spinbuttons
  57. /** The step size also determines the number of decimal places to display
  58. \param step: stepsize used for value changes when pressing spinbuttons */
  59. virtual void setStepSize(f32 step=1.f) = 0;
  60. //! Sets the number of decimal places to display.
  61. //! Note: This also rounds the range to the same number of decimal places.
  62. //! Note: This is only used for the buttons so far, text-input ignores it (TODO)
  63. /** \param places: The number of decimal places to display, use -1 to reset */
  64. virtual void setDecimalPlaces(s32 places) = 0;
  65. //! get the current step size
  66. virtual f32 getStepSize() const = 0;
  67. //! Sets when the spinbox has to validate entered text.
  68. /** \param validateOn Can be any combination of EGUI_SPINBOX_VALIDATION bit flags */
  69. virtual void setValidateOn(u32 validateOn) = 0;
  70. //! Gets when the spinbox has to validate entered text.
  71. /** \return A combination of EGUI_SPINBOX_VALIDATION bit flags */
  72. virtual u32 getValidateOn() const = 0;
  73. //! Gets previous value in EGET_SPINBOX_CHANGED events
  74. /** Note: That value changes as soon as a new value is set (to the new value).
  75. So it's only useful to check for last value in the event and has no use otherwise.
  76. Also it's possible to mess it up by setting text via the editbox sub-element directly. */
  77. virtual f32 getOldValue() const = 0;
  78. };
  79. } // end namespace gui
  80. } // end namespace irr
  81. #endif // IRR_I_GUI_SPIN_BOX_H_INCLUDED