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( WXUINT
WXUNUSED(uParam
),
45 WXWORD
WXUNUSED(wId
) )
47 wxCommandEvent
rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
48 rEvent
.SetInt(GetValue());
49 rEvent
.SetEventObject(this);
50 ProcessCommand(rEvent
);
52 } // end of wxCheckBox::OS2Command
54 bool wxCheckBox::Create(
57 , const wxString
& rsLabel
61 , const wxValidator
& rValidator
62 , const wxString
& rsName
68 if (!CreateControl( pParent
79 long osStyle
= BS_AUTOCHECKBOX
|
83 bOk
= OS2CreateControl( wxT("BUTTON")
90 m_backgroundColour
= pParent
->GetBackgroundColour();
91 lColor
= (LONG
)m_backgroundColour
.GetPixel();
92 ::WinSetPresParam( m_hWnd
97 wxAssociateWinWithHandle(m_hWnd
, this);
99 } // end of wxCheckBox::Create
101 void wxCheckBox::SetLabel(
102 const wxString
& rsLabel
105 wxString sLabel
=::wxPMTextToLabel(rsLabel
);
106 ::WinSetWindowText(GetHwnd(), (PSZ
)sLabel
.c_str());
107 } // end of wxCheckBox::SetLabel
109 wxSize
wxCheckBox::DoGetBestSize() const
111 static int nCheckSize
= 0;
117 vDc
.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
120 // The height of a standard button in the dialog units is 8,
121 // translate this to pixels (as one dialog unit is precisely equal to
122 // 8 character heights, it's just the char height)
124 nCheckSize
= vDc
.GetCharHeight();
129 wxString sStr
= wxGetWindowText(GetHWND());
137 nWidthCheckbox
+= nCheckSize
+ GetCharWidth();
139 if (nHeightCheckbox
< nCheckSize
)
140 nHeightCheckbox
= nCheckSize
;
144 nWidthCheckbox
= nCheckSize
;
145 nHeightCheckbox
= nCheckSize
;
148 return wxSize( nWidthCheckbox
151 } // end of wxCheckBox::DoGetBestSize
153 void wxCheckBox::SetValue(
157 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
158 } // end of wxCheckBox::SetValue
161 #define BST_CHECKED 0x0001
164 bool wxCheckBox::GetValue() const
166 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
167 } // end of wxCheckBox::GetValue
169 void wxCheckBox::Command (
170 wxCommandEvent
& rEvent
173 SetValue((rEvent
.GetInt() != 0));
174 ProcessCommand(rEvent
);
175 } // end of wxCheckBox:: Command
177 // ----------------------------------------------------------------------------
179 // ----------------------------------------------------------------------------
181 bool wxBitmapCheckBox::Create( wxWindow
* pParent
,
183 const wxBitmap
* WXUNUSED(pLabel
),
187 const wxValidator
& rValidator
,
188 const wxString
& rsName
)
192 SetValidator(rValidator
);
195 pParent
->AddChild(this);
197 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
198 SetForegroundColour(pParent
->GetForegroundColour()) ;
199 m_windowStyle
= lStyle
;
202 m_windowId
= NewControlId();
208 int nWidth
= rSize
.x
;
209 int nHeight
= rSize
.y
;
212 m_nCheckHeight
= -1 ;
213 // long msStyle = CHECK_FLAGS;
215 HWND hButton
= 0; // TODO: Create the bitmap checkbox
217 m_hWnd
= (WXHWND
)hButton
;
220 // Subclass again for purposes of dialog editing mode
222 SubclassWin((WXHWND
)hButton
);
230 ::WinShowWindow(hButton
, TRUE
);
232 } // end of wxBitmapCheckBox::Create
234 void wxBitmapCheckBox::SetLabel( const wxBitmap
& WXUNUSED(rBitmap
) )
236 wxFAIL_MSG(wxT("not implemented"));
237 } // end of wxBitmapCheckBox::SetLabel