From fba2d5e6943c1687509cbcfe2e684a88b5878638 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 31 May 2002 10:00:24 +0000 Subject: [PATCH] Added wxToolBar::FindControl() to fish out controls in a toolbar by its id. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15712 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/tbarbase.h | 3 +++ src/common/tbarbase.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/wx/tbarbase.h b/include/wx/tbarbase.h index 7899208435..dfa4dcb40d 100644 --- a/include/wx/tbarbase.h +++ b/include/wx/tbarbase.h @@ -329,6 +329,9 @@ public: // NB: the control should have toolbar as its parent virtual wxToolBarToolBase *AddControl(wxControl *control); virtual wxToolBarToolBase *InsertControl(size_t pos, wxControl *control); + + // get the control with the given id or return NULL + virtual wxControl *FindControl( int id ); // add a separator to the toolbar virtual wxToolBarToolBase *AddSeparator(); diff --git a/src/common/tbarbase.cpp b/src/common/tbarbase.cpp index 14b0bd80e2..d99e214263 100644 --- a/src/common/tbarbase.cpp +++ b/src/common/tbarbase.cpp @@ -206,6 +206,24 @@ wxToolBarToolBase *wxToolBarBase::InsertControl(size_t pos, wxControl *control) return tool; } +wxControl *wxToolBarBase::FindControl( int id ) +{ + for ( wxToolBarToolsList::Node* node = m_tools.GetFirst(); + node; + node = node->GetNext() ) + { + wxControl *control = node->GetData()->GetControl(); + + if (control) + { + if (control->GetId() == id) + return control; + } + } + + return NULL; +} + wxToolBarToolBase *wxToolBarBase::AddSeparator() { return InsertSeparator(GetToolsCount()); -- 2.45.2