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 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
)
27 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
29 // ============================================================================
31 // ============================================================================
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 bool wxCheckBox::OS2Command(WXUINT
WXUNUSED(param
), WXWORD
WXUNUSED(id
))
39 wxCommandEvent
event(wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
40 event
.SetInt(GetValue());
41 event
.SetEventObject(this);
42 ProcessCommand(event
);
46 // Single check box item
47 bool wxCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxString
& label
,
49 const wxSize
& size
, long style
,
51 const wxValidator
& validator
,
57 SetValidator(validator
);
59 if (parent
) parent
->AddChild(this);
61 SetBackgroundColour(parent
->GetBackgroundColour()) ;
62 SetForegroundColour(parent
->GetForegroundColour()) ;
64 m_windowStyle
= style
;
66 wxString Label
= label
;
68 Label
= wxT(" "); // Apparently needed or checkbox won't show
71 m_windowId
= NewControlId();
80 // TODO: create checkbox
82 // Subclass again for purposes of dialog editing mode
85 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
87 ::WinSetPresParam( m_hWnd
93 SetFont(parent
->GetFont());
95 SetSize(x
, y
, width
, height
);
100 void wxCheckBox::SetLabel(const wxString
& label
)
105 wxSize
wxCheckBox::DoGetBestSize() const
107 int wCheckbox
, hCheckbox
;
109 wxString str
= wxGetWindowText(GetHWND());
111 if ( !str
.IsEmpty() )
113 GetTextExtent(str
, &wCheckbox
, &hCheckbox
);
114 wCheckbox
+= RADIO_SIZE
;
116 if ( hCheckbox
< RADIO_SIZE
)
117 hCheckbox
= RADIO_SIZE
;
121 wCheckbox
= RADIO_SIZE
;
122 hCheckbox
= RADIO_SIZE
;
125 return wxSize(wCheckbox
, hCheckbox
);
128 void wxCheckBox::SetValue(bool val
)
134 #define BST_CHECKED 0x0001
137 bool wxCheckBox::GetValue() const
143 WXHBRUSH
wxCheckBox::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
144 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
151 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
153 return (WXHBRUSH) hbrush;
157 if (GetParent()->GetTransparentBackground())
158 SetBkMode((HDC) pDC, TRANSPARENT);
160 SetBkMode((HDC) pDC, OPAQUE);
162 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
163 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
167 wxBrush
*backgroundBrush
= wxTheBrushList
->FindOrCreateBrush(GetBackgroundColour(), wxSOLID
);
170 // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
171 // has a zero usage count.
172 // backgroundBrush->RealizeResource();
173 return (WXHBRUSH
) backgroundBrush
->GetResourceHandle();
176 void wxCheckBox::Command (wxCommandEvent
& event
)
178 SetValue ((event
.GetInt() != 0));
179 ProcessCommand (event
);
182 // ----------------------------------------------------------------------------
184 // ----------------------------------------------------------------------------
186 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxBitmap
*label
,
188 const wxSize
& size
, long style
,
190 const wxValidator
& validator
,
192 const wxString
& name
)
196 SetValidator(validator
);
198 if (parent
) parent
->AddChild(this);
200 SetBackgroundColour(parent
->GetBackgroundColour()) ;
201 SetForegroundColour(parent
->GetForegroundColour()) ;
202 m_windowStyle
= style
;
205 m_windowId
= NewControlId();
216 // long msStyle = CHECK_FLAGS;
218 HWND wx_button
= 0; // TODO: Create the bitmap checkbox
220 m_hWnd
= (WXHWND
)wx_button
;
222 // Subclass again for purposes of dialog editing mode
223 SubclassWin((WXHWND
)wx_button
);
225 SetSize(x
, y
, width
, height
);
227 // TODO: ShowWindow(wx_button, SW_SHOW);
232 void wxBitmapCheckBox::SetLabel(const wxBitmap
& bitmap
)
234 wxFAIL_MSG(wxT("not implemented"));