]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/msw/spinctrl.h
Fixed to work with the new wxMacControl system.
[wxWidgets.git] / include / wx / msw / spinctrl.h
... / ...
CommitLineData
1////////////////////////////////////////////////////////////////////////////
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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MSW_SPINCTRL_H_
13#define _WX_MSW_SPINCTRL_H_
14
15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "spinctrl.h"
17#endif
18
19#include "wx/spinbutt.h" // the base class
20
21#include "wx/dynarray.h"
22
23class WXDLLEXPORT wxSpinCtrl;
24WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl *, wxArraySpins);
25
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// ----------------------------------------------------------------------------
31
32class WXDLLEXPORT wxSpinCtrl : public wxSpinButton
33{
34public:
35 wxSpinCtrl() { }
36
37 wxSpinCtrl(wxWindow *parent,
38 wxWindowID id = -1,
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"))
45 {
46 Create(parent, id, value, pos, size, style, min, max, initial, name);
47 }
48
49 bool Create(wxWindow *parent,
50 wxWindowID id = -1,
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"));
57
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);
61
62 // another wxTextCtrl-like method
63 void SetSelection(long from, long to);
64
65 // implementation only from now on
66 // -------------------------------
67
68 virtual ~wxSpinCtrl();
69
70 virtual void SetValue(int val) { wxSpinButton::SetValue(val); }
71 virtual int GetValue() const;
72 virtual bool SetFont(const wxFont &font);
73 virtual void SetFocus();
74
75 virtual bool Enable(bool enable = TRUE);
76 virtual bool Show(bool show = TRUE);
77
78 // wxSpinButton doesn't accept focus, but we do
79 virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); }
80
81 // for internal use only
82
83 // get the subclassed window proc of the buddy text
84 WXFARPROC GetBuddyWndProc() const { return m_wndProcBuddy; }
85
86 // return the spinctrl object whose buddy is the given window or NULL
87 static wxSpinCtrl *GetSpinForTextCtrl(WXHWND hwndBuddy);
88
89 // process a WM_COMMAND generated by the buddy text control
90 bool ProcessTextCommand(WXWORD cmd, WXWORD id);
91
92protected:
93 virtual void DoGetPosition(int *x, int *y) const;
94 virtual void DoMoveWindow(int x, int y, int width, int height);
95 virtual wxSize DoGetBestSize() const;
96 virtual void DoGetSize(int *width, int *height) const;
97
98 // the handler for wxSpinButton events
99 void OnSpinChange(wxSpinEvent& event);
100
101 // Handle processing of special keys
102 void OnChar(wxKeyEvent& event);
103 void OnSetFocus(wxFocusEvent& event);
104
105 // the data for the "buddy" text ctrl
106 WXHWND m_hwndBuddy;
107 WXFARPROC m_wndProcBuddy;
108
109 // all existing wxSpinCtrls - this allows to find the one corresponding to
110 // the given buddy window in GetSpinForTextCtrl()
111 static wxArraySpins ms_allSpins;
112
113private:
114 DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
115 DECLARE_EVENT_TABLE()
116 DECLARE_NO_COPY_CLASS(wxSpinCtrl)
117};
118
119#endif // _WX_MSW_SPINCTRL_H_
120
121