If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
-
MrRage
- Knows some wx things

- Posts: 35
- Joined: Fri Mar 11, 2005 3:43 am
Post
by MrRage » Wed Mar 16, 2005 1:50 am
I want to make a Frame that would have multiple Panels associated with it. So if I click on a tool bar button it could change the panel currently associated with the frame.
I think I can have a set of wxSizers inside a panel, so I can take advantage of panel size. If I can do that then that would be awesome. Thanks for the help.

-
Cursor
- Earned some good credits

- Posts: 120
- Joined: Sun Aug 29, 2004 3:09 pm
- Location: Grenoble, France
-
Contact:
Post
by Cursor » Wed Mar 16, 2005 8:34 am
You can do it with a wxSizer where all your panels are embedded and with hidding and showing wanted panels on tool click.
You can also attach and detach (with hide and show) the panels on tool click.
If you use toolbar, why dont use a wxNotebook to do it. You can override the current panel changement to custom processing on panel leaving.
-
MrRage
- Knows some wx things

- Posts: 35
- Joined: Fri Mar 11, 2005 3:43 am
Post
by MrRage » Fri Mar 18, 2005 12:58 am
This might sound dumb.. but could someone post an exaple of how I would attach the wxSizers and then show/hide them?
Code: Select all
class wxMyFrame : public wxFrame{...};
wxMyFrame *wxMyFrame (...);
// Would the wxMyFrame constructor look something like this?
wxMyFrame::wxMyFrame(...){
// Create Status / ToolBar
statusBar = new wxStatusBar(...);
mainToolBar = new wxToolBar(...);
SetToolBar(mainToolBar );
SetStatusBar(statusBar );
// Each Build Sizer function returns a built wxSizer,
// with panels n stuff.
sizer1 = buildSizer1();
sizer2 = buildSizer2();
sizer3 = buildSizer3();
// So now do I add all 3 sizers?
}
-
Cursor
- Earned some good credits

- Posts: 120
- Joined: Sun Aug 29, 2004 3:09 pm
- Location: Grenoble, France
-
Contact:
Post
by Cursor » Fri Mar 18, 2005 7:13 am
wxMyFrame::wxMyFrame(...){
...
m_pSizer = new wxBoxSize(wxVERTICAL); // m_pSizer is a class member of type wxSizer*
m_pSizer->Add(pPanel0, 1, wxGROW);
m_pSizer->Add(pPanel1, 1, wxGROW);
m_pSizer->Add(pPanel2, 1, wxGROW);
...
SetSizer(pSizer);
ShowPanel(0);
}
wxMyFrame::ShowPanel(int iPanel){
m_pSizer->Show(pPanel0, iPanel==0);
m_pSizer->Show(pPanel1, iPanel==1);
m_pSizer->Show(pPanel2, iPanel==2);
...
}
And it is a little exemple, you can write it with array of panel.