1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/checkbox.cpp
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"
15 #include "wx/checkbox.h"
19 #include "wx/scrolwin.h"
20 #include "wx/dcscreen.h"
21 #include "wx/settings.h"
24 #include "wx/os2/private.h"
26 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
30 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
)
31 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
33 extern void wxAssociateWinWithHandle( HWND hWnd
37 // ============================================================================
39 // ============================================================================
41 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
45 bool wxCheckBox::OS2Command( WXUINT
WXUNUSED(uParam
),
46 WXWORD
WXUNUSED(wId
) )
48 wxCommandEvent
rEvent( wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
49 rEvent
.SetInt(GetValue());
50 rEvent
.SetEventObject(this);
51 ProcessCommand(rEvent
);
53 } // end of wxCheckBox::OS2Command
55 bool wxCheckBox::Create(wxWindow
* pParent
,
57 const wxString
& rsLabel
,
61 const wxValidator
& rValidator
,
62 const wxString
& rsName
)
64 if (!CreateControl( pParent
75 long osStyle
= BS_AUTOCHECKBOX
| WS_TABSTOP
| WS_VISIBLE
;
77 bool bOk
= OS2CreateControl( wxT("BUTTON")
84 m_backgroundColour
= pParent
->GetBackgroundColour();
86 LONG lColor
= (LONG
)m_backgroundColour
.GetPixel();
87 ::WinSetPresParam( m_hWnd
92 wxAssociateWinWithHandle(m_hWnd
, this);
94 } // end of wxCheckBox::Create
96 void wxCheckBox::SetLabel( const wxString
& rsLabel
)
98 wxString sLabel
=::wxPMTextToLabel(rsLabel
);
99 ::WinSetWindowText(GetHwnd(), sLabel
.c_str());
100 } // end of wxCheckBox::SetLabel
102 wxSize
wxCheckBox::DoGetBestSize() const
104 // We should probably compute nCheckSize but it seems to be a constant
105 // independent of its label's font size and not made available by OS/2.
106 int nCheckSize
= RADIO_SIZE
;
109 wxString sStr
= wxGetWindowText(GetHWND());
117 nWidthCheckbox
+= nCheckSize
;
119 if (nHeightCheckbox
< nCheckSize
)
120 nHeightCheckbox
= nCheckSize
;
124 nWidthCheckbox
= nCheckSize
;
125 nHeightCheckbox
= nCheckSize
;
128 return wxSize( nWidthCheckbox
, nHeightCheckbox
);
129 } // end of wxCheckBox::DoGetBestSize
131 void wxCheckBox::SetValue( bool bValue
)
133 ::WinSendMsg(GetHwnd(), BM_SETCHECK
, (MPARAM
)bValue
, 0);
134 } // end of wxCheckBox::SetValue
137 #define BST_CHECKED 0x0001
140 bool wxCheckBox::GetValue() const
142 return((LONGFROMMR(::WinSendMsg(GetHwnd(), BM_QUERYCHECK
, (MPARAM
)0, (MPARAM
)0)) == 1L));
143 } // end of wxCheckBox::GetValue
145 void wxCheckBox::Command ( wxCommandEvent
& rEvent
)
147 SetValue((rEvent
.GetInt() != 0));
148 ProcessCommand(rEvent
);
149 } // end of wxCheckBox:: Command
151 // ----------------------------------------------------------------------------
153 // ----------------------------------------------------------------------------
155 bool wxBitmapCheckBox::Create( wxWindow
* pParent
,
157 const wxBitmap
* WXUNUSED(pLabel
),
161 const wxValidator
& rValidator
,
162 const wxString
& rsName
)
166 SetValidator(rValidator
);
169 pParent
->AddChild(this);
171 SetBackgroundColour(pParent
->GetBackgroundColour()) ;
172 SetForegroundColour(pParent
->GetForegroundColour()) ;
173 m_windowStyle
= lStyle
;
176 m_windowId
= NewControlId();
182 int nWidth
= rSize
.x
;
183 int nHeight
= rSize
.y
;
186 m_nCheckHeight
= -1 ;
187 // long msStyle = CHECK_FLAGS;
189 HWND hButton
= 0; // TODO: Create the bitmap checkbox
191 m_hWnd
= (WXHWND
)hButton
;
194 // Subclass again for purposes of dialog editing mode
196 SubclassWin((WXHWND
)hButton
);
204 ::WinShowWindow(hButton
, TRUE
);
206 } // end of wxBitmapCheckBox::Create
208 void wxBitmapCheckBox::SetLabel( const wxBitmap
& WXUNUSED(rBitmap
) )
210 wxFAIL_MSG(wxT("not implemented"));
211 } // end of wxBitmapCheckBox::SetLabel