collpaneg.h 3.3 KB

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