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 // ----------------------------------------------------------------------------
49 // default alignment: left everywhere except Mac where it is top
52 // put the list control to the left/right/top/bottom of the page area
58 // the mask which can be used to extract the alignment from the style
62 // ----------------------------------------------------------------------------
64 // ----------------------------------------------------------------------------
66 class WXDLLEXPORT wxListbook
: public wxBookCtrl
74 wxListbook(wxWindow
*parent
,
76 const wxPoint
& pos
= wxDefaultPosition
,
77 const wxSize
& size
= wxDefaultSize
,
79 const wxString
& name
= wxEmptyString
)
83 (void)Create(parent
, id
, pos
, size
, style
, name
);
87 bool Create(wxWindow
*parent
,
89 const wxPoint
& pos
= wxDefaultPosition
,
90 const wxSize
& size
= wxDefaultSize
,
92 const wxString
& name
= wxEmptyString
);
95 virtual int GetSelection() const;
96 virtual bool SetPageText(size_t n
, const wxString
& strText
);
97 virtual wxString
GetPageText(size_t n
) const;
98 virtual int GetPageImage(size_t n
) const;
99 virtual bool SetPageImage(size_t n
, int imageId
);
100 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
101 virtual bool InsertPage(size_t n
,
103 const wxString
& text
,
104 bool bSelect
= false,
106 virtual int SetSelection(size_t n
);
107 virtual void SetImageList(wxImageList
*imageList
);
109 // returns true if we have wxLB_TOP or wxLB_BOTTOM style
110 bool IsVertical() const { return HasFlag(wxLB_BOTTOM
| wxLB_TOP
); }
112 virtual bool DeleteAllPages();
114 wxListView
* GetListView() { return m_list
; }
117 virtual wxWindow
*DoRemovePage(size_t page
);
119 // get the size which the list control should have
120 wxSize
GetListSize() const;
123 wxRect
GetPageRect() const;
126 void OnSize(wxSizeEvent
& event
);
127 void OnListSelected(wxListEvent
& event
);
129 // the list control we use for showing the pages index
132 #if wxUSE_LINE_IN_LISTBOOK
133 // the line separating it from the page area
134 wxStaticLine
*m_line
;
135 #endif // wxUSE_LINE_IN_LISTBOOK
137 // the currently selected page or wxNOT_FOUND if none
141 // common part of all constructors
144 DECLARE_EVENT_TABLE()
145 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook
)
148 // ----------------------------------------------------------------------------
149 // listbook event class and related stuff
150 // ----------------------------------------------------------------------------
152 class WXDLLEXPORT wxListbookEvent
: public wxBookCtrlEvent
155 wxListbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
156 int nSel
= -1, int nOldSel
= -1)
157 : wxBookCtrlEvent(commandType
, id
, nSel
, nOldSel
)
162 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent
)
165 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
;
166 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
;
168 typedef void (wxEvtHandler::*wxListbookEventFunction
)(wxListbookEvent
&);
170 #define EVT_LISTBOOK_PAGE_CHANGED(id, fn) \
171 DECLARE_EVENT_TABLE_ENTRY( \
172 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, \
175 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
179 #define EVT_LISTBOOK_PAGE_CHANGING(id, fn) \
180 DECLARE_EVENT_TABLE_ENTRY( \
181 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, \
184 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
188 #endif // wxUSE_LISTBOOK
190 #endif // _WX_LISTBOOK_H_