Search code examples
phpwxwidgetswxphp

How to refresh wxAuiManager panes when updating their properties in wxPHP?


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.


Solution

  • I abandoned this task before completing it. As I recall, there was not an easy way to refresh panes, and while the current maintainer has done some sterling work on the project, they no longer have the time to work on it and thus it has become somewhat abandoned. This may be due to the difficulty of tracing awkward reliability bugs, or the challenge of getting compiled PHP extension binaries into the official repos of major Linux distributions.

    For the time being it may be wise for users to regard this as "not possible" for the time being, since I did put a lot of effort into trying to solve it. Of course, if someone finds a reliable way to achieve this objective, please add your own answer and I will select it in preference to this one.