Contents Up Previous Next

wxCollapsiblePane

A collapsible pane is a container with an embedded button-like control which can be used by the user to collapse or expand the pane's contents.

Once constructed you should use the GetPane function to access the pane and add your controls inside it (i.e. use the GetPane's returned pointer as parent for the controls which must go in the pane, NOT the wxCollapsiblePane itself!).

Note that because of its nature of control which can dynamically (and drastically) change its size at run-time under user-input, when putting wxCollapsiblePane inside a wxSizer you should be careful to add it with a proportion value of zero; this is because otherwise all other windows with non-null proportion values would automatically get resized each time the user expands or collapse the pane window resulting usually in a weird, flickering effect.

Usage sample:

    wxCollapsiblePane *collpane = new wxCollapsiblePane(this, wxID_ANY, wxT("Details:"));

    // add the pane with a zero proportion value to the 'sz' sizer which contains it
    sz->Add(collpane, 0, wxGROW|wxALL, 5);

    // now add a test label in the collapsible pane using a sizer to layout it:
    wxWindow *win = collpane->GetPane();
    wxSizer *paneSz = new wxBoxSizer(wxVERTICAL);
    paneSz->Add(new wxStaticText(win, wxID_ANY, wxT("test!")), 1, wxGROW|wxALL, 2);
    win->SetSizer(paneSz);
    paneSz->SetSizeHints(win);

It is only available if wxUSE_COLLPANE is set to 1 (the default).

Derived from

wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/collpane.h>

Window styles

wxCP_DEFAULT_STYLE The default style: 0.

Event handling

To process a collapsible pane event, use these event handler macros to direct input to member functions that take a wxCollapsiblePaneEvent argument.

EVT_COLLAPSIBLEPANE_CHANGED(id, func) The user showed or hidden the collapsible pane.

See also

wxPanel,
wxCollapsiblePaneEvent

Members

wxCollapsiblePane::wxCollapsiblePane
wxCollapsiblePane::Create
wxCollapsiblePane::IsCollapsed
wxCollapsiblePane::IsExpanded
wxCollapsiblePane::Collapse
wxCollapsiblePane::Expand
wxCollapsiblePane::GetPane


wxCollapsiblePane::wxCollapsiblePane

wxCollapsiblePane(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "collapsiblePane")

Initializes the object and calls Create with all the parameters.


wxCollapsiblePane::Create

bool Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "collapsiblePane")

Parameters

parent

id

label

pos

size

style

validator

name

Return value

true if the control was successfully created or false if creation failed.


wxCollapsiblePane::IsCollapsed

bool IsCollapsed() const

Returns true if the pane window is currently hidden.


wxCollapsiblePane::IsExpanded

bool IsExpanded() const

Returns true if the pane window is currently shown.


wxCollapsiblePane::Collapse

void Collapse(bool collapse = true)

Collapses or expands the pane window.


wxCollapsiblePane::Expand

void Expand()

Same as Collapse(false).


wxCollapsiblePane::GetPane

wxWindow * GetPane() const

Returns a pointer to the pane window. Add controls to the returned wxWindow to make them collapsible.