Skip to content
Search

WxAuiManager

lastmod 2018-08-17created 2015-03-206 edits

Example

Use it as follows.

m_mgr.SetManagedWindow(this);
wxTextCtrl* text1 = new wxTextCtrl(this, -1);
wxTextCtrl* text2 = new wxTextCtrl(this, -1);
m_mgr.AddPane(text1, wxLEFT, "Pane Caption");
m_mgr.AddPane(text2, wxBOTTOM, "Pane Caption");
m_mgr.Update();

A caveat when using it in the constructor: if you use it before building the layout (before applying wxSizer, etc.), the program crashes. So it is best to use it right before calling Centre() of wxWindowBase. <span style="color:red"><- This information is wrong. Depending on the program structure, it may or may not crash.

Note that it can also be used right after calling Centre(), in which case GetPosition() etc. can be used. However, do not add widgets directly to the parent window with SetSizer() etc.; add them to wxAuiManager as follows.

_media_panel = new MediaPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
_aui_manager.AddPane(_media_panel, wxCENTER, wxT("main"));

When you are done using it (in the destructor, etc.), call UnInit() as follows.

m_mgr.UnInit();

Flip Show/Hide Panel

To flip show/hide, apply the following.

void MainFrame::flipShowAndHidePanel(wxString const & name)
{
    wxAuiPaneInfo & info = _aui_manager.GetPane(name);
    if (info.IsOk() == false) {
        return;
    }

    if (info.IsShown() == true) {
        info.Hide();
    } else {
        info.Show();
    }

    _aui_manager.Update();
}

Favorite site