1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListbook: wxListCtrl and wxNotebook combination
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOOK_H_
13 #define _WX_LISTBOOK_H_
19 #include "wx/bookctrl.h"
20 #include "wx/containr.h"
22 class WXDLLIMPEXP_FWD_CORE wxListView
;
23 class WXDLLIMPEXP_FWD_CORE wxListEvent
;
25 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
, wxBookCtrlEvent
);
26 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
, wxBookCtrlEvent
);
29 #define wxLB_DEFAULT wxBK_DEFAULT
30 #define wxLB_TOP wxBK_TOP
31 #define wxLB_BOTTOM wxBK_BOTTOM
32 #define wxLB_LEFT wxBK_LEFT
33 #define wxLB_RIGHT wxBK_RIGHT
34 #define wxLB_ALIGN_MASK wxBK_ALIGN_MASK
36 // ----------------------------------------------------------------------------
38 // ----------------------------------------------------------------------------
40 class WXDLLIMPEXP_CORE wxListbook
: public wxNavigationEnabled
<wxBookCtrlBase
>
45 wxListbook(wxWindow
*parent
,
47 const wxPoint
& pos
= wxDefaultPosition
,
48 const wxSize
& size
= wxDefaultSize
,
50 const wxString
& name
= wxEmptyString
)
52 (void)Create(parent
, id
, pos
, size
, style
, name
);
56 bool Create(wxWindow
*parent
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
61 const wxString
& name
= wxEmptyString
);
64 // overridden base class methods
65 virtual bool SetPageText(size_t n
, const wxString
& strText
);
66 virtual wxString
GetPageText(size_t n
) const;
67 virtual int GetPageImage(size_t n
) const;
68 virtual bool SetPageImage(size_t n
, int imageId
);
69 virtual bool InsertPage(size_t n
,
73 int imageId
= NO_IMAGE
);
74 virtual int SetSelection(size_t n
) { return DoSetSelection(n
, SetSelection_SendEvent
); }
75 virtual int ChangeSelection(size_t n
) { return DoSetSelection(n
); }
76 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
77 virtual void SetImageList(wxImageList
*imageList
);
79 virtual bool DeleteAllPages();
81 wxListView
* GetListView() const { return (wxListView
*)m_bookctrl
; }
84 virtual wxWindow
*DoRemovePage(size_t page
);
86 void UpdateSelectedPage(size_t newsel
);
88 wxBookCtrlEvent
* CreatePageChangingEvent() const;
89 void MakeChangedEvent(wxBookCtrlEvent
&event
);
91 // Get the correct wxListCtrl flags to use depending on our own flags.
92 long GetListCtrlFlags() const;
95 void OnListSelected(wxListEvent
& event
);
96 void OnSize(wxSizeEvent
& event
);
99 // this should be called when we need to be relaid out
103 DECLARE_EVENT_TABLE()
104 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook
)
107 // ----------------------------------------------------------------------------
108 // listbook event class and related stuff
109 // ----------------------------------------------------------------------------
111 // wxListbookEvent is obsolete and defined for compatibility only (notice that
112 // we use #define and not typedef to also keep compatibility with the existing
113 // code which forward declares it)
114 #define wxListbookEvent wxBookCtrlEvent
115 typedef wxBookCtrlEventFunction wxListbookEventFunction
;
116 #define wxListbookEventHandler(func) wxBookCtrlEventHandler(func)
118 #define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
119 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
121 #define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
122 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
124 #endif // wxUSE_LISTBOOK
126 #endif // _WX_LISTBOOK_H_