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 # if defined(__VISAGECPP__)
54 const wxValidator
* validator
,
56 const wxValidator
& validator
,
63 SetValidator(validator
);
65 if (parent
) parent
->AddChild(this);
67 SetBackgroundColour(parent
->GetBackgroundColour()) ;
68 SetForegroundColour(parent
->GetForegroundColour()) ;
70 m_windowStyle
= style
;
72 wxString Label
= label
;
74 Label
= wxT(" "); // Apparently needed or checkbox won't show
77 m_windowId
= NewControlId();
86 // TODO: create checkbox
88 // Subclass again for purposes of dialog editing mode
91 SetFont(parent
->GetFont());
93 SetSize(x
, y
, width
, height
);
98 void wxCheckBox::SetLabel(const wxString
& label
)
103 wxSize
wxCheckBox::DoGetBestSize()
105 int wCheckbox
, hCheckbox
;
107 wxString str
= wxGetWindowText(GetHWND());
109 if ( !str
.IsEmpty() )
111 GetTextExtent(str
, &wCheckbox
, &hCheckbox
);
112 wCheckbox
+= RADIO_SIZE
;
114 if ( hCheckbox
< RADIO_SIZE
)
115 hCheckbox
= RADIO_SIZE
;
119 wCheckbox
= RADIO_SIZE
;
120 hCheckbox
= RADIO_SIZE
;
123 return wxSize(wCheckbox
, hCheckbox
);
126 void wxCheckBox::SetValue(bool val
)
132 #define BST_CHECKED 0x0001
135 bool wxCheckBox::GetValue() const
141 WXHBRUSH
wxCheckBox::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
142 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
149 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
151 return (WXHBRUSH) hbrush;
155 if (GetParent()->GetTransparentBackground())
156 SetBkMode((HDC) pDC, TRANSPARENT);
158 SetBkMode((HDC) pDC, OPAQUE);
160 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
161 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
165 wxBrush
*backgroundBrush
= wxTheBrushList
->FindOrCreateBrush(GetBackgroundColour(), wxSOLID
);
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();
174 void wxCheckBox::Command (wxCommandEvent
& event
)
176 SetValue ((event
.GetInt() != 0));
177 ProcessCommand (event
);
180 // ----------------------------------------------------------------------------
182 // ----------------------------------------------------------------------------
184 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxBitmap
*label
,
186 const wxSize
& size
, long style
,
188 # if defined(__VISAGECPP__)
189 const wxValidator
* validator
,
191 const wxValidator
& validator
,
194 const wxString
& name
)
198 SetValidator(validator
);
200 if (parent
) parent
->AddChild(this);
202 SetBackgroundColour(parent
->GetBackgroundColour()) ;
203 SetForegroundColour(parent
->GetForegroundColour()) ;
204 m_windowStyle
= style
;
207 m_windowId
= NewControlId();
218 long msStyle
= CHECK_FLAGS
;
220 HWND wx_button
= 0; // TODO: Create the bitmap checkbox
222 m_hWnd
= (WXHWND
)wx_button
;
224 // Subclass again for purposes of dialog editing mode
225 SubclassWin((WXHWND
)wx_button
);
227 SetSize(x
, y
, width
, height
);
229 // TODO: ShowWindow(wx_button, SW_SHOW);
234 void wxBitmapCheckBox::SetLabel(const wxBitmap
& bitmap
)
236 wxFAIL_MSG(wxT("not implemented"));