]>
Commit | Line | Data |
---|---|---|
f6bcfd97 | 1 | //////////////////////////////////////////////////////////////////////////// |
b782f2e0 VZ |
2 | // Name: msw/spinctrl.h |
3 | // Purpose: wxSpinCtrl class declaration for Win32 | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 22.07.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Vadim Zeitlin | |
65571936 | 9 | // Licence: wxWindows licence |
b782f2e0 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_MSW_SPINCTRL_H_ | |
13 | #define _WX_MSW_SPINCTRL_H_ | |
14 | ||
b782f2e0 VZ |
15 | #include "wx/spinbutt.h" // the base class |
16 | ||
0e871ad0 WS |
17 | #if wxUSE_SPINCTRL |
18 | ||
6fe19057 | 19 | #include "wx/dynarray.h" |
d77254fc | 20 | |
b5dbe15d | 21 | class WXDLLIMPEXP_FWD_CORE wxSpinCtrl; |
d5d29b8a | 22 | WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl *, wxArraySpins); |
6fe19057 | 23 | |
b782f2e0 VZ |
24 | // ---------------------------------------------------------------------------- |
25 | // Under Win32, wxSpinCtrl is a wxSpinButton with a buddy (as MSDN docs call | |
26 | // it) text window whose contents is automatically updated when the spin | |
27 | // control is clicked. | |
28 | // ---------------------------------------------------------------------------- | |
29 | ||
53a2db12 | 30 | class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinButton |
b782f2e0 VZ |
31 | { |
32 | public: | |
33 | wxSpinCtrl() { } | |
34 | ||
35 | wxSpinCtrl(wxWindow *parent, | |
57f4f925 | 36 | wxWindowID id = wxID_ANY, |
678cd6de | 37 | const wxString& value = wxEmptyString, |
b782f2e0 VZ |
38 | const wxPoint& pos = wxDefaultPosition, |
39 | const wxSize& size = wxDefaultSize, | |
f1ddb476 | 40 | long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, |
b782f2e0 | 41 | int min = 0, int max = 100, int initial = 0, |
9a83f860 | 42 | const wxString& name = wxT("wxSpinCtrl")) |
b782f2e0 | 43 | { |
678cd6de | 44 | Create(parent, id, value, pos, size, style, min, max, initial, name); |
b782f2e0 VZ |
45 | } |
46 | ||
47 | bool Create(wxWindow *parent, | |
57f4f925 | 48 | wxWindowID id = wxID_ANY, |
678cd6de | 49 | const wxString& value = wxEmptyString, |
b782f2e0 VZ |
50 | const wxPoint& pos = wxDefaultPosition, |
51 | const wxSize& size = wxDefaultSize, | |
f1ddb476 | 52 | long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT, |
b782f2e0 | 53 | int min = 0, int max = 100, int initial = 0, |
9a83f860 | 54 | const wxString& name = wxT("wxSpinCtrl")); |
b782f2e0 | 55 | |
678cd6de VZ |
56 | // a wxTextCtrl-like method (but we can't have GetValue returning wxString |
57 | // because the base class already has one returning int!) | |
58 | void SetValue(const wxString& text); | |
59 | ||
07901ec9 VZ |
60 | // another wxTextCtrl-like method |
61 | void SetSelection(long from, long to); | |
62 | ||
882a8f40 VZ |
63 | // implementation only from now on |
64 | // ------------------------------- | |
65 | ||
f6bcfd97 BP |
66 | virtual ~wxSpinCtrl(); |
67 | ||
eeea41ab | 68 | virtual void SetValue(int val); |
b44d69ba | 69 | virtual int GetValue() const; |
345ff9c6 | 70 | virtual void SetRange(int minVal, int maxVal); |
baccb514 | 71 | virtual bool SetFont(const wxFont &font); |
b44d69ba | 72 | virtual void SetFocus(); |
baccb514 | 73 | |
57f4f925 WS |
74 | virtual bool Enable(bool enable = true); |
75 | virtual bool Show(bool show = true); | |
882a8f40 | 76 | |
03d4194d VZ |
77 | virtual bool Reparent(wxWindowBase *newParent); |
78 | ||
f6bcfd97 BP |
79 | // wxSpinButton doesn't accept focus, but we do |
80 | virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); } | |
81 | ||
ddc4214a VZ |
82 | // we're like wxTextCtrl and not (default) wxButton |
83 | virtual wxVisualAttributes GetDefaultAttributes() const | |
84 | { | |
85 | return GetClassDefaultAttributes(GetWindowVariant()); | |
86 | } | |
87 | ||
88 | static wxVisualAttributes | |
89 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL) | |
90 | { | |
91 | return GetCompositeControlsDefaultAttributes(variant); | |
92 | } | |
93 | ||
6fe19057 VZ |
94 | // for internal use only |
95 | ||
96 | // get the subclassed window proc of the buddy text | |
97 | WXFARPROC GetBuddyWndProc() const { return m_wndProcBuddy; } | |
98 | ||
99 | // return the spinctrl object whose buddy is the given window or NULL | |
100 | static wxSpinCtrl *GetSpinForTextCtrl(WXHWND hwndBuddy); | |
101 | ||
102 | // process a WM_COMMAND generated by the buddy text control | |
103 | bool ProcessTextCommand(WXWORD cmd, WXWORD id); | |
8614c467 | 104 | |
ea283460 VZ |
105 | // recognize buddy window as part of this control at wx level |
106 | virtual bool ContainsHWND(WXHWND hWnd) const { return hWnd == m_hwndBuddy; } | |
107 | ||
b782f2e0 | 108 | protected: |
f6bcfd97 | 109 | virtual void DoGetPosition(int *x, int *y) const; |
baccb514 | 110 | virtual void DoMoveWindow(int x, int y, int width, int height); |
f68586e5 | 111 | virtual wxSize DoGetBestSize() const; |
f6bcfd97 | 112 | virtual void DoGetSize(int *width, int *height) const; |
b7527dde | 113 | virtual void DoGetClientSize(int *x, int *y) const; |
74124ea9 VZ |
114 | #if wxUSE_TOOLTIPS |
115 | virtual void DoSetToolTip( wxToolTip *tip ); | |
116 | #endif // wxUSE_TOOLTIPS | |
b782f2e0 | 117 | |
177e38e6 RR |
118 | virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); |
119 | virtual bool MSWOnScroll(int orientation, WXWORD wParam, | |
120 | WXWORD pos, WXHWND control); | |
9750fc42 | 121 | |
d40e9e06 | 122 | // handle processing of special keys |
e08d628d | 123 | void OnChar(wxKeyEvent& event); |
c5c04fab | 124 | void OnSetFocus(wxFocusEvent& event); |
4c81b431 | 125 | void OnKillFocus(wxFocusEvent& event); |
e08d628d | 126 | |
d40e9e06 VZ |
127 | // generate spin control update event with the given value |
128 | void SendSpinUpdate(int value); | |
129 | ||
130 | // called to ensure that the value is in the correct range | |
1e8dba5e | 131 | virtual void NormalizeValue(); |
d40e9e06 VZ |
132 | |
133 | ||
134 | // the value of the control before the latest change (which might not have | |
135 | // changed anything in fact -- this is why we need this field) | |
136 | int m_oldValue; | |
137 | ||
f6bcfd97 BP |
138 | // the data for the "buddy" text ctrl |
139 | WXHWND m_hwndBuddy; | |
6fe19057 VZ |
140 | WXFARPROC m_wndProcBuddy; |
141 | ||
03647350 | 142 | // Block text update event after SetValue() |
ea6cbf48 RR |
143 | bool m_blockEvent; |
144 | ||
9750fc42 | 145 | private: |
b782f2e0 | 146 | DECLARE_DYNAMIC_CLASS(wxSpinCtrl) |
9750fc42 | 147 | DECLARE_EVENT_TABLE() |
c0c133e1 | 148 | wxDECLARE_NO_COPY_CLASS(wxSpinCtrl); |
b782f2e0 VZ |
149 | }; |
150 | ||
0e871ad0 WS |
151 | #endif // wxUSE_SPINCTRL |
152 | ||
b782f2e0 VZ |
153 | #endif // _WX_MSW_SPINCTRL_H_ |
154 | ||
155 |