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 SetFont(parent
->GetFont());
87 SetSize(x
, y
, width
, height
);
92 void wxCheckBox::SetLabel(const wxString
& label
)
97 wxSize
wxCheckBox::DoGetBestSize() const
99 int wCheckbox
, hCheckbox
;
101 wxString str
= wxGetWindowText(GetHWND());
103 if ( !str
.IsEmpty() )
105 GetTextExtent(str
, &wCheckbox
, &hCheckbox
);
106 wCheckbox
+= RADIO_SIZE
;
108 if ( hCheckbox
< RADIO_SIZE
)
109 hCheckbox
= RADIO_SIZE
;
113 wCheckbox
= RADIO_SIZE
;
114 hCheckbox
= RADIO_SIZE
;
117 return wxSize(wCheckbox
, hCheckbox
);
120 void wxCheckBox::SetValue(bool val
)
126 #define BST_CHECKED 0x0001
129 bool wxCheckBox::GetValue() const
135 WXHBRUSH
wxCheckBox::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
136 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
143 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
145 return (WXHBRUSH) hbrush;
149 if (GetParent()->GetTransparentBackground())
150 SetBkMode((HDC) pDC, TRANSPARENT);
152 SetBkMode((HDC) pDC, OPAQUE);
154 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
155 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
159 wxBrush
*backgroundBrush
= wxTheBrushList
->FindOrCreateBrush(GetBackgroundColour(), wxSOLID
);
162 // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
163 // has a zero usage count.
164 // backgroundBrush->RealizeResource();
165 return (WXHBRUSH
) backgroundBrush
->GetResourceHandle();
168 void wxCheckBox::Command (wxCommandEvent
& event
)
170 SetValue ((event
.GetInt() != 0));
171 ProcessCommand (event
);
174 // ----------------------------------------------------------------------------
176 // ----------------------------------------------------------------------------
178 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxBitmap
*label
,
180 const wxSize
& size
, long style
,
182 const wxValidator
& validator
,
184 const wxString
& name
)
188 SetValidator(validator
);
190 if (parent
) parent
->AddChild(this);
192 SetBackgroundColour(parent
->GetBackgroundColour()) ;
193 SetForegroundColour(parent
->GetForegroundColour()) ;
194 m_windowStyle
= style
;
197 m_windowId
= NewControlId();
208 // long msStyle = CHECK_FLAGS;
210 HWND wx_button
= 0; // TODO: Create the bitmap checkbox
212 m_hWnd
= (WXHWND
)wx_button
;
214 // Subclass again for purposes of dialog editing mode
215 SubclassWin((WXHWND
)wx_button
);
217 SetSize(x
, y
, width
, height
);
219 // TODO: ShowWindow(wx_button, SW_SHOW);
224 void wxBitmapCheckBox::SetLabel(const wxBitmap
& bitmap
)
226 wxFAIL_MSG(wxT("not implemented"));