1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/checkbox.h
3 // Purpose: wxCheckBox declaration
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_CHECKBOX_H_
13 #define _WX_UNIV_CHECKBOX_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "univcheckbox.h"
19 #include "wx/button.h" // for wxStdButtonInputHandler
21 // ----------------------------------------------------------------------------
22 // the actions supported by wxCheckBox
23 // ----------------------------------------------------------------------------
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
29 // additionally it accepts wxACTION_BUTTON_PRESS and RELEASE
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 // X11 headers may define this
40 class WXDLLEXPORT wxCheckBox
: public wxCheckBoxBase
62 wxCheckBox() { Init(); }
64 wxCheckBox(wxWindow
*parent
,
66 const wxString
& label
,
67 const wxPoint
& pos
= wxDefaultPosition
,
68 const wxSize
& size
= wxDefaultSize
,
70 const wxValidator
& validator
= wxDefaultValidator
,
71 const wxString
& name
= wxCheckBoxNameStr
)
75 Create(parent
, id
, label
, pos
, size
, style
, validator
, name
);
78 bool Create(wxWindow
*parent
,
80 const wxString
& label
,
81 const wxPoint
& pos
= wxDefaultPosition
,
82 const wxSize
& size
= wxDefaultSize
,
84 const wxValidator
& validator
= wxDefaultValidator
,
85 const wxString
& name
= wxCheckBoxNameStr
);
87 // implement the checkbox interface
88 virtual void SetValue(bool value
);
89 virtual bool GetValue() const;
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;
98 virtual void Release();
99 virtual void ChangeValue(bool value
);
101 // overridden base class virtuals
102 virtual bool IsPressed() const { return m_isPressed
; }
104 virtual bool HasTransparentBackground() { return true; }
107 virtual void DoSet3StateValue(wxCheckBoxState
WXUNUSED(state
));
108 virtual wxCheckBoxState
DoGet3StateValue() const;
110 virtual bool PerformAction(const wxControlAction
& action
,
112 const wxString
& strArg
= wxEmptyString
);
113 virtual void DoDraw(wxControlRenderer
*renderer
);
114 virtual wxSize
DoGetBestClientSize() const;
116 virtual bool CanBeHighlighted() const { return true; }
118 // get the size of the bitmap using either the current one or the default
119 // one (query renderer then)
120 virtual wxSize
GetBitmapSize() const;
122 // common part of all ctors
125 // send command event notifying about the checkbox state change
126 virtual void SendEvent();
128 // called when the checkbox becomes checked - radio button hook
129 virtual void OnCheck();
131 // get the state corresponding to the flags (combination of wxCONTROL_XXX)
132 wxCheckBox::State
GetState(int flags
) const;
134 // directly access the bitmaps array without trying to find a valid bitmap
135 // to use as GetBitmap() does
136 wxBitmap
DoGetBitmap(State state
, Status status
) const
137 { return m_bitmaps
[state
][status
]; }
139 // get the current status
140 Status
GetStatus() const { return m_status
; }
143 // the current check status
146 // the bitmaps to use for the different states
147 wxBitmap m_bitmaps
[State_Max
][Status_Max
];
149 // is the checkbox currently pressed?
152 DECLARE_DYNAMIC_CLASS(wxCheckBox
)
155 // ----------------------------------------------------------------------------
156 // wxStdCheckboxInputHandler: handles the mouse events for the check and radio
157 // boxes (handling the keyboard input is simple, but its handling differs a
158 // lot between GTK and MSW, so a new class should be derived for this)
159 // ----------------------------------------------------------------------------
161 class WXDLLEXPORT wxStdCheckboxInputHandler
: public wxStdButtonInputHandler
164 wxStdCheckboxInputHandler(wxInputHandler
*inphand
);
166 // we have to override this one as wxStdButtonInputHandler version works
167 // only with the buttons
168 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
171 #endif // _WX_UNIV_CHECKBOX_H_