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