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
;
84 m_hWnd
= (WXHWND
)::WinCreateWindow ( GetHwndOf(pParent
)
95 wxCHECK_MSG(m_hWnd
, FALSE
, wxT("Failed to create radiobutton"));
97 if (rsLabel
!= wxT(""))
102 GetTextExtent( rsLabel
110 nWidth
= (int)(nLabelWidth
+ RADIO_SIZE
);
113 nHeight
= (int)(nLabelHeight
);
114 if (nHeight
< RADIO_SIZE
)
115 nHeight
= RADIO_SIZE
;
123 nHeight
= RADIO_SIZE
;
127 // Subclass again for purposes of dialog editing mode
129 SubclassWin((WXHWND
)m_hWnd
);
130 SetFont(pParent
->GetFont());
137 } // end of wxRadioButton::Create
140 // Get single selection, for single choice list items
142 bool wxRadioButton::GetValue() const
144 return((::WinSendMsg((HWND
) GetHWND(), BM_QUERYCHECK
, (MPARAM
)0L, (MPARAM
)0L) != 0));
145 } // end of wxRadioButton::GetValue
147 bool wxRadioButton::OS2Command(
152 if (wParam
== BN_CLICKED
)
154 wxCommandEvent
rEvent( wxEVT_COMMAND_RADIOBUTTON_SELECTED
158 rEvent
.SetEventObject(this);
159 ProcessCommand(rEvent
);
164 } // end of wxRadioButton::OS2Command
166 void wxRadioButton::SetLabel(
167 const wxString
& rsLabel
170 ::WinSetWindowText((HWND
)GetHWND(), (const char *)rsLabel
.c_str());
171 } // end of wxRadioButton::SetLabel
173 void wxRadioButton::SetValue(
177 ::WinSendMsg((HWND
)GetHWND(), BM_SETCHECK
, (MPARAM
)bValue
, (MPARAM
)0);
178 } // end of wxRadioButton::SetValue