]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/checkbox.h
Added MSWPositionForWxMenu() method which is used to translate wxWindows
[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 // RCS-ID: $Id$
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UNIV_CHECKBOX_H_
13 #define _WX_UNIV_CHECKBOX_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "univcheckbox.h"
17 #endif
18
19 #include "wx/button.h" // for wxStdButtonInputHandler
20
21 // ----------------------------------------------------------------------------
22 // the actions supported by wxCheckBox
23 // ----------------------------------------------------------------------------
24
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
28
29 // additionally it accepts wxACTION_BUTTON_PRESS and RELEASE
30
31 // ----------------------------------------------------------------------------
32 // wxCheckBox
33 // ----------------------------------------------------------------------------
34
35 // X11 headers may define this
36 #ifdef Status
37 #undef Status
38 #endif
39
40 class WXDLLEXPORT wxCheckBox : public wxCheckBoxBase
41 {
42 public:
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,
57 Status_Unknown,
58 Status_Max
59 };
60
61 // constructors
62 wxCheckBox();
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,
71 const wxString& name = wxCheckBoxNameStr);
72
73 bool Create(wxWindow *parent,
74 wxWindowID id,
75 const wxString& label,
76 const wxPoint& pos = wxDefaultPosition,
77 const wxSize& size = wxDefaultSize,
78 long style = 0,
79 const wxValidator& validator = wxDefaultValidator,
80 const wxString& name = wxCheckBoxNameStr);
81
82 // implement the checkbox interface
83 virtual void SetValue(bool value);
84 virtual bool GetValue() const;
85
86 // set/get the bitmaps to use for the checkbox indicator
87 void SetBitmap(const wxBitmap& bmp, State state, Status status);
88 virtual wxBitmap GetBitmap(State state, Status status) const;
89
90 // wxCheckBox actions
91 void Toggle();
92 virtual void Press();
93 virtual void Release();
94 virtual void ChangeValue(bool value);
95
96 // overridden base class virtuals
97 virtual bool IsPressed() const { return m_isPressed; }
98
99 virtual bool HasTransparentBackground() { return TRUE; }
100
101 protected:
102 virtual bool PerformAction(const wxControlAction& action,
103 long numArg = -1,
104 const wxString& strArg = wxEmptyString);
105 virtual void DoDraw(wxControlRenderer *renderer);
106 virtual wxSize DoGetBestClientSize() const;
107
108 virtual bool CanBeHighlighted() const { return TRUE; }
109
110 // get the size of the bitmap using either the current one or the default
111 // one (query renderer then)
112 virtual wxSize GetBitmapSize() const;
113
114 // common part of all ctors
115 void Init();
116
117 // send command event notifying about the checkbox state change
118 virtual void SendEvent();
119
120 // called when the checkbox becomes checked - radio button hook
121 virtual void OnCheck();
122
123 // get the state corresponding to the flags (combination of wxCONTROL_XXX)
124 wxCheckBox::State GetState(int flags) const;
125
126 // directly access the bitmaps array without trying to find a valid bitmap
127 // to use as GetBitmap() does
128 wxBitmap DoGetBitmap(State state, Status status) const
129 { return m_bitmaps[state][status]; }
130
131 // get the current status
132 Status GetStatus() const { return m_status; }
133
134 private:
135 // the current check status
136 Status m_status;
137
138 // the bitmaps to use for the different states
139 wxBitmap m_bitmaps[State_Max][Status_Max];
140
141 // is the checkbox currently pressed?
142 bool m_isPressed;
143
144 DECLARE_DYNAMIC_CLASS(wxCheckBox)
145 };
146
147 // ----------------------------------------------------------------------------
148 // wxStdCheckboxInputHandler: handles the mouse events for the check and radio
149 // boxes (handling the keyboard input is simple, but its handling differs a
150 // lot between GTK and MSW, so a new class should be derived for this)
151 // ----------------------------------------------------------------------------
152
153 class WXDLLEXPORT wxStdCheckboxInputHandler : public wxStdButtonInputHandler
154 {
155 public:
156 wxStdCheckboxInputHandler(wxInputHandler *inphand);
157
158 // we have to override this one as wxStdButtonInputHandler version works
159 // only with the buttons
160 virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
161 };
162
163 #endif // _WX_UNIV_CHECKBOX_H_