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
,
49 const wxValidator
& validator
,
53 SetValidator(validator
);
55 if (parent
) parent
->AddChild(this);
57 SetBackgroundColour(parent
->GetBackgroundColour());
58 SetForegroundColour(parent
->GetForegroundColour());
61 m_windowId
= (int)NewControlId();
70 m_windowStyle
= style
;
72 // TODO create radiobutton
75 if (m_windowStyle & wxRB_GROUP)
76 groupStyle = WS_GROUP;
78 // long msStyle = groupStyle | RADIO_FLAGS;
79 long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ;
82 WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
84 m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label,
86 (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
88 wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") );
91 SetFont(parent->GetFont());
93 // Subclass again for purposes of dialog editing mode
94 SubclassWin((WXHWND)m_hWnd);
100 if (label
!= wxT(""))
102 int label_width
, label_height
;
103 GetTextExtent(label
, &label_width
, &label_height
, NULL
, NULL
, & this->GetFont());
105 width
= (int)(label_width
+ RADIO_SIZE
);
108 height
= (int)(label_height
);
109 if (height
< RADIO_SIZE
)
122 SetSize(x
, y
, width
, height
);
126 void wxRadioButton::SetLabel(const wxString
& label
)
131 void wxRadioButton::SetValue(bool value
)
136 // Get single selection, for single choice list items
137 bool wxRadioButton::GetValue() const
143 void wxRadioButton::Command (wxCommandEvent
& event
)
145 SetValue ( (event
.m_commandInt
!= 0) );
146 ProcessCommand (event
);
149 bool wxBitmapRadioButton::Create(wxWindow
*parent
, wxWindowID id
,
150 const wxBitmap
*bitmap
,
152 const wxSize
& size
, long style
,
153 const wxValidator
& validator
,
154 const wxString
& name
)
157 SetValidator(validator
);
159 if (parent
) parent
->AddChild(this);
160 SetBackgroundColour(parent
->GetBackgroundColour());
161 SetForegroundColour(parent
->GetForegroundColour());
164 m_windowId
= (int)NewControlId();
172 m_windowStyle
= style
;
175 if (m_windowStyle
& wxRB_GROUP
)
176 groupStyle
= WS_GROUP
;
180 // long msStyle = groupStyle | RADIO_FLAGS;
181 // long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ;
183 m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle",
185 (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
187 wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE );
190 // Subclass again for purposes of dialog editing mode
191 SubclassWin(GetHWND());
193 SetSize(x
, y
, width
, height
);
198 void wxBitmapRadioButton::SetLabel(const wxBitmap
*bitmap
)
202 void wxBitmapRadioButton::SetValue(bool value
)
204 // Following necessary for Win32s, because Win32s translate BM_SETCHECK
205 // SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L);
208 // Get single selection, for single choice list items
209 bool wxBitmapRadioButton::GetValue(void) const
211 // return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L);