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:
@@ -4030,6 +4030,7 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \
|
|||||||
wx/paper.h \
|
wx/paper.h \
|
||||||
wx/persist.h \
|
wx/persist.h \
|
||||||
wx/persist/bookctrl.h \
|
wx/persist/bookctrl.h \
|
||||||
|
wx/persist/splitter.h \
|
||||||
wx/persist/toplevel.h \
|
wx/persist/toplevel.h \
|
||||||
wx/persist/treebook.h \
|
wx/persist/treebook.h \
|
||||||
wx/persist/window.h \
|
wx/persist/window.h \
|
||||||
|
@@ -998,6 +998,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
|||||||
wx/paper.h
|
wx/paper.h
|
||||||
wx/persist.h
|
wx/persist.h
|
||||||
wx/persist/bookctrl.h
|
wx/persist/bookctrl.h
|
||||||
|
wx/persist/splitter.h
|
||||||
wx/persist/toplevel.h
|
wx/persist/toplevel.h
|
||||||
wx/persist/treebook.h
|
wx/persist/treebook.h
|
||||||
wx/persist/window.h
|
wx/persist/window.h
|
||||||
|
@@ -6808,6 +6808,10 @@ SOURCE=..\..\include\wx\splash.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\include\wx\persist\splitter.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\include\wx\splitter.h
|
SOURCE=..\..\include\wx\splitter.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@@ -5681,6 +5681,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\splash.h">
|
RelativePath="..\..\include\wx\splash.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\persist\splitter.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\splitter.h">
|
RelativePath="..\..\include\wx\splitter.h">
|
||||||
</File>
|
</File>
|
||||||
|
@@ -7595,6 +7595,10 @@
|
|||||||
RelativePath="..\..\include\wx\splash.h"
|
RelativePath="..\..\include\wx\splash.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\persist\splitter.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\splitter.h"
|
RelativePath="..\..\include\wx\splitter.h"
|
||||||
>
|
>
|
||||||
|
@@ -7591,6 +7591,10 @@
|
|||||||
RelativePath="..\..\include\wx\splash.h"
|
RelativePath="..\..\include\wx\splash.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\include\wx\persist\splitter.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\include\wx\splitter.h"
|
RelativePath="..\..\include\wx\splitter.h"
|
||||||
>
|
>
|
||||||
|
@@ -467,6 +467,7 @@ All (GUI):
|
|||||||
- Added wxDataViewCtrl::GetSelectedItemsCount() and HasSelection().
|
- Added wxDataViewCtrl::GetSelectedItemsCount() and HasSelection().
|
||||||
- Added wxFLP_SMALL and wxDIRP_SMALL styles.
|
- Added wxFLP_SMALL and wxDIRP_SMALL styles.
|
||||||
- Added support for saving alpha with TIFF images.
|
- Added support for saving alpha with TIFF images.
|
||||||
|
- Added wxPersistentSplitter.
|
||||||
|
|
||||||
OSX:
|
OSX:
|
||||||
|
|
||||||
|
69
include/wx/persist/splitter.h
Normal file
69
include/wx/persist/splitter.h
Normal 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_
|
Reference in New Issue
Block a user