wxAUI: Can't "Show" a closed pane (simple example enclosed)
Fred Cailleau-Lepetit
softinthebox-anti_SPAM at free.fr
Thu Aug 30 11:05:50 PDT 2007
Hi,
for the left pane, try with this code on the constructor of your frame.
wxTextCtrl *p = new wxTextCtrl(this, -1, wxT("pane"));
m_mgr.AddPane(p, wxAuiPaneInfo().Name(wxT("pane")).
Caption(wxT("Pane")).DestroyOnClose(false).Left());
Regards
Fred Cailleau-Lepetit
defreitas at gmail.com a écrit :
> I create a wxAUI app with a center text pane and a docked text pane on
> the left. I close the left pane by clicking on the "X", but I cannot
> seem to make it reappear by using the "Show" member function of
> wxAuiPaneInfo.
>
> I must be doing something wrong, as I have the same problem with wxMSW
> and wxGTK. The simple example is:
>
>
>
> #include "wx/wx.h"
> #include "wx/aui/aui.h"
>
> //
> =============================================================================
> // Declare the application class
> //
> =============================================================================
>
> class MyApp : public wxApp
> {
> public:
> virtual bool OnInit();
> };
>
> //
> =============================================================================
> // Declare the main frame class
> //
> =============================================================================
>
> class MyFrame : public wxFrame
> {
> public:
>
> enum {
> ID_ShowPane = wxID_HIGHEST + 1,
> };
>
> MyFrame(const wxString& title);
> ~MyFrame();
>
> private:
> void onExit(wxCommandEvent& event);
> void onShowPane(wxCommandEvent& event);
>
> wxAuiManager m_mgr;
>
> // This class handles events
> DECLARE_EVENT_TABLE()
> };
>
> DECLARE_APP(MyApp) // Standard macros to declare your
> Application
> IMPLEMENT_APP(MyApp) // ... and implement it
>
> //
> =============================================================================
> // MyApp::OnInit: Initialize the application
> //
> =============================================================================
>
> bool MyApp::OnInit()
> {
> MyFrame *frame = new MyFrame(wxT("My App"));
> SetTopWindow(frame);
> frame->Show(true);
> return true;
> }
>
> //
> =============================================================================
> //
> =============================================================================
> //===
> //=== Implementation of MyFrame
> //===
> //
> =============================================================================
> //
> =============================================================================
>
> //~~~ Event table for MyFrame: maps event id's to event handlers
>
> BEGIN_EVENT_TABLE(MyFrame, wxFrame)
> EVT_MENU(wxID_EXIT, MyFrame::onExit)
> EVT_MENU(MyFrame::ID_ShowPane, MyFrame::onShowPane)
> END_EVENT_TABLE()
>
> //
> =============================================================================
> // MyFrame::MyFrame: Constructor.
> //
> =============================================================================
>
> MyFrame::MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY,
> title)
> {
> //~~~ Tell wxFrameManager to manage this frame
>
> m_mgr.SetManagedWindow(this);
>
> //~~~ Build the menubar
>
> wxMenuBar *menuBar = new wxMenuBar();
>
> wxMenu *fileMenu = new wxMenu;
> fileMenu->Append(wxID_EXIT, wxT("Exit"));
>
> wxMenu *viewMenu = new wxMenu;
> viewMenu->Append(ID_ShowPane, wxT("Show Pane"));
>
> menuBar->Append(fileMenu, wxT("&File"));
> menuBar->Append(viewMenu, wxT("&View"));
>
> SetMenuBar(menuBar);
>
> //~~~ Create a docked pane
>
> wxTextCtrl *p = new wxTextCtrl(this, -1, wxT("pane"));
> m_mgr.AddPane(p, wxAuiPaneInfo().Name(wxT("pane")).
> Caption(wxT("Pane")).Left());
>
> //~~~ Create a center pane
>
> wxTextCtrl *c = new wxTextCtrl(this, -1, wxT("Center"));
> m_mgr.AddPane(c, wxAuiPaneInfo().Name(wxT("center")).CenterPane());
>
> //~~~ Commit changes to wxAuiManager
>
> m_mgr.Update();
> }
>
> //
> =============================================================================
> // MyFrame::~MyFrame: Destructor.
> //
> =============================================================================
>
> MyFrame::~MyFrame()
> {
> m_mgr.UnInit();
> }
>
> //
> =============================================================================
> // MyFrame::onExit: Exit event handler
> //
> =============================================================================
>
> void MyFrame::onExit(wxCommandEvent& event)
> {
> Close();
> }
>
> //
> =============================================================================
> // MyFrame::onShowPane: Show the Navigator panel.
> //
> =============================================================================
>
> void MyFrame::onShowPane(wxCommandEvent& event)
> {
> wxAuiPaneInfo pi = m_mgr.GetPane(wxT("pane"));
> if (pi.IsOk()) {
> if (!pi.IsShown()) {
> pi.Show();
> m_mgr.Update();
> }
> }
> }
>
More information about the wx-users
mailing list