const wxString& longHelp,
wxObject *clientData)
{
- wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( pos <= GetToolsCount(), NULL,
_T("invalid position in wxToolBar::InsertTool()") );
wxToolBarToolBase *tool = CreateTool(id, label, bitmap, bmpDisabled, kind,
wxToolBarToolBase *
wxToolBarBase::InsertTool(size_t pos, wxToolBarToolBase *tool)
{
- wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( pos <= GetToolsCount(), NULL,
_T("invalid position in wxToolBar::InsertTool()") );
if ( !tool || !DoInsertTool(pos, tool) )
wxControl *control,
const wxString& label)
{
- wxCHECK_MSG( control, (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( control, NULL,
_T("toolbar: can't insert NULL control") );
- wxCHECK_MSG( control->GetParent() == this, (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( control->GetParent() == this, NULL,
_T("control must have toolbar as parent") );
- wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( pos <= GetToolsCount(), NULL,
_T("invalid position in wxToolBar::InsertControl()") );
wxToolBarToolBase *tool = CreateTool(control, label);
wxToolBarToolBase *wxToolBarBase::InsertSeparator(size_t pos)
{
- wxCHECK_MSG( pos <= GetToolsCount(), (wxToolBarToolBase *)NULL,
+ wxCHECK_MSG( pos <= GetToolsCount(), NULL,
_T("invalid position in wxToolBar::InsertSeparator()") );
wxToolBarToolBase *tool = CreateTool(wxID_SEPARATOR,
wxEmptyString,
wxNullBitmap, wxNullBitmap,
- wxITEM_SEPARATOR, (wxObject *)NULL,
+ wxITEM_SEPARATOR, NULL,
wxEmptyString, wxEmptyString);
if ( !tool || !DoInsertTool(pos, tool) )
wxToolBarToolBase *wxToolBarBase::FindById(int id) const
{
- wxToolBarToolBase *tool = (wxToolBarToolBase *)NULL;
+ wxToolBarToolBase *tool = NULL;
for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
node;
}
}
+void wxToolBarBase::AdjustToolBitmapSize()
+{
+ const wxSize sizeOrig(m_defaultWidth, m_defaultHeight);
+
+ wxSize sizeActual(sizeOrig);
+
+ for ( wxToolBarToolsList::const_iterator i = m_tools.begin();
+ i != m_tools.end();
+ ++i )
+ {
+ const wxBitmap& bmp = (*i)->GetNormalBitmap();
+ if ( bmp.IsOk() )
+ sizeActual.IncTo(bmp.GetSize());
+ }
+
+ if ( sizeActual != sizeOrig )
+ SetToolBitmapSize(sizeActual);
+}
+
bool wxToolBarBase::Realize()
{
+ // check if we have anything to do
+ 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):
+ AdjustToolBitmapSize();
+
return true;
}
{
wxToolBarToolBase *tool = FindById(id);
- return tool ? tool->GetClientData() : (wxObject *)NULL;
+ return tool ? tool->GetClientData() : NULL;
}
void wxToolBarBase::SetToolClientData(int id, wxObject *clientData)
event.SetExtraLong((long)toggleDown);
// Send events to this toolbar instead (and thence up the window hierarchy)
- GetEventHandler()->ProcessEvent(event);
+ HandleWindowEvent(event);
return true;
}
node;
node = node->GetNext() )
{
- int id = node->GetData()->GetId();
+ wxToolBarToolBase * const tool = node->GetData();
+ if ( tool->IsSeparator() )
+ continue;
+
+ int id = tool->GetId();
wxUpdateUIEvent event(id);
event.SetEventObject(this);