aui LoadPerspective with a new window

Riccardo Cohen rcohen at articque.com
Wed Feb 13 00:24:11 PST 2008


Thanks a lot for that piece of code. I'll try this way. But I think that 
one little patch could be applied : after LoadPerspective, it should be 
easy to check if some pane are not visible (ideally also not in screen), 
and build a new paneinfo for these.

I tried to do that, but I could not find the way of checking if a pane 
is visible...

Leslie Newell wrote:
> The problem is that perspectives save the exact AUI state. If you add or 
> remove something, the AUI manager gets upset. IMHO this is a fairly 
> major problem with AUI.
> 
> I ended up writing my own version of LoadPerspective that gets around 
> this. As it has considerably different behavior to the existing AUI load 
> and could potentially break code that relies on it, I haven't submitted 
> it as a patch. This version safely handles new/missing panes and also 
> only updates the data that I think needs to be saved. It does not load 
> the caption or size hints (I can't see why you would ever want to load 
> these).
> 
> void wxPositionChecker::LoadAui(const wxString& name, wxAuiManager& 
> manager, wxConfigBase& cfg, bool update)
> {
>    cfg.SetPath(name);
>    wxAuiPaneInfoArray& panes = manager.GetAllPanes();
>    int nPanes = panes.GetCount();
>    for(int ct=0; ct<nPanes; ct++)
>    {
>        wxAuiPaneInfo& pane = panes[ct];
>        wxString paneData;
>        cfg.Read(pane.name,&paneData);
>        if(!paneData.IsEmpty())
>        {
>            wxAuiPaneInfo tempPane;
>            manager.LoadPaneInfo(paneData, tempPane);
>            if (pane.IsOk())
>            {
>                tempPane.caption = pane.caption;
>                tempPane.best_size = pane.best_size;
>                tempPane.min_size = pane.min_size;
>                tempPane.max_size = pane.max_size;
>                pane.SafeSet(tempPane);
>            }
>        }
>    }
>    if(update)
>    {
>        manager.Update();
>    }
>    cfg.SetPath(_T(".."));
> }
> 
> 
> Les
> 
> Riccardo Cohen wrote:
>> Hi
>> I have 2 panes. and I save the perspective.
>> Then I restart my program but for some reason there is an additionnal 
>> pane in aui manager.(lets say on monday I need 3 panes)
>>
>> If I call LoadPerspective(), the 3rd pane disappear, since it is not 
>> in the saved configuration.
>> I tried to call Show() again, change the size etc. Impossible to see 
>> the new window
>> I tried to add the pane once more, and it gave me an assertion failure 
>> (A pane with that name already exists in the manager!) but finally 
>> showed the 3rd window:
>>
>>   // add the window
>>   m_auiManager.AddPane(thirdwindow,paneinfo);
>>
>>   // load perspective that does not have the third window in it
>>   m_auiManager.LoadPerspective(str);
>>
>>   // test if the window appear
>>   wxSize size=thirdwindow->GetSize();
>>   if (size.GetWidth()==0 || size.GetHeight()==0)
>>     m_auiManager.AddPane(thirdwindow,paneinfo); // THIS GIVES AN 
>> ASSERTION FAILURE BUT SHOWS THE WINDOW
>>
>>
>> What is the best practice for this case ?
>>
>> Thanks
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
> 
> 

-- 
Très cordialement,

Riccardo Cohen
-------------------------------------------
Articque
http://www.articque.com
149 av Général de Gaulle
37230 Fondettes - France
tel : 02-47-49-90-49
fax : 02-47-49-91-49




More information about the wx-users mailing list