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
65 , const wxValidator
& rValidator
66 , const wxString
& rsName
72 if (!CreateControl( pParent
83 long osStyle
= BS_AUTOCHECKBOX
|
87 bOk
= OS2CreateControl( wxT("BUTTON")
94 m_backgroundColour
= pParent
->GetBackgroundColour();
95 lColor
= (LONG
)m_backgroundColour
.GetPixel();
96 ::WinSetPresParam( m_hWnd
101 wxAssociateWinWithHandle(m_hWnd
, this);
103 } // end of wxCheckBox::Create
105 void wxCheckBox::SetLabel(
106 const wxString
& rsLabel
109 ::WinSetWindowText(GetHwnd(), rsLabel
.c_str());
110 } // end of wxCheckBox::SetLabel
112 wxSize
wxCheckBox::DoGetBestSize() const
114 static int nCheckSize
= 0;
120 vDc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
123 // The height of a standard button in the dialog units is 8,
124 // translate this to pixels (as one dialog unit is precisely equal to
125 // 8 character heights, it's just the char height)
127 nCheckSize
= vDc
.GetCharHeight();
132 wxString sStr
= wxGetWindowText(GetHWND());
140 nWidthCheckbox
+= nCheckSize
+ GetCharWidth();
142 if (nHeightCheckbox
< nCheckSize
)
143 nHeightCheckbox
= nCheckSize
;
147 nWidthCheckbox
= nCheckSize
;
148 nHeightCheckbox
= nCheckSize
;
151 return wxSize( nWidthCheckbox
154 } // end of wxCheckBox::DoGetBestSize
156 void wxCheckBox::SetValue(
160 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
161 } // end of wxCheckBox::SetValue
164 #define BST_CHECKED 0x0001
167 bool wxCheckBox::GetValue() const
169 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
170 } // end of wxCheckBox::GetValue
172 void wxCheckBox::Command (
173 wxCommandEvent
& rEvent
176 SetValue((rEvent
.GetInt() != 0));
177 ProcessCommand(rEvent
);
178 } // end of wxCheckBox:: Command
180 // ----------------------------------------------------------------------------
182 // ----------------------------------------------------------------------------
184 bool wxBitmapCheckBox::Create(
187 , const wxBitmap
* pLabel
188 , const wxPoint
& rPos
189 , const wxSize
& rSize
191 , const wxValidator
& rValidator
192 , const wxString
& rsName
197 SetValidator(rValidator
);
200 pParent
->AddChild(this);
202 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
203 SetForegroundColour(pParent
->GetForegroundColour()) ;
204 m_windowStyle
= lStyle
;
207 m_windowId
= NewControlId();
213 int nWidth
= rSize
.x
;
214 int nHeight
= rSize
.y
;
217 m_nCheckHeight
= -1 ;
218 // long msStyle = CHECK_FLAGS;
220 HWND hButton
= 0; // TODO: Create the bitmap checkbox
222 m_hWnd
= (WXHWND
)hButton
;
225 // Subclass again for purposes of dialog editing mode
227 SubclassWin((WXHWND
)hButton
);
235 ::WinShowWindow(hButton
, TRUE
);
237 } // end of wxBitmapCheckBox::Create
239 void wxBitmapCheckBox::SetLabel(
240 const wxBitmap
& rBitmap
243 wxFAIL_MSG(wxT("not implemented"));
244 } // end of wxBitmapCheckBox::SetLabel