X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fa36fe3680d7bdf55a54885444972368fe5edfe6..69659fd770f615210efac4b4fa741b3ad6223616:/src/common/tbarbase.cpp diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 8a63d697a0..071dac26d3 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -35,6 +35,7 @@ #if WXWIN_COMPATIBILITY_2_8 #include "wx/image.h" #endif // WXWIN_COMPATIBILITY_2_8 + #include "wx/menu.h" #endif // ---------------------------------------------------------------------------- @@ -58,6 +59,12 @@ WX_DEFINE_LIST(wxToolBarToolsList) IMPLEMENT_DYNAMIC_CLASS(wxToolBarToolBase, wxObject) +wxToolBarToolBase::~wxToolBarToolBase() +{ + delete m_dropdownMenu; +} + + bool wxToolBarToolBase::Enable(bool enable) { if ( m_enabled == enable ) @@ -111,6 +118,13 @@ bool wxToolBarToolBase::SetLongHelp(const wxString& help) return true; } + +void wxToolBarToolBase::SetDropdownMenu(wxMenu* menu) +{ + delete m_dropdownMenu; + m_dropdownMenu = menu; +} + // ---------------------------------------------------------------------------- // wxToolBarBase adding/deleting items // ---------------------------------------------------------------------------- @@ -628,7 +642,7 @@ void wxToolBarBase::OnMouseEnter(int id) event.SetInt(id); wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); - if( frame ) + if ( frame ) { wxString help; if ( id != wxID_ANY ) @@ -638,9 +652,9 @@ void wxToolBarBase::OnMouseEnter(int id) help = tool->GetLongHelp(); } - // do it even if help string is empty to avoid showing the help for the - // previously selected tool when another one is selected - frame->DoGiveHelp(help); + // call DoGiveHelp() even if help string is empty to avoid showing the + // help for the previously selected tool when another one is selected + frame->DoGiveHelp(help, id != wxID_ANY); } (void)GetEventHandler()->ProcessEvent(event); @@ -690,6 +704,19 @@ void wxToolBarBase::UpdateWindowUI(long flags) } } +bool wxToolBarBase::SetDropdownMenu(int toolid, wxMenu* menu) +{ + wxToolBarToolBase * const tool = FindById(toolid); + wxCHECK_MSG( tool, false, _T("invalid tool id") ); + + wxCHECK_MSG( tool->GetKind() == wxITEM_DROPDOWN, false, + _T("menu can be only associated with drop down tools") ); + + tool->SetDropdownMenu(menu); + + return true; +} + #if WXWIN_COMPATIBILITY_2_8 bool wxCreateGreyedImage(const wxImage& in, wxImage& out) @@ -699,7 +726,6 @@ bool wxCreateGreyedImage(const wxImage& in, wxImage& out) if ( out.Ok() ) return true; #endif // wxUSE_IMAGE - return false; }