1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxCollapsiblePane
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 #define wxCP_DEFAULT_STYLE (wxTAB_TRAVERSAL | wxNO_BORDER)
10 #define wxCP_NO_TLW_RESIZE (0x0002)
13 @class wxCollapsiblePaneEvent
15 This event class is used for the events generated by wxCollapsiblePane.
17 @beginEventTable{wxCollapsiblePaneEvent}
18 @event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
19 The user expanded or collapsed the collapsible pane.
25 @see wxCollapsiblePane
27 class wxCollapsiblePaneEvent
: public wxCommandEvent
31 The constructor is not normally used by the user code.
33 wxCollapsiblePaneEvent(wxObject
* generator
, int id
, bool collapsed
);
36 Returns @true if the pane has been collapsed.
38 bool GetCollapsed() const;
41 Sets this as a collapsed pane event (if @a collapsed is @true) or as an
42 expanded pane event (if @a collapsed is @false).
44 void SetCollapsed(bool collapsed
);
47 wxEventType wxEVT_COMMAND_COLLPANE_CHANGED
;
50 @class wxCollapsiblePane
52 A collapsible pane is a container with an embedded button-like control
53 which can be used by the user to collapse or expand the pane's contents.
55 Once constructed you should use the GetPane() function to access the pane
56 and add your controls inside it (i.e. use the returned pointer from
57 GetPane() as parent for the controls which must go in the pane, @b not the
58 wxCollapsiblePane itself!).
60 Note that because of its nature of control which can dynamically (and
61 drastically) change its size at run-time under user-input, when putting
62 wxCollapsiblePane inside a wxSizer you should be careful to add it with a
63 proportion value of zero; this is because otherwise all other windows with
64 non-null proportion values will automatically resize each time the user
65 expands or collapse the pane window usually resulting in a weird,
71 wxCollapsiblePane *collpane = new wxCollapsiblePane(this, wxID_ANY, "Details:");
73 // add the pane with a zero proportion value to the 'sz' sizer which contains it
74 sz->Add(collpane, 0, wxGROW|wxALL, 5);
76 // now add a test label in the collapsible pane using a sizer to layout it:
77 wxWindow *win = collpane->GetPane();
78 wxSizer *paneSz = new wxBoxSizer(wxVERTICAL);
79 paneSz->Add(new wxStaticText(win, wxID_ANY, "test!"), 1, wxGROW|wxALL, 2);
80 win->SetSizer(paneSz);
81 paneSz->SetSizeHints(win);
84 It is only available if @c wxUSE_COLLPANE is set to 1 (the default).
87 @style{wxCP_DEFAULT_STYLE}
88 The default style. It includes wxTAB_TRAVERSAL and wxBORDER_NONE.
89 @style{wxCP_NO_TLW_RESIZE}
90 By default wxCollapsiblePane resizes the top level window containing it
91 when its own size changes. This allows to easily implement dialogs
92 containing an optionally shown part, for example, and so is the default
93 behaviour but can be inconvenient in some specific cases -- use this
94 flag to disable this automatic parent resizing then.
97 @beginEventEmissionTable{wxCollapsiblePaneEvent,wxNavigationKeyEvent}
98 @event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
99 The user expanded or collapsed the collapsible pane.
100 @event{EVT_NAVIGATION_KEY(func)}
101 Process a navigation key event.
106 @appearance{collapsiblepane.png}
108 @see wxPanel, wxCollapsiblePaneEvent
110 class wxCollapsiblePane
: public wxControl
119 Initializes the object and calls Create() with all the parameters.
121 wxCollapsiblePane(wxWindow
* parent
, wxWindowID id
,
122 const wxString
& label
,
123 const wxPoint
& pos
= wxDefaultPosition
,
124 const wxSize
& size
= wxDefaultSize
,
125 long style
= wxCP_DEFAULT_STYLE
,
126 const wxValidator
& validator
= wxDefaultValidator
,
127 const wxString
& name
= wxCollapsiblePaneNameStr
);
131 Parent window, must not be non-@NULL.
133 The identifier for the control.
135 The initial label shown in the button which allows the user to
136 expand or collapse the pane window.
142 The window style, see wxCP_* flags.
144 Validator which can be used for additional date checks.
148 @return @true if the control was successfully created or @false if
151 bool Create(wxWindow
* parent
, wxWindowID id
,
152 const wxString
& label
,
153 const wxPoint
& pos
= wxDefaultPosition
,
154 const wxSize
& size
= wxDefaultSize
,
155 long style
= wxCP_DEFAULT_STYLE
,
156 const wxValidator
& validator
= wxDefaultValidator
,
157 const wxString
& name
= wxCollapsiblePaneNameStr
);
160 Collapses or expands the pane window.
162 virtual void Collapse(bool collapse
= true);
165 Same as calling Collapse(@false).
170 Returns a pointer to the pane window. Add controls to the returned
171 wxWindow to make them collapsible.
173 virtual wxWindow
* GetPane() const;
176 Returns @true if the pane window is currently hidden.
178 virtual bool IsCollapsed() const;
181 Returns @true if the pane window is currently shown.
183 bool IsExpanded() const;