]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/persist/window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/persist/window.h
3 // Purpose: interface of wxPersistentWindow<>
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 Base class for persistent windows.
13 Compared to wxPersistentObject this class does three things:
14 - Most importantly, wxPersistentWindow catches wxWindowDestroyEvent
15 generated when the window is destroyed and saves its properties
16 automatically when it happens.
17 - It implements GetName() using wxWindow::GetName() so that the derived
18 classes don't need to do it.
19 - It adds a convenient wxPersistentWindow::Get() accessor returning the
20 window object of the correct type.
23 class wxPersistentWindow
: public wxPersistentObject
26 /// The type of the associated window.
30 Constructor for a persistent window object.
32 The constructor uses wxEvtHandler::Connect() to catch
33 wxWindowDestroyEvent generated when the window is destroyed and call
34 wxPersistenceManager::SaveAndUnregister() when this happens. This
35 ensures that the window properties are saved and that this object
36 itself is deleted when the window is.
38 wxPersistentWindow(WindowType
*win
);
40 WindowType
*Get() const { return static_cast<WindowType
*>(GetWindow()); }
42 Implements the base class pure virtual method using wxWindow::GetName().
44 Notice that window names are usually not unique while this function
45 must return a unique (at least among the objects of this type) string.
46 Because of this you need to specify a non-default window name in its
47 constructor when creating it or explicitly call wxWindow::SetName()
48 before saving or restoring persistent properties.
50 virtual wxString
GetName() const;