1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: wx/generic/collpaneg.h 3 // Purpose: wxGenericCollapsiblePane 4 // Author: Francesco Montorsi 5 // Modified by: 6 // Created: 8/10/2006 7 // Copyright: (c) Francesco Montorsi 8 // Licence: wxWindows Licence 9 ///////////////////////////////////////////////////////////////////////////// 10 11 #ifndef _WX_COLLAPSABLE_PANE_H_GENERIC_ 12 #define _WX_COLLAPSABLE_PANE_H_GENERIC_ 13 14 // forward declared 15 class WXDLLIMPEXP_FWD_CORE wxButton; 16 class WXDLLIMPEXP_FWD_CORE wxStaticLine; 17 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) 18 class WXDLLIMPEXP_FWD_CORE wxDisclosureTriangle; 19 #endif 20 21 #include "wx/containr.h" 22 23 // ---------------------------------------------------------------------------- 24 // wxGenericCollapsiblePane 25 // ---------------------------------------------------------------------------- 26 27 class WXDLLIMPEXP_CORE wxGenericCollapsiblePane : 28 public wxNavigationEnabled<wxCollapsiblePaneBase> 29 { 30 public: wxGenericCollapsiblePane()31 wxGenericCollapsiblePane() { Init(); } 32 33 wxGenericCollapsiblePane(wxWindow *parent, 34 wxWindowID winid, 35 const wxString& label, 36 const wxPoint& pos = wxDefaultPosition, 37 const wxSize& size = wxDefaultSize, 38 long style = wxCP_DEFAULT_STYLE, 39 const wxValidator& val = wxDefaultValidator, 40 const wxString& name = wxCollapsiblePaneNameStr) 41 { 42 Init(); 43 44 Create(parent, winid, label, pos, size, style, val, name); 45 } 46 47 virtual ~wxGenericCollapsiblePane(); 48 49 bool Create(wxWindow *parent, 50 wxWindowID winid, 51 const wxString& label, 52 const wxPoint& pos = wxDefaultPosition, 53 const wxSize& size = wxDefaultSize, 54 long style = wxCP_DEFAULT_STYLE, 55 const wxValidator& val = wxDefaultValidator, 56 const wxString& name = wxCollapsiblePaneNameStr); 57 58 // public wxCollapsiblePane API 59 virtual void Collapse(bool collapse = true); 60 virtual void SetLabel(const wxString &label); 61 IsCollapsed()62 virtual bool IsCollapsed() const 63 { return m_pPane==NULL || !m_pPane->IsShown(); } GetPane()64 virtual wxWindow *GetPane() const 65 { return m_pPane; } GetLabel()66 virtual wxString GetLabel() const 67 { return m_strLabel; } 68 69 virtual bool Layout(); 70 71 72 // for the generic collapsible pane only: GetControlWidget()73 wxControl* GetControlWidget() const 74 { return (wxControl*)m_pButton; } 75 76 // implementation only, don't use 77 void OnStateChange(const wxSize& sizeNew); 78 79 protected: 80 // overridden methods 81 virtual wxSize DoGetBestSize() const; 82 83 wxString GetBtnLabel() const; 84 int GetBorder() const; 85 86 // child controls 87 #if defined( __WXMAC__ ) && !defined(__WXUNIVERSAL__) 88 wxDisclosureTriangle *m_pButton; 89 #else 90 wxButton *m_pButton; 91 #endif 92 wxStaticLine *m_pStaticLine; 93 wxWindow *m_pPane; 94 wxSizer *m_sz; 95 96 // the button label without ">>" or "<<" 97 wxString m_strLabel; 98 99 private: 100 void Init(); 101 102 // event handlers 103 void OnButton(wxCommandEvent &ev); 104 void OnSize(wxSizeEvent &ev); 105 106 DECLARE_DYNAMIC_CLASS(wxGenericCollapsiblePane) 107 DECLARE_EVENT_TABLE() 108 }; 109 110 #endif // _WX_COLLAPSABLE_PANE_H_GENERIC_ 111