File: window.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (50 lines) | stat: -rw-r--r-- 2,088 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/persist/window.h
// Purpose:     interface of wxPersistentWindow<>
// Author:      Vadim Zeitlin
// Copyright:   (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

/**
    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;
};