2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: collpane.h
|
2008-04-09 22:57:09 -04:00
|
|
|
// Purpose: interface of wxCollapsiblePane
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-09-02 21:39:02 -04:00
|
|
|
#define wxCP_DEFAULT_STYLE (wxTAB_TRAVERSAL | wxNO_BORDER)
|
|
|
|
#define wxCP_NO_TLW_RESIZE (0x0002)
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxCollapsiblePaneEvent
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
This event class is used for the events generated by wxCollapsiblePane.
|
|
|
|
|
|
|
|
@beginEventTable{wxCollapsiblePaneEvent}
|
|
|
|
@event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
|
|
|
|
The user expanded or collapsed the collapsible pane.
|
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-04-09 22:57:09 -04:00
|
|
|
@category{events}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxCollapsiblePane
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxCollapsiblePaneEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
The constructor is not normally used by the user code.
|
|
|
|
*/
|
2008-04-09 22:57:09 -04:00
|
|
|
wxCollapsiblePaneEvent(wxObject* generator, int id, bool collapsed);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the pane has been collapsed.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool GetCollapsed() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Sets this as a collapsed pane event (if @a collapsed is @true) or as an
|
2008-04-09 22:57:09 -04:00
|
|
|
expanded pane event (if @a collapsed is @false).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetCollapsed(bool collapsed);
|
|
|
|
};
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
wxEventType wxEVT_COLLAPSIBLEPANE_CHANGED;
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxCollapsiblePane
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-09 22:57:09 -04:00
|
|
|
Once constructed you should use the GetPane() function to access the pane
|
|
|
|
and add your controls inside it (i.e. use the returned pointer from
|
|
|
|
GetPane() as parent for the controls which must go in the pane, @b not the
|
|
|
|
wxCollapsiblePane itself!).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Note that because of its nature of control which can dynamically (and
|
2008-04-09 22:57:09 -04:00
|
|
|
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 will automatically resize each time the user
|
|
|
|
expands or collapse the pane window usually resulting in a weird,
|
|
|
|
flickering effect.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Usage sample:
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
2009-01-18 16:46:46 -05:00
|
|
|
wxCollapsiblePane *collpane = new wxCollapsiblePane(this, wxID_ANY, "Details:");
|
2008-04-09 22:57:09 -04:00
|
|
|
|
|
|
|
// 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);
|
2009-01-18 16:46:46 -05:00
|
|
|
paneSz->Add(new wxStaticText(win, wxID_ANY, "test!"), 1, wxGROW|wxALL, 2);
|
2008-04-09 22:57:09 -04:00
|
|
|
win->SetSizer(paneSz);
|
|
|
|
paneSz->SetSizeHints(win);
|
2008-03-08 08:52:38 -05:00
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
It is only available if @c wxUSE_COLLPANE is set to 1 (the default).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCP_DEFAULT_STYLE}
|
2008-08-29 13:35:30 -04:00
|
|
|
The default style. It includes wxTAB_TRAVERSAL and wxBORDER_NONE.
|
|
|
|
@style{wxCP_NO_TLW_RESIZE}
|
|
|
|
By default wxCollapsiblePane resizes the top level window containing it
|
2019-01-25 21:14:20 -05:00
|
|
|
when its own size changes. This allows easily implementing dialogs
|
2008-08-29 13:35:30 -04:00
|
|
|
containing an optionally shown part, for example, and so is the default
|
|
|
|
behaviour but can be inconvenient in some specific cases -- use this
|
|
|
|
flag to disable this automatic parent resizing then.
|
2008-03-08 08:52:38 -05:00
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{wxCollapsiblePaneEvent,wxNavigationKeyEvent}
|
2008-04-09 22:57:09 -04:00
|
|
|
@event{EVT_COLLAPSIBLEPANE_CHANGED(id, func)}
|
2009-02-18 12:58:51 -05:00
|
|
|
The user expanded or collapsed the collapsible pane.
|
|
|
|
@event{EVT_NAVIGATION_KEY(func)}
|
|
|
|
Process a navigation key event.
|
2008-04-09 22:57:09 -04:00
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{ctrl}
|
2012-11-03 14:32:50 -04:00
|
|
|
@appearance{collapsiblepane}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxPanel, wxCollapsiblePaneEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxCollapsiblePane : public wxControl
|
|
|
|
{
|
|
|
|
public:
|
2008-04-15 04:49:08 -04:00
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxCollapsiblePane();
|
2008-09-21 19:48:04 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Initializes the object and calls Create() with all the parameters.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxCollapsiblePane(wxWindow* parent, wxWindowID id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& label,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxCP_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-09-21 19:48:04 -04:00
|
|
|
const wxString& name = wxCollapsiblePaneNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window, must not be non-@NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
The identifier for the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param label
|
2008-04-09 22:57:09 -04:00
|
|
|
The initial label shown in the button which allows the user to
|
|
|
|
expand or collapse the pane window.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial size.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
The window style, see wxCP_* flags.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
Validator which can be used for additional date checks.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Control name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the control was successfully created or @false if
|
|
|
|
creation failed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& label,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxCP_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-09-21 19:48:04 -04:00
|
|
|
const wxString& name = wxCollapsiblePaneNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Collapses or expands the pane window.
|
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
virtual void Collapse(bool collapse = true);
|
2008-04-09 22:57:09 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Same as calling Collapse(@false).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void Expand();
|
|
|
|
|
|
|
|
/**
|
2008-04-09 22:57:09 -04:00
|
|
|
Returns a pointer to the pane window. Add controls to the returned
|
|
|
|
wxWindow to make them collapsible.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
virtual wxWindow* GetPane() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the pane window is currently hidden.
|
|
|
|
*/
|
2008-09-22 15:01:17 -04:00
|
|
|
virtual bool IsCollapsed() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the pane window is currently shown.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsExpanded() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|