在 wxPHP 中更新其属性时如何刷新 wxAuiManager 窗格? [英] How to refresh wxAuiManager panes when updating their properties in wxPHP?

查看:23
本文介绍了在 wxPHP 中更新其属性时如何刷新 wxAuiManager 窗格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个简单的 wxAuiManager 系统,其中包含八个文本控件,每个控件都设置为一个窗格,所有控件都围绕一个中央静态控件排列.我有两个分别捕捉到顶部、左侧、右侧和底部窗格方向.这部分工作正常.

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.

我现在想修改每个窗格的属性,我认为可以通过重置关联的 wxAuiPaneInfo 来完成.例如,我想添加/删除图钉或最大化图标.我可以让它自己工作,但在重置这些属性后重新绘制托管窗口被证明是一个挑战.

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.

有什么想法吗?

更新:我已经找到了如何使用透视图捕获窗格信息,可以这样做:

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;
}

我现在需要做的就是捕获窗格移动事件,然后我可以通过 LoadPaneInfo() 使用这些数据.这证明有些困难——wxPHP 似乎没有提供足够的wxEVT 常量来允许这样做.我提出了一个新问题关于这个.

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.

推荐答案

我在完成之前放弃了这个任务.我记得,刷新窗格并不是一种简单的方法,虽然当前的维护者在该项目上做了一些出色的工作,但他们不再有时间来处理它,因此它有点被放弃了.这可能是由于难以跟踪尴尬的可靠性错误,或者将编译的 PHP 扩展二进制文件放入主要 Linux 发行版的官方存储库中存在挑战.

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.

这篇关于在 wxPHP 中更新其属性时如何刷新 wxAuiManager 窗格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆