]>
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_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "spinctrl.h"
19 #include "wx/spinbutt.h" // the base class
23 #include "wx/dynarray.h"
25 class WXDLLEXPORT wxSpinCtrl
;
26 WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl
*, wxArraySpins
);
28 // ----------------------------------------------------------------------------
29 // Under Win32, wxSpinCtrl is a wxSpinButton with a buddy (as MSDN docs call
30 // it) text window whose contents is automatically updated when the spin
31 // control is clicked.
32 // ----------------------------------------------------------------------------
34 class WXDLLEXPORT wxSpinCtrl
: public wxSpinButton
39 wxSpinCtrl(wxWindow
*parent
,
40 wxWindowID id
= wxID_ANY
,
41 const wxString
& value
= wxEmptyString
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
,
44 long style
= wxSP_ARROW_KEYS
,
45 int min
= 0, int max
= 100, int initial
= 0,
46 const wxString
& name
= _T("wxSpinCtrl"))
48 Create(parent
, id
, value
, pos
, size
, style
, min
, max
, initial
, name
);
51 bool Create(wxWindow
*parent
,
52 wxWindowID id
= wxID_ANY
,
53 const wxString
& value
= wxEmptyString
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
56 long style
= wxSP_ARROW_KEYS
,
57 int min
= 0, int max
= 100, int initial
= 0,
58 const wxString
& name
= _T("wxSpinCtrl"));
60 // a wxTextCtrl-like method (but we can't have GetValue returning wxString
61 // because the base class already has one returning int!)
62 void SetValue(const wxString
& text
);
64 // another wxTextCtrl-like method
65 void SetSelection(long from
, long to
);
67 // implementation only from now on
68 // -------------------------------
70 virtual ~wxSpinCtrl();
72 virtual void SetValue(int val
) { wxSpinButton::SetValue(val
); }
73 virtual int GetValue() const;
74 virtual bool SetFont(const wxFont
&font
);
75 virtual void SetFocus();
77 virtual bool Enable(bool enable
= true);
78 virtual bool Show(bool show
= true);
80 // wxSpinButton doesn't accept focus, but we do
81 virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); }
83 // for internal use only
85 // get the subclassed window proc of the buddy text
86 WXFARPROC
GetBuddyWndProc() const { return m_wndProcBuddy
; }
88 // return the spinctrl object whose buddy is the given window or NULL
89 static wxSpinCtrl
*GetSpinForTextCtrl(WXHWND hwndBuddy
);
91 // process a WM_COMMAND generated by the buddy text control
92 bool ProcessTextCommand(WXWORD cmd
, WXWORD id
);
95 virtual void DoGetPosition(int *x
, int *y
) const;
96 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
97 virtual wxSize
DoGetBestSize() const;
98 virtual void DoGetSize(int *width
, int *height
) const;
100 virtual void DoSetToolTip( wxToolTip
*tip
);
101 #endif // wxUSE_TOOLTIPS
103 // the handler for wxSpinButton events
104 void OnSpinChange(wxSpinEvent
& event
);
106 // Handle processing of special keys
107 void OnChar(wxKeyEvent
& event
);
108 void OnSetFocus(wxFocusEvent
& event
);
110 // the data for the "buddy" text ctrl
112 WXFARPROC m_wndProcBuddy
;
114 // all existing wxSpinCtrls - this allows to find the one corresponding to
115 // the given buddy window in GetSpinForTextCtrl()
116 static wxArraySpins ms_allSpins
;
119 DECLARE_DYNAMIC_CLASS(wxSpinCtrl
)
120 DECLARE_EVENT_TABLE()
121 DECLARE_NO_COPY_CLASS(wxSpinCtrl
)
124 #endif // wxUSE_SPINCTRL
126 #endif // _WX_MSW_SPINCTRL_H_