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"
18 #include "wx/scrolwin.h"
19 #include "wx/dcscreen.h"
20 #include "wx/settings.h"
23 #include "wx/os2/private.h"
25 // ----------------------------------------------------------------------------
27 // ----------------------------------------------------------------------------
29 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
)
30 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
32 // ============================================================================
34 // ============================================================================
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 bool wxCheckBox::OS2Command(
41 WXUINT
WXUNUSED(uParam
)
42 , WXWORD
WXUNUSED(wId
)
45 wxCommandEvent
rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED
48 rEvent
.SetInt(GetValue());
49 rEvent
.SetEventObject(this);
50 ProcessCommand(rEvent
);
52 } // end of wxCheckBox::OS2Command
54 bool wxCheckBox::Create(
57 , const wxString
& rsLabel
62 , const wxValidator
& rValidator
64 , const wxString
& rsName
69 SetValidator(rValidator
);
72 pParent
->AddChild(this);
74 SetBackgroundColour(pParent
->GetBackgroundColour());
75 SetForegroundColour(pParent
->GetForegroundColour());
76 m_windowStyle
= lStyle
;
78 wxString sLabel
= rsLabel
;
80 if (sLabel
== wxT(""))
81 sLabel
= wxT(" "); // Apparently needed or checkbox won't show
84 m_windowId
= NewControlId();
91 int nHeight
= rSize
.y
;
94 lSstyle
= BS_AUTOCHECKBOX
|
97 if (lStyle
& wxCLIP_SIBLINGS
)
98 lSstyle
|= WS_CLIPSIBLINGS
;
101 // If the parent is a scrolled window the controls must
102 // have this style or they will overlap the scrollbars
105 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
106 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
107 lSstyle
|= WS_CLIPSIBLINGS
;
109 m_hWnd
= (WXHWND
)::WinCreateWindow ( GetHwndOf(pParent
)
122 // Subclass again for purposes of dialog editing mode
126 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
128 ::WinSetPresParam( m_hWnd
134 SetFont(*wxSMALL_FONT
);
142 } // end of wxCheckBox::Create
144 void wxCheckBox::SetLabel(
145 const wxString
& rsLabel
148 ::WinSetWindowText(GetHwnd(), rsLabel
.c_str());
149 } // end of wxCheckBox::SetLabel
151 wxSize
wxCheckBox::DoGetBestSize() const
153 static int nCheckSize
= 0;
159 vDc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
162 // The height of a standard button in the dialog units is 8,
163 // translate this to pixels (as one dialog unit is precisely equal to
164 // 8 character heights, it's just the char height)
166 nCheckSize
= vDc
.GetCharHeight();
171 wxString sStr
= wxGetWindowText(GetHWND());
179 nWidthCheckbox
+= nCheckSize
+ GetCharWidth();
181 if (nHeightCheckbox
< nCheckSize
)
182 nHeightCheckbox
= nCheckSize
;
186 nWidthCheckbox
= nCheckSize
;
187 nHeightCheckbox
= nCheckSize
;
190 return wxSize( nWidthCheckbox
193 } // end of wxCheckBox::DoGetBestSize
195 void wxCheckBox::SetValue(
199 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
200 } // end of wxCheckBox::SetValue
203 #define BST_CHECKED 0x0001
206 bool wxCheckBox::GetValue() const
208 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
209 } // end of wxCheckBox::GetValue
211 void wxCheckBox::Command (
212 wxCommandEvent
& rEvent
215 SetValue((rEvent
.GetInt() != 0));
216 ProcessCommand(rEvent
);
217 } // end of wxCheckBox:: Command
219 // ----------------------------------------------------------------------------
221 // ----------------------------------------------------------------------------
223 bool wxBitmapCheckBox::Create(
226 , const wxBitmap
* pLabel
227 , const wxPoint
& rPos
228 , const wxSize
& rSize
231 , const wxValidator
& rValidator
233 , const wxString
& rsName
238 SetValidator(rValidator
);
241 pParent
->AddChild(this);
243 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
244 SetForegroundColour(pParent
->GetForegroundColour()) ;
245 m_windowStyle
= lStyle
;
248 m_windowId
= NewControlId();
254 int nWidth
= rSize
.x
;
255 int nHeight
= rSize
.y
;
258 m_nCheckHeight
= -1 ;
259 // long msStyle = CHECK_FLAGS;
261 HWND hButton
= 0; // TODO: Create the bitmap checkbox
263 m_hWnd
= (WXHWND
)hButton
;
266 // Subclass again for purposes of dialog editing mode
268 SubclassWin((WXHWND
)hButton
);
276 ::WinShowWindow(hButton
, TRUE
);
278 } // end of wxBitmapCheckBox::Create
280 void wxBitmapCheckBox::SetLabel(
281 const wxBitmap
& rBitmap
284 wxFAIL_MSG(wxT("not implemented"));
285 } // end of wxBitmapCheckBox::SetLabel