File: treebook.h

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (171 lines) | stat: -rw-r--r-- 6,198 bytes parent folder | download | duplicates (14)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/////////////////////////////////////////////////////////////////////////////
// Name:        treebook.h
// Purpose:     interface of wxTreebook
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////


wxEventType wxEVT_TREEBOOK_PAGE_CHANGED;
wxEventType wxEVT_TREEBOOK_PAGE_CHANGING;
wxEventType wxEVT_TREEBOOK_NODE_COLLAPSED;
wxEventType wxEVT_TREEBOOK_NODE_EXPANDED;

/**
    @class wxTreebook

    This class is an extension of the wxNotebook class that allows a tree
    structured set of pages to be shown in a control. A classic example is a
    netscape preferences dialog that shows a tree of preference sections on
    the left and select section page on the right.

    To use the class simply create it and populate with pages using
    InsertPage(), InsertSubPage(), AddPage(), AddSubPage().

    If your tree is no more than 1 level in depth then you could simply use
    AddPage() and AddSubPage() to sequentially populate your tree by adding at
    every step a page or a subpage to the end of the tree.

    @beginEventEmissionTable{wxBookCtrlEvent}
    @event{EVT_TREEBOOK_PAGE_CHANGED(id, func)}
        The page selection was changed.
        Processes a @c wxEVT_TREEBOOK_PAGE_CHANGED event.
    @event{EVT_TREEBOOK_PAGE_CHANGING(id, func)}
        The page selection is about to be changed.
        Processes a @c wxEVT_TREEBOOK_PAGE_CHANGING event.
        This event can be @ref wxNotifyEvent::Veto() "vetoed".
    @event{EVT_TREEBOOK_NODE_COLLAPSED(id, func)}
        The page node is going to be collapsed.
        Processes a @c wxEVT_TREEBOOK_NODE_COLLAPSED event.
    @event{EVT_TREEBOOK_NODE_EXPANDED(id, func)}
        The page node is going to be expanded.
        Processes a @c wxEVT_TREEBOOK_NODE_EXPANDED event.
    @endEventTable

    @library{wxcore}
    @category{bookctrl}

    @see wxBookCtrl, wxBookCtrlEvent, wxNotebook, wxTreeCtrl, wxImageList,
         @ref overview_bookctrl, @ref page_samples_notebook
*/
class wxTreebook : public wxBookCtrlBase
{
public:
    /**
        Default constructor.
    */
    wxTreebook();

    /**
        Creates an empty wxTreebook.

        @param parent
            The parent window. Must be non-@NULL.
        @param id
            The window identifier.
        @param pos
            The window position.
        @param size
            The window size.
        @param style
            The window style. See wxNotebook.
        @param name
            The name of the control (used only under Motif).
    */
    wxTreebook(wxWindow* parent, wxWindowID id,
               const wxPoint& pos = wxDefaultPosition,
               const wxSize& size = wxDefaultSize,
               long style = wxBK_DEFAULT,
               const wxString& name = wxEmptyString);

    /**
        Destroys the wxTreebook object.
        Also deletes all the pages owned by the control (inserted previously into it).
    */
    virtual ~wxTreebook();

    /**
        Adds a new page. The page is placed at the topmost level after all other
        pages. @NULL could be specified for page to create an empty page.
    */
    virtual bool AddPage(wxWindow* page, const wxString& text,
                         bool bSelect = false, int imageId = wxNOT_FOUND);

    /**
        Adds a new child-page to the last top-level page. @NULL could be
        specified for page to create an empty page.
    */
    virtual bool AddSubPage(wxWindow* page, const wxString& text,
                            bool bSelect = false, int imageId = wxNOT_FOUND);


    /**
        Shortcut for @ref wxTreebook::ExpandNode() "ExpandNode"( @a pageId,
        @false ).
    */
    bool CollapseNode(size_t pageId);

    /**
        Creates a treebook control. See wxTreebook::wxTreebook() for the
        description of the parameters.
    */
    bool Create(wxWindow* parent, wxWindowID id,
                const wxPoint& pos = wxDefaultPosition,
                const wxSize& size = wxDefaultSize,
                long style = wxBK_DEFAULT,
                const wxString& name = wxEmptyString);

    /**
        Deletes the page at the specified position and all its children.
        Could trigger page selection change in a case when selected page is removed.
        In that case its parent is selected (or the next page if no parent).
    */
    virtual bool DeletePage(size_t pagePos);

    /**
        Expands (collapses) the @a pageId node. Returns the previous state.
        May generate page changing events (if selected page is under the collapsed
        branch, then its parent is autoselected).
    */
    virtual bool ExpandNode(size_t pageId, bool expand = true);

    /**
        Returns the parent page of the given one or @c wxNOT_FOUND if this is a
        top-level page.
    */
    int GetPageParent(size_t page) const;

    /**
        Returns the currently selected page, or @c wxNOT_FOUND if none was selected.

        @note This method may return either the previously or newly selected
              page when called from the EVT_TREEBOOK_PAGE_CHANGED() handler
              depending on the platform and so wxBookCtrlEvent::GetSelection()
              should be used instead in this case.
    */
    virtual int GetSelection() const;

    /**
        Inserts a new page just before the page indicated by @a pagePos.
        The new page is placed before @a pagePos page and on the same level.
        @NULL could be specified for page to create an empty page.
    */
    virtual bool InsertPage(size_t pagePos, wxWindow* page,
                            const wxString& text, bool bSelect = false,
                            int imageId = wxNOT_FOUND);

    /**
        Inserts a sub page under the specified page.

        @NULL could be specified for page to create an empty page.
    */
    virtual bool InsertSubPage(size_t pagePos, wxWindow* page,
                               const wxString& text, bool bSelect = false,
                               int imageId = wxNOT_FOUND);

    /**
        Returns @true if the page represented by @a pageId is expanded.
    */
    virtual bool IsNodeExpanded(size_t pageId) const;
};