I'm trying to use wxAuiNotebook but it produces an error if I press on its tab.
Also I can see memory leaks when adding tabs to wxAuiNotebook.
Detected memory leaks!
Dumping objects ->
{5908} normal block at 0x00FEC888, 24 bytes long.
Data: <0 > 30 D1 15 00 FF FF FF FF 00 00 00 00 00 00 00 00
{5907} normal block at 0x01006F30, 364 bytes long.
Data: <T > 54 DD 98 00 00 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.
The program '[3444] DockingWindowsSample.exe: Native' has exited with code 0 (0x0).
All this problems appear only in Debug mode.
The source coe is listed below.
Header
- Code: Select all
#ifndef _DOCKING_WINDOWS_SAMPLE_MAINFRAME_H
#define _DOCKING_WINDOWS_SAMPLE_MAINFRAME_H
#include <wx/wx.h>
#include <wx/treectrl.h>
#include <wx/aui/aui.h>
#define wxDWSTitleStr _("Docking Windows Sample")
class DockingWindowsSampleMainFrame : public wxFrame
{
wxAuiManager m_Manager;
wxToolBar * m_StdToolBar;
wxToolBar * m_AddToolBar;
wxTreeCtrl * m_InfoTree;
wxAuiNotebook * m_Notebook;
wxPanel * m_Page1;
wxPanel * m_Page2;
void CreateControls();
void CreateStdToolBar();
void CreateAddToolBar();
void CreateInfoTree();
DECLARE_DYNAMIC_CLASS(DockingWindowsSampleMainFrame)
public:
DockingWindowsSampleMainFrame();
DockingWindowsSampleMainFrame(wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxString & title = wxDWSTitleStr,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxSize(650, 450),
long style = wxDEFAULT_FRAME_STYLE);
~DockingWindowsSampleMainFrame();
bool Create(wxWindow * parent,
wxWindowID id = wxID_ANY,
const wxString & title = wxDWSTitleStr,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxSize(650, 450),
long style = wxDEFAULT_FRAME_STYLE);
DECLARE_EVENT_TABLE()
void OnExit(wxCommandEvent & event);
};
#endif
Implementation
- Code: Select all
#include "DockingWindowsSampleMainFrame.h"
//#include "wxAuiAeroDockArt.h"
#include "wxwin16x16.xpm"
#include "new.xpm"
#include "fileopen.xpm"
#include "filesave.xpm"
#include "htmfoldr.xpm"
#include "cut.xpm"
#include "copy.xpm"
#include "find.xpm"
IMPLEMENT_DYNAMIC_CLASS(DockingWindowsSampleMainFrame, wxFrame);
enum
{
ID_TOGGLE_STANDARD_TOOLBAR = 10001,
ID_TOGGLE_ADDITIONAL_TOOLBAR,
ID_TOGGLE_STATUSBAR,
ID_LOAD_LAYOUT,
ID_SAVE_LAYOUT,
ID_NOTEBOOK,
ID_INFO_TREE
};
BEGIN_EVENT_TABLE(DockingWindowsSampleMainFrame, wxFrame)
EVT_MENU(wxID_EXIT, DockingWindowsSampleMainFrame::OnExit)
END_EVENT_TABLE()
DockingWindowsSampleMainFrame::DockingWindowsSampleMainFrame()
{
}
DockingWindowsSampleMainFrame::DockingWindowsSampleMainFrame(wxWindow * parent,
wxWindowID id, const wxString & title, const wxPoint & pos,
const wxSize & size, long style)
{
m_StdToolBar = NULL;
m_AddToolBar = NULL;
m_Page1 = NULL;
m_Page2 = NULL;
m_Notebook = NULL;
Create(parent, id, title, pos, size, style);
}
DockingWindowsSampleMainFrame::~DockingWindowsSampleMainFrame()
{
m_Manager.UnInit();
}
bool DockingWindowsSampleMainFrame::Create(wxWindow * parent,
wxWindowID id, const wxString & title, const wxPoint & pos,
const wxSize & size, long style)
{
bool res = wxFrame::Create(parent, id, title, pos, size, style);
if(res)
{
SetIcon(wxIcon(wxwin16x16_xpm));
CreateControls();
}
return res;
}
void DockingWindowsSampleMainFrame::CreateControls()
{
wxMenuBar * menuBar = new wxMenuBar;
SetMenuBar(menuBar);
wxMenu * fileMenu = new wxMenu;
fileMenu->Append(wxID_NEW, _("New\tCtrl+N"));
fileMenu->Append(wxID_OPEN, _("Open\tCtrl+O"));
fileMenu->Append(wxID_SAVE, _("Save\tCtrl+S"));
fileMenu->AppendSeparator();
fileMenu->Append(wxID_EXIT, _("Exit\tAlt+F4"));
wxMenu * toolbarsMenu = new wxMenu;
toolbarsMenu->Append(ID_TOGGLE_STANDARD_TOOLBAR, _("Standard"));
toolbarsMenu->Append(ID_TOGGLE_ADDITIONAL_TOOLBAR, _("Additional"));
wxMenu * layoutMenu = new wxMenu;
layoutMenu->Append(ID_LOAD_LAYOUT, _("Load"));
layoutMenu->Append(ID_SAVE_LAYOUT, _("Save"));
wxMenu * viewMenu = new wxMenu;
viewMenu->Append(wxID_ANY, _("Toolbars"), toolbarsMenu);
viewMenu->Append(wxID_ANY, _("Layout"), layoutMenu);
viewMenu->Append(ID_TOGGLE_STATUSBAR, _("Status Bar"));
wxMenu * helpMenu = new wxMenu;
helpMenu->Append(wxID_ABOUT, _("About..."));
menuBar->Append(fileMenu, _("File"));
menuBar->Append(viewMenu, _("View"));
menuBar->Append(helpMenu, _("Help"));
m_Manager.SetManagedWindow(this);
/*wxAuiAeroDockArt * dockart = new wxAuiAeroDockArt;
m_Manager.SetArtProvider(dockart);*/
CreateStatusBar();
CreateStdToolBar();
CreateAddToolBar();
CreateInfoTree();
m_Notebook = new wxAuiNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxSize(600, 450));
m_Page1 = new wxPanel(m_Notebook, wxID_ANY);
m_Page2 = new wxPanel(m_Notebook, wxID_ANY);
m_Notebook->AddPage(m_Page1, _("Page1"));
m_Notebook->AddPage(m_Page2, _("Page2"));
m_Manager.AddPane(m_Notebook, wxAuiPaneInfo().CenterPane());
m_Manager.AddPane(m_StdToolBar, wxAuiPaneInfo().ToolbarPane().Top());
m_Manager.AddPane(m_AddToolBar, wxAuiPaneInfo().ToolbarPane().Top().Position(2));
m_Manager.AddPane(m_InfoTree, wxAuiPaneInfo().Left());
m_Manager.Update();
}
void DockingWindowsSampleMainFrame::CreateStdToolBar()
{
m_StdToolBar = new wxToolBar(this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxBORDER_NONE|wxTB_HORIZONTAL|wxTB_NODIVIDER|wxTB_FLAT);
/*wxAuiAeroDockArt * dockart = (wxAuiAeroDockArt *) m_Manager.GetArtProvider();
if(dockart)
{
m_StdToolBar->SetBackgroundColour(dockart->GetBackgroundBrush().GetColour());
}*/
m_StdToolBar->SetToolBitmapSize(wxSize(16, 15));
m_StdToolBar->AddTool(wxID_NEW, _("New"), wxBitmap(new_xpm));
m_StdToolBar->AddTool(wxID_OPEN, _("Open"), wxBitmap(fileopen_xpm));
m_StdToolBar->AddTool(wxID_SAVE, _("Save"), wxBitmap(filesave_xpm));
m_StdToolBar->AddSeparator();
m_StdToolBar->AddTool(wxID_ABOUT, _("About..."), wxBitmap(htmfoldr_xpm));
m_StdToolBar->Realize();
}
void DockingWindowsSampleMainFrame::CreateAddToolBar()
{
m_AddToolBar = new wxToolBar(this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxBORDER_NONE|wxTB_HORIZONTAL|wxTB_NODIVIDER|wxTB_FLAT);
/*wxAuiAeroDockArt * dockart = (wxAuiAeroDockArt *) m_Manager.GetArtProvider();
if(dockart)
{
m_AddToolBar->SetBackgroundColour(dockart->GetBackgroundBrush().GetColour());
}*/
m_AddToolBar->SetToolBitmapSize(wxSize(16, 15));
m_AddToolBar->AddTool(wxID_CUT, _("Cut"), wxBitmap(cut_xpm));
m_AddToolBar->AddTool(wxID_COPY, _("Copy"), wxBitmap(copy_xpm));
m_AddToolBar->AddTool(wxID_FIND, _("Find"), wxBitmap(find_xpm));
m_AddToolBar->Realize();
}
void DockingWindowsSampleMainFrame::CreateInfoTree()
{
m_InfoTree = new wxTreeCtrl(this, ID_INFO_TREE, wxDefaultPosition, wxSize(170, 250),
wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT|wxTR_SINGLE);
wxTreeItemId root = m_InfoTree->AddRoot(_("Document"));
m_InfoTree->AppendItem(root, _("Item 1"));
m_InfoTree->AppendItem(root, _("Item 2"));
m_InfoTree->AppendItem(root, _("Item 3"));
m_InfoTree->Expand(root);
}
void DockingWindowsSampleMainFrame::OnExit(wxCommandEvent & event)
{
Close();
}
Does anybody know how to solve this problem?
wxWidgets-2.7.2
wxWidgets-2.8.0-rc1
VS2005