NumericUpDown.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. GWEN
  3. Copyright (c) 2010 Facepunch Studios
  4. See license in Gwen.h
  5. */
  6. #pragma once
  7. #ifndef GWEN_CONTROLS_NUMERICUPDOWN_H
  8. #define GWEN_CONTROLS_NUMERICUPDOWN_H
  9. #include "Gwen/Controls/Base.h"
  10. #include "Gwen/Controls/Button.h"
  11. #include "Gwen/Controls/TextBox.h"
  12. namespace Gwen
  13. {
  14. namespace Controls
  15. {
  16. class GWEN_EXPORT NumericUpDownButton_Up : public Button
  17. {
  18. GWEN_CONTROL_INLINE( NumericUpDownButton_Up, Button ){}
  19. virtual void Render( Skin::Base* skin )
  20. {
  21. skin->DrawNumericUpDownButton( this, m_bDepressed, true );
  22. }
  23. };
  24. class GWEN_EXPORT NumericUpDownButton_Down : public Button
  25. {
  26. GWEN_CONTROL_INLINE( NumericUpDownButton_Down, Button ){}
  27. virtual void Render( Skin::Base* skin )
  28. {
  29. skin->DrawNumericUpDownButton( this, m_bDepressed, false );
  30. }
  31. };
  32. class GWEN_EXPORT NumericUpDown : public TextBoxNumeric
  33. {
  34. public:
  35. GWEN_CONTROL( NumericUpDown, TextBoxNumeric );
  36. virtual void SetMin( int i );
  37. virtual void SetMax( int i );
  38. virtual void SetValue( int i );
  39. Event::Caller onChanged;
  40. private:
  41. virtual void OnEnter();
  42. virtual void OnChange();
  43. virtual void OnTextChanged();
  44. virtual void OnButtonUp( Base* control );
  45. virtual void OnButtonDown( Base* control );
  46. virtual bool OnKeyUp( bool bDown ) { if ( bDown ) OnButtonUp( NULL ); return true; }
  47. virtual bool OnKeyDown( bool bDown ){ if ( bDown ) OnButtonDown( NULL ); return true; }
  48. virtual void SyncTextFromNumber();
  49. virtual void SyncNumberFromText();
  50. int m_iNumber;
  51. int m_iMax;
  52. int m_iMin;
  53. };
  54. }
  55. }
  56. #endif