]>
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
6 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_PERSIST_BOOKCTRL_H_
11 #define _WX_PERSIST_BOOKCTRL_H_
13 #include "wx/persist/window.h"
15 #include "wx/bookctrl.h"
17 // ----------------------------------------------------------------------------
18 // string constants used by wxPersistentBookCtrl
19 // ----------------------------------------------------------------------------
21 #define wxPERSIST_BOOK_KIND "Book"
23 #define wxPERSIST_BOOK_SELECTION "Selection"
25 // ----------------------------------------------------------------------------
26 // wxPersistentBookCtrl: supports saving/restoring book control selection
27 // ----------------------------------------------------------------------------
29 class wxPersistentBookCtrl
: public wxPersistentWindow
<wxBookCtrlBase
>
32 wxPersistentBookCtrl(wxBookCtrlBase
*book
)
33 : wxPersistentWindow
<wxBookCtrlBase
>(book
)
37 virtual void Save() const
39 SaveValue(wxPERSIST_BOOK_SELECTION
, Get()->GetSelection());
42 virtual bool Restore()
45 if ( RestoreValue(wxPERSIST_BOOK_SELECTION
, &sel
) )
47 wxBookCtrlBase
* const book
= Get();
48 if ( sel
>= 0 && (unsigned)sel
< book
->GetPageCount() )
50 book
->SetSelection(sel
);
58 virtual wxString
GetKind() const { return wxPERSIST_BOOK_KIND
; }
61 inline wxPersistentObject
*wxCreatePersistentObject(wxBookCtrlBase
*book
)
63 return new wxPersistentBookCtrl(book
);
66 #endif // _WX_PERSIST_BOOKCTRL_H_