]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/spinctrl.h
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: msw/spinctrl.h
3 // Purpose: wxSpinCtrl class declaration for Win32
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_MSW_SPINCTRL_H_
13 #define _WX_MSW_SPINCTRL_H_
16 #pragma interface "spinctrl.h"
19 #include "wx/spinbutt.h" // the base class
21 #include "wx/dynarray.h"
23 class WXDLLEXPORT wxSpinCtrl
;
24 WX_DEFINE_EXPORTED_ARRAY(wxSpinCtrl
*, wxArraySpins
);
26 // ----------------------------------------------------------------------------
27 // Under Win32, wxSpinCtrl is a wxSpinButton with a buddy (as MSDN docs call
28 // it) text window whose contents is automatically updated when the spin
29 // control is clicked.
30 // ----------------------------------------------------------------------------
32 class WXDLLEXPORT wxSpinCtrl
: public wxSpinButton
37 wxSpinCtrl(wxWindow
*parent
,
39 const wxString
& value
= wxEmptyString
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
42 long style
= wxSP_ARROW_KEYS
,
43 int min
= 0, int max
= 100, int initial
= 0,
44 const wxString
& name
= _T("wxSpinCtrl"))
46 Create(parent
, id
, value
, pos
, size
, style
, min
, max
, initial
, name
);
49 bool Create(wxWindow
*parent
,
51 const wxString
& value
= wxEmptyString
,
52 const wxPoint
& pos
= wxDefaultPosition
,
53 const wxSize
& size
= wxDefaultSize
,
54 long style
= wxSP_ARROW_KEYS
,
55 int min
= 0, int max
= 100, int initial
= 0,
56 const wxString
& name
= _T("wxSpinCtrl"));
58 // a wxTextCtrl-like method (but we can't have GetValue returning wxString
59 // because the base class already has one returning int!)
60 void SetValue(const wxString
& text
);
62 // implementation only from now on
63 // -------------------------------
65 virtual ~wxSpinCtrl();
67 virtual void SetValue(int val
) { wxSpinButton::SetValue(val
); }
68 virtual int GetValue() const;
69 virtual bool SetFont(const wxFont
&font
);
70 virtual void SetFocus();
72 virtual bool Enable(bool enable
= TRUE
);
73 virtual bool Show(bool show
= TRUE
);
75 // wxSpinButton doesn't accept focus, but we do
76 virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); }
78 // for internal use only
80 // get the subclassed window proc of the buddy text
81 WXFARPROC
GetBuddyWndProc() const { return m_wndProcBuddy
; }
83 // return the spinctrl object whose buddy is the given window or NULL
84 static wxSpinCtrl
*GetSpinForTextCtrl(WXHWND hwndBuddy
);
86 // process a WM_COMMAND generated by the buddy text control
87 bool ProcessTextCommand(WXWORD cmd
, WXWORD id
);
90 virtual void DoGetPosition(int *x
, int *y
) const;
91 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
92 virtual wxSize
DoGetBestSize() const;
93 virtual void DoGetSize(int *width
, int *height
) const;
95 // the handler for wxSpinButton events
96 void OnSpinChange(wxSpinEvent
& event
);
98 // Handle processing of special keys
99 void OnChar(wxKeyEvent
& event
);
101 // the data for the "buddy" text ctrl
103 WXFARPROC m_wndProcBuddy
;
105 // all existing wxSpinCtrls - this allows to find the one corresponding to
106 // the given buddy window in GetSpinForTextCtrl()
107 static wxArraySpins ms_allSpins
;
110 DECLARE_DYNAMIC_CLASS(wxSpinCtrl
)
111 DECLARE_EVENT_TABLE()
114 #endif // _WX_MSW_SPINCTRL_H_