Author Topic: Add toolbar to specific sizer with wxSmith  (Read 1785 times)

Offline eranon

  • Almost regular
  • **
  • Posts: 180
Add toolbar to specific sizer with wxSmith
« on: July 31, 2013, 05:50:44 pm »

I would like to add a wxToolbar (created from wxSmith) to a wxFlexGridSizer which is not the top-level one in the frame. So, doing "sizer->Add(toolbar)" rather than the usual "SetToolbar(toolbar)" generated by wxSmith.

Is there a way to do it with wxSmith (and continue to manage this toolbar from within wxSmith) ?

EDIT : OK, solved this specific point overriding SetToolBar like this :

Code: [Select]
void TestFrame::SetToolBar(wxToolBar* toolBar)
    if (toolBar->GetName() == "ID_TOOLBAR1")

So, I can stay with the code generated by wxSmith (which call SetToolBar() systematically)... But, now, I've another problem to solve : my toolbar must be owned by a panel inside the frame (otherwise, I have an issue about events ; but it's another subject). So, my new derived question is : How to indicate the toolbar's parent with wxSmith ? Knowing this panel is not a separated class derived from wxPanel, but directly a wxPanel declared as variable during frame ctor. I don't see any parent field in the properties grid. Is there a way (keeping wxSmith) to decide about the parameter passed to the toolbar ctor ?

EDIT #2 : solved changing the parent afterward in my same SetToolBar() overriding, like this :

Code: [Select]
void TestFrame::SetToolBar(wxToolBar* toolBar)
    // Override wxFrame::SetToolbar to customize the association and position
    // NB : workaround for using wxSmith even if it calls SetToolBar systematically and doesn't allow custom parent
    if (toolBar->GetName() == "ID_TOOLBAR1"){
    else {

Well, it's really because I like wxSmith (and its CodeBlocks integration) and want to continue with it... Hoping it's a good long term choice :)
« Last Edit: August 01, 2013, 12:26:58 am by eranon »
[Independent dev. - wxWidgets 3.0.0 under "Win 7 Pro 64-bit, C::B SVN 9435 & wxSmith, TDM64-GCC 4.7 & MSVC9" + "OS X 10.8, FSF GCC 4.7 & C::B SVN 8909"]