I've set up a simple wxAuiManager
system containing eight text controls, each set up as a pane, with all arranged around a central static control. I have two each snapped to the top, left, right and bottom pane directions. This part works fine.
I'd now like to modify the properties of each pane, which I think can be done by resetting the associated wxAuiPaneInfo
. For example, I'd like to add/remove the pin or maximise icons. I can get this to work in itself, but redrawing the managed window after resetting these properties is proving to be a bit of a challenge.
Here is the code I am using at present:
// Get the currently selected pane
$paneIndex = $this->getSelectedPaneIndex();
/* @var $paneInfo wxAuiPaneInfo */
$paneInfo = $this->getPaneInfoByIndex($paneIndex);
// Set new flag true/false on paneinfo, using setter methods
/* @var $ctrl wxCheckBox */
$ctrl = wxDynamicCast($event->GetEventObject(), "wxCheckBox");
$methods = $this->getPaneSetterMethods();
$method = $methods[$ctrl->GetName()];
$paneInfo->$method($ctrl->GetValue());
/* @var $window \wxTextCtrl */
/* @var $manager \wxAuiManager */
$window = $this->getManagedWindow()->getWindowByIndex($paneIndex);
$manager = $this->getManagedWindow()->getAuiManager();
// This sort of works, but the pane sometimes ends up being moved
$manager->DetachPane($window);
$manager->AddPane($window, $paneInfo);
// Now redraw the panes
$this->getManagedWindow()->getAuiManager()->Update();
As you can see, what I presently do is to detach the pane from the manager, re-add it, then force the manager to redraw everything. This is fine, except it often re-docks the window in a new position. It also doesn't "feel right" - modifying these properties must be achievable independently of detaching the pane.
Instead of this I thought it would be worth trying to hide and show the pane, to no avail:
// This does not work at all
$paneInfo->Hide();
$paneInfo->Show();
Also, I have tried using the pane loader, though I don't know what a "perspective string" is - it is not a control property as far as I can tell.
// The string should be a "perspective string"
$this->getManagedWindow()->getAuiManager()->LoadPaneInfo('auiPane0', $paneInfo);
So, in summary: I have a working solution but it is not ideal, since it re-docks the pane in question. I suppose I could work out the correct command to re-dock it in the same place, but it still feels like I should be able to do this in an easier fashion.
Any ideas?
Update: I've found out how to capture pane information using perspectives, which can be done thus:
$this->winSave = [];
for($i = 0; $i <= 7; $i++)
{
$pi = $this->getPaneInfoByIndex($i);
$persp = $this->getManagedWindow()->getAuiManager()->SavePaneInfo($pi);
echo $persp . "\n";
$this->winSave[$i] = $persp;
}
All I need to do now is to capture a pane move event, and then I can use this data with LoadPaneInfo()
. That is proving somewhat difficult - wxPHP does not seem to provide sufficient wxEVT
constants to permit this. I have asked a new question about this.
I will continue to try some new things.