1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxCollapsiblePane
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
8 #define wxCP_DEFAULT_STYLE (wxTAB_TRAVERSAL | wxNO_BORDER)
9 #define wxCP_NO_TLW_RESIZE (0x0002)
12 @class wxCollapsiblePaneEvent
14 This event class is used for the events generated by wxCollapsiblePane.
16 @beginEventTable{wxCollapsiblePaneEvent}
17 @event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
18 The user expanded or collapsed the collapsible pane.
24 @see wxCollapsiblePane
26 class wxCollapsiblePaneEvent
: public wxCommandEvent
30 The constructor is not normally used by the user code.
32 wxCollapsiblePaneEvent(wxObject
* generator
, int id
, bool collapsed
);
35 Returns @true if the pane has been collapsed.
37 bool GetCollapsed() const;
40 Sets this as a collapsed pane event (if @a collapsed is @true) or as an
41 expanded pane event (if @a collapsed is @false).
43 void SetCollapsed(bool collapsed
);
46 wxEventType wxEVT_COLLAPSIBLEPANE_CHANGED
;
49 @class wxCollapsiblePane
51 A collapsible pane is a container with an embedded button-like control
52 which can be used by the user to collapse or expand the pane's contents.
54 Once constructed you should use the GetPane() function to access the pane
55 and add your controls inside it (i.e. use the returned pointer from
56 GetPane() as parent for the controls which must go in the pane, @b not the
57 wxCollapsiblePane itself!).
59 Note that because of its nature of control which can dynamically (and
60 drastically) change its size at run-time under user-input, when putting
61 wxCollapsiblePane inside a wxSizer you should be careful to add it with a
62 proportion value of zero; this is because otherwise all other windows with
63 non-null proportion values will automatically resize each time the user
64 expands or collapse the pane window usually resulting in a weird,
70 wxCollapsiblePane *collpane = new wxCollapsiblePane(this, wxID_ANY, "Details:");
72 // add the pane with a zero proportion value to the 'sz' sizer which contains it
73 sz->Add(collpane, 0, wxGROW|wxALL, 5);
75 // now add a test label in the collapsible pane using a sizer to layout it:
76 wxWindow *win = collpane->GetPane();
77 wxSizer *paneSz = new wxBoxSizer(wxVERTICAL);
78 paneSz->Add(new wxStaticText(win, wxID_ANY, "test!"), 1, wxGROW|wxALL, 2);
79 win->SetSizer(paneSz);
80 paneSz->SetSizeHints(win);
83 It is only available if @c wxUSE_COLLPANE is set to 1 (the default).
86 @style{wxCP_DEFAULT_STYLE}
87 The default style. It includes wxTAB_TRAVERSAL and wxBORDER_NONE.
88 @style{wxCP_NO_TLW_RESIZE}
89 By default wxCollapsiblePane resizes the top level window containing it
90 when its own size changes. This allows to easily implement dialogs
91 containing an optionally shown part, for example, and so is the default
92 behaviour but can be inconvenient in some specific cases -- use this
93 flag to disable this automatic parent resizing then.
96 @beginEventEmissionTable{wxCollapsiblePaneEvent,wxNavigationKeyEvent}
97 @event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
98 The user expanded or collapsed the collapsible pane.
99 @event{EVT_NAVIGATION_KEY(func)}
100 Process a navigation key event.
105 @appearance{collapsiblepane}
107 @see wxPanel, wxCollapsiblePaneEvent
109 class wxCollapsiblePane
: public wxControl
118 Initializes the object and calls Create() with all the parameters.
120 wxCollapsiblePane(wxWindow
* parent
, wxWindowID id
,
121 const wxString
& label
,
122 const wxPoint
& pos
= wxDefaultPosition
,
123 const wxSize
& size
= wxDefaultSize
,
124 long style
= wxCP_DEFAULT_STYLE
,
125 const wxValidator
& validator
= wxDefaultValidator
,
126 const wxString
& name
= wxCollapsiblePaneNameStr
);
130 Parent window, must not be non-@NULL.
132 The identifier for the control.
134 The initial label shown in the button which allows the user to
135 expand or collapse the pane window.
141 The window style, see wxCP_* flags.
143 Validator which can be used for additional date checks.
147 @return @true if the control was successfully created or @false if
150 bool Create(wxWindow
* parent
, wxWindowID id
,
151 const wxString
& label
,
152 const wxPoint
& pos
= wxDefaultPosition
,
153 const wxSize
& size
= wxDefaultSize
,
154 long style
= wxCP_DEFAULT_STYLE
,
155 const wxValidator
& validator
= wxDefaultValidator
,
156 const wxString
& name
= wxCollapsiblePaneNameStr
);
159 Collapses or expands the pane window.
161 virtual void Collapse(bool collapse
= true);
164 Same as calling Collapse(@false).
169 Returns a pointer to the pane window. Add controls to the returned
170 wxWindow to make them collapsible.
172 virtual wxWindow
* GetPane() const;
175 Returns @true if the pane window is currently hidden.
177 virtual bool IsCollapsed() const;
180 Returns @true if the pane window is currently shown.
182 bool IsExpanded() const;