]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: checkbox.cpp | |
3 | // Purpose: wxCheckBox | |
37f214d5 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
37f214d5 | 6 | // Created: 10/13/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
37f214d5 DW |
8 | // Copyright: (c) David Webster |
9 | // Licence: wxWindows licence | |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
37f214d5 DW |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifndef WX_PRECOMP | |
16 | #include "wx/checkbox.h" | |
17 | #include "wx/brush.h" | |
0e320a79 DW |
18 | #endif |
19 | ||
37f214d5 DW |
20 | #include "wx/os2/private.h" |
21 | ||
22 | // ---------------------------------------------------------------------------- | |
23 | // macros | |
24 | // ---------------------------------------------------------------------------- | |
0e320a79 DW |
25 | |
26 | #if !USE_SHARED_LIBRARY | |
27 | IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) | |
28 | IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox) | |
29 | #endif | |
30 | ||
37f214d5 DW |
31 | // ============================================================================ |
32 | // implementation | |
33 | // ============================================================================ | |
34 | ||
35 | // ---------------------------------------------------------------------------- | |
36 | // wxCheckBox | |
37 | // ---------------------------------------------------------------------------- | |
38 | ||
39 | bool wxCheckBox::OS2Command(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id)) | |
40 | { | |
41 | wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId); | |
42 | event.SetInt(GetValue()); | |
43 | event.SetEventObject(this); | |
44 | ProcessCommand(event); | |
45 | return TRUE; | |
46 | } | |
47 | ||
0e320a79 DW |
48 | // Single check box item |
49 | bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, | |
50 | const wxPoint& pos, | |
51 | const wxSize& size, long style, | |
52 | const wxValidator& validator, | |
53 | const wxString& name) | |
54 | { | |
55 | SetName(name); | |
56 | SetValidator(validator); | |
37f214d5 DW |
57 | if (parent) parent->AddChild(this); |
58 | ||
59 | SetBackgroundColour(parent->GetBackgroundColour()) ; | |
60 | SetForegroundColour(parent->GetForegroundColour()) ; | |
61 | ||
0e320a79 DW |
62 | m_windowStyle = style; |
63 | ||
37f214d5 DW |
64 | wxString Label = label; |
65 | if (Label == wxT("")) | |
66 | Label = wxT(" "); // Apparently needed or checkbox won't show | |
0e320a79 DW |
67 | |
68 | if ( id == -1 ) | |
69 | m_windowId = NewControlId(); | |
70 | else | |
71 | m_windowId = id; | |
72 | ||
37f214d5 DW |
73 | int x = pos.x; |
74 | int y = pos.y; | |
75 | int width = size.x; | |
76 | int height = size.y; | |
77 | ||
0e320a79 DW |
78 | // TODO: create checkbox |
79 | ||
37f214d5 DW |
80 | // Subclass again for purposes of dialog editing mode |
81 | SubclassWin(m_hWnd); | |
82 | ||
83 | SetFont(parent->GetFont()); | |
84 | ||
85 | SetSize(x, y, width, height); | |
86 | ||
0e320a79 DW |
87 | return FALSE; |
88 | } | |
89 | ||
90 | void wxCheckBox::SetLabel(const wxString& label) | |
91 | { | |
92 | // TODO | |
93 | } | |
94 | ||
37f214d5 | 95 | wxSize wxCheckBox::DoGetBestSize() |
0e320a79 | 96 | { |
37f214d5 DW |
97 | int wCheckbox, hCheckbox; |
98 | ||
99 | wxString str = wxGetWindowText(GetHWND()); | |
100 | ||
101 | if ( !str.IsEmpty() ) | |
102 | { | |
103 | GetTextExtent(str, &wCheckbox, &hCheckbox); | |
104 | wCheckbox += RADIO_SIZE; | |
105 | ||
106 | if ( hCheckbox < RADIO_SIZE ) | |
107 | hCheckbox = RADIO_SIZE; | |
108 | } | |
109 | else | |
110 | { | |
111 | wCheckbox = RADIO_SIZE; | |
112 | hCheckbox = RADIO_SIZE; | |
113 | } | |
114 | ||
115 | return wxSize(wCheckbox, hCheckbox); | |
0e320a79 DW |
116 | } |
117 | ||
118 | void wxCheckBox::SetValue(bool val) | |
119 | { | |
120 | // TODO | |
121 | } | |
122 | ||
37f214d5 DW |
123 | #ifndef BST_CHECKED |
124 | #define BST_CHECKED 0x0001 | |
125 | #endif | |
126 | ||
0e320a79 DW |
127 | bool wxCheckBox::GetValue() const |
128 | { | |
129 | // TODO | |
130 | return FALSE; | |
131 | } | |
132 | ||
37f214d5 DW |
133 | WXHBRUSH wxCheckBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
134 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam) | |
135 | { | |
136 | // TODO: | |
137 | /* | |
138 | #if wxUSE_CTL3D | |
139 | if ( m_useCtl3D ) | |
140 | { | |
141 | HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam); | |
142 | ||
143 | return (WXHBRUSH) hbrush; | |
144 | } | |
145 | #endif | |
146 | ||
147 | if (GetParent()->GetTransparentBackground()) | |
148 | SetBkMode((HDC) pDC, TRANSPARENT); | |
149 | else | |
150 | SetBkMode((HDC) pDC, OPAQUE); | |
151 | ||
152 | ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue())); | |
153 | ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue())); | |
154 | ||
155 | */ | |
156 | ||
157 | wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID); | |
158 | ||
159 | ||
160 | // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush | |
161 | // has a zero usage count. | |
162 | // backgroundBrush->RealizeResource(); | |
163 | return (WXHBRUSH) backgroundBrush->GetResourceHandle(); | |
164 | } | |
165 | ||
0e320a79 DW |
166 | void wxCheckBox::Command (wxCommandEvent & event) |
167 | { | |
168 | SetValue ((event.GetInt() != 0)); | |
169 | ProcessCommand (event); | |
170 | } | |
171 | ||
37f214d5 DW |
172 | // ---------------------------------------------------------------------------- |
173 | // wxBitmapCheckBox | |
174 | // ---------------------------------------------------------------------------- | |
175 | ||
0e320a79 DW |
176 | bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label, |
177 | const wxPoint& pos, | |
178 | const wxSize& size, long style, | |
179 | const wxValidator& validator, | |
180 | const wxString& name) | |
181 | { | |
182 | SetName(name); | |
183 | SetValidator(validator); | |
0e320a79 DW |
184 | if (parent) parent->AddChild(this); |
185 | ||
37f214d5 DW |
186 | SetBackgroundColour(parent->GetBackgroundColour()) ; |
187 | SetForegroundColour(parent->GetForegroundColour()) ; | |
188 | m_windowStyle = style; | |
189 | ||
0e320a79 DW |
190 | if ( id == -1 ) |
191 | m_windowId = NewControlId(); | |
192 | else | |
193 | m_windowId = id; | |
194 | ||
37f214d5 DW |
195 | int x = pos.x; |
196 | int y = pos.y; | |
197 | int width = size.x; | |
198 | int height = size.y; | |
0e320a79 | 199 | |
37f214d5 DW |
200 | checkWidth = -1 ; |
201 | checkHeight = -1 ; | |
202 | long msStyle = CHECK_FLAGS; | |
0e320a79 | 203 | |
37f214d5 | 204 | HWND wx_button = 0; // TODO: Create the bitmap checkbox |
0e320a79 | 205 | |
37f214d5 | 206 | m_hWnd = (WXHWND)wx_button; |
0e320a79 | 207 | |
37f214d5 DW |
208 | // Subclass again for purposes of dialog editing mode |
209 | SubclassWin((WXHWND)wx_button); | |
210 | ||
211 | SetSize(x, y, width, height); | |
212 | ||
213 | // TODO: ShowWindow(wx_button, SW_SHOW); | |
214 | ||
215 | return TRUE; | |
0e320a79 DW |
216 | } |
217 | ||
37f214d5 | 218 | void wxBitmapCheckBox::SetLabel(const wxBitmap& bitmap) |
0e320a79 | 219 | { |
37f214d5 | 220 | wxFAIL_MSG(wxT("not implemented")); |
0e320a79 DW |
221 | } |
222 |