spinctrl.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk1/spinctrl.h
  3. // Purpose: wxSpinCtrl class
  4. // Author: Robert Roebling
  5. // Modified by:
  6. // Copyright: (c) Robert Roebling
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef __GTKSPINCTRLH__
  10. #define __GTKSPINCTRLH__
  11. #include "wx/defs.h"
  12. #if wxUSE_SPINCTRL
  13. #include "wx/control.h"
  14. //-----------------------------------------------------------------------------
  15. // wxSpinCtrl
  16. //-----------------------------------------------------------------------------
  17. class WXDLLIMPEXP_CORE wxSpinCtrl : public wxControl
  18. {
  19. public:
  20. wxSpinCtrl() {}
  21. wxSpinCtrl(wxWindow *parent,
  22. wxWindowID id = -1,
  23. const wxString& value = wxEmptyString,
  24. const wxPoint& pos = wxDefaultPosition,
  25. const wxSize& size = wxDefaultSize,
  26. long style = wxSP_ARROW_KEYS,
  27. int min = 0, int max = 100, int initial = 0,
  28. const wxString& name = wxT("wxSpinCtrl"))
  29. {
  30. Create(parent, id, value, pos, size, style, min, max, initial, name);
  31. }
  32. bool Create(wxWindow *parent,
  33. wxWindowID id = -1,
  34. const wxString& value = wxEmptyString,
  35. const wxPoint& pos = wxDefaultPosition,
  36. const wxSize& size = wxDefaultSize,
  37. long style = wxSP_ARROW_KEYS,
  38. int min = 0, int max = 100, int initial = 0,
  39. const wxString& name = wxT("wxSpinCtrl"));
  40. void SetValue(const wxString& text);
  41. void SetSelection(long from, long to);
  42. virtual int GetValue() const;
  43. virtual void SetValue( int value );
  44. virtual void SetRange( int minVal, int maxVal );
  45. virtual int GetMin() const;
  46. virtual int GetMax() const;
  47. static wxVisualAttributes
  48. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  49. // implementation
  50. void OnChar( wxKeyEvent &event );
  51. bool IsOwnGtkWindow( GdkWindow *window );
  52. void GtkDisableEvents();
  53. void GtkEnableEvents();
  54. GtkAdjustment *m_adjust;
  55. float m_oldPos;
  56. virtual int GetBase() const { return m_base; }
  57. virtual bool SetBase(int base);
  58. protected:
  59. virtual wxSize DoGetBestSize() const;
  60. // Widgets that use the style->base colour for the BG colour should
  61. // override this and return true.
  62. virtual bool UseGTKStyleBase() const { return true; }
  63. private:
  64. // Common part of all ctors.
  65. void Init()
  66. {
  67. m_base = 10;
  68. }
  69. int m_base;
  70. DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
  71. DECLARE_EVENT_TABLE()
  72. };
  73. #endif
  74. // wxUSE_SPINCTRL
  75. #endif
  76. // __GTKSPINCTRLH__