X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6337cacce92d9d3f3d453753102a152ace004b60..e0954e729dabaad5603d9970d123d6b96ed73463:/src/common/radiocmn.cpp diff --git a/src/common/radiocmn.cpp b/src/common/radiocmn.cpp index b236ec9f17..82d9d5bef7 100644 --- a/src/common/radiocmn.cpp +++ b/src/common/radiocmn.cpp @@ -34,6 +34,10 @@ #include "wx/tooltip.h" #endif // wxUSE_TOOLTIPS +#if wxUSE_HELP + #include "wx/cshelp.h" +#endif + // ============================================================================ // implementation // ============================================================================ @@ -228,18 +232,49 @@ wxRadioBoxBase::~wxRadioBoxBase() #endif // wxUSE_TOOLTIPS } -#if WXWIN_COMPATIBILITY_2_4 +#if wxUSE_HELP + +// set helptext for a particular item +void wxRadioBoxBase::SetItemHelpText(unsigned int n, const wxString& helpText) +{ + wxCHECK_RET( n < GetCount(), _T("Invalid item index") ); + + if ( m_itemsHelpTexts.empty() ) + { + // once-only initialization of the array: reserve space for all items + m_itemsHelpTexts.Add(wxEmptyString, GetCount()); + } + + m_itemsHelpTexts[n] = helpText; +} -// these functions are deprecated and don't do anything -int wxRadioBoxBase::GetNumberOfRowsOrCols() const +// retrieve helptext for a particular item +wxString wxRadioBoxBase::GetItemHelpText( unsigned int n ) const { - return 1; + wxCHECK_MSG( n < GetCount(), wxEmptyString, _T("Invalid item index") ); + + return m_itemsHelpTexts.empty() ? wxString() : m_itemsHelpTexts[n]; } -void wxRadioBoxBase::SetNumberOfRowsOrCols(int WXUNUSED(n)) +// return help text for the item for which wxEVT_HELP was generated. +wxString wxRadioBoxBase::DoGetHelpTextAtPoint(const wxWindow *derived, + const wxPoint& pt, + wxHelpEvent::Origin origin) const { + const int item = origin == wxHelpEvent::Origin_HelpButton + ? GetItemFromPoint(pt) + : GetSelection(); + + if ( item != wxNOT_FOUND ) + { + wxString text = GetItemHelpText(wx_static_cast(unsigned int, item)); + if( !text.empty() ) + return text; + } + + return derived->wxWindowBase::GetHelpTextAtPoint(pt, origin); } -#endif // WXWIN_COMPATIBILITY_2_4 +#endif // wxUSE_HELP #endif // wxUSE_RADIOBOX