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 WXDLLIMPEXP_FWD_CORE wxListView
;
22 class WXDLLIMPEXP_FWD_CORE wxListEvent
;
24 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
;
25 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
;
28 #define wxLB_DEFAULT wxBK_DEFAULT
29 #define wxLB_TOP wxBK_TOP
30 #define wxLB_BOTTOM wxBK_BOTTOM
31 #define wxLB_LEFT wxBK_LEFT
32 #define wxLB_RIGHT wxBK_RIGHT
33 #define wxLB_ALIGN_MASK wxBK_ALIGN_MASK
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 class WXDLLIMPEXP_CORE wxListbook
: public wxBookCtrlBase
47 wxListbook(wxWindow
*parent
,
49 const wxPoint
& pos
= wxDefaultPosition
,
50 const wxSize
& size
= wxDefaultSize
,
52 const wxString
& name
= wxEmptyString
)
56 (void)Create(parent
, id
, pos
, size
, style
, name
);
60 bool Create(wxWindow
*parent
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
,
65 const wxString
& name
= wxEmptyString
);
68 // overridden base class methods
69 virtual int GetSelection() const;
70 virtual bool SetPageText(size_t n
, const wxString
& strText
);
71 virtual wxString
GetPageText(size_t n
) const;
72 virtual int GetPageImage(size_t n
) const;
73 virtual bool SetPageImage(size_t n
, int imageId
);
74 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
75 virtual bool InsertPage(size_t n
,
80 virtual int SetSelection(size_t n
) { return DoSetSelection(n
, SetSelection_SendEvent
); }
81 virtual int ChangeSelection(size_t n
) { return DoSetSelection(n
); }
82 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
83 virtual void SetImageList(wxImageList
*imageList
);
85 virtual bool DeleteAllPages();
87 wxListView
* GetListView() const { return (wxListView
*)m_bookctrl
; }
90 virtual wxWindow
*DoRemovePage(size_t page
);
92 // get the size which the list control should have
93 virtual wxSize
GetControllerSize() const;
95 void UpdateSelectedPage(size_t newsel
);
97 wxBookCtrlBaseEvent
* CreatePageChangingEvent() const;
98 void MakeChangedEvent(wxBookCtrlBaseEvent
&event
);
101 void OnListSelected(wxListEvent
& event
);
102 void OnSize(wxSizeEvent
& event
);
104 // the currently selected page or wxNOT_FOUND if none
108 // common part of all constructors
111 DECLARE_EVENT_TABLE()
112 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook
)
115 // ----------------------------------------------------------------------------
116 // listbook event class and related stuff
117 // ----------------------------------------------------------------------------
119 class WXDLLIMPEXP_CORE wxListbookEvent
: public wxBookCtrlBaseEvent
122 wxListbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
123 int nSel
= wxNOT_FOUND
, int nOldSel
= wxNOT_FOUND
)
124 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
128 wxListbookEvent(const wxListbookEvent
& event
)
129 : wxBookCtrlBaseEvent(event
)
133 virtual wxEvent
*Clone() const { return new wxListbookEvent(*this); }
136 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxListbookEvent
)
139 typedef void (wxEvtHandler::*wxListbookEventFunction
)(wxListbookEvent
&);
141 #define wxListbookEventHandler(func) \
142 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func)
144 #define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
145 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn))
147 #define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
148 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn))
150 #endif // wxUSE_LISTBOOK
152 #endif // _WX_LISTBOOK_H_