spinctrl.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/os2/spinctrl.h
  3. // Purpose: wxSpinCtrl class declaration for Win32
  4. // Author: David Webster
  5. // Modified by:
  6. // Created: 10/15/99
  7. // Copyright: (c) David Webster
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_MSW_SPINCTRL_H_
  11. #define _WX_MSW_SPINCTRL_H_
  12. #include "wx/spinbutt.h" // the base class
  13. #include "wx/dynarray.h"
  14. class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
  15. WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl *, wxArraySpins);
  16. // ----------------------------------------------------------------------------
  17. // Under Win32 and OS2 PM, wxSpinCtrl is a wxSpinButton with a buddy
  18. // text window whose contents is automatically updated when the spin
  19. // control is clicked.
  20. // ----------------------------------------------------------------------------
  21. class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinButton
  22. {
  23. public:
  24. wxSpinCtrl() { }
  25. wxSpinCtrl( wxWindow* pParent
  26. ,wxWindowID vId = wxID_ANY
  27. ,const wxString& rsValue = wxEmptyString
  28. ,const wxPoint& rPos = wxDefaultPosition
  29. ,const wxSize& rSize = wxDefaultSize
  30. ,long lStyle = wxSP_ARROW_KEYS
  31. ,int nMin = 0
  32. ,int nMax = 100
  33. ,int nInitial = 0
  34. ,const wxString& rsName = wxT("wxSpinCtrl")
  35. )
  36. {
  37. Create(pParent, vId, rsValue, rPos, rSize, lStyle, nMin, nMax, nInitial, rsName);
  38. }
  39. virtual ~wxSpinCtrl();
  40. bool Create(wxWindow* pParent
  41. ,wxWindowID vId = wxID_ANY
  42. ,const wxString& rsValue = wxEmptyString
  43. ,const wxPoint& rPos = wxDefaultPosition
  44. ,const wxSize& rSize = wxDefaultSize
  45. ,long lStyle = wxSP_ARROW_KEYS
  46. ,int nMin = 0
  47. ,int nMax = 100
  48. ,int nInitial = 0
  49. ,const wxString& rsName = wxT("wxSpinCtrl")
  50. );
  51. //
  52. // A wxTextCtrl-like method (but we can't have GetValue returning wxString
  53. // because the base class already has one returning int!)
  54. //
  55. void SetValue(const wxString& rsText);
  56. //
  57. // implementation only from now on
  58. // -------------------------------
  59. //
  60. virtual bool Enable(bool bEnable = true);
  61. virtual int GetValue(void) const;
  62. virtual bool SetFont(const wxFont &rFont);
  63. virtual void SetFocus(void);
  64. inline virtual void SetValue(int nVal) { wxSpinButton::SetValue(nVal); }
  65. void SetSelection(long lFrom, long lTo);
  66. virtual bool Show(bool bShow = true);
  67. //
  68. // wxSpinButton doesn't accept focus, but we do
  69. //
  70. inline virtual bool AcceptsFocus(void) const { return false; }
  71. //
  72. // Return the spinctrl object whose buddy is the given window or NULL
  73. // Doesn't really do much under OS/2
  74. //
  75. static wxSpinCtrl* GetSpinForTextCtrl(WXHWND hWndBuddy);
  76. //
  77. // Process a WM_COMMAND generated by the buddy text control
  78. //
  79. bool ProcessTextCommand( WXWORD wCmd
  80. ,WXWORD wId
  81. );
  82. protected:
  83. virtual void DoGetPosition( int* nlX
  84. ,int* nlY
  85. ) const;
  86. void DoMoveWindow( int nX
  87. ,int nY
  88. ,int nWidth
  89. ,int nHeight
  90. );
  91. virtual wxSize DoGetBestSize(void) const;
  92. virtual void DoGetSize( int* pnWidth
  93. ,int* pnHeight
  94. ) const;
  95. //
  96. // The handler for wxSpinButton events
  97. //
  98. void OnSpinChange(wxSpinEvent& rEvent);
  99. void OnChar(wxKeyEvent& rEvent);
  100. void OnSetFocus(wxFocusEvent& rEvent);
  101. WXHWND m_hWndBuddy;
  102. static wxArraySpins m_svAllSpins;
  103. private:
  104. DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
  105. DECLARE_EVENT_TABLE()
  106. }; // end of CLASS wxSpinCtrl
  107. #endif // _WX_MSW_SPINCTRL_H_