1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
16 #include "wx/checkbox.h"
20 #include "wx/os2/private.h"
22 // ----------------------------------------------------------------------------
24 // ----------------------------------------------------------------------------
26 #if !USE_SHARED_LIBRARY
27 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
)
28 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
31 // ============================================================================
33 // ============================================================================
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 bool wxCheckBox::OS2Command(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
41 wxCommandEvent
event(wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
42 event
.SetInt(GetValue());
43 event
.SetEventObject(this);
44 ProcessCommand(event
);
48 // Single check box item
49 bool wxCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxString
& label
,
51 const wxSize
& size
, long style
,
53 const wxValidator
& validator
,
59 SetValidator(validator
);
61 if (parent
) parent
->AddChild(this);
63 SetBackgroundColour(parent
->GetBackgroundColour()) ;
64 SetForegroundColour(parent
->GetForegroundColour()) ;
66 m_windowStyle
= style
;
68 wxString Label
= label
;
70 Label
= wxT(" "); // Apparently needed or checkbox won't show
73 m_windowId
= NewControlId();
82 // TODO: create checkbox
84 // Subclass again for purposes of dialog editing mode
87 SetFont(parent
->GetFont());
89 SetSize(x
, y
, width
, height
);
94 void wxCheckBox::SetLabel(const wxString
& label
)
99 wxSize
wxCheckBox::DoGetBestSize() const
101 int wCheckbox
, hCheckbox
;
103 wxString str
= wxGetWindowText(GetHWND());
105 if ( !str
.IsEmpty() )
107 GetTextExtent(str
, &wCheckbox
, &hCheckbox
);
108 wCheckbox
+= RADIO_SIZE
;
110 if ( hCheckbox
< RADIO_SIZE
)
111 hCheckbox
= RADIO_SIZE
;
115 wCheckbox
= RADIO_SIZE
;
116 hCheckbox
= RADIO_SIZE
;
119 return wxSize(wCheckbox
, hCheckbox
);
122 void wxCheckBox::SetValue(bool val
)
128 #define BST_CHECKED 0x0001
131 bool wxCheckBox::GetValue() const
137 WXHBRUSH
wxCheckBox::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
138 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
145 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
147 return (WXHBRUSH) hbrush;
151 if (GetParent()->GetTransparentBackground())
152 SetBkMode((HDC) pDC, TRANSPARENT);
154 SetBkMode((HDC) pDC, OPAQUE);
156 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
157 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
161 wxBrush
*backgroundBrush
= wxTheBrushList
->FindOrCreateBrush(GetBackgroundColour(), wxSOLID
);
164 // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
165 // has a zero usage count.
166 // backgroundBrush->RealizeResource();
167 return (WXHBRUSH
) backgroundBrush
->GetResourceHandle();
170 void wxCheckBox::Command (wxCommandEvent
& event
)
172 SetValue ((event
.GetInt() != 0));
173 ProcessCommand (event
);
176 // ----------------------------------------------------------------------------
178 // ----------------------------------------------------------------------------
180 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxBitmap
*label
,
182 const wxSize
& size
, long style
,
184 const wxValidator
& validator
,
186 const wxString
& name
)
190 SetValidator(validator
);
192 if (parent
) parent
->AddChild(this);
194 SetBackgroundColour(parent
->GetBackgroundColour()) ;
195 SetForegroundColour(parent
->GetForegroundColour()) ;
196 m_windowStyle
= style
;
199 m_windowId
= NewControlId();
210 // long msStyle = CHECK_FLAGS;
212 HWND wx_button
= 0; // TODO: Create the bitmap checkbox
214 m_hWnd
= (WXHWND
)wx_button
;
216 // Subclass again for purposes of dialog editing mode
217 SubclassWin((WXHWND
)wx_button
);
219 SetSize(x
, y
, width
, height
);
221 // TODO: ShowWindow(wx_button, SW_SHOW);
226 void wxBitmapCheckBox::SetLabel(const wxBitmap
& bitmap
)
228 wxFAIL_MSG(wxT("not implemented"));