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