add support for persistent controls
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58529 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
47
interface/wx/persist/bookctrl.h
Normal file
47
interface/wx/persist/bookctrl.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/persist/bookctrl.h
|
||||
// Purpose: interface of wxPersistentBookCtrl
|
||||
// Author: Vadim Zeitlin
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
Persistence adapter for wxBookCtrlBase.
|
||||
|
||||
This adapter handles the selected page of wxBookCtrlBase, i.e. it saves its
|
||||
value when the associated book control is destroyed and restores it when it
|
||||
is recreated.
|
||||
|
||||
@see wxPersistentTreeBookCtrl
|
||||
*/
|
||||
class wxPersistentBookCtrl : public wxPersistentWindow<wxBookCtrlBase>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
|
||||
@param book
|
||||
The associated book control.
|
||||
*/
|
||||
wxPersistentBookCtrl(wxBookCtrlBase *book);
|
||||
|
||||
/**
|
||||
Save the currently selected page index.
|
||||
*/
|
||||
virtual void Save() const;
|
||||
|
||||
/**
|
||||
Restore the selected page index.
|
||||
|
||||
The book control must be initialized before calling this function, i.e.
|
||||
all of its pages should be already added to it -- otherwise restoring
|
||||
the selection has no effect.
|
||||
*/
|
||||
virtual bool Restore();
|
||||
};
|
||||
|
||||
/// Overload allowing persistence adapter creation for wxBookCtrlBase-derived
|
||||
/// objects.
|
||||
wxPersistentObject *wxCreatePersistentObject(wxBookCtrlBase *book);
|
43
interface/wx/persist/toplevel.h
Normal file
43
interface/wx/persist/toplevel.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/persist/toplevel.h
|
||||
// Purpose: interface of wxPersistentTLW
|
||||
// Author: Vadim Zeitlin
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
Persistence adapter for wxTopLevelWindow.
|
||||
|
||||
This adapter saves and restores the geometry (i.e. position and size) and
|
||||
the state (iconized, maximized or normal) of top level windows. It can be
|
||||
used with both wxFrame and wxDialog.
|
||||
|
||||
Note that it does @em not save nor restore the window visibility.
|
||||
*/
|
||||
class wxPersistentTLW : public wxPersistentWindow<wxTopLevelWindow>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
|
||||
@param book
|
||||
The associated window.
|
||||
*/
|
||||
wxPersistentTLW(wxTopLevelWindow *book);
|
||||
|
||||
/**
|
||||
Save the current window geometry.
|
||||
*/
|
||||
virtual void Save() const;
|
||||
|
||||
/**
|
||||
Restore the window geometry.
|
||||
*/
|
||||
virtual bool Restore();
|
||||
};
|
||||
|
||||
/// Overload allowing persistence adapter creation for wxTopLevelWindow-derived
|
||||
/// objects.
|
||||
wxPersistentObject *wxCreatePersistentObject(wxTopLevelWindow *book);
|
43
interface/wx/persist/treebook.h
Normal file
43
interface/wx/persist/treebook.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/persist/treebook.h
|
||||
// Purpose: interface of wxPersistentTreeBook
|
||||
// Author: Vadim Zeitlin
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
Persistence adapter for wxTreebook.
|
||||
|
||||
This adapter saves and restores the expanded branches of the wxTreeCtrl
|
||||
used by wxTreebook, in addition to saving and restoring the selection as
|
||||
implemented by the base wxPersistentBookCtrl class.
|
||||
*/
|
||||
class wxPersistentTreeBook : public wxPersistentBookCtrl
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
|
||||
@param book
|
||||
The associated tree book control.
|
||||
*/
|
||||
wxPersistentTreeBook(wxTreebook *book);
|
||||
|
||||
/**
|
||||
Save the currently opened branches.
|
||||
*/
|
||||
virtual void Save() const;
|
||||
|
||||
/**
|
||||
Restore the opened branches.
|
||||
|
||||
The book control must be initialized before calling this function, i.e.
|
||||
all of its pages should be already added to it.
|
||||
*/
|
||||
virtual bool Restore();
|
||||
};
|
||||
|
||||
/// Overload allowing persistence adapter creation for wxTreebook objects.
|
||||
wxPersistentObject *wxCreatePersistentObject(wxTreebook *book);
|
51
interface/wx/persist/window.h
Normal file
51
interface/wx/persist/window.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/persist/window.h
|
||||
// Purpose: interface of wxPersistentWindow<>
|
||||
// Author: Vadim Zeitlin
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
Base class for persistent windows.
|
||||
|
||||
Compared to wxPersistentObject this class does three things:
|
||||
- Most importantly, wxPersistentWindow catches wxWindowDestroyEvent
|
||||
generated when the window is destroyed and saves its properties
|
||||
automatically when it happens.
|
||||
- It implements GetName() using wxWindow::GetName() so that the derived
|
||||
classes don't need to do it.
|
||||
- It adds a convenient wxPersistentWindow::Get() accessor returning the
|
||||
window object of the correct type.
|
||||
*/
|
||||
template <class T>
|
||||
class wxPersistentWindow : public wxPersistentObject
|
||||
{
|
||||
public:
|
||||
/// The type of the associated window.
|
||||
typedef T WindowType;
|
||||
|
||||
/**
|
||||
Constructor for a persistent window object.
|
||||
|
||||
The constructor uses wxEvtHandler::Connect() to catch
|
||||
wxWindowDestroyEvent generated when the window is destroyed and call
|
||||
wxPersistenceManager::SaveAndUnregister() when this happens. This
|
||||
ensures that the window properties are saved and that this object
|
||||
itself is deleted when the window is.
|
||||
*/
|
||||
wxPersistentWindow(WindowType *win);
|
||||
|
||||
WindowType *Get() const { return static_cast<WindowType *>(GetWindow()); }
|
||||
/**
|
||||
Implements the base class pure virtual method using wxWindow::GetName().
|
||||
|
||||
Notice that window names are usually not unique while this function
|
||||
must return a unique (at least among the objects of this type) string.
|
||||
Because of this you need to specify a non-default window name in its
|
||||
constructor when creating it or explicitly call wxWindow::SetName()
|
||||
before saving or restoring persistent properties.
|
||||
*/
|
||||
virtual wxString GetName() const;
|
||||
};
|
Reference in New Issue
Block a user