- int x = pos.x;
- int y = pos.y;
- int width = size.x;
- int height = size.y;
-
- m_windowStyle = style ;
-
-// TODO create radiobutton
-/*
- long groupStyle = 0;
- if (m_windowStyle & wxRB_GROUP)
- groupStyle = WS_GROUP;
-
-// long msStyle = groupStyle | RADIO_FLAGS;
- long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ;
-
- bool want3D;
- WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
-
- m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label,
- msStyle,0,0,0,0,
- (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL);
-
- wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") );
+void wxRadioButton::Command (
+ wxCommandEvent& rEvent
+)
+{
+ SetValue ((rEvent.GetInt() != 0) );
+ ProcessCommand (rEvent);
+} // end of wxRadioButton::Command
+
+bool wxRadioButton::Create(
+ wxWindow* pParent
+, wxWindowID vId
+, const wxString& rsLabel
+, const wxPoint& rPos
+, const wxSize& rSize
+, long lStyle
+, const wxValidator& rValidator
+, const wxString& rsName
+)
+{
+ if ( !CreateControl( pParent
+ ,vId
+ ,rPos
+ ,rSize
+ ,lStyle
+ ,rValidator
+ ,rsName))
+ return FALSE;
+
+ long lSstyle = WS_TABSTOP;
+
+ if (HasFlag(wxRB_GROUP))
+ lSstyle |= WS_GROUP;
+
+ //
+ // wxRB_SINGLE is a temporary workaround for the following problem: if you
+ // have 2 radiobuttons in the same group but which are not consecutive in
+ // the dialog, Windows can enter an infinite loop! The simplest way to
+ // reproduce it is to create radio button, then a panel and then another
+ // radio button: then checking the last button hangs the app.
+ //
+ // Ideally, we'd detect (and avoid) such situation automatically but for
+ // now, as I don't know how to do it, just allow the user to create
+ // BS_RADIOBUTTON buttons for such situations.
+ //
+ lSstyle |= HasFlag(wxRB_SINGLE) ? BS_RADIOBUTTON : BS_AUTORADIOBUTTON;
+
+ if (HasFlag(wxCLIP_SIBLINGS))
+ lSstyle |= WS_CLIPSIBLINGS;
+
+ if (!OS2CreateControl( _T("BUTTON")
+ ,lSstyle
+ ,rPos
+ ,rSize
+ ,rsLabel
+ ,0
+ ))
+ return FALSE;
+
+ wxAssociateWinWithHandle(m_hWnd, this);
+ if (HasFlag(wxRB_GROUP))
+ SetValue(TRUE);
+
+ SetFont(*wxSMALL_FONT);
+ SetSize( rPos.x
+ ,rPos.y
+ ,rSize.x
+ ,rSize.y
+ );
+ return TRUE;
+} // end of wxRadioButton::Create