Recommend using wxStaticBox as parent more strongly
Not doing it, i.e. creating the window inside the static box as its siblings, rather than children, may appear to work, but actually doesn't always do it, for example the windows are not shown correctly when using RTL locale. Closes #19086.
This commit is contained in:
@@ -1892,7 +1892,7 @@ 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.1 you are encouraged to create the windows
|
Note that since wxWidgets 2.9.1 you are strongly encouraged to create the windows
|
||||||
which are added to wxStaticBoxSizer as children of wxStaticBox itself, see
|
which are added to wxStaticBoxSizer as children of wxStaticBox itself, see
|
||||||
this class documentation for more details.
|
this class documentation for more details.
|
||||||
|
|
||||||
|
@@ -13,12 +13,12 @@
|
|||||||
|
|
||||||
Note that while the previous versions required that windows appearing
|
Note that while the previous versions required that windows appearing
|
||||||
inside a static box be created as its siblings (i.e. use the same parent as
|
inside a static box be created as its siblings (i.e. use the same parent as
|
||||||
the static box itself), since wxWidgets 2.9.1 it is also possible to create
|
the static box itself), since wxWidgets 2.9.1 it is possible to create
|
||||||
them as children of wxStaticBox itself and you are actually encouraged to
|
them as children of wxStaticBox itself and doing this is strongly
|
||||||
do it like this if compatibility with the previous versions is not
|
recommended and avoids several different repainting problems that could
|
||||||
important.
|
happen when creating the other windows as siblings of the box.
|
||||||
|
|
||||||
So the new recommended way to create static box is:
|
So the recommended way to create static box and the controls inside it is:
|
||||||
@code
|
@code
|
||||||
void MyFrame::CreateControls()
|
void MyFrame::CreateControls()
|
||||||
{
|
{
|
||||||
@@ -30,13 +30,9 @@
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
While the compatible -- and now deprecated -- way is
|
Creating the windows with the static box parent (i.e. @c panel in the
|
||||||
@code
|
example above) as parent still works but can result in refresh and repaint
|
||||||
wxStaticBox *box = new wxStaticBox(panel, wxID_ANY, "StaticBox");
|
problems.
|
||||||
|
|
||||||
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