I'm trying out the wxAuiToolBar class as a replacement for an existing wxToolbar.
My initialization is working fine -- I'm even able to set embedded / vectorized .png files as the bitmaps for the items, which is really cool -- but I'd like for the user to be able to specify what toolbar size they want (16x16, 22x22 or 32x32). I think that means calling wxAuiToolBarItem.SetBitmap() for each toolbar item and then wxToolBar.Realize() to redraw the changes. Correct me if there's a better way to do this!
As an example, I've got a standard File toolbar with new/open/save/print buttons. These are added to a member wxAuiManager guy like so:
auiFileToolBar = new wxAuiToolbar(pFrame, ID_AUIFILETOOLBAR, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE);
auiFileToolBar->AddTool(ID_TBI_FILE_NEW, _("New"), wxNullBitmap, wxNullBitmap, wxITEM_NORMAL, wxEmptyString, wxEmptyString, NULL);
// ... other toolbar items
auiFileToolBar->Realize();
m_AuiManager->AddPane(auiFileToolBar, wxAuiPaneInfo().Name(_T("File")).ToolbarPane().Caption(_T("File")).Layer(10).Top.Gripper(false));
So now that I have all that set up, how do I get at a given ToolBarItem, given the member wxAuiManager (m_AuiManager) associated with the frame? Or is there a better way to resize the toolbars?
Okay, so maybe this was a two-part question:
I was able to get at the wxToolBarItem by using the wxAuiToolBar->FindTool() method. I've got the toolbar as a member variable, which makes access fairly easy. The code looks something like this:
wxAuiToolBarItem *tbi;
tbi = pMainFrame->m_AuiToolbar-FindTool(ID_TBI_FILE_NEW);
// do something with the toolbar item
tbi->SetBitmap(random_bitmap_thingy);
For the second part of the question--the question of best practices for switching between a big and little toolbar--I'm not sure that I have an answer. Right now I've got a method that calls:
pMainFrame->m_AuiToolbar->ClearTools();
and then calls m_AuiToolbar->AddTool() with the new bitmaps passed in as params to the AddTool() method. This does seem to work, as I can switch between small and large bitmaps without issue. Is it the best way to do it? No idea.