X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3d0974f0f4ea623b5255db0b70b5e8374bf9d3f..739e35e4fba5df59532ef7e62bcfc8ebbcd72bb5:/src/common/tbarbase.cpp?ds=sidebyside diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 36d6474ab4..69f106b9ee 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -41,7 +41,7 @@ #include "wx/toolbar.h" // ---------------------------------------------------------------------------- -// wxWindows macros +// wxWidgets macros // ---------------------------------------------------------------------------- BEGIN_EVENT_TABLE(wxToolBarBase, wxControl) @@ -59,10 +59,13 @@ WX_DEFINE_LIST(wxToolBarToolsList); // wxToolBarToolBase // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxToolBarToolBase, wxObject) +IMPLEMENT_DYNAMIC_CLASS(wxToolBarToolBase, wxObject) bool wxToolBarToolBase::Enable(bool enable) { + if ( m_enabled == enable ) + return false; + m_enabled = enable; return true; @@ -72,6 +75,9 @@ bool wxToolBarToolBase::Toggle(bool toggle) { wxASSERT_MSG( CanBeToggled(), _T("can't toggle this tool") ); + if ( m_toggled == toggle ) + return false; + m_toggled = toggle; return true; @@ -80,6 +86,8 @@ bool wxToolBarToolBase::Toggle(bool toggle) bool wxToolBarToolBase::SetToggle(bool toggle) { wxItemKind kind = toggle ? wxITEM_CHECK : wxITEM_NORMAL; + if ( m_kind == kind ) + return false; m_kind = kind; @@ -88,6 +96,9 @@ bool wxToolBarToolBase::SetToggle(bool toggle) bool wxToolBarToolBase::SetShortHelp(const wxString& help) { + if ( m_shortHelpString == help ) + return false; + m_shortHelpString = help; return true; @@ -95,6 +106,9 @@ bool wxToolBarToolBase::SetShortHelp(const wxString& help) bool wxToolBarToolBase::SetLongHelp(const wxString& help) { + if ( m_longHelpString == help ) + return false; + m_longHelpString = help; return true; @@ -127,6 +141,7 @@ wxToolBarToolBase *wxToolBarBase::DoAddTool(int id, wxCoord WXUNUSED(xPos), wxCoord WXUNUSED(yPos)) { + InvalidateBestSize(); return InsertTool(GetToolsCount(), id, label, bitmap, bmpDisabled, kind, shortHelp, longHelp, clientData); } @@ -370,7 +385,10 @@ void wxToolBarBase::UnToggleRadioGroup(wxToolBarToolBase *tool) if ( !tool->IsButton() || tool->GetKind() != wxITEM_RADIO ) break; - tool->Toggle(false); + if ( tool->Toggle(false) ) + { + DoToggleTool(tool, false); + } nodeNext = nodeNext->GetNext(); } @@ -383,7 +401,10 @@ void wxToolBarBase::UnToggleRadioGroup(wxToolBarToolBase *tool) if ( !tool->IsButton() || tool->GetKind() != wxITEM_RADIO ) break; - tool->Toggle(false); + if ( tool->Toggle(false) ) + { + DoToggleTool(tool, false); + } nodePrev = nodePrev->GetPrevious(); } @@ -577,7 +598,7 @@ void wxToolBarBase::OnRightClick(int id, } // Called when the mouse cursor enters a tool bitmap (no button pressed). -// Argument is -1 if mouse is exiting the toolbar. +// Argument is wxID_ANY if mouse is exiting the toolbar. // Note that for this event, the id of the window is used, // and the integer parameter of wxCommandEvent is used to retrieve // the tool id. @@ -590,9 +611,9 @@ void wxToolBarBase::OnMouseEnter(int id) wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); if( frame ) { - wxToolBarToolBase* tool = id == -1 ? (wxToolBarToolBase*)0 : FindById(id); + wxToolBarToolBase* tool = id == wxID_ANY ? (wxToolBarToolBase*)0 : FindById(id); wxString help = tool ? tool->GetLongHelp() : wxString(); - frame->DoGiveHelp( help, id != -1 ); + frame->DoGiveHelp( help, id != wxID_ANY ); } (void)GetEventHandler()->ProcessEvent(event); @@ -607,6 +628,12 @@ void wxToolBarBase::UpdateWindowUI(long flags) { wxWindowBase::UpdateWindowUI(flags); + // There is no sense in updating the toolbar UI + // if the parent window is about to get destroyed + wxWindow *tlw = wxGetTopLevelParent( this ); + if (tlw && wxPendingDelete.Member( tlw )) + return; + wxEvtHandler* evtHandler = GetEventHandler() ; for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();