wxAUI: Can't "Show" a closed pane (simple example enclosed)
Fred Cailleau-Lepetit
softinthebox-anti_SPAM at free.fr
Sat Sep 1 04:53:51 PDT 2007
Hi,
i don't exactly why! But this example work fine.
The controls are the same as your example.
Regards
Fred Cailleau-Lepetit
/* ------------------------------------------------------------ */
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#define ID_MNUSHOWHIDE 15001
#include "wx/aui/framemanager.h"
#include "wx/frame.h"
#include <wx/treectrl.h>
#include <wx/aui/auibook.h>
class Project1App: public wxApp
{
public:
Project1App(){}
virtual bool OnInit();
};
class TestwxAUI: public wxFrame
{
DECLARE_CLASS( TestwxAUI )
DECLARE_EVENT_TABLE()
public:
TestwxAUI(){}
TestwxAUI(wxWindow* parent, wxWindowID id = -1,
const wxString& caption = _("Test wxAUI"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);
bool Create(wxWindow* parent, wxWindowID id = -1,
const wxString& caption = _("Test wxAUI"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE);
~TestwxAUI();
void CreateControls();
protected:
void OnMnushowhideClick( wxCommandEvent& event );
void OnExitClick( wxCommandEvent& event );
wxAuiManager& GetAuiManager() {return m_auiManager;}
private:
wxAuiManager m_auiManager;
void HideShowPane(const wxString& name);
};
IMPLEMENT_APP(Project1App)
bool Project1App::OnInit()
{
TestwxAUI* mainWindow = new TestwxAUI(NULL);
mainWindow->Show(true);
return true;
}
IMPLEMENT_CLASS( TestwxAUI, wxFrame )
BEGIN_EVENT_TABLE( TestwxAUI, wxFrame )
EVT_MENU( ID_MNUSHOWHIDE, TestwxAUI::OnMnushowhideClick )
EVT_MENU( wxID_EXIT, TestwxAUI::OnExitClick )
END_EVENT_TABLE()
TestwxAUI::TestwxAUI(wxWindow* parent, wxWindowID id,
const wxString& caption, const wxPoint& pos,
const wxSize& size, long style)
{
Create( parent, id, caption, pos, size, style );
}
bool TestwxAUI::Create(wxWindow* parent, wxWindowID id,
const wxString& caption, const wxPoint& pos,
const wxSize& size, long style)
{
wxFrame::Create(parent, id, caption, pos, size, style);
CreateControls();
return true;
}
TestwxAUI::~TestwxAUI(){GetAuiManager().UnInit();}
void TestwxAUI::CreateControls()
{
GetAuiManager().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_MNUSHOWHIDE, 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"));
GetAuiManager().AddPane(p, wxAuiPaneInfo().Name(wxT("pane")).
Caption(wxT("Pane")).Left());
//~~~ Create a center pane
wxTextCtrl *c = new wxTextCtrl(this, -1, wxT("Center"));
GetAuiManager().AddPane(c,
wxAuiPaneInfo().Name(wxT("center")).CenterPane());
//~~~ Commit changes to wxAuiManager
GetAuiManager().Update();
}
void TestwxAUI::OnMnushowhideClick(wxCommandEvent& event)
{
HideShowPane(_T("pane"));
}
void TestwxAUI::HideShowPane(const wxString& name)
{
wxAuiPaneInfo& pane = GetAuiManager().GetPane(name);
if (pane.IsOk()&&)
{
pane.Show(!pane.IsShown());
GetAuiManager().Update();
}
}
void TestwxAUI::OnExitClick( wxCommandEvent& event ){Close();}
More information about the wx-users
mailing list