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_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "listbook.h"
23 // this can be defined to put a static line as separator between the list
24 // control and the page area; but I think it finally looks better without it so
25 // it is not enabled by default
26 //#define wxUSE_LINE_IN_LISTBOOK 1
29 #undef wxUSE_LINE_IN_LISTBOOK
30 #define wxUSE_LINE_IN_LISTBOOK 0
33 #include "wx/bookctrl.h"
35 class WXDLLEXPORT wxListView
;
36 class WXDLLEXPORT wxListEvent
;
38 #if wxUSE_LINE_IN_LISTBOOK
39 class WXDLLEXPORT wxStaticLine
;
40 #endif // wxUSE_LINE_IN_LISTBOOK
42 // ----------------------------------------------------------------------------
44 // ----------------------------------------------------------------------------
46 class WXDLLEXPORT wxListbook
: public wxBookCtrl
54 wxListbook(wxWindow
*parent
,
56 const wxPoint
& pos
= wxDefaultPosition
,
57 const wxSize
& size
= wxDefaultSize
,
59 const wxString
& name
= wxEmptyString
)
63 (void)Create(parent
, id
, pos
, size
, style
, name
);
67 bool Create(wxWindow
*parent
,
69 const wxPoint
& pos
= wxDefaultPosition
,
70 const wxSize
& size
= wxDefaultSize
,
72 const wxString
& name
= wxEmptyString
);
75 virtual int GetSelection() const;
76 virtual bool SetPageText(size_t n
, const wxString
& strText
);
77 virtual wxString
GetPageText(size_t n
) const;
78 virtual int GetPageImage(size_t n
) const;
79 virtual bool SetPageImage(size_t n
, int imageId
);
80 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
81 virtual bool InsertPage(size_t n
,
86 virtual int SetSelection(size_t n
);
87 virtual void SetImageList(wxImageList
*imageList
);
89 // returns true if we have wxLB_TOP or wxLB_BOTTOM style
90 bool IsVertical() const { return HasFlag(wxLB_BOTTOM
| wxLB_TOP
); }
92 virtual bool DeleteAllPages();
94 wxListView
* GetListView() { return m_list
; }
97 virtual wxWindow
*DoRemovePage(size_t page
);
99 // get the size which the list control should have
100 wxSize
GetListSize() const;
103 wxRect
GetPageRect() const;
106 void OnSize(wxSizeEvent
& event
);
107 void OnListSelected(wxListEvent
& event
);
109 // the list control we use for showing the pages index
112 #if wxUSE_LINE_IN_LISTBOOK
113 // the line separating it from the page area
114 wxStaticLine
*m_line
;
115 #endif // wxUSE_LINE_IN_LISTBOOK
117 // the currently selected page or wxNOT_FOUND if none
121 // common part of all constructors
124 DECLARE_EVENT_TABLE()
125 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook
)
128 // ----------------------------------------------------------------------------
129 // listbook event class and related stuff
130 // ----------------------------------------------------------------------------
132 class WXDLLEXPORT wxListbookEvent
: public wxBookCtrlEvent
135 wxListbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
136 int nSel
= wxNOT_FOUND
, int nOldSel
= wxNOT_FOUND
)
137 : wxBookCtrlEvent(commandType
, id
, nSel
, nOldSel
)
142 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent
)
145 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
;
146 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
;
148 typedef void (wxEvtHandler::*wxListbookEventFunction
)(wxListbookEvent
&);
150 #define EVT_LISTBOOK_PAGE_CHANGED(id, fn) \
151 DECLARE_EVENT_TABLE_ENTRY( \
152 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, \
155 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
159 #define EVT_LISTBOOK_PAGE_CHANGING(id, fn) \
160 DECLARE_EVENT_TABLE_ENTRY( \
161 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, \
164 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
168 #endif // wxUSE_LISTBOOK
170 #endif // _WX_LISTBOOK_H_