I was starting off with a simple dockable interface and
noticed a problem when you have 2 wxDockWindows docked
on any of the edges. The problem appears when you use
wxLayoutManager::LoadFromStream(). The second window
does not appear until you resize the main window.
I have attached my code and here are the steps that I
used to reproduce the bug.
1) Dock two windows on one side.
2) Make the first/top window take up about 75% of the
space.
3) Resize the window in the direction that will make
that space smaller (if it's docked on the right resize
in the y direction)
4) Close the program
5) Reopen the and second/bottom window will not be
there until you resize the main window or the "messed
up" window.
Note: I tried calling Refresh() on the main wxFrame and
OnSize() on the wxLayoutManager and it did not fix the
problem.
Here's my code:
In the constructor:
// create dockwindows
m_hudWindow = new wxDockWindow(this, wxID_ANY, "HUD
Window", wxPoint(64, 64), wxSize(128, 128), "d0");
m_logsWindow = new wxDockWindow(this, wxID_ANY, "Logs
Window", wxPoint(96, 96), wxSize(128, 128), "d1");
m_pidWindow = new wxDockWindow(this, wxID_ANY, "PID
Window", wxPoint(128, 128), wxSize(128, 128), "d2");
m_valuesWindow = new wxDockWindow(this, wxID_ANY,
"Values Window", wxPoint(160, 160), wxSize(128, 128),
"d3");
// setup dockmanager
m_layoutManager = new wxLayoutManager(this);
m_layoutManager->AddDefaultHosts();
m_layoutManager->AddDockWindow(m_hudWindow);
m_layoutManager->AddDockWindow(m_logsWindow);
m_layoutManager->AddDockWindow(m_pidWindow);
m_layoutManager->AddDockWindow(m_valuesWindow);
// add main client window
m_mapWindow = new MapWindow(this);
wxPane *pane = new wxPane(this, 0, "Map");
m_layoutManager->SetLayout(wxDWF_SPLITTER_BORDERS, pane);
pane->SetClient(m_mapWindow, true);
pane->ShowCloseButton(false);
wxFileInputStream inputStream("Config/layout.bin");
if (inputStream.Ok())
{
wxUtil::ReadWindowLayout(inputStream, this);
m_layoutManager->LoadFromStream(inputStream);
}
else
{
m_hudWindow->Show();
m_logsWindow->Show();
m_pidWindow->Show();
m_valuesWindow->Show();
}
In the destructor:
wxFileOutputStream outputStream("Config/layout.bin");
if (outputStream.Ok())
{
wxUtil::WriteWindowLayout(outputStream, this);
m_layoutManager->SaveToStream(outputStream);
}