collpane.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/collpane.h
  3. // Purpose: wxCollapsiblePane
  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_BASE_
  11. #define _WX_COLLAPSABLE_PANE_H_BASE_
  12. #include "wx/defs.h"
  13. #if wxUSE_COLLPANE
  14. #include "wx/control.h"
  15. // class name
  16. extern WXDLLIMPEXP_DATA_CORE(const char) wxCollapsiblePaneNameStr[];
  17. // ----------------------------------------------------------------------------
  18. // wxCollapsiblePaneBase: interface for wxCollapsiblePane
  19. // ----------------------------------------------------------------------------
  20. #define wxCP_DEFAULT_STYLE (wxTAB_TRAVERSAL | wxNO_BORDER)
  21. #define wxCP_NO_TLW_RESIZE (0x0002)
  22. class WXDLLIMPEXP_CORE wxCollapsiblePaneBase : public wxControl
  23. {
  24. public:
  25. wxCollapsiblePaneBase() {}
  26. virtual void Collapse(bool collapse = true) = 0;
  27. void Expand() { Collapse(false); }
  28. virtual bool IsCollapsed() const = 0;
  29. bool IsExpanded() const { return !IsCollapsed(); }
  30. virtual wxWindow *GetPane() const = 0;
  31. virtual wxString GetLabel() const = 0;
  32. virtual void SetLabel(const wxString& label) = 0;
  33. };
  34. // ----------------------------------------------------------------------------
  35. // event types and macros
  36. // ----------------------------------------------------------------------------
  37. class WXDLLIMPEXP_FWD_CORE wxCollapsiblePaneEvent;
  38. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COLLAPSIBLEPANE_CHANGED, wxCollapsiblePaneEvent );
  39. class WXDLLIMPEXP_CORE wxCollapsiblePaneEvent : public wxCommandEvent
  40. {
  41. public:
  42. wxCollapsiblePaneEvent() {}
  43. wxCollapsiblePaneEvent(wxObject *generator, int id, bool collapsed)
  44. : wxCommandEvent(wxEVT_COLLAPSIBLEPANE_CHANGED, id),
  45. m_bCollapsed(collapsed)
  46. {
  47. SetEventObject(generator);
  48. }
  49. bool GetCollapsed() const { return m_bCollapsed; }
  50. void SetCollapsed(bool c) { m_bCollapsed = c; }
  51. // default copy ctor, assignment operator and dtor are ok
  52. virtual wxEvent *Clone() const { return new wxCollapsiblePaneEvent(*this); }
  53. private:
  54. bool m_bCollapsed;
  55. DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxCollapsiblePaneEvent)
  56. };
  57. // ----------------------------------------------------------------------------
  58. // event types and macros
  59. // ----------------------------------------------------------------------------
  60. typedef void (wxEvtHandler::*wxCollapsiblePaneEventFunction)(wxCollapsiblePaneEvent&);
  61. #define wxCollapsiblePaneEventHandler(func) \
  62. wxEVENT_HANDLER_CAST(wxCollapsiblePaneEventFunction, func)
  63. #define EVT_COLLAPSIBLEPANE_CHANGED(id, fn) \
  64. wx__DECLARE_EVT1(wxEVT_COLLAPSIBLEPANE_CHANGED, id, wxCollapsiblePaneEventHandler(fn))
  65. #if defined(__WXGTK20__) && !defined(__WXUNIVERSAL__)
  66. #include "wx/gtk/collpane.h"
  67. #else
  68. #include "wx/generic/collpaneg.h"
  69. // use #define and not a typedef to allow forward declaring the class
  70. #define wxCollapsiblePane wxGenericCollapsiblePane
  71. #endif
  72. // old wxEVT_COMMAND_* constant
  73. #define wxEVT_COMMAND_COLLPANE_CHANGED wxEVT_COLLAPSIBLEPANE_CHANGED
  74. #endif // wxUSE_COLLPANE
  75. #endif // _WX_COLLAPSABLE_PANE_H_BASE_