]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/checkbox.h
Updated versions to 2.3.3
[wxWidgets.git] / include / wx / univ / checkbox.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/checkbox.h
3 // Purpose: wxCheckBox declaration
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 07.09.00
7 // RCS-ID: $Id$
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UNIV_CHECKBOX_H_
13 #define _WX_UNIV_CHECKBOX_H_
14
15 #ifdef __GNUG__
16 #pragma interface "univcheckbox.h"
17 #endif
18
19 #include "wx/button.h" // for wxStdButtonInputHandler
20
21 // ----------------------------------------------------------------------------
22 // the actions supported by wxCheckBox
23 // ----------------------------------------------------------------------------
24
25 #define wxACTION_CHECKBOX_CHECK _T("check") // SetValue(TRUE)
26 #define wxACTION_CHECKBOX_CLEAR _T("clear") // SetValue(FALSE)
27 #define wxACTION_CHECKBOX_TOGGLE _T("toggle") // toggle the check state
28
29 // additionally it accepts wxACTION_BUTTON_PRESS and RELEASE
30
31 // ----------------------------------------------------------------------------
32 // wxCheckBox
33 // ----------------------------------------------------------------------------
34
35 class WXDLLEXPORT wxCheckBox : public wxCheckBoxBase
36 {
37 public:
38 // checkbox constants
39 enum State
40 {
41 State_Normal,
42 State_Pressed,
43 State_Disabled,
44 State_Current,
45 State_Max
46 };
47
48 enum Status
49 {
50 Status_Checked,
51 Status_Unchecked,
52 Status_Unknown,
53 Status_Max
54 };
55
56 // constructors
57 wxCheckBox() { Init(); }
58
59 wxCheckBox(wxWindow *parent,
60 wxWindowID id,
61 const wxString& label,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = 0,
65 const wxValidator& validator = wxDefaultValidator,
66 const wxString& name = wxCheckBoxNameStr)
67 {
68 Init();
69
70 Create(parent, id, label, pos, size, style, validator, name);
71 }
72
73 bool Create(wxWindow *parent,
74 wxWindowID id,
75 const wxString& label,
76 const wxPoint& pos = wxDefaultPosition,
77 const wxSize& size = wxDefaultSize,
78 long style = 0,
79 const wxValidator& validator = wxDefaultValidator,
80 const wxString& name = wxCheckBoxNameStr);
81
82 // implement the checkbox interface
83 virtual void SetValue(bool value);
84 virtual bool GetValue() const;
85
86 // set/get the bitmaps to use for the checkbox indicator
87 void SetBitmap(const wxBitmap& bmp, State state, Status status);
88 virtual wxBitmap GetBitmap(State state, Status status) const;
89
90 // wxCheckBox actions
91 void Toggle();
92 virtual void Press();
93 virtual void Release();
94 virtual void ChangeValue(bool value);
95
96 // overridden base class virtuals
97 virtual bool IsPressed() const { return m_isPressed; }
98
99 protected:
100 virtual bool PerformAction(const wxControlAction& action,
101 long numArg = -1,
102 const wxString& strArg = wxEmptyString);
103 virtual void DoDraw(wxControlRenderer *renderer);
104 virtual wxSize DoGetBestClientSize() const;
105
106 virtual bool CanBeHighlighted() const { return TRUE; }
107
108 // get the size of the bitmap using either the current one or the default
109 // one (query renderer then)
110 virtual wxSize GetBitmapSize() const;
111
112 // common part of all ctors
113 void Init();
114
115 // send command event notifying about the checkbox state change
116 virtual void SendEvent();
117
118 // called when the checkbox becomes checked - radio button hook
119 virtual void OnCheck();
120
121 // get the state corresponding to the flags (combination of wxCONTROL_XXX)
122 wxCheckBox::State GetState(int flags) const;
123
124 // directly access the bitmaps array without trying to find a valid bitmap
125 // to use as GetBitmap() does
126 wxBitmap DoGetBitmap(State state, Status status) const
127 { return m_bitmaps[state][status]; }
128
129 // get the current status
130 Status GetStatus() const { return m_status; }
131
132 private:
133 // the current check status
134 Status m_status;
135
136 // the bitmaps to use for the different states
137 wxBitmap m_bitmaps[State_Max][Status_Max];
138
139 // is the checkbox currently pressed?
140 bool m_isPressed;
141
142 DECLARE_DYNAMIC_CLASS(wxCheckBox)
143 };
144
145 // ----------------------------------------------------------------------------
146 // wxStdCheckboxInputHandler: handles the mouse events for the check and radio
147 // boxes (handling the keyboard input is simple, but its handling differs a
148 // lot between GTK and MSW, so a new class should be derived for this)
149 // ----------------------------------------------------------------------------
150
151 class WXDLLEXPORT wxStdCheckboxInputHandler : public wxStdButtonInputHandler
152 {
153 public:
154 wxStdCheckboxInputHandler(wxInputHandler *inphand);
155
156 // we have to override this one as wxStdButtonInputHandler version works
157 // only with the buttons
158 virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
159 };
160
161 #endif // _WX_UNIV_CHECKBOX_H_