1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/persist/splitter.h
3 // Purpose: Persistence support for wxSplitterWindow.
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_PERSIST_SPLITTER_H_
11 #define _WX_PERSIST_SPLITTER_H_
13 #include "wx/persist/window.h"
15 #include "wx/splitter.h"
17 // ----------------------------------------------------------------------------
18 // string constants used by wxPersistentSplitter
19 // ----------------------------------------------------------------------------
21 #define wxPERSIST_SPLITTER_KIND "Splitter"
23 // Special position value of -1 means the splitter is not split at all.
24 #define wxPERSIST_SPLITTER_POSITION "Position"
26 // ----------------------------------------------------------------------------
27 // wxPersistentSplitter: supports saving/restoring splitter position
28 // ----------------------------------------------------------------------------
30 class wxPersistentSplitter
: public wxPersistentWindow
<wxSplitterWindow
>
33 wxPersistentSplitter(wxSplitterWindow
* splitter
)
34 : wxPersistentWindow
<wxSplitterWindow
>(splitter
)
38 virtual void Save() const
40 wxSplitterWindow
* const splitter
= Get();
42 int pos
= splitter
->IsSplit() ? splitter
->GetSashPosition() : -1;
43 SaveValue(wxPERSIST_SPLITTER_POSITION
, pos
);
46 virtual bool Restore()
49 if ( !RestoreValue(wxPERSIST_SPLITTER_POSITION
, &pos
) )
55 Get()->SetSashPosition(pos
);
60 virtual wxString
GetKind() const { return wxPERSIST_SPLITTER_KIND
; }
63 inline wxPersistentObject
*wxCreatePersistentObject(wxSplitterWindow
* splitter
)
65 return new wxPersistentSplitter(splitter
);
68 #endif // _WX_PERSIST_SPLITTER_H_