X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..79c78d4284afd3ca726edf16763d248dc6253386:/src/common/tbarbase.cpp diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index f04db4ad71..2d250e20d5 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -59,7 +59,7 @@ WX_DEFINE_LIST(wxToolBarToolsList); // wxToolBarToolBase // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxToolBarToolBase, wxObject) +IMPLEMENT_DYNAMIC_CLASS(wxToolBarToolBase, wxObject) bool wxToolBarToolBase::Enable(bool enable) { @@ -114,10 +114,6 @@ bool wxToolBarToolBase::SetLongHelp(const wxString& help) return true; } -wxToolBarToolBase::~wxToolBarToolBase() -{ -} - // ---------------------------------------------------------------------------- // wxToolBarBase adding/deleting items // ---------------------------------------------------------------------------- @@ -141,6 +137,7 @@ wxToolBarToolBase *wxToolBarBase::DoAddTool(int id, wxCoord WXUNUSED(xPos), wxCoord WXUNUSED(yPos)) { + InvalidateBestSize(); return InsertTool(GetToolsCount(), id, label, bitmap, bmpDisabled, kind, shortHelp, longHelp, clientData); } @@ -384,7 +381,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(); } @@ -397,7 +397,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(); } @@ -416,6 +419,14 @@ bool wxToolBarBase::Realize() wxToolBarBase::~wxToolBarBase() { WX_CLEAR_LIST(wxToolBarToolsList, m_tools); + + // notify the frame that it doesn't have a tool bar any longer to avoid + // dangling pointers + wxFrameBase *frame = wxDynamicCast(GetParent(), wxFrameBase); + if ( frame && frame->GetToolBar() == this ) + { + frame->SetToolBar(NULL); + } } // ---------------------------------------------------------------------------- @@ -591,7 +602,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. @@ -604,9 +615,11 @@ void wxToolBarBase::OnMouseEnter(int id) wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); if( frame ) { - wxToolBarToolBase* tool = id == -1 ? (wxToolBarToolBase*)0 : FindById(id); - wxString help = tool ? tool->GetLongHelp() : wxString(); - frame->DoGiveHelp( help, id != -1 ); + wxString help; + wxToolBarToolBase* tool = id == wxID_ANY ? (wxToolBarToolBase*)NULL : FindById(id); + if(tool) + help = tool->GetLongHelp(); + frame->DoGiveHelp( help, id != wxID_ANY ); } (void)GetEventHandler()->ProcessEvent(event);