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