User forums > General (but related to Code::Blocks)
Add toolbar to specific sizer with wxSmith
(1/1)
eranon:
Hello,
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: ---void TestFrame::SetToolBar(wxToolBar* toolBar)
{
if (toolBar->GetName() == "ID_TOOLBAR1")
sizerForToolbar1->Add(toolBar);
else
wxFrame::SetToolBar(toolBar);
}
--- End code ---
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: ---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"){
toolBar->Reparent(Panel1);
sizerForToolbar1->Add(toolBar);}
else {
wxFrame::SetToolBar(toolBar);}
}
--- End code ---
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 :)
Navigation
[0] Message Index
Go to full version