]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/persist/bookctrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/persist/bookctrl.h
3 // Purpose: persistence support for wxBookCtrl
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_PERSIST_BOOKCTRL_H_
12 #define _WX_PERSIST_BOOKCTRL_H_
14 #include "wx/persist/window.h"
16 #include "wx/bookctrl.h"
18 // ----------------------------------------------------------------------------
19 // string constants used by wxPersistentBookCtrl
20 // ----------------------------------------------------------------------------
22 #define wxPERSIST_BOOK_KIND "Book"
24 #define wxPERSIST_BOOK_SELECTION "Selection"
26 // ----------------------------------------------------------------------------
27 // wxPersistentBookCtrl: supports saving/restoring book control selection
28 // ----------------------------------------------------------------------------
30 class wxPersistentBookCtrl
: public wxPersistentWindow
<wxBookCtrlBase
>
33 wxPersistentBookCtrl(wxBookCtrlBase
*book
)
34 : wxPersistentWindow
<wxBookCtrlBase
>(book
)
38 virtual void Save() const
40 SaveValue(wxPERSIST_BOOK_SELECTION
, Get()->GetSelection());
43 virtual bool Restore()
46 if ( RestoreValue(wxPERSIST_BOOK_SELECTION
, &sel
) )
48 wxBookCtrlBase
* const book
= Get();
49 if ( sel
>= 0 && (unsigned)sel
< book
->GetPageCount() )
51 book
->SetSelection(sel
);
59 virtual wxString
GetKind() const { return wxPERSIST_BOOK_KIND
; }
62 inline wxPersistentObject
*wxCreatePersistentObject(wxBookCtrlBase
*book
)
64 return new wxPersistentBookCtrl(book
);
67 #endif // _WX_PERSIST_BOOKCTRL_H_