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