]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: collpane.h | |
968f15e2 | 3 | // Purpose: interface of wxCollapsiblePane |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
8ff9b17d RD |
9 | #define wxCP_DEFAULT_STYLE (wxTAB_TRAVERSAL | wxNO_BORDER) |
10 | #define wxCP_NO_TLW_RESIZE (0x0002) | |
11 | ||
23324ae1 FM |
12 | /** |
13 | @class wxCollapsiblePaneEvent | |
7c913512 | 14 | |
968f15e2 BP |
15 | This event class is used for the events generated by wxCollapsiblePane. |
16 | ||
17 | @beginEventTable{wxCollapsiblePaneEvent} | |
18 | @event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)} | |
19 | The user expanded or collapsed the collapsible pane. | |
20 | @endEventTable | |
7c913512 | 21 | |
23324ae1 | 22 | @library{wxcore} |
968f15e2 | 23 | @category{events} |
7c913512 | 24 | |
e54c96f1 | 25 | @see wxCollapsiblePane |
23324ae1 FM |
26 | */ |
27 | class wxCollapsiblePaneEvent : public wxCommandEvent | |
28 | { | |
29 | public: | |
30 | /** | |
31 | The constructor is not normally used by the user code. | |
32 | */ | |
968f15e2 | 33 | wxCollapsiblePaneEvent(wxObject* generator, int id, bool collapsed); |
23324ae1 FM |
34 | |
35 | /** | |
36 | Returns @true if the pane has been collapsed. | |
37 | */ | |
328f5751 | 38 | bool GetCollapsed() const; |
23324ae1 FM |
39 | |
40 | /** | |
4cc4bfaf | 41 | Sets this as a collapsed pane event (if @a collapsed is @true) or as an |
968f15e2 | 42 | expanded pane event (if @a collapsed is @false). |
23324ae1 FM |
43 | */ |
44 | void SetCollapsed(bool collapsed); | |
45 | }; | |
46 | ||
ce7fe42e | 47 | wxEventType wxEVT_COLLAPSIBLEPANE_CHANGED; |
e54c96f1 | 48 | |
23324ae1 FM |
49 | /** |
50 | @class wxCollapsiblePane | |
7c913512 | 51 | |
968f15e2 BP |
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. | |
7c913512 | 54 | |
968f15e2 BP |
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!). | |
7c913512 | 59 | |
23324ae1 | 60 | Note that because of its nature of control which can dynamically (and |
968f15e2 BP |
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, | |
66 | flickering effect. | |
7c913512 | 67 | |
23324ae1 | 68 | Usage sample: |
7c913512 | 69 | |
23324ae1 | 70 | @code |
f8ebb70d | 71 | wxCollapsiblePane *collpane = new wxCollapsiblePane(this, wxID_ANY, "Details:"); |
968f15e2 BP |
72 | |
73 | // add the pane with a zero proportion value to the 'sz' sizer which contains it | |
74 | sz->Add(collpane, 0, wxGROW|wxALL, 5); | |
75 | ||
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); | |
f8ebb70d | 79 | paneSz->Add(new wxStaticText(win, wxID_ANY, "test!"), 1, wxGROW|wxALL, 2); |
968f15e2 BP |
80 | win->SetSizer(paneSz); |
81 | paneSz->SetSizeHints(win); | |
23324ae1 | 82 | @endcode |
7c913512 | 83 | |
23324ae1 | 84 | It is only available if @c wxUSE_COLLPANE is set to 1 (the default). |
7c913512 | 85 | |
23324ae1 | 86 | @beginStyleTable |
8c6791e4 | 87 | @style{wxCP_DEFAULT_STYLE} |
b18f47d0 VZ |
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. | |
23324ae1 | 95 | @endStyleTable |
7c913512 | 96 | |
3051a44a | 97 | @beginEventEmissionTable{wxCollapsiblePaneEvent,wxNavigationKeyEvent} |
968f15e2 | 98 | @event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)} |
3051a44a FM |
99 | The user expanded or collapsed the collapsible pane. |
100 | @event{EVT_NAVIGATION_KEY(func)} | |
101 | Process a navigation key event. | |
968f15e2 BP |
102 | @endEventTable |
103 | ||
23324ae1 FM |
104 | @library{wxcore} |
105 | @category{ctrl} | |
ce154616 | 106 | @appearance{collapsiblepane} |
7c913512 | 107 | |
e54c96f1 | 108 | @see wxPanel, wxCollapsiblePaneEvent |
23324ae1 FM |
109 | */ |
110 | class wxCollapsiblePane : public wxControl | |
111 | { | |
112 | public: | |
c559feea RR |
113 | /** |
114 | Default constructor. | |
115 | */ | |
116 | wxCollapsiblePane(); | |
9d9c1c24 | 117 | |
23324ae1 | 118 | /** |
968f15e2 | 119 | Initializes the object and calls Create() with all the parameters. |
23324ae1 | 120 | */ |
4cc4bfaf | 121 | wxCollapsiblePane(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
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, | |
9d9c1c24 | 127 | const wxString& name = wxCollapsiblePaneNameStr); |
23324ae1 | 128 | |
23324ae1 | 129 | /** |
7c913512 | 130 | @param parent |
4cc4bfaf | 131 | Parent window, must not be non-@NULL. |
7c913512 | 132 | @param id |
4cc4bfaf | 133 | The identifier for the control. |
7c913512 | 134 | @param label |
968f15e2 BP |
135 | The initial label shown in the button which allows the user to |
136 | expand or collapse the pane window. | |
7c913512 | 137 | @param pos |
4cc4bfaf | 138 | Initial position. |
7c913512 | 139 | @param size |
4cc4bfaf | 140 | Initial size. |
7c913512 | 141 | @param style |
4cc4bfaf | 142 | The window style, see wxCP_* flags. |
7c913512 | 143 | @param validator |
4cc4bfaf | 144 | Validator which can be used for additional date checks. |
7c913512 | 145 | @param name |
4cc4bfaf | 146 | Control name. |
3c4f71cc | 147 | |
d29a9a8a BP |
148 | @return @true if the control was successfully created or @false if |
149 | creation failed. | |
23324ae1 | 150 | */ |
4cc4bfaf | 151 | bool Create(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
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, | |
9d9c1c24 | 157 | const wxString& name = wxCollapsiblePaneNameStr); |
23324ae1 FM |
158 | |
159 | /** | |
968f15e2 BP |
160 | Collapses or expands the pane window. |
161 | */ | |
b7e94bd7 | 162 | virtual void Collapse(bool collapse = true); |
968f15e2 BP |
163 | |
164 | /** | |
165 | Same as calling Collapse(@false). | |
23324ae1 FM |
166 | */ |
167 | void Expand(); | |
168 | ||
169 | /** | |
968f15e2 BP |
170 | Returns a pointer to the pane window. Add controls to the returned |
171 | wxWindow to make them collapsible. | |
23324ae1 | 172 | */ |
b7e94bd7 | 173 | virtual wxWindow* GetPane() const; |
23324ae1 FM |
174 | |
175 | /** | |
176 | Returns @true if the pane window is currently hidden. | |
177 | */ | |
b7e94bd7 | 178 | virtual bool IsCollapsed() const; |
23324ae1 FM |
179 | |
180 | /** | |
181 | Returns @true if the pane window is currently shown. | |
182 | */ | |
328f5751 | 183 | bool IsExpanded() const; |
23324ae1 | 184 | }; |