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 #include "wx/button.h" // for wxStdButtonInputHandler
17 // ----------------------------------------------------------------------------
18 // the actions supported by wxCheckBox
19 // ----------------------------------------------------------------------------
21 #define wxACTION_CHECKBOX_CHECK _T("check") // SetValue(true)
22 #define wxACTION_CHECKBOX_CLEAR _T("clear") // SetValue(false)
23 #define wxACTION_CHECKBOX_TOGGLE _T("toggle") // toggle the check state
25 // additionally it accepts wxACTION_BUTTON_PRESS and RELEASE
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 // X11 headers may define this
36 class WXDLLEXPORT wxCheckBox
: public wxCheckBoxBase
58 wxCheckBox() { Init(); }
60 wxCheckBox(wxWindow
*parent
,
62 const wxString
& label
,
63 const wxPoint
& pos
= wxDefaultPosition
,
64 const wxSize
& size
= wxDefaultSize
,
66 const wxValidator
& validator
= wxDefaultValidator
,
67 const wxString
& name
= wxCheckBoxNameStr
)
71 Create(parent
, id
, label
, pos
, size
, style
, validator
, name
);
74 bool Create(wxWindow
*parent
,
76 const wxString
& label
,
77 const wxPoint
& pos
= wxDefaultPosition
,
78 const wxSize
& size
= wxDefaultSize
,
80 const wxValidator
& validator
= wxDefaultValidator
,
81 const wxString
& name
= wxCheckBoxNameStr
);
83 // implement the checkbox interface
84 virtual void SetValue(bool value
);
85 virtual bool GetValue() const;
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;
94 virtual void Release();
95 virtual void ChangeValue(bool value
);
97 // overridden base class virtuals
98 virtual bool IsPressed() const { return m_isPressed
; }
101 virtual void DoSet3StateValue(wxCheckBoxState
WXUNUSED(state
));
102 virtual wxCheckBoxState
DoGet3StateValue() const;
104 virtual bool PerformAction(const wxControlAction
& action
,
106 const wxString
& strArg
= wxEmptyString
);
107 virtual void DoDraw(wxControlRenderer
*renderer
);
108 virtual wxSize
DoGetBestClientSize() const;
110 virtual bool CanBeHighlighted() const { return true; }
112 // get the size of the bitmap using either the current one or the default
113 // one (query renderer then)
114 virtual wxSize
GetBitmapSize() const;
116 // common part of all ctors
119 // send command event notifying about the checkbox state change
120 virtual void SendEvent();
122 // called when the checkbox becomes checked - radio button hook
123 virtual void OnCheck();
125 // get the state corresponding to the flags (combination of wxCONTROL_XXX)
126 wxCheckBox::State
GetState(int flags
) const;
128 // directly access the bitmaps array without trying to find a valid bitmap
129 // to use as GetBitmap() does
130 wxBitmap
DoGetBitmap(State state
, Status status
) const
131 { return m_bitmaps
[state
][status
]; }
133 // get the current status
134 Status
GetStatus() const { return m_status
; }
137 // the current check status
140 // the bitmaps to use for the different states
141 wxBitmap m_bitmaps
[State_Max
][Status_Max
];
143 // is the checkbox currently pressed?
146 DECLARE_DYNAMIC_CLASS(wxCheckBox
)
149 // ----------------------------------------------------------------------------
150 // wxStdCheckboxInputHandler: handles the mouse events for the check and radio
151 // boxes (handling the keyboard input is simple, but its handling differs a
152 // lot between GTK and MSW, so a new class should be derived for this)
153 // ----------------------------------------------------------------------------
155 class WXDLLEXPORT wxStdCheckboxInputHandler
: public wxStdButtonInputHandler
158 wxStdCheckboxInputHandler(wxInputHandler
*inphand
);
160 // we have to override this one as wxStdButtonInputHandler version works
161 // only with the buttons
162 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
165 #endif // _WX_UNIV_CHECKBOX_H_