Kirix Support Forums

SavePerspective/LoadPerspective

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

SavePerspective/LoadPerspective

Postby Exhumer on Tue Dec 19, 2006 5:36 am

I'm using wxWidgets 2.7.2 and wxAUI shipped with it. Both compiled as DLLs.
I've a main frame managed by wxAuiManager. I need to save layout of panes on exit and restore it on next start. So, I'm calls wxAuiManager::SavePerspective in the destructor of the main frame, before wxAuiManager::UnInit(). And calls wxAuiManager::LoadPerspective in the constructor, after wxAuiManager::SetManagedWindow and all panes created. The string seems good, but LoadPerspective also returns false and all panes disappear.
How can I check what is wrong?
Exhumer
Registered User
 
Posts: 4
Joined: Mon Oct 23, 2006 4:36 am
Location: Odessa, Ukraine

Postby Exhumer on Tue Dec 19, 2006 6:32 am

I found that value of the "name" in the load/save string is differ in each session.
Code: Select all
"layout1|name=<value>;...

That's why loading fails. The value seems like random set of digits. Any ideas?
Exhumer
Registered User
 
Posts: 4
Joined: Mon Oct 23, 2006 4:36 am
Location: Odessa, Ukraine

Postby Ben on Thu Dec 21, 2006 12:46 am

If you don't specify a name with the wxPaneInfo::Name() method, there's no way that LoadPerspective/SavePerspective() can associate your pane info with a window pointer, because window pointers (and much of the time window ids) are different each time you run. You need to add panes with names, like the wxaui sample does.

After this your LoadPerspective() call will work.

Best,
Ben
User avatar
Ben
Kirix Support Team
 
Posts: 522
Joined: Mon Dec 19, 2005 6:29 am

Postby Exhumer on Thu Dec 21, 2006 1:00 am

bwilliams wrote:If you don't specify a name with the wxPaneInfo::Name() method, there's no way that LoadPerspective/SavePerspective() can associate your pane info with a window pointer
Thanks a lot! Fixed it now.
But seems that this tip should be reflected in docs, because it's not evident.
Exhumer
Registered User
 
Posts: 4
Joined: Mon Oct 23, 2006 4:36 am
Location: Odessa, Ukraine

Postby Ben on Sat Dec 23, 2006 3:37 am

Thanks a lot! Fixed it now.
But seems that this tip should be reflected in docs, because it's not evident.


Agreed!

Thanks,
Ben
User avatar
Ben
Kirix Support Team
 
Posts: 522
Joined: Mon Dec 19, 2005 6:29 am

Re: SavePerspective/LoadPerspective

Postby daveisfera on Mon Feb 09, 2009 3:28 pm

It appears that the example code doesn't set the AuiPaneInfo anymore, so the above mentioned problem occurs when attempting to use the perspective saving/loading.

Just for anyone who stumbles along this post, here's an example of what you would change to get it to work.

Replace
Code: Select all
   m_mgr.AddPane(text1, wxLEFT, wxT("Pane Number One"));
   m_mgr.AddPane(text2, wxBOTTOM, wxT("Pane Number Two"));
   m_mgr.AddPane(text3, wxCENTER);

With
Code: Select all
   m_mgr.AddPane(text1, wxAuiPaneInfo().Name("Text1").Left().Caption("Pane Number One"));
   m_mgr.AddPane(text2, wxAuiPaneInfo().Name("Text2").Bottom().Caption("Pane Number Two"));
   m_mgr.AddPane(text3, wxAuiPaneInfo().Name("Text3").Center());
daveisfera
Registered User
 
Posts: 1
Joined: Mon Feb 09, 2009 3:19 pm

Re:

Postby jojosoto on Sat Mar 26, 2011 2:54 pm

Ben wrote:If you don't specify a name with the wxPaneInfo::Name() method, there's no way that LoadPerspective/SavePerspective() can associate your pane info with a window pointer, because window pointers (and much of the time window ids) are different each time you run. You need to add panes with names, like the wxaui sample does.

After this your LoadPerspective() call will work.

Best,
Ben


This was my issue. I kept of believing it knew what I wanted it to do, when I actually had to tell it.
jojosoto
Registered User
 
Posts: 6
Joined: Fri Mar 25, 2011 12:39 pm

Return to wxAUI Questions, Thoughts & Feedback