Add persistence support for wxSplitterWindow.

New wxPersistentSplitter class allows to easily save and restore the splitter
position in config.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69001 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-09-04 23:01:45 +00:00
parent 8f2139d0d8
commit d6397a9f35
20 changed files with 448 additions and 361 deletions

View File

@@ -4030,6 +4030,7 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \
wx/paper.h \
wx/persist.h \
wx/persist/bookctrl.h \
wx/persist/splitter.h \
wx/persist/toplevel.h \
wx/persist/treebook.h \
wx/persist/window.h \

View File

@@ -998,6 +998,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
wx/paper.h
wx/persist.h
wx/persist/bookctrl.h
wx/persist/splitter.h
wx/persist/toplevel.h
wx/persist/treebook.h
wx/persist/window.h

View File

@@ -6808,6 +6808,10 @@ SOURCE=..\..\include\wx\splash.h
# End Source File
# Begin Source File
SOURCE=..\..\include\wx\persist\splitter.h
# End Source File
# Begin Source File
SOURCE=..\..\include\wx\splitter.h
# End Source File
# Begin Source File

View File

@@ -5681,6 +5681,9 @@
<File
RelativePath="..\..\include\wx\splash.h">
</File>
<File
RelativePath="..\..\include\wx\persist\splitter.h">
</File>
<File
RelativePath="..\..\include\wx\splitter.h">
</File>

View File

@@ -7595,6 +7595,10 @@
RelativePath="..\..\include\wx\splash.h"
>
</File>
<File
RelativePath="..\..\include\wx\persist\splitter.h"
>
</File>
<File
RelativePath="..\..\include\wx\splitter.h"
>

View File

@@ -7591,6 +7591,10 @@
RelativePath="..\..\include\wx\splash.h"
>
</File>
<File
RelativePath="..\..\include\wx\persist\splitter.h"
>
</File>
<File
RelativePath="..\..\include\wx\splitter.h"
>

View File

@@ -467,6 +467,7 @@ All (GUI):
- Added wxDataViewCtrl::GetSelectedItemsCount() and HasSelection().
- Added wxFLP_SMALL and wxDIRP_SMALL styles.
- Added support for saving alpha with TIFF images.
- Added wxPersistentSplitter.
OSX:

View File

@@ -0,0 +1,69 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/persist/splitter.h
// Purpose: Persistence support for wxSplitterWindow.
// Author: Vadim Zeitlin
// Created: 2011-08-31
// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PERSIST_SPLITTER_H_
#define _WX_PERSIST_SPLITTER_H_
#include "wx/persist/window.h"
#include "wx/splitter.h"
// ----------------------------------------------------------------------------
// string constants used by wxPersistentSplitter
// ----------------------------------------------------------------------------
#define wxPERSIST_SPLITTER_KIND "Splitter"
// Special position value of -1 means the splitter is not split at all.
#define wxPERSIST_SPLITTER_POSITION "Position"
// ----------------------------------------------------------------------------
// wxPersistentSplitter: supports saving/restoring splitter position
// ----------------------------------------------------------------------------
class wxPersistentSplitter : public wxPersistentWindow<wxSplitterWindow>
{
public:
wxPersistentSplitter(wxSplitterWindow* splitter)
: wxPersistentWindow<wxSplitterWindow>(splitter)
{
}
virtual void Save() const
{
wxSplitterWindow* const splitter = Get();
int pos = splitter->IsSplit() ? splitter->GetSashPosition() : -1;
SaveValue(wxPERSIST_SPLITTER_POSITION, pos);
}
virtual bool Restore()
{
int pos;
if ( RestoreValue(wxPERSIST_SPLITTER_POSITION, &pos) )
{
if ( pos == -1 )
Get()->Unsplit();
else
Get()->SetSashPosition(pos);
}
return false;
}
virtual wxString GetKind() const { return wxPERSIST_SPLITTER_KIND; }
};
inline wxPersistentObject *wxCreatePersistentObject(wxSplitterWindow* splitter)
{
return new wxPersistentSplitter(splitter);
}
#endif // _WX_PERSIST_SPLITTER_H_