wxRuby Documentation Home

# Wx::CollapsiblePane

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 get_pane
function to access the pane and add your controls inside it (i.e. use
the get_pane return value as parent for the
controls which must go in the pane, NOT the CollapsiblePane 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
CollapsiblePane inside a Sizer 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:

coll_pane = Wx::CollapsiblePane.new(self, :label => ’Details)

1. add the pane with a zero proportion to the sizer which contains it
   sizer.add(coll_pane, 0, Wx::GROW|Wx::ALL)

1. now add a test label in the collapsible pane, using a sizer for layout
   win = coll_pane.pane
   sizer = Wx::BoxSizer(Wx::VERTICAL)
   s_text = Wx::StaticText.new(win, :label => ‘Test!’)
   sizer.add(s_text, 1, Wx::GROW|Wx::ALL, 2)
   win.sizer = sizer
   sizer.set_size_hints(pane)

## Derived from

Control

Window

EvtHandler

Object

## Window styles

`CP_DEFAULT_STYLE` | The default style
`CP_TLW_NO_RESIZE` | Don’t resize the containing frame when collapsed

## Event handling

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

evt_collapsiblepane_changed(id) { | event | … } | The user showed or hidden the collapsible pane.

## See also

Panel,

CollapsiblePaneEvent

## Methods

- CollapsiblePane.new
- CollapsiblePane#create
- CollapsiblePane#is_collapsed
- CollapsiblePane#is_expanded
- CollapsiblePane#collapse
- CollapsiblePane#expand
- CollapsiblePane#get_pane

### CollapsiblePane.new

CollapsiblePane.new(%(arg-type)Window% parent, Integer id, String label, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = CP_DEFAULT_STYLE, Validator validator = DEFAULT_VALIDATOR, String name = “collapsiblePane”)

Initializes the object and calls Create with
all the parameters.

### CollapsiblePane#create

Boolean create(%(arg-type)Window% parent, Integer id, String label, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = CP_DEFAULT_STYLE, Validator validator = DEFAULT_VALIDATOR, String name = “collapsiblePane”)

#### Parameters

- parent Parent window, must not be non-`NULL`.
- id The identifier for the control.
- label The initial label shown in the button which allows the user to expand or collapse the pane window.
- pos Initial position.
- size Initial size.
- style The window style, see `CP_*` flags.
- validator Validator which can be used for additional date checks.
- name Control name.

#### Return value

if the control was successfully created or if creation failed.

### CollapsiblePane#is_collapsed

Boolean is_collapsed()

Returns if the pane window is currently hidden.

### CollapsiblePane#is_expanded

Boolean is_expanded()

Returns if the pane window is currently shown.

### CollapsiblePane#collapse

collapse(%(arg-type)Boolean% collapse = true)

Collapses or expands the pane window.

### CollapsiblePane#expand

expand()

Same as collapse(false).

### CollapsiblePane#get_pane

Window get_pane()

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

[This page automatically generated from the Textile source at 2023-06-09 00:45:29 +0000]