How to find wxAuiToolBarItem from wxAuiManager?

I am testing the wxAuiToolBar class as a replacement for the existing wxToolbar.

My initialization works fine - I can even set nested / vectorized .png files as bitmaps for elements, which is really cool - but I would like the user to be able to specify what size of the toolbar 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 is a better way to do this!

As an example, I have a standard File toolbar with new buttons / open / save / print. They are added to the wxAuiManager member as follows:

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 everything configured, how do I get into this ToolBarItem given the wxAuiManager (m_AuiManager) member associated with the frame? Or is there a better way to resize toolbars?

+3
source share
1 answer

Well, maybe this was a two-part question:

  • How do I get the wxAuiToolBarItem file after creating it?
  • What is the best way to resize a toolbar after creating it?

I managed to get to wxToolBarItem using the wxAuiToolBar-> FindTool () method. I have a 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);

- - , . , :

pMainFrame->m_AuiToolbar->ClearTools();

m_AuiToolbar- > AddTool() , AddTool(). , . ? .

+1

All Articles