]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/spinctrl.h
change wxDataViewItem id to void*
[wxWidgets.git] / include / wx / msw / spinctrl.h
CommitLineData
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 21class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
d5d29b8a 22WX_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
30class WXDLLEXPORT wxSpinCtrl : public wxSpinButton
31{
32public:
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,
40 long style = wxSP_ARROW_KEYS,
41 int min = 0, int max = 100, int initial = 0,
42 const wxString& name = _T("wxSpinCtrl"))
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,
52 long style = wxSP_ARROW_KEYS,
53 int min = 0, int max = 100, int initial = 0,
54 const wxString& name = _T("wxSpinCtrl"));
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;
baccb514 70 virtual bool SetFont(const wxFont &font);
b44d69ba 71 virtual void SetFocus();
baccb514 72
57f4f925
WS
73 virtual bool Enable(bool enable = true);
74 virtual bool Show(bool show = true);
882a8f40 75
f6bcfd97
BP
76 // wxSpinButton doesn't accept focus, but we do
77 virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); }
78
6fe19057
VZ
79 // for internal use only
80
81 // get the subclassed window proc of the buddy text
82 WXFARPROC GetBuddyWndProc() const { return m_wndProcBuddy; }
83
84 // return the spinctrl object whose buddy is the given window or NULL
85 static wxSpinCtrl *GetSpinForTextCtrl(WXHWND hwndBuddy);
86
87 // process a WM_COMMAND generated by the buddy text control
88 bool ProcessTextCommand(WXWORD cmd, WXWORD id);
8614c467 89
b782f2e0 90protected:
f6bcfd97 91 virtual void DoGetPosition(int *x, int *y) const;
baccb514 92 virtual void DoMoveWindow(int x, int y, int width, int height);
f68586e5 93 virtual wxSize DoGetBestSize() const;
f6bcfd97 94 virtual void DoGetSize(int *width, int *height) const;
74124ea9
VZ
95#if wxUSE_TOOLTIPS
96 virtual void DoSetToolTip( wxToolTip *tip );
97#endif // wxUSE_TOOLTIPS
b782f2e0 98
9750fc42
VZ
99 // the handler for wxSpinButton events
100 void OnSpinChange(wxSpinEvent& event);
101
d40e9e06 102 // handle processing of special keys
e08d628d 103 void OnChar(wxKeyEvent& event);
c5c04fab 104 void OnSetFocus(wxFocusEvent& event);
4c81b431 105 void OnKillFocus(wxFocusEvent& event);
e08d628d 106
d40e9e06
VZ
107 // generate spin control update event with the given value
108 void SendSpinUpdate(int value);
109
110 // called to ensure that the value is in the correct range
1e8dba5e 111 virtual void NormalizeValue();
d40e9e06
VZ
112
113
114 // the value of the control before the latest change (which might not have
115 // changed anything in fact -- this is why we need this field)
116 int m_oldValue;
117
f6bcfd97
BP
118 // the data for the "buddy" text ctrl
119 WXHWND m_hwndBuddy;
6fe19057
VZ
120 WXFARPROC m_wndProcBuddy;
121
122 // all existing wxSpinCtrls - this allows to find the one corresponding to
123 // the given buddy window in GetSpinForTextCtrl()
124 static wxArraySpins ms_allSpins;
b782f2e0 125
9750fc42 126private:
b782f2e0 127 DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
9750fc42 128 DECLARE_EVENT_TABLE()
22f3361e 129 DECLARE_NO_COPY_CLASS(wxSpinCtrl)
b782f2e0
VZ
130};
131
0e871ad0
WS
132#endif // wxUSE_SPINCTRL
133
b782f2e0
VZ
134#endif // _WX_MSW_SPINCTRL_H_
135
136