I am using an .xrc file to setup my wxWidgets GUI. For most GUI elements I can specify <hidden>1</hidden>
and the element will not be drawn.
What I'd like is to be able to hide my wxStaticBoxSizer
and have it and its contents not be drawn.
It's set up as follows, but adding <hidden>1</hidden>
does not have any effect. The static box still draws as does everything it contains.
<object class="wxStaticBoxSizer" name="wxID_ANY">
<orient>wxVERTICAL</orient>
<label>Flight Formation</label>
<object class="sizeritem">
<flag>wxGROW|wxALL</flag>
<border>10</border>
<option>1</option>
Is it possible to hide this wxStaticBoxSizer
from the .xrc file?
Quick hack: nest the sizer inside a wxPanel
and hide the panel.
If you're willing to rebuild the XRC lib, here's a quick patch that will provide the functionality you need.
In src/xrc/xh_sizer.cpp
, in the body of wxSizerXmlHandler::Handle_sizer()
, add the following right after the call to CreateChildren(parent, true/*only this handler*/);
:
// This has to be done after CreateChildren().
if(GetBool(wxT("hideitems"), 0) == 1)
sizer->ShowItems(false);
That's it. Rebuild the lib, and now you can specify <hideitems>1</hideitems>
on a sizer, which means it will be created with all its items hidden.
This will handle all sizers except wxStdDialogButtonSizer
, which has separate code. I tested it for wxBoxSizer
and wxStaticBoxSizer
using the XRC sample. I think I'll send a pull request to add this feature to wx; in the mean time, if anyone could do some more testing on this using a larger application, that would be great.