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
)
29 IMPLEMENT_DYNAMIC_CLASS(wxBitmapRadioButton
, wxRadioButton
)
31 bool wxRadioButton::OS2Command(WXUINT param
, WXWORD id
)
33 if (param
== BN_CLICKED
)
35 wxCommandEvent
event(wxEVT_COMMAND_RADIOBUTTON_SELECTED
, m_windowId
);
36 event
.SetEventObject( this );
37 ProcessCommand(event
);
43 bool wxRadioButton::Create(wxWindow
*parent
, wxWindowID id
,
44 const wxString
& label
,
46 const wxSize
& size
, long style
,
48 const wxValidator
& validator
,
54 SetValidator(validator
);
57 if (parent
) parent
->AddChild(this);
59 SetBackgroundColour(parent
->GetBackgroundColour());
60 SetForegroundColour(parent
->GetForegroundColour());
63 m_windowId
= (int)NewControlId();
72 m_windowStyle
= style
;
74 // TODO create radiobutton
77 if (m_windowStyle & wxRB_GROUP)
78 groupStyle = WS_GROUP;
80 // long msStyle = groupStyle | RADIO_FLAGS;
81 long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ;
84 WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
86 m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label,
88 (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
90 wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") );
93 SetFont(parent->GetFont());
95 // Subclass again for purposes of dialog editing mode
96 SubclassWin((WXHWND)m_hWnd);
102 if (label
!= wxT(""))
104 int label_width
, label_height
;
105 GetTextExtent(label
, &label_width
, &label_height
, NULL
, NULL
, & this->GetFont());
107 width
= (int)(label_width
+ RADIO_SIZE
);
110 height
= (int)(label_height
);
111 if (height
< RADIO_SIZE
)
124 SetSize(x
, y
, width
, height
);
128 void wxRadioButton::SetLabel(const wxString
& label
)
133 void wxRadioButton::SetValue(bool value
)
138 // Get single selection, for single choice list items
139 bool wxRadioButton::GetValue() const
145 void wxRadioButton::Command (wxCommandEvent
& event
)
147 SetValue ( (event
.m_commandInt
!= 0) );
148 ProcessCommand (event
);
151 bool wxBitmapRadioButton::Create(wxWindow
*parent
, wxWindowID id
,
152 const wxBitmap
*bitmap
,
154 const wxSize
& size
, long style
,
156 const wxValidator
& validator
,
158 const wxString
& name
)
162 SetValidator(validator
);
165 if (parent
) parent
->AddChild(this);
166 SetBackgroundColour(parent
->GetBackgroundColour());
167 SetForegroundColour(parent
->GetForegroundColour());
170 m_windowId
= (int)NewControlId();
178 m_windowStyle
= style
;
181 if (m_windowStyle
& wxRB_GROUP
)
182 groupStyle
= WS_GROUP
;
186 // long msStyle = groupStyle | RADIO_FLAGS;
187 // long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ;
189 m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle",
191 (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
193 wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE );
196 // Subclass again for purposes of dialog editing mode
197 SubclassWin(GetHWND());
199 SetSize(x
, y
, width
, height
);
204 void wxBitmapRadioButton::SetLabel(const wxBitmap
*bitmap
)
208 void wxBitmapRadioButton::SetValue(bool value
)
210 // Following necessary for Win32s, because Win32s translate BM_SETCHECK
211 // SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L);
214 // Get single selection, for single choice list items
215 bool wxBitmapRadioButton::GetValue(void) const
217 // return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L);