X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c5b3143a47afa4dfab849e465cbd46e8a331a41b..6945b5878c8d46a56f1a59f558837a0943492f3c:/src/msw/radiobut.cpp diff --git a/src/msw/radiobut.cpp b/src/msw/radiobut.cpp index 2b3b4925cc..42bbdc43e5 100644 --- a/src/msw/radiobut.cpp +++ b/src/msw/radiobut.cpp @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "radiobut.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -168,6 +164,12 @@ void wxRadioButton::SetValue(bool value) // buttons in the same group: Windows doesn't do it automatically if ( m_isChecked ) { + // If another radiobutton in the group currently has the focus, we have to + // set it to this radiobutton, else the old readiobutton will be reselected + // automatically, if a parent window loses the focus and regains it. + bool shouldSetFocus = false; + wxWindow* pFocusWnd = FindFocus(); + const wxWindowList& siblings = GetParent()->GetChildren(); wxWindowList::compatibility_iterator nodeThis = siblings.Find(this); wxCHECK_RET( nodeThis, _T("radio button not a child of its parent?") ); @@ -190,6 +192,9 @@ void wxRadioButton::SetValue(bool value) if (btn) { + if (btn == pFocusWnd) + shouldSetFocus = true; + btn->SetValue(false); if ( btn->HasFlag(wxRB_GROUP) ) @@ -217,8 +222,15 @@ void wxRadioButton::SetValue(bool value) } if (btn) + { + if (btn == pFocusWnd) + shouldSetFocus = true; + btn->SetValue(false); + } } + if (shouldSetFocus) + SetFocus(); } } @@ -237,7 +249,7 @@ bool wxRadioButton::GetValue() const void wxRadioButton::Command (wxCommandEvent& event) { - SetValue(event.m_commandInt != 0); + SetValue(event.GetInt() != 0); ProcessCommand(event); } @@ -284,7 +296,7 @@ wxSize wxRadioButton::DoGetBestSize() const int wRadio, hRadio; if ( !str.empty() ) { - GetTextExtent(str, &wRadio, &hRadio); + GetTextExtent(wxStripMenuCodes(str), &wRadio, &hRadio); wRadio += s_radioSize + GetCharWidth(); if ( hRadio < s_radioSize ) @@ -296,7 +308,9 @@ wxSize wxRadioButton::DoGetBestSize() const hRadio = s_radioSize; } - return wxSize(wRadio, hRadio); + wxSize best(wRadio, hRadio); + CacheBestSize(best); + return best; } #endif // wxUSE_RADIOBTN