]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/checkbox.h
Remove all lines containing cvs/svn "$Id$" keyword.
[wxWidgets.git] / include / wx / univ / checkbox.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/checkbox.h
3 // Purpose: wxCheckBox declaration
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 07.09.00
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_UNIV_CHECKBOX_H_
12 #define _WX_UNIV_CHECKBOX_H_
13
14 #include "wx/button.h" // for wxStdButtonInputHandler
15
16 // ----------------------------------------------------------------------------
17 // the actions supported by wxCheckBox
18 // ----------------------------------------------------------------------------
19
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
23
24 // additionally it accepts wxACTION_BUTTON_PRESS and RELEASE
25
26 // ----------------------------------------------------------------------------
27 // wxCheckBox
28 // ----------------------------------------------------------------------------
29
30 class WXDLLIMPEXP_CORE wxCheckBox : public wxCheckBoxBase
31 {
32 public:
33 // checkbox constants
34 enum State
35 {
36 State_Normal,
37 State_Pressed,
38 State_Disabled,
39 State_Current,
40 State_Max
41 };
42
43 enum Status
44 {
45 Status_Checked,
46 Status_Unchecked,
47 Status_3rdState,
48 Status_Max
49 };
50
51 // constructors
52 wxCheckBox() { Init(); }
53
54 wxCheckBox(wxWindow *parent,
55 wxWindowID id,
56 const wxString& label,
57 const wxPoint& pos = wxDefaultPosition,
58 const wxSize& size = wxDefaultSize,
59 long style = 0,
60 const wxValidator& validator = wxDefaultValidator,
61 const wxString& name = wxCheckBoxNameStr)
62 {
63 Init();
64
65 Create(parent, id, label, pos, size, style, validator, name);
66 }
67
68 bool Create(wxWindow *parent,
69 wxWindowID id,
70 const wxString& label,
71 const wxPoint& pos = wxDefaultPosition,
72 const wxSize& size = wxDefaultSize,
73 long style = 0,
74 const wxValidator& validator = wxDefaultValidator,
75 const wxString& name = wxCheckBoxNameStr);
76
77 // implement the checkbox interface
78 virtual void SetValue(bool value);
79 virtual bool GetValue() const;
80
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;
84
85 // wxCheckBox actions
86 void Toggle();
87 virtual void Press();
88 virtual void Release();
89 virtual void ChangeValue(bool value);
90
91 // overridden base class virtuals
92 virtual bool IsPressed() const { return m_isPressed; }
93
94 virtual bool PerformAction(const wxControlAction& action,
95 long numArg = -1,
96 const wxString& strArg = wxEmptyString);
97
98 virtual bool CanBeHighlighted() const { return true; }
99 virtual wxInputHandler *CreateStdInputHandler(wxInputHandler *handlerDef);
100 virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
101 {
102 return CreateStdInputHandler(handlerDef);
103 }
104
105 protected:
106 virtual void DoSet3StateValue(wxCheckBoxState WXUNUSED(state));
107 virtual wxCheckBoxState DoGet3StateValue() const;
108
109 virtual void DoDraw(wxControlRenderer *renderer);
110 virtual wxSize DoGetBestClientSize() const;
111
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;
115
116 // common part of all ctors
117 void Init();
118
119 // send command event notifying about the checkbox state change
120 virtual void SendEvent();
121
122 // called when the checkbox becomes checked - radio button hook
123 virtual void OnCheck();
124
125 // get the state corresponding to the flags (combination of wxCONTROL_XXX)
126 wxCheckBox::State GetState(int flags) const;
127
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]; }
132
133 // get the current status
134 Status GetStatus() const { return m_status; }
135
136 private:
137 // the current check status
138 Status m_status;
139
140 // the bitmaps to use for the different states
141 wxBitmap m_bitmaps[State_Max][Status_Max];
142
143 // is the checkbox currently pressed?
144 bool m_isPressed;
145
146 DECLARE_DYNAMIC_CLASS(wxCheckBox)
147 };
148
149 #endif // _WX_UNIV_CHECKBOX_H_