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 wxString sLabel
=::wxPMTextToLabel(rsLabel
);
110 ::WinSetWindowText(GetHwnd(), (PSZ
)sLabel
.c_str());
111 } // end of wxCheckBox::SetLabel
113 wxSize
wxCheckBox::DoGetBestSize() const
115 static int nCheckSize
= 0;
121 vDc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
124 // The height of a standard button in the dialog units is 8,
125 // translate this to pixels (as one dialog unit is precisely equal to
126 // 8 character heights, it's just the char height)
128 nCheckSize
= vDc
.GetCharHeight();
133 wxString sStr
= wxGetWindowText(GetHWND());
141 nWidthCheckbox
+= nCheckSize
+ GetCharWidth();
143 if (nHeightCheckbox
< nCheckSize
)
144 nHeightCheckbox
= nCheckSize
;
148 nWidthCheckbox
= nCheckSize
;
149 nHeightCheckbox
= nCheckSize
;
152 return wxSize( nWidthCheckbox
155 } // end of wxCheckBox::DoGetBestSize
157 void wxCheckBox::SetValue(
161 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
162 } // end of wxCheckBox::SetValue
165 #define BST_CHECKED 0x0001
168 bool wxCheckBox::GetValue() const
170 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
171 } // end of wxCheckBox::GetValue
173 void wxCheckBox::Command (
174 wxCommandEvent
& rEvent
177 SetValue((rEvent
.GetInt() != 0));
178 ProcessCommand(rEvent
);
179 } // end of wxCheckBox:: Command
181 // ----------------------------------------------------------------------------
183 // ----------------------------------------------------------------------------
185 bool wxBitmapCheckBox::Create(
188 , const wxBitmap
* pLabel
189 , const wxPoint
& rPos
190 , const wxSize
& rSize
192 , const wxValidator
& rValidator
193 , const wxString
& rsName
198 SetValidator(rValidator
);
201 pParent
->AddChild(this);
203 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
204 SetForegroundColour(pParent
->GetForegroundColour()) ;
205 m_windowStyle
= lStyle
;
208 m_windowId
= NewControlId();
214 int nWidth
= rSize
.x
;
215 int nHeight
= rSize
.y
;
218 m_nCheckHeight
= -1 ;
219 // long msStyle = CHECK_FLAGS;
221 HWND hButton
= 0; // TODO: Create the bitmap checkbox
223 m_hWnd
= (WXHWND
)hButton
;
226 // Subclass again for purposes of dialog editing mode
228 SubclassWin((WXHWND
)hButton
);
236 ::WinShowWindow(hButton
, TRUE
);
238 } // end of wxBitmapCheckBox::Create
240 void wxBitmapCheckBox::SetLabel(
241 const wxBitmap
& rBitmap
244 wxFAIL_MSG(wxT("not implemented"));
245 } // end of wxBitmapCheckBox::SetLabel