#include "wx/menu.h"
#endif
+extern WXDLLEXPORT_DATA(const char) wxToolBarNameStr[] = "toolbar";
+
// ----------------------------------------------------------------------------
// wxWidgets macros
// ----------------------------------------------------------------------------
wxToolBarToolBase::~wxToolBarToolBase()
{
+#if wxUSE_MENUS
delete m_dropdownMenu;
+#endif
+
if ( IsControl() )
GetControl()->Destroy();
}
}
+#if wxUSE_MENUS
void wxToolBarToolBase::SetDropdownMenu(wxMenu* menu)
{
delete m_dropdownMenu;
m_dropdownMenu = menu;
}
+#endif
// ----------------------------------------------------------------------------
wxCHECK_MSG( pos <= GetToolsCount(), NULL,
wxT("invalid position in wxToolBar::InsertTool()") );
- wxToolBarToolBase *tool = CreateTool(id, label, bitmap, bmpDisabled, kind,
- clientData, shortHelp, longHelp);
-
- if ( !InsertTool(pos, tool) )
- {
- delete tool;
-
- return NULL;
- }
-
- return tool;
+ return DoInsertNewTool(pos, CreateTool(id, label, bitmap, bmpDisabled, kind,
+ clientData, shortHelp, longHelp));
}
wxToolBarToolBase *wxToolBarBase::AddTool(wxToolBarToolBase *tool)
wxCHECK_MSG( control->GetParent() == this, NULL,
wxT("control must have toolbar as parent") );
- wxCHECK_MSG( pos <= GetToolsCount(), NULL,
- wxT("invalid position in wxToolBar::InsertControl()") );
-
- wxToolBarToolBase *tool = CreateTool(control, label);
-
- if ( !InsertTool(pos, tool) )
- {
- delete tool;
-
- return NULL;
- }
-
- return tool;
+ return DoInsertNewTool(pos, CreateTool(control, label));
}
wxControl *wxToolBarBase::FindControl( int id )
wxToolBarToolBase *wxToolBarBase::InsertSeparator(size_t pos)
{
- wxCHECK_MSG( pos <= GetToolsCount(), NULL,
- wxT("invalid position in wxToolBar::InsertSeparator()") );
+ return DoInsertNewTool(pos, CreateSeparator());
+}
- wxToolBarToolBase *tool = CreateTool(wxID_SEPARATOR,
- wxEmptyString,
- wxNullBitmap, wxNullBitmap,
- wxITEM_SEPARATOR, NULL,
- wxEmptyString, wxEmptyString);
+wxToolBarToolBase *wxToolBarBase::AddStretchableSpace()
+{
+ return InsertStretchableSpace(GetToolsCount());
+}
- if ( !tool || !DoInsertTool(pos, tool) )
+wxToolBarToolBase *wxToolBarBase::InsertStretchableSpace(size_t pos)
+{
+ wxToolBarToolBase * const tool = CreateSeparator();
+ if ( tool )
{
- delete tool;
-
- return NULL;
+ // this is a hack but we know that all the current implementations
+ // don't really use the tool when it's created, they will do it
+ // InsertTool() at earliest and maybe even in Realize() much later
+ //
+ // so we can create the tool as a plain separator and mark it as being
+ // a stretchable space later
+ tool->MakeStretchable();
}
- m_tools.Insert(pos, tool);
-
- return tool;
+ return DoInsertNewTool(pos, tool);
}
wxToolBarToolBase *wxToolBarBase::RemoveTool(int id)
if ( m_tools.empty() )
return false;
- // make sure tool size is larger enough for all all bitmaps to fit in
- // (this is consistent with what other ports do):
+ // make sure tool size is large enough for all bitmaps to fit in
AdjustToolBitmapSize();
return true;
}
}
+#if wxUSE_MENUS
bool wxToolBarBase::SetDropdownMenu(int toolid, wxMenu* menu)
{
wxToolBarToolBase * const tool = FindById(toolid);
return true;
}
+#endif
#if WXWIN_COMPATIBILITY_2_8