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
,
52 const wxValidator
& validator
,
56 SetValidator(validator
);
57 if (parent
) parent
->AddChild(this);
59 SetBackgroundColour(parent
->GetBackgroundColour()) ;
60 SetForegroundColour(parent
->GetForegroundColour()) ;
62 m_windowStyle
= style
;
64 wxString Label
= label
;
66 Label
= wxT(" "); // Apparently needed or checkbox won't show
69 m_windowId
= NewControlId();
78 // TODO: create checkbox
80 // Subclass again for purposes of dialog editing mode
83 SetFont(parent
->GetFont());
85 SetSize(x
, y
, width
, height
);
90 void wxCheckBox::SetLabel(const wxString
& label
)
95 wxSize
wxCheckBox::DoGetBestSize()
97 int wCheckbox
, hCheckbox
;
99 wxString str
= wxGetWindowText(GetHWND());
101 if ( !str
.IsEmpty() )
103 GetTextExtent(str
, &wCheckbox
, &hCheckbox
);
104 wCheckbox
+= RADIO_SIZE
;
106 if ( hCheckbox
< RADIO_SIZE
)
107 hCheckbox
= RADIO_SIZE
;
111 wCheckbox
= RADIO_SIZE
;
112 hCheckbox
= RADIO_SIZE
;
115 return wxSize(wCheckbox
, hCheckbox
);
118 void wxCheckBox::SetValue(bool val
)
124 #define BST_CHECKED 0x0001
127 bool wxCheckBox::GetValue() const
133 WXHBRUSH
wxCheckBox::OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
134 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
141 HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
143 return (WXHBRUSH) hbrush;
147 if (GetParent()->GetTransparentBackground())
148 SetBkMode((HDC) pDC, TRANSPARENT);
150 SetBkMode((HDC) pDC, OPAQUE);
152 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
153 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
157 wxBrush
*backgroundBrush
= wxTheBrushList
->FindOrCreateBrush(GetBackgroundColour(), wxSOLID
);
160 // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
161 // has a zero usage count.
162 // backgroundBrush->RealizeResource();
163 return (WXHBRUSH
) backgroundBrush
->GetResourceHandle();
166 void wxCheckBox::Command (wxCommandEvent
& event
)
168 SetValue ((event
.GetInt() != 0));
169 ProcessCommand (event
);
172 // ----------------------------------------------------------------------------
174 // ----------------------------------------------------------------------------
176 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxBitmap
*label
,
178 const wxSize
& size
, long style
,
179 const wxValidator
& validator
,
180 const wxString
& name
)
183 SetValidator(validator
);
184 if (parent
) parent
->AddChild(this);
186 SetBackgroundColour(parent
->GetBackgroundColour()) ;
187 SetForegroundColour(parent
->GetForegroundColour()) ;
188 m_windowStyle
= style
;
191 m_windowId
= NewControlId();
202 long msStyle
= CHECK_FLAGS
;
204 HWND wx_button
= 0; // TODO: Create the bitmap checkbox
206 m_hWnd
= (WXHWND
)wx_button
;
208 // Subclass again for purposes of dialog editing mode
209 SubclassWin((WXHWND
)wx_button
);
211 SetSize(x
, y
, width
, height
);
213 // TODO: ShowWindow(wx_button, SW_SHOW);
218 void wxBitmapCheckBox::SetLabel(const wxBitmap
& bitmap
)
220 wxFAIL_MSG(wxT("not implemented"));