1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/persist/splitter.h
3 // Purpose: Persistence support for wxSplitterWindow.
4 // Author: Vadim Zeitlin
6 // RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_PERSIST_SPLITTER_H_
12 #define _WX_PERSIST_SPLITTER_H_
14 #include "wx/persist/window.h"
16 #include "wx/splitter.h"
18 // ----------------------------------------------------------------------------
19 // string constants used by wxPersistentSplitter
20 // ----------------------------------------------------------------------------
22 #define wxPERSIST_SPLITTER_KIND "Splitter"
24 // Special position value of -1 means the splitter is not split at all.
25 #define wxPERSIST_SPLITTER_POSITION "Position"
27 // ----------------------------------------------------------------------------
28 // wxPersistentSplitter: supports saving/restoring splitter position
29 // ----------------------------------------------------------------------------
31 class wxPersistentSplitter
: public wxPersistentWindow
<wxSplitterWindow
>
34 wxPersistentSplitter(wxSplitterWindow
* splitter
)
35 : wxPersistentWindow
<wxSplitterWindow
>(splitter
)
39 virtual void Save() const
41 wxSplitterWindow
* const splitter
= Get();
43 int pos
= splitter
->IsSplit() ? splitter
->GetSashPosition() : -1;
44 SaveValue(wxPERSIST_SPLITTER_POSITION
, pos
);
47 virtual bool Restore()
50 if ( !RestoreValue(wxPERSIST_SPLITTER_POSITION
, &pos
) )
56 Get()->SetSashPosition(pos
);
61 virtual wxString
GetKind() const { return wxPERSIST_SPLITTER_KIND
; }
64 inline wxPersistentObject
*wxCreatePersistentObject(wxSplitterWindow
* splitter
)
66 return new wxPersistentSplitter(splitter
);
69 #endif // _WX_PERSIST_SPLITTER_H_