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 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_DYNAMIC_CLASS(wxRadioButton
, wxControl
)
30 IMPLEMENT_DYNAMIC_CLASS(wxBitmapRadioButton
, wxRadioButton
)
33 bool wxRadioButton::OS2Command(WXUINT param
, WXWORD id
)
35 if (param
== BN_CLICKED
)
37 wxCommandEvent
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, m_windowId
);
38 event
.SetEventObject( this );
39 ProcessCommand(event
);
45 bool wxRadioButton::Create(wxWindow
*parent
, wxWindowID id
,
46 const wxString
& label
,
48 const wxSize
& size
, long style
,
50 # if defined(__VISAGECPP__)
51 const wxValidator
* validator
,
53 const wxValidator
& validator
,
60 SetValidator(validator
);
63 if (parent
) parent
->AddChild(this);
65 SetBackgroundColour(parent
->GetBackgroundColour());
66 SetForegroundColour(parent
->GetForegroundColour());
69 m_windowId
= (int)NewControlId();
78 m_windowStyle
= style
;
80 // TODO create radiobutton
83 if (m_windowStyle & wxRB_GROUP)
84 groupStyle = WS_GROUP;
86 // long msStyle = groupStyle | RADIO_FLAGS;
87 long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ;
90 WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
92 m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label,
94 (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
96 wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") );
99 SetFont(parent->GetFont());
101 // Subclass again for purposes of dialog editing mode
102 SubclassWin((WXHWND)m_hWnd);
108 if (label
!= wxT(""))
110 int label_width
, label_height
;
111 GetTextExtent(label
, &label_width
, &label_height
, NULL
, NULL
, & this->GetFont());
113 width
= (int)(label_width
+ RADIO_SIZE
);
116 height
= (int)(label_height
);
117 if (height
< RADIO_SIZE
)
130 SetSize(x
, y
, width
, height
);
134 void wxRadioButton::SetLabel(const wxString
& label
)
139 void wxRadioButton::SetValue(bool value
)
144 // Get single selection, for single choice list items
145 bool wxRadioButton::GetValue() const
151 void wxRadioButton::Command (wxCommandEvent
& event
)
153 SetValue ( (event
.m_commandInt
!= 0) );
154 ProcessCommand (event
);
157 bool wxBitmapRadioButton::Create(wxWindow
*parent
, wxWindowID id
,
158 const wxBitmap
*bitmap
,
160 const wxSize
& size
, long style
,
162 # if defined(__VISAGECPP__)
163 const wxValidator
* validator
,
165 const wxValidator
& validator
,
168 const wxString
& name
)
172 SetValidator(validator
);
175 if (parent
) parent
->AddChild(this);
176 SetBackgroundColour(parent
->GetBackgroundColour());
177 SetForegroundColour(parent
->GetForegroundColour());
180 m_windowId
= (int)NewControlId();
188 m_windowStyle
= style
;
191 if (m_windowStyle
& wxRB_GROUP
)
192 groupStyle
= WS_GROUP
;
196 // long msStyle = groupStyle | RADIO_FLAGS;
197 // long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ;
199 m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle",
201 (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
203 wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE );
206 // Subclass again for purposes of dialog editing mode
207 SubclassWin(GetHWND());
209 SetSize(x
, y
, width
, height
);
214 void wxBitmapRadioButton::SetLabel(const wxBitmap
*bitmap
)
218 void wxBitmapRadioButton::SetValue(bool value
)
220 // Following necessary for Win32s, because Win32s translate BM_SETCHECK
221 // SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L);
224 // Get single selection, for single choice list items
225 bool wxBitmapRadioButton::GetValue(void) const
227 // return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L);