listbook.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/listbook.h
  3. // Purpose: wxListbook: wxListCtrl and wxNotebook combination
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 19.08.03
  7. // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_LISTBOOK_H_
  11. #define _WX_LISTBOOK_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_LISTBOOK
  14. #include "wx/bookctrl.h"
  15. #include "wx/containr.h"
  16. class WXDLLIMPEXP_FWD_CORE wxListView;
  17. class WXDLLIMPEXP_FWD_CORE wxListEvent;
  18. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LISTBOOK_PAGE_CHANGED, wxBookCtrlEvent );
  19. wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_LISTBOOK_PAGE_CHANGING, wxBookCtrlEvent );
  20. // wxListbook flags
  21. #define wxLB_DEFAULT wxBK_DEFAULT
  22. #define wxLB_TOP wxBK_TOP
  23. #define wxLB_BOTTOM wxBK_BOTTOM
  24. #define wxLB_LEFT wxBK_LEFT
  25. #define wxLB_RIGHT wxBK_RIGHT
  26. #define wxLB_ALIGN_MASK wxBK_ALIGN_MASK
  27. // ----------------------------------------------------------------------------
  28. // wxListbook
  29. // ----------------------------------------------------------------------------
  30. class WXDLLIMPEXP_CORE wxListbook : public wxNavigationEnabled<wxBookCtrlBase>
  31. {
  32. public:
  33. wxListbook() { }
  34. wxListbook(wxWindow *parent,
  35. wxWindowID id,
  36. const wxPoint& pos = wxDefaultPosition,
  37. const wxSize& size = wxDefaultSize,
  38. long style = 0,
  39. const wxString& name = wxEmptyString)
  40. {
  41. (void)Create(parent, id, pos, size, style, name);
  42. }
  43. // quasi ctor
  44. bool Create(wxWindow *parent,
  45. wxWindowID id,
  46. const wxPoint& pos = wxDefaultPosition,
  47. const wxSize& size = wxDefaultSize,
  48. long style = 0,
  49. const wxString& name = wxEmptyString);
  50. // overridden base class methods
  51. virtual bool SetPageText(size_t n, const wxString& strText);
  52. virtual wxString GetPageText(size_t n) const;
  53. virtual int GetPageImage(size_t n) const;
  54. virtual bool SetPageImage(size_t n, int imageId);
  55. virtual bool InsertPage(size_t n,
  56. wxWindow *page,
  57. const wxString& text,
  58. bool bSelect = false,
  59. int imageId = NO_IMAGE);
  60. virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
  61. virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
  62. virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
  63. virtual void SetImageList(wxImageList *imageList);
  64. virtual bool DeleteAllPages();
  65. wxListView* GetListView() const { return (wxListView*)m_bookctrl; }
  66. protected:
  67. virtual wxWindow *DoRemovePage(size_t page);
  68. void UpdateSelectedPage(size_t newsel);
  69. wxBookCtrlEvent* CreatePageChangingEvent() const;
  70. void MakeChangedEvent(wxBookCtrlEvent &event);
  71. // Get the correct wxListCtrl flags to use depending on our own flags.
  72. long GetListCtrlFlags() const;
  73. // event handlers
  74. void OnListSelected(wxListEvent& event);
  75. void OnSize(wxSizeEvent& event);
  76. private:
  77. // this should be called when we need to be relaid out
  78. void UpdateSize();
  79. DECLARE_EVENT_TABLE()
  80. DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
  81. };
  82. // ----------------------------------------------------------------------------
  83. // listbook event class and related stuff
  84. // ----------------------------------------------------------------------------
  85. // wxListbookEvent is obsolete and defined for compatibility only (notice that
  86. // we use #define and not typedef to also keep compatibility with the existing
  87. // code which forward declares it)
  88. #define wxListbookEvent wxBookCtrlEvent
  89. typedef wxBookCtrlEventFunction wxListbookEventFunction;
  90. #define wxListbookEventHandler(func) wxBookCtrlEventHandler(func)
  91. #define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
  92. wx__DECLARE_EVT1(wxEVT_LISTBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
  93. #define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
  94. wx__DECLARE_EVT1(wxEVT_LISTBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
  95. // old wxEVT_COMMAND_* constants
  96. #define wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED wxEVT_LISTBOOK_PAGE_CHANGED
  97. #define wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING wxEVT_LISTBOOK_PAGE_CHANGING
  98. #endif // wxUSE_LISTBOOK
  99. #endif // _WX_LISTBOOK_H_