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"
21 class WXDLLEXPORT wxListView
;
22 class WXDLLEXPORT wxListEvent
;
24 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
;
25 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
;
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class WXDLLEXPORT wxListbook
: public wxBookCtrlBase
39 wxListbook(wxWindow
*parent
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
44 const wxString
& name
= wxEmptyString
)
48 (void)Create(parent
, id
, pos
, size
, style
, name
);
52 bool Create(wxWindow
*parent
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
57 const wxString
& name
= wxEmptyString
);
60 virtual int GetSelection() const;
61 virtual bool SetPageText(size_t n
, const wxString
& strText
);
62 virtual wxString
GetPageText(size_t n
) const;
63 virtual int GetPageImage(size_t n
) const;
64 virtual bool SetPageImage(size_t n
, int imageId
);
65 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
66 virtual bool InsertPage(size_t n
,
71 virtual int SetSelection(size_t n
) { return DoSetSelection(n
, SetSelection_SendEvent
); }
72 virtual int ChangeSelection(size_t n
) { return DoSetSelection(n
); }
73 virtual void SetImageList(wxImageList
*imageList
);
75 virtual bool DeleteAllPages();
77 wxListView
* GetListView() const { return (wxListView
*)m_bookctrl
; }
80 virtual wxWindow
*DoRemovePage(size_t page
);
82 // get the size which the list control should have
83 virtual wxSize
GetControllerSize() const;
85 // return the page corresponding to the tab at the specified position
86 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
88 int DoSetSelection(size_t nPage
, int flags
= 0);
90 void UpdateSelectedPage(size_t newsel
);
92 void MakeChangedEvent(wxBookCtrlBaseEvent
&event
)
94 event
.SetEventType(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
);
98 void OnListSelected(wxListEvent
& event
);
99 void OnSize(wxSizeEvent
& event
);
101 // the currently selected page or wxNOT_FOUND if none
105 // common part of all constructors
108 DECLARE_EVENT_TABLE()
109 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook
)
112 // ----------------------------------------------------------------------------
113 // listbook event class and related stuff
114 // ----------------------------------------------------------------------------
116 class WXDLLEXPORT wxListbookEvent
: public wxBookCtrlBaseEvent
119 wxListbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
120 int nSel
= wxNOT_FOUND
, int nOldSel
= wxNOT_FOUND
)
121 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
125 wxListbookEvent(const wxListbookEvent
& event
)
126 : wxBookCtrlBaseEvent(event
)
130 virtual wxEvent
*Clone() const { return new wxListbookEvent(*this); }
133 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxListbookEvent
)
136 typedef void (wxEvtHandler::*wxListbookEventFunction
)(wxListbookEvent
&);
138 #define wxListbookEventHandler(func) \
139 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func)
141 #define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
142 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn))
144 #define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
145 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn))
147 #endif // wxUSE_LISTBOOK
149 #endif // _WX_LISTBOOK_H_