Update of /cvsroot/mahogany/M/src/wx/generic
In directory sc8-pr-cvs1:/tmp/cvs-serv26786/src/wx/generic

Modified Files:
        persctrl.cpp 
Log Message:
added wxPListbook

Index: persctrl.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/wx/generic/persctrl.cpp,v
retrieving revision 1.81
retrieving revision 1.82
diff -b -u -2 -r1.81 -r1.82
--- persctrl.cpp        13 Aug 2003 23:10:38 -0000      1.81
+++ persctrl.cpp        22 Aug 2003 22:16:22 -0000      1.82
@@ -81,4 +81,12 @@
 END_EVENT_TABLE()
 
+#if wxUSE_LISTBOOK
+
+BEGIN_EVENT_TABLE(wxPListbook, wxListbook)
+    EVT_SIZE(wxPListbook::OnSize)
+END_EVENT_TABLE()
+
+#endif // wxUSE_LISTBOOK
+
 BEGIN_EVENT_TABLE(wxPListCtrl, wxListCtrl)
     EVT_SIZE(wxPListCtrl::OnSize)
@@ -311,5 +319,5 @@
     if ( m_persist->ChangePath() ) {
         int nPage = (int)m_persist->GetConfig()->Read(m_persist->GetKey(), 0l);
-        if ( (nPage >= 0) && (nPage < GetPageCount()) ) {
+        if ( (nPage >= 0) && (nPage < (int)GetPageCount()) ) {
             SetSelection(nPage);
         }
@@ -358,4 +366,100 @@
     m_persist->SetPath(path, ms_path);
 }
+
+// ----------------------------------------------------------------------------
+// wxPListbook
+// ----------------------------------------------------------------------------
+
+#if wxUSE_LISTBOOK
+
+// the key where we store our last selected page
+const char *wxPListbook::ms_path = "ListbookPages";
+
+wxPListbook::wxPListbook()
+{
+    m_bFirstTime = true;
+    m_persist = new wxPHelper;
+}
+
+wxPListbook::wxPListbook(const wxString& configPath,
+                         wxWindow *parent,
+                         wxWindowID id,
+                         const wxPoint& pos,
+                         const wxSize& size,
+                         long style,
+                         wxConfigBase *config)
+          : wxListbook(parent, id, pos, size, style)
+{
+    m_bFirstTime = true;
+    m_persist = new wxPHelper(configPath, ms_path, config);
+}
+
+bool wxPListbook::Create(const wxString& configPath,
+                         wxWindow *parent,
+                         wxWindowID id,
+                         const wxPoint& pos,
+                         const wxSize& size,
+                         long style,
+                         wxConfigBase *config)
+{
+   m_persist->SetConfig(config);
+   m_persist->SetPath(configPath, ms_path);
+
+   return wxListbook::Create(parent, id, pos, size, style);
+}
+
+void wxPListbook::RestorePage()
+{
+    if ( m_persist->ChangePath() ) {
+        int nPage = (int)m_persist->GetConfig()->Read(m_persist->GetKey(), 0l);
+        if ( (nPage >= 0) && (nPage < (int)GetPageCount()) ) {
+            SetSelection(nPage);
+        }
+        else {
+            // invalid page index, (almost) silently ignore
+            wxLogDebug(_T("Couldn't restore wxPListbook page %d."), nPage);
+        }
+
+        m_persist->RestorePath();
+    }
+}
+
+wxPListbook::~wxPListbook()
+{
+    if ( m_persist->ChangePath() ) {
+        int nSelection = GetSelection();
+        m_persist->GetConfig()->Write(m_persist->GetKey(), (long)nSelection);
+    }
+    //else: couldn't change path, probably because there is no config object.
+
+    delete m_persist;
+}
+
+// first time our OnSize() is called we restore the page: there is no other
+// event sent specifically after window creation and we can't do in the ctor
+// (too early) - this should change in wxWin 2.1...
+void wxPListbook::OnSize(wxSizeEvent& event)
+{
+    if ( m_bFirstTime ) {
+        RestorePage();
+
+        m_bFirstTime = FALSE;
+    }
+
+    // important things are done in the base class version!
+    event.Skip();
+}
+
+void wxPListbook::SetConfigObject(wxConfigBase *config)
+{
+    m_persist->SetConfig(config);
+}
+
+void wxPListbook::SetConfigPath(const wxString& path)
+{
+    m_persist->SetPath(path, ms_path);
+}
+
+#endif // wxUSE_LISTBOOK
 
 // ----------------------------------------------------------------------------



-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to