I'm experimenting with wxAuiManager using wxPHP to see how pane elements can be arranged in a dockable window around a central fixed element. The documentation is rather sparse here so I am feeling my way around using auto-complete!
My pane elements have a close icon by default, and clicking this closes the pane successfully, but I am now interested in restoring closed panes. This does not seem to be as trivial as one would expect.
It seems that by default closing a window destroys it, but I believe this can be prevented by using DestroyOnClose()
. I am doing initialisation like this, in the context of a wxFrame
:
$this->manager = new wxAuiManager($this, wxAUI_MGR_DEFAULT);
$textCtrl = new wxTextCtrl($this, -1, "Pane");
$paneInfo = new wxAuiPaneInfo();
$info->Top(); // Dock in the top direction
$info->PinButton(); // Give the pane a pin (or "undock") icon
$info->DestroyOnClose(false);
$info->Name('auiPane'); // Make this item individually addressable
$this->manager->AddPane($textCtrl, $paneInfo);
After closing a pane, to restore I am doing this, in the same wxFrame
context:
$info = $this->manager->GetPane('auiPane');
echo "Is shown: " . ($info->IsShown() ? 'yes' : 'no') . "\n";
// These two are probably unnecessary - grasping at straws here!
$info->Top();
$info->TopDockable();
// Show the pane again
$info->Show();
The text output initially indicates "no" after it is closed, and then running this code again produces a "yes". Thus the Show()
does seem to have an effect, but it doesn't snap back into the wxAuiManager arrangement - I can see no difference in the frame contents at all.
What am I missing? I am running PHP 5.5.9 on Ubuntu 14.04, with the wxwidgets
extension custom-compiled.
I figured it out - quite easy really. The wxAuiPaneInfo
method Show()
was correct, but after this, the manager needs an Update()
to force it to redraw immediately:
// Show all available panes
for($i = 0; $i <= 7; $i++)
{
$info = $this->manager->GetPane('auiPane' . $i);
$info->Show();
}
// Redraw the managed window
$this->manager->Update();