1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/checkbox.h
3 // Purpose: wxCheckBox declaration
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIV_CHECKBOX_H_
12 #define _WX_UNIV_CHECKBOX_H_
14 #include "wx/button.h" // for wxStdButtonInputHandler
16 // ----------------------------------------------------------------------------
17 // the actions supported by wxCheckBox
18 // ----------------------------------------------------------------------------
20 #define wxACTION_CHECKBOX_CHECK wxT("check") // SetValue(true)
21 #define wxACTION_CHECKBOX_CLEAR wxT("clear") // SetValue(false)
22 #define wxACTION_CHECKBOX_TOGGLE wxT("toggle") // toggle the check state
24 // additionally it accepts wxACTION_BUTTON_PRESS and RELEASE
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 class WXDLLIMPEXP_CORE wxCheckBox
: public wxCheckBoxBase
52 wxCheckBox() { Init(); }
54 wxCheckBox(wxWindow
*parent
,
56 const wxString
& label
,
57 const wxPoint
& pos
= wxDefaultPosition
,
58 const wxSize
& size
= wxDefaultSize
,
60 const wxValidator
& validator
= wxDefaultValidator
,
61 const wxString
& name
= wxCheckBoxNameStr
)
65 Create(parent
, id
, label
, pos
, size
, style
, validator
, name
);
68 bool Create(wxWindow
*parent
,
70 const wxString
& label
,
71 const wxPoint
& pos
= wxDefaultPosition
,
72 const wxSize
& size
= wxDefaultSize
,
74 const wxValidator
& validator
= wxDefaultValidator
,
75 const wxString
& name
= wxCheckBoxNameStr
);
77 // implement the checkbox interface
78 virtual void SetValue(bool value
);
79 virtual bool GetValue() const;
81 // set/get the bitmaps to use for the checkbox indicator
82 void SetBitmap(const wxBitmap
& bmp
, State state
, Status status
);
83 virtual wxBitmap
GetBitmap(State state
, Status status
) const;
88 virtual void Release();
89 virtual void ChangeValue(bool value
);
91 // overridden base class virtuals
92 virtual bool IsPressed() const { return m_isPressed
; }
94 virtual bool PerformAction(const wxControlAction
& action
,
96 const wxString
& strArg
= wxEmptyString
);
98 virtual bool CanBeHighlighted() const { return true; }
99 virtual wxInputHandler
*CreateStdInputHandler(wxInputHandler
*handlerDef
);
100 virtual wxInputHandler
*DoGetStdInputHandler(wxInputHandler
*handlerDef
)
102 return CreateStdInputHandler(handlerDef
);
106 virtual void DoSet3StateValue(wxCheckBoxState
WXUNUSED(state
));
107 virtual wxCheckBoxState
DoGet3StateValue() const;
109 virtual void DoDraw(wxControlRenderer
*renderer
);
110 virtual wxSize
DoGetBestClientSize() const;
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 #endif // _WX_UNIV_CHECKBOX_H_