1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxRadioButton
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"
22 #include "wx/radiobut.h"
26 #include "wx/os2/private.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton
, wxControl
)
30 void wxRadioButton::Command (
31 wxCommandEvent
& rEvent
34 SetValue ((rEvent
.GetInt() != 0) );
35 ProcessCommand (rEvent
);
36 } // end of wxRadioButton::Command
38 bool wxRadioButton::Create(
41 , const wxString
& rsLabel
46 , const wxValidator
& rValidator
48 , const wxString
& rsName
54 int nHeight
= rSize
.y
;
56 long lGroupStyle
= 0L;
60 SetValidator(rValidator
);
64 pParent
->AddChild(this);
66 SetBackgroundColour(pParent
->GetBackgroundColour());
67 SetForegroundColour(pParent
->GetForegroundColour());
70 m_windowId
= (int)NewControlId();
75 m_windowStyle
= lStyle
;
77 if (m_windowStyle
& wxRB_GROUP
)
78 lGroupStyle
= WS_GROUP
;
80 lsStyle
= lGroupStyle
| BS_AUTORADIOBUTTON
| WS_VISIBLE
;
82 if (m_windowStyle
& wxCLIP_SIBLINGS
)
83 lsStyle
|= WS_CLIPSIBLINGS
;
85 // If the parent is a scrolled window the controls must
86 // have this style or they will overlap the scrollbars
89 if (pParent
->IsKindOf(CLASSINFO(wxScrolledWindow
)) ||
90 pParent
->IsKindOf(CLASSINFO(wxGenericScrolledWindow
)))
91 lsStyle
|= WS_CLIPSIBLINGS
;
93 m_hWnd
= (WXHWND
)::WinCreateWindow ( GetHwndOf(pParent
)
104 wxCHECK_MSG(m_hWnd
, FALSE
, wxT("Failed to create radiobutton"));
106 if (rsLabel
!= wxT(""))
111 GetTextExtent( rsLabel
119 nWidth
= (int)(nLabelWidth
+ RADIO_SIZE
);
122 nHeight
= (int)(nLabelHeight
);
123 if (nHeight
< RADIO_SIZE
)
124 nHeight
= RADIO_SIZE
;
132 nHeight
= RADIO_SIZE
;
136 // Subclass again for purposes of dialog editing mode
138 SubclassWin((WXHWND
)m_hWnd
);
139 SetFont(pParent
->GetFont());
146 } // end of wxRadioButton::Create
149 // Get single selection, for single choice list items
151 bool wxRadioButton::GetValue() const
153 return((::WinSendMsg((HWND
) GetHWND(), BM_QUERYCHECK
, (MPARAM
)0L, (MPARAM
)0L) != 0));
154 } // end of wxRadioButton::GetValue
156 bool wxRadioButton::OS2Command(
161 if (wParam
== BN_CLICKED
)
163 wxCommandEvent
rEvent( wxEVT_COMMAND_RADIOBUTTON_SELECTED
167 rEvent
.SetEventObject(this);
168 ProcessCommand(rEvent
);
173 } // end of wxRadioButton::OS2Command
175 void wxRadioButton::SetLabel(
176 const wxString
& rsLabel
179 ::WinSetWindowText((HWND
)GetHWND(), (const char *)rsLabel
.c_str());
180 } // end of wxRadioButton::SetLabel
182 void wxRadioButton::SetValue(
186 ::WinSendMsg((HWND
)GetHWND(), BM_SETCHECK
, (MPARAM
)bValue
, (MPARAM
)0);
187 } // end of wxRadioButton::SetValue