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
;
100 m_hWnd
= (WXHWND
)::WinCreateWindow ( GetHwndOf(pParent
)
113 // Subclass again for purposes of dialog editing mode
117 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
119 ::WinSetPresParam( m_hWnd
125 wxFont
* pTextFont
= new wxFont( 10
138 } // end of wxCheckBox::Create
140 void wxCheckBox::SetLabel(
141 const wxString
& rsLabel
144 ::WinSetWindowText(GetHwnd(), rsLabel
.c_str());
145 } // end of wxCheckBox::SetLabel
147 wxSize
wxCheckBox::DoGetBestSize() const
149 static int nCheckSize
= 0;
155 vDc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
158 // The height of a standard button in the dialog units is 8,
159 // translate this to pixels (as one dialog unit is precisely equal to
160 // 8 character heights, it's just the char height)
162 nCheckSize
= vDc
.GetCharHeight();
167 wxString sStr
= wxGetWindowText(GetHWND());
175 nWidthCheckbox
+= nCheckSize
+ GetCharWidth();
177 if (nHeightCheckbox
< nCheckSize
)
178 nHeightCheckbox
= nCheckSize
;
182 nWidthCheckbox
= nCheckSize
;
183 nHeightCheckbox
= nCheckSize
;
186 return wxSize( nWidthCheckbox
189 } // end of wxCheckBox::DoGetBestSize
191 void wxCheckBox::SetValue(
195 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
196 } // end of wxCheckBox::SetValue
199 #define BST_CHECKED 0x0001
202 bool wxCheckBox::GetValue() const
204 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
205 } // end of wxCheckBox::GetValue
207 void wxCheckBox::Command (
208 wxCommandEvent
& rEvent
211 SetValue((rEvent
.GetInt() != 0));
212 ProcessCommand(rEvent
);
213 } // end of wxCheckBox:: Command
215 // ----------------------------------------------------------------------------
217 // ----------------------------------------------------------------------------
219 bool wxBitmapCheckBox::Create(
222 , const wxBitmap
* pLabel
223 , const wxPoint
& rPos
224 , const wxSize
& rSize
227 , const wxValidator
& rValidator
229 , const wxString
& rsName
234 SetValidator(rValidator
);
237 pParent
->AddChild(this);
239 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
240 SetForegroundColour(pParent
->GetForegroundColour()) ;
241 m_windowStyle
= lStyle
;
244 m_windowId
= NewControlId();
250 int nWidth
= rSize
.x
;
251 int nHeight
= rSize
.y
;
254 m_nCheckHeight
= -1 ;
255 // long msStyle = CHECK_FLAGS;
257 HWND hButton
= 0; // TODO: Create the bitmap checkbox
259 m_hWnd
= (WXHWND
)hButton
;
262 // Subclass again for purposes of dialog editing mode
264 SubclassWin((WXHWND
)hButton
);
272 ::WinShowWindow(hButton
, TRUE
);
274 } // end of wxBitmapCheckBox::Create
276 void wxBitmapCheckBox::SetLabel(
277 const wxBitmap
& rBitmap
280 wxFAIL_MSG(wxT("not implemented"));
281 } // end of wxBitmapCheckBox::SetLabel