// Author: Julian Smart
// Modified by:
// Created: 04/01/98
-// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
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()
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),
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;
}
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 );
}
}
+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)
{