Correct examples in wxStaticBox(Sizer) documentation.
Added missing wxID_ANY in the control creation calls. Also rephrase/extend the discussion about creating windows shown inside the static box as its children or siblings. Closes #11086. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1654,18 +1654,22 @@ public:
|
|||||||
itself as a convenience. In any case, the sizer owns the wxStaticBox control
|
itself as a convenience. In any case, the sizer owns the wxStaticBox control
|
||||||
and will delete it in the wxStaticBoxSizer destructor.
|
and will delete it in the wxStaticBoxSizer destructor.
|
||||||
|
|
||||||
Note that since wxWidgets 2.9.0 you are encouraged to build the windows which are
|
Note that since wxWidgets 2.9.1 you are encouraged to create the windows
|
||||||
placed inside wxStaticBoxes as children of the wxStaticBox itself:
|
which are added to wxStaticBoxSizer as children of wxStaticBox itself, see
|
||||||
@code
|
this class documentation for more details.
|
||||||
...
|
|
||||||
wxStaticBoxSizer *sz = new wxStaticBoxSizer(wxVERTICAL, parentWindow, "StaticBox");
|
|
||||||
sz->Add(new wxStaticText(sz->GetStaticBox(), "This window is a child of the staticbox"));
|
|
||||||
...
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
Creating the windows which are placed inside wxStaticBoxes as siblings of the
|
Example of use of this class:
|
||||||
wxStaticBox is still allowed but it's deprecated as it gives some problems
|
@code
|
||||||
(e.g. relative to tooltips) on some ports.
|
void MyFrame::CreateControls()
|
||||||
|
{
|
||||||
|
wxPanel *panel = new wxPanel(this);
|
||||||
|
...
|
||||||
|
wxStaticBoxSizer *sz = new wxStaticBoxSizer(wxVERTICAL, panel, "Box");
|
||||||
|
sz->Add(new wxStaticText(sz->GetStaticBox(), wxID_ANY,
|
||||||
|
"This window is a child of the staticbox"));
|
||||||
|
...
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
@library{wxcore}
|
@library{wxcore}
|
||||||
@category{winlayout}
|
@category{winlayout}
|
||||||
|
@@ -12,19 +12,32 @@
|
|||||||
A static box is a rectangle drawn around other windows to denote
|
A static box is a rectangle drawn around other windows to denote
|
||||||
a logical grouping of items.
|
a logical grouping of items.
|
||||||
|
|
||||||
Note that since wxWidgets 2.9.0 you are encouraged to build the windows which are
|
Note that while the previous versions required that windows appearing
|
||||||
placed inside wxStaticBoxes as children of the wxStaticBox itself:
|
inside a static box be created as its siblings (i.e. use the same parent as
|
||||||
@code
|
the static box itself), since wxWidgets 2.9.1 it is also possible to create
|
||||||
...
|
them as children of wxStaticBox itself and you are actually encouraged to
|
||||||
wxStaticBox *stbox = new wxStaticBox(parentWindow, wxID_ANY, "StaticBox");
|
do it like this if compatibility with the previous versions is not
|
||||||
|
important.
|
||||||
|
|
||||||
new wxStaticText(stbox, "This window is a child of the staticbox");
|
So the new recommended way to create static box is:
|
||||||
...
|
@code
|
||||||
|
void MyFrame::CreateControls()
|
||||||
|
{
|
||||||
|
wxPanel *panel = new wxPanel(this);
|
||||||
|
wxStaticBox *box = new wxStaticBox(panel, wxID_ANY, "StaticBox");
|
||||||
|
|
||||||
|
new wxStaticText(box, wxID_ANY "This window is a child of the staticbox");
|
||||||
|
...
|
||||||
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Creating the windows which are placed inside wxStaticBoxes as siblings of the
|
While the compatible -- and now deprecated -- way is
|
||||||
wxStaticBox is still allowed but it's deprecated as it gives some problems
|
@code
|
||||||
(e.g. relative to tooltips) on some ports.
|
wxStaticBox *box = new wxStaticBox(panel, wxID_ANY, "StaticBox");
|
||||||
|
|
||||||
|
new wxStaticText(panel, wxID_ANY "This window is a child of the panel");
|
||||||
|
...
|
||||||
|
@endcode
|
||||||
|
|
||||||
Also note that there is a specialized wxSizer class (wxStaticBoxSizer) which can
|
Also note that there is a specialized wxSizer class (wxStaticBoxSizer) which can
|
||||||
be used as an easier way to pack items into a static box.
|
be used as an easier way to pack items into a static box.
|
||||||
|
Reference in New Issue
Block a user