initial draft of wxCollapsiblePane (patch 1577412 by Francesco)
[wxWidgets.git] / include / wx / collpane.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/collpane.h
3 // Purpose: wxCollapsiblePane
4 // Author: Francesco Montorsi
5 // Modified by:
6 // Created: 8/10/2006
7 // RCS-ID: $Id$
8 // Copyright: (c) Francesco Montorsi
9 // Licence: wxWindows Licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_COLLAPSABLE_PANE_H_BASE_
13 #define _WX_COLLAPSABLE_PANE_H_BASE_
14
15 #include "wx/control.h"
16
17
18 // ----------------------------------------------------------------------------
19 // wxCollapsiblePaneBase: interface for wxCollapsiblePane
20 // ----------------------------------------------------------------------------
21
22 #define wxCP_DEFAULT_STYLE (0)
23
24 class WXDLLEXPORT wxCollapsiblePaneBase : public wxControl
25 {
26 public:
27 wxCollapsiblePaneBase() {}
28
29 virtual void Expand()
30 { Collapse(false); }
31
32 virtual void Collapse(bool collapse = true) = 0;
33 virtual bool IsCollapsed() const = 0;
34 virtual wxWindow *GetPane() const = 0;
35
36 virtual wxString GetLabel() const = 0;
37 virtual void SetLabel(const wxString &label) = 0;
38 };
39
40
41 // ----------------------------------------------------------------------------
42 // event types and macros
43 // ----------------------------------------------------------------------------
44
45 BEGIN_DECLARE_EVENT_TYPES()
46 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_COLLPANE_CHANGED, 1102)
47 END_DECLARE_EVENT_TYPES()
48
49 class WXDLLIMPEXP_CORE wxCollapsiblePaneEvent : public wxCommandEvent
50 {
51 public:
52 wxCollapsiblePaneEvent() {}
53 wxCollapsiblePaneEvent(wxObject *generator, int id, bool collapsed)
54 : wxCommandEvent(wxEVT_COMMAND_COLLPANE_CHANGED, id),
55 m_bCollapsed(collapsed)
56 {
57 SetEventObject(generator);
58 }
59
60 bool GetCollapsed() const { return m_bCollapsed; }
61 void SetCollapsed(bool c) { m_bCollapsed = c; }
62
63
64 // default copy ctor, assignment operator and dtor are ok
65 virtual wxEvent *Clone() const { return new wxCollapsiblePaneEvent(*this); }
66
67 private:
68 bool m_bCollapsed;
69
70 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCollapsiblePaneEvent)
71 };
72
73 // ----------------------------------------------------------------------------
74 // event types and macros
75 // ----------------------------------------------------------------------------
76
77 typedef void (wxEvtHandler::*wxCollapsiblePaneEventFunction)(wxCollapsiblePaneEvent&);
78
79 #define wxCollapsiblePaneEventHandler(func) \
80 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxCollapsiblePaneEventFunction, &func)
81
82 #define EVT_COLLAPSIBLEPANE_CHANGED(id, fn) \
83 wx__DECLARE_EVT1(wxEVT_COMMAND_COLLPANE_CHANGED, id, wxCollapsiblePaneEventFunction(fn))
84
85
86 #if defined(__WXGTK24__)
87 #include "wx/gtk/collpane.h"
88 #else
89 #include "wx/generic/collpaneg.h"
90 #define wxCollapsiblePane wxGenericCollapsiblePane
91 #endif
92
93 #endif
94 // _WX_COLLAPSABLE_PANE_H_BASE_