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 extern void wxAssociateWinWithHandle( HWND hWnd
36 // ============================================================================
38 // ============================================================================
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 bool wxCheckBox::OS2Command(
45 WXUINT
WXUNUSED(uParam
)
46 , WXWORD
WXUNUSED(wId
)
49 wxCommandEvent
rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED
52 rEvent
.SetInt(GetValue());
53 rEvent
.SetEventObject(this);
54 ProcessCommand(rEvent
);
56 } // end of wxCheckBox::OS2Command
58 bool wxCheckBox::Create(
61 , const wxString
& rsLabel
66 , const wxValidator
& rValidator
68 , const wxString
& rsName
74 if (!CreateControl( pParent
87 long osStyle
= BS_AUTOCHECKBOX
|
91 bOk
= OS2CreateControl( wxT("BUTTON")
98 m_backgroundColour
= pParent
->GetBackgroundColour();
99 lColor
= (LONG
)m_backgroundColour
.GetPixel();
100 ::WinSetPresParam( m_hWnd
105 wxAssociateWinWithHandle(m_hWnd
, this);
107 } // end of wxCheckBox::Create
109 void wxCheckBox::SetLabel(
110 const wxString
& rsLabel
113 ::WinSetWindowText(GetHwnd(), rsLabel
.c_str());
114 } // end of wxCheckBox::SetLabel
116 wxSize
wxCheckBox::DoGetBestSize() const
118 static int nCheckSize
= 0;
124 vDc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
127 // The height of a standard button in the dialog units is 8,
128 // translate this to pixels (as one dialog unit is precisely equal to
129 // 8 character heights, it's just the char height)
131 nCheckSize
= vDc
.GetCharHeight();
136 wxString sStr
= wxGetWindowText(GetHWND());
144 nWidthCheckbox
+= nCheckSize
+ GetCharWidth();
146 if (nHeightCheckbox
< nCheckSize
)
147 nHeightCheckbox
= nCheckSize
;
151 nWidthCheckbox
= nCheckSize
;
152 nHeightCheckbox
= nCheckSize
;
155 return wxSize( nWidthCheckbox
158 } // end of wxCheckBox::DoGetBestSize
160 void wxCheckBox::SetValue(
164 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
165 } // end of wxCheckBox::SetValue
168 #define BST_CHECKED 0x0001
171 bool wxCheckBox::GetValue() const
173 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
174 } // end of wxCheckBox::GetValue
176 void wxCheckBox::Command (
177 wxCommandEvent
& rEvent
180 SetValue((rEvent
.GetInt() != 0));
181 ProcessCommand(rEvent
);
182 } // end of wxCheckBox:: Command
184 // ----------------------------------------------------------------------------
186 // ----------------------------------------------------------------------------
188 bool wxBitmapCheckBox::Create(
191 , const wxBitmap
* pLabel
192 , const wxPoint
& rPos
193 , const wxSize
& rSize
196 , const wxValidator
& rValidator
198 , const wxString
& rsName
203 SetValidator(rValidator
);
206 pParent
->AddChild(this);
208 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
209 SetForegroundColour(pParent
->GetForegroundColour()) ;
210 m_windowStyle
= lStyle
;
213 m_windowId
= NewControlId();
219 int nWidth
= rSize
.x
;
220 int nHeight
= rSize
.y
;
223 m_nCheckHeight
= -1 ;
224 // long msStyle = CHECK_FLAGS;
226 HWND hButton
= 0; // TODO: Create the bitmap checkbox
228 m_hWnd
= (WXHWND
)hButton
;
231 // Subclass again for purposes of dialog editing mode
233 SubclassWin((WXHWND
)hButton
);
241 ::WinShowWindow(hButton
, TRUE
);
243 } // end of wxBitmapCheckBox::Create
245 void wxBitmapCheckBox::SetLabel(
246 const wxBitmap
& rBitmap
249 wxFAIL_MSG(wxT("not implemented"));
250 } // end of wxBitmapCheckBox::SetLabel