39

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Did you get it to work? I'm having some what of the same issue on my project... – Gal Silberman Jan 11 '16 at 08:15
  • 1
    @Gal, I haven't tried anything new since I wrote the post. I rather ran out of ideas, so I am tolerating it for now and hoping someone notices this in the future. Are you using wxPHP specifically, or wxWidgets with another language binding? – halfer Jan 11 '16 at 08:36
  • 1
    I hope some one will notice this and be able to help. I'm using wxWidgets with Python bind. – Gal Silberman Jan 11 '16 at 08:42
  • 1
    Perhaps the docs for wxPython will help you with "perspective strings", @Gal - that might be a worthwhile thing to try. I rather gave up at that point, since a lot of things had not worked, but it would be the next thing I would research. – halfer Jan 11 '16 at 08:44
  • 1
    Ah, I wonder if it is a serialised internal representation of a window, @Gal? It looks like [`SavePaneInfo`](http://wxpython.org/Phoenix/docs/html/lib.agw.aui.framemanager.AuiManager.html#lib.agw.aui.framemanager.AuiManager.SavePaneInfo) will output something here - try that, and then use that as an input to `LoadPaneInfo`? Maybe the perspective string can be captured before pane close (or after pane update) and stored in the app somewhere. – halfer Jan 11 '16 at 08:47
  • I'll give it a try soon and let you know. – Gal Silberman Jan 11 '16 at 08:50
  • @Gal: it looks like this might work. I'm trapping the AUI pane close event to save the perspective strings, but I think that might be too late, since the closing item might already have a closed flag in the perspective string. There is probably a general update event that can be captured to update the latest perspectives. Very close, I think! – halfer Jan 11 '16 at 13:43
  • Thanks for the bounty on this @Alex. I'm no longer actively working on wxphp, but if you are stuck on something, let me know and I'll try to assist. – halfer Jun 24 '16 at 23:34
  • another Alex here, I never used wxPHP but... shouldn't `$this->getManagedWindow()->Refresh()` work? [Refresh](http://docs.wxwidgets.org/trunk/classwx_window.html#a29dc7251746154c821b17841b9877830), see `Update` also for an immediate refresh. – Alex Nov 18 '16 at 14:44
  • It's been a white since I've touched this @Alex, but thanks. I can see an `Update()` in my code, so that didn't work - maybe `Refresh` would do? I expect I would have tried it, but I do not recall! I think I worked around this in the related linked question. – halfer Nov 18 '16 at 14:52
  • Unfortunately despite a valiant effort from the sole maintainer, I did not find wxPHP to be very stable in practice, so I did not pursue it. It does not have much community interest, so I can understand why he is unable to commit a great deal of time on it. – halfer Nov 18 '16 at 14:52
  • 1
    I didn't check but I guess `Refresh` just queue an event for a later `Update`, weird though, `getManagedWindow()` return a `wxWindow` pointer, `Refresh` and `Update` should work – Alex Nov 18 '16 at 14:57
  • Is this question able to be answered, or should it just be deleted? It just sits there at the top of the unanswered questions list, taunting us... – miken32 Jan 17 '17 at 23:26
  • It should be answerable @miken32, even if the answer is "it is not possible in PHP". I was previously mystified why it was getting so many upvotes, but being in the unanswered queue probably explains it. It's probably why it has also attracted a silly answer below. Would it help if I answered it as best as I can (so that the silly answer can be deleted)? – halfer Jan 17 '17 at 23:29
  • Yup it's the highest voted unanswered question by a long shot: http://stackoverflow.com/questions/tagged/php?filter=need-answers&sort=votes. I'd recommend a self-answer, but it's your question! As you say, the project seems... stalled, if not quite dead. – miken32 Jan 17 '17 at 23:33
  • 1
    @miken32: I've added a placeholder answer, which I think is good/accurate enough for now. Hope that fixes your queue! – halfer Jan 17 '17 at 23:45
  • @vatsa287: most of your edits were unnecessary, so I rejected it. Contractions are perfectly fine in technical writing, and do not need to be expanded. The word "maximise" is fine for British English, and does not need amending to American English. I have given way on "re-dock". – halfer Jul 31 '20 at 14:52

1 Answers1

-1

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.

halfer
  • 19,824
  • 17
  • 99
  • 186