Search code examples
c++user-interfacewxwidgets

wxWidgets - Switch between different view on button click


I am making a music application, I have it show like a mini-view of the app as the default view, and I want it to switch to a big view on a button click. The default/mini view has a panel -> sizer -> sub-sizer -> widgets. And for the big view, I have a separate sizer and panel.

The default view looks like this

Mini View

And when I press the L button on bottom right, I want it to switch to big view which is supposed to look like this

Big View

The top panel is empty here, I have not added widgets to it yet. I can provide additional information if required, like code snippets and all. But I want everything to be on the same wxFrame. I have defined all widgets in the constructor, but it overrides the previous panel and sizer. Also I want to be able to switch back and forth between the 2 layouts.


Solution

  • For completely replacing the frame contents like this you may find wxSimplebook useful as you can then just call its ChangeSelection() method to switch pages. You will need to adjust the frame size, e.g. by calling frame->SetClientSize(book->GetBestSize()), after switching pages manually however.