Hi i am trying to remove all elements(including wxSizers and wxWindows) from inside a wxBoxSizer(wxVERTICAL) . The hierarchy structure I am using is shown in the screenshot below.
Note that there are two more vertical spacers that are placed above and below the statictext to make the static text vertically centered but I have not shown them in the diagram.
I have exactly one mainSizer and many such elementPanels vertically placed, as the containing mainSizer is vertical. Now I want to remove all the vertically placed elementPanels(and everything inside it) from the mainSizer. How can I achieve this? And does a wxsizer have an id associated with it? If not, how can i find this particular mainSizer from another part of the program so that i can remove everything inside of it. That is, I want to remove all the elementPanels(and everything inside) that I added in the mainSizer but do not delete the mainSizer itself.
I guess i can have the mainSizer inside a wxPanel and use its id to get to the mainSizer. But still the problem remains how can i delete every child(including sizer and wxWindow) from the mainSizer?
As far as I know there is no command to remove or destroy the children of a sizer. From the documentation of the deprecated function wxSizer::Remove(wxWindow* window)
wxSizer::Remove(wxWindow* window); "Removes a child window from the sizer, but does not destroy it (because windows are owned by their parent window, not the sizer)."
So to destroy elements of a sizer you'd have to call DestroyChildren() from the parents of the panels. You could make a window solely for this purpose and have it's children be the elements you want in your box sizer.
parentWindowInsideBoxSizer->DestroyChildren();
You can also remove individual children.
parentWindowInsideBoxSizer->RemoveChild(child)
https://docs.wxwidgets.org/3.0/classwx_window.html#acee332ed4368d26e8bc3db5767c1240a