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