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