Discussion:
Move sizer hierarchy inside another sizer
Vincent R.
2014-10-17 07:15:26 UTC
Permalink
Hi,

I have some pages that are designed under wxFormBuilder and I would like to
add by code a panel below taking 13% of the space.
So I am trying to move the page 's sizer inside another sizer and to
declare the right proportion but it doesn't work.
Here is what I tried :

enum { NAVPANEL_PERCENT_SZE = 13 };

wxSizer* pPageSizer = pWndPage->GetSizer();
if (pPageSizer)
{
wxBoxSizer* pNewPageSizer = new wxBoxSizer( wxVERTICAL );
pWndPage->SetSizer(pNewPageSizer);
pNewPageSizer->Insert(0, pPageSizer, 100 - NAVPANEL_PERCENT_SZE,
wxALL|wxEXPAND);
wxBoxSizer* pNavPanelSizer = new wxBoxSizer( wxVERTICAL );
StatusAndNavigateHTMLPanel* pNavStatus = new
StatusAndNavigateHTMLPanel(pWndPage, true);
pNavPanelSizer->Add(pNavStatus, NAVPANEL_PERCENT_SZE, wxALL|wxEXPAND);
pNewPageSizer->Add(pNavPanelSizer, NAVPANEL_PERCENT_SZE, wxALL|wxEXPAND);
pWndPage->Layout();
}

I assume that when I do pWndPage->SetSizer(pNewPageSizer); the sizer is
deallocated and that's why maybe it doesn't work.
So my question is how can I change the sizer tree to achieve what I want.

Thanks
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-10-17 12:14:28 UTC
Permalink
On Fri, 17 Oct 2014 00:15:26 -0700 (PDT) Vincent R. wrote:

VR> I assume that when I do pWndPage->SetSizer(pNewPageSizer); the sizer is
VR> deallocated and that's why maybe it doesn't work.

If this is correct, then you just need to pass "false" as second argument
of SetSizer() to prevent the old sizer from being deleted.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Vincent R.
2014-10-17 13:27:21 UTC
Permalink
Yes my assumption my right and you answer too :-)
Post by Vadim Zeitlin
VR> I assume that when I do pWndPage->SetSizer(pNewPageSizer); the sizer is
VR> deallocated and that's why maybe it doesn't work.
If this is correct, then you just need to pass "false" as second argument
of SetSizer() to prevent the old sizer from being deleted.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vincent R.
2014-10-17 13:27:55 UTC
Permalink
Yes my assumption was right and you answer too :-)
Post by Vadim Zeitlin
VR> I assume that when I do pWndPage->SetSizer(pNewPageSizer); the sizer is
VR> deallocated and that's why maybe it doesn't work.
If this is correct, then you just need to pass "false" as second argument
of SetSizer() to prevent the old sizer from being deleted.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...