X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f7dd07f64d344e5b84c8dbe278ce4ad9da2a3c67..7dd6983e0bc7dc7d75b0a86e09da72e9c621e221:/src/msw/radiobox.cpp diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 1414e04edd..053da03797 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -4,7 +4,6 @@ // Author: Julian Smart // Modified by: // Created: 04/01/98 -// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -81,7 +80,7 @@ wxEND_FLAGS( wxRadioBoxStyle ) IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioBox, wxControl,"wx/radiobox.h") wxBEGIN_PROPERTIES_TABLE(wxRadioBox) - wxEVENT_PROPERTY( Select , wxEVT_COMMAND_RADIOBOX_SELECTED , wxCommandEvent ) + wxEVENT_PROPERTY( Select , wxEVT_RADIOBOX , wxCommandEvent ) wxPROPERTY_FLAGS( WindowStyle , wxRadioBoxStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style wxEND_PROPERTIES_TABLE() @@ -203,7 +202,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowIDRef subid = NewControlId(); HWND hwndBtn = ::CreateWindow(wxT("BUTTON"), - choices[i].wx_str(), + choices[i].t_str(), styleBtn, 0, 0, 0, 0, // will be set in SetSize() GetHwndOf(parent), @@ -256,6 +255,12 @@ bool wxRadioBox::Create(wxWindow *parent, const wxSize actualSize = GetSize(); PositionAllButtons(pos.x, pos.y, actualSize.x, actualSize.y); + // The base wxStaticBox class never accepts focus, but we do because giving + // focus to a wxRadioBox actually gives it to one of its buttons, which are + // not visible at wx level and hence are not taken into account by the + // logic in wxControlContainer code. + m_container.EnableSelfFocus(); + return true; } @@ -377,7 +382,7 @@ void wxRadioBox::Command(wxCommandEvent & event) void wxRadioBox::SendNotificationEvent() { - wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId); + wxCommandEvent event(wxEVT_RADIOBOX, m_windowId); event.SetInt( m_selectedButton ); event.SetString(GetString(m_selectedButton)); event.SetEventObject( this ); @@ -438,6 +443,25 @@ void wxRadioBox::SetFocus() } } +bool wxRadioBox::CanBeFocused() const +{ + // If the control itself is hidden or disabled, no need to check anything + // else. + if ( !wxStaticBox::CanBeFocused() ) + return false; + + // Otherwise, check if we have any buttons that can be focused. + for ( size_t item = 0; item < m_radioButtons->GetCount(); item++ ) + { + if ( IsItemEnabled(item) && IsItemShown(item) ) + return true; + } + + // We didn't find any items that can accept focus, so neither can we as a + // whole accept it. + return false; +} + // Enable a specific button bool wxRadioBox::Enable(unsigned int item, bool enable) {