// Modified by: VZ at 11.12.99 (wxScrollableToolBar splitted off)
// Created: 04/01/98
// RCS-ID: $Id$
-// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Copyright: (c) Julian Smart
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
wxToolBarToolBase *tool = CreateTool(id, label, bitmap, bmpDisabled, kind,
clientData, shortHelp, longHelp);
- if ( !tool || !DoInsertTool(pos, tool) )
+ if ( !InsertTool(pos, tool) )
{
delete tool;
return NULL;
}
+ return tool;
+}
+
+wxToolBarToolBase *wxToolBarBase::AddTool(wxToolBarToolBase *tool)
+{
+ return InsertTool(GetToolsCount(), tool);
+}
+
+wxToolBarToolBase *
+wxToolBarBase::InsertTool(size_t pos, wxToolBarToolBase *tool)
+{
+ wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
+ _T("invalid position in wxToolBar::InsertTool()") );
+
+ if ( !tool || !DoInsertTool(pos, tool) )
+ {
+ return NULL;
+ }
+
m_tools.Insert(pos, tool);
return tool;
wxToolBarToolBase *tool = CreateTool(control);
- if ( !tool || !DoInsertTool(pos, tool) )
+ if ( !InsertTool(pos, tool) )
{
delete tool;
return NULL;
}
- m_tools.Insert(pos, tool);
-
return tool;
}
+wxControl *wxToolBarBase::FindControl( int id )
+{
+ for ( wxToolBarToolsList::Node* node = m_tools.GetFirst();
+ node;
+ node = node->GetNext() )
+ {
+ const wxToolBarToolBase * const tool = node->GetData();
+ if ( tool->IsControl() )
+ {
+ wxControl * const control = tool->GetControl();
+
+ if ( !control )
+ {
+ wxFAIL_MSG( _T("NULL control in toolbar?") );
+ }
+ else if ( control->GetId() == id )
+ {
+ // found
+ return control;
+ }
+ }
+ }
+
+ return NULL;
+}
+
wxToolBarToolBase *wxToolBarBase::AddSeparator()
{
return InsertSeparator(GetToolsCount());
event.SetEventObject(this);
event.SetInt(id);
- (void)GetEventHandler()->ProcessEvent(event);
-
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
- if ( !frame )
- return;
-
- wxString helpstring;
-
- if ( id != -1 )
+ if( frame )
{
- wxToolBarToolBase *tool = FindById(id);
- if ( tool )
- helpstring = tool->GetLongHelp();
+ wxToolBarToolBase* tool = id == -1 ? (wxToolBarToolBase*)0 : FindById(id);
+ wxString help = tool ? tool->GetLongHelp() : wxString();
+ frame->DoGiveHelp( help, id != -1 );
}
- // set the status text anyhow, even if the string is empty: this ensures
- // that it is cleared when the mouse leaves the toolbar or enters a tool
- // without help
- if (frame->GetStatusBar())
- frame->SetStatusText(helpstring);
+ (void)GetEventHandler()->ProcessEvent(event);
}
// ----------------------------------------------------------------------------
while (parent->GetParent())
parent = parent->GetParent();
-#ifdef __WXMSW__
- wxWindow* focusWin = wxFindFocusDescendant(parent);
-#else
+// 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
+// #endif
wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler() ;