X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e6c96a7ca418179cee6b1418bd9c59be641d5456..f1e269209afbcbec4e46ab5df4ba43d902a6bf2f:/src/common/tbarbase.cpp?ds=sidebyside diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 020171d8f4..1438c9f3c6 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "tbarbase.h" #endif @@ -38,16 +38,13 @@ #include "wx/image.h" #include "wx/settings.h" -#include "wx/tbarbase.h" +#include "wx/toolbar.h" // ---------------------------------------------------------------------------- // wxWindows macros // ---------------------------------------------------------------------------- -IMPLEMENT_CLASS(wxToolBarBase, wxControl) - BEGIN_EVENT_TABLE(wxToolBarBase, wxControl) - EVT_IDLE(wxToolBarBase::OnIdle) END_EVENT_TABLE() #include "wx/listimpl.cpp" @@ -126,8 +123,6 @@ wxToolBarToolBase::~wxToolBarToolBase() wxToolBarBase::wxToolBarBase() { // the list owns the pointers - m_tools.DeleteContents(TRUE); - m_xMargin = m_yMargin = 0; m_maxRows = m_maxCols = 0; @@ -225,7 +220,7 @@ wxToolBarToolBase *wxToolBarBase::InsertControl(size_t pos, wxControl *control) wxControl *wxToolBarBase::FindControl( int id ) { - for ( wxToolBarToolsList::Node* node = m_tools.GetFirst(); + for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; node = node->GetNext() ) { @@ -280,7 +275,7 @@ wxToolBarToolBase *wxToolBarBase::InsertSeparator(size_t pos) wxToolBarToolBase *wxToolBarBase::RemoveTool(int id) { size_t pos = 0; - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { if ( node->GetData()->GetId() == id ) @@ -302,10 +297,7 @@ wxToolBarToolBase *wxToolBarBase::RemoveTool(int id) return (wxToolBarToolBase *)NULL; } - // the node would delete the data, so set it to NULL to avoid this - node->SetData(NULL); - - m_tools.DeleteNode(node); + m_tools.Erase(node); return tool; } @@ -315,14 +307,15 @@ bool wxToolBarBase::DeleteToolByPos(size_t pos) wxCHECK_MSG( pos < GetToolsCount(), FALSE, _T("invalid position in wxToolBar::DeleteToolByPos()") ); - wxToolBarToolsList::Node *node = m_tools.Item(pos); + wxToolBarToolsList::compatibility_iterator node = m_tools.Item(pos); if ( !DoDeleteTool(pos, node->GetData()) ) { return FALSE; } - m_tools.DeleteNode(node); + delete node->GetData(); + m_tools.Erase(node); return TRUE; } @@ -330,7 +323,7 @@ bool wxToolBarBase::DeleteToolByPos(size_t pos) bool wxToolBarBase::DeleteTool(int id) { size_t pos = 0; - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { if ( node->GetData()->GetId() == id ) @@ -344,7 +337,8 @@ bool wxToolBarBase::DeleteTool(int id) return FALSE; } - m_tools.DeleteNode(node); + delete node->GetData(); + m_tools.Erase(node); return TRUE; } @@ -353,7 +347,7 @@ wxToolBarToolBase *wxToolBarBase::FindById(int id) const { wxToolBarToolBase *tool = (wxToolBarToolBase *)NULL; - for ( wxToolBarToolsList::Node *node = m_tools.GetFirst(); + for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; node = node->GetNext() ) { @@ -372,7 +366,7 @@ wxToolBarToolBase *wxToolBarBase::FindById(int id) const void wxToolBarBase::ClearTools() { - m_tools.Clear(); + WX_CLEAR_LIST(wxToolBarToolsList, m_tools); } bool wxToolBarBase::Realize() @@ -382,6 +376,7 @@ bool wxToolBarBase::Realize() wxToolBarBase::~wxToolBarBase() { + WX_CLEAR_LIST(wxToolBarToolsList, m_tools); } // ---------------------------------------------------------------------------- @@ -461,7 +456,7 @@ void wxToolBarBase::SetToolClientData(int id, wxObject *clientData) int wxToolBarBase::GetToolPos(int id) const { size_t pos = 0; - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { @@ -581,33 +576,14 @@ void wxToolBarBase::OnMouseEnter(int id) // UI updates // ---------------------------------------------------------------------------- -void wxToolBarBase::OnIdle(wxIdleEvent& event) -{ - DoToolbarUpdates(); - - event.Skip(); -} - // Do the toolbar button updates (check for EVT_UPDATE_UI handlers) -void wxToolBarBase::DoToolbarUpdates() +void wxToolBarBase::UpdateWindowUI(long flags) { - wxWindow* parent = this; - while (parent->GetParent()) - parent = parent->GetParent(); - -// This kind of #ifdef is a good way to annoy people. It breaks -// apps, but only on one platform and due to a hack in officially -// platform independent code. It took me hours to fix this. RR. -// -// #ifdef __WXMSW__ -// wxWindow* focusWin = wxFindFocusDescendant(parent); -// #else - wxWindow* focusWin = (wxWindow*) NULL; -// #endif + wxWindowBase::UpdateWindowUI(flags); - wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler() ; + wxEvtHandler* evtHandler = GetEventHandler() ; - for ( wxToolBarToolsList::Node* node = m_tools.GetFirst(); + for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); node; node = node->GetNext() ) {