IGUISpinBox.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 __I_GUI_SPIN_BOX_H_INCLUDED__
  5. #define __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. //! set the range of values which can be used in the spinbox
  44. /** \param min: minimum value
  45. \param max: maximum value */
  46. virtual void setRange(f32 min, f32 max) = 0;
  47. //! get the minimum value which can be used in the spinbox
  48. virtual f32 getMin() const = 0;
  49. //! get the maximum value which can be used in the spinbox
  50. virtual f32 getMax() const = 0;
  51. //! Step size by which values are changed when pressing the spinbuttons
  52. /** The step size also determines the number of decimal places to display
  53. \param step: stepsize used for value changes when pressing spinbuttons */
  54. virtual void setStepSize(f32 step=1.f) = 0;
  55. //! Sets the number of decimal places to display.
  56. //! Note that this also rounds the range to the same number of decimal places.
  57. /** \param places: The number of decimal places to display, use -1 to reset */
  58. virtual void setDecimalPlaces(s32 places) = 0;
  59. //! get the current step size
  60. virtual f32 getStepSize() const = 0;
  61. //! Sets when the spinbox has to validate entered text.
  62. /** \param validateOn Can be any combination of EGUI_SPINBOX_VALIDATION bit flags */
  63. virtual void setValidateOn(u32 validateOn) = 0;
  64. //! Gets when the spinbox has to validate entered text.
  65. /** \return A combination of EGUI_SPINBOX_VALIDATION bit flags */
  66. virtual u32 getValidateOn() const = 0;
  67. };
  68. } // end namespace gui
  69. } // end namespace irr
  70. #endif // __I_GUI_SPIN_BOX_H_INCLUDED__