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
); }
113 virtual wxWindow
*DoRemovePage(size_t page
);
116 // common part of all constructors
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
);
130 // the list control we use for showing the pages index
133 #if wxUSE_LINE_IN_LISTBOOK
134 // the line separating it from the page area
135 wxStaticLine
*m_line
;
136 #endif // wxUSE_LINE_IN_LISTBOOK
138 // the currently selected page or wxNOT_FOUND if none
142 DECLARE_EVENT_TABLE()
143 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook
)
146 // ----------------------------------------------------------------------------
147 // listbook event class and related stuff
148 // ----------------------------------------------------------------------------
150 class WXDLLEXPORT wxListbookEvent
: public wxBookCtrlEvent
153 wxListbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
154 int nSel
= -1, int nOldSel
= -1)
155 : wxBookCtrlEvent(commandType
, id
, nSel
, nOldSel
)
160 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent
)
163 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
;
164 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
;
166 typedef void (wxEvtHandler::*wxListbookEventFunction
)(wxListbookEvent
&);
168 #define EVT_LISTBOOK_PAGE_CHANGED(id, fn) \
169 DECLARE_EVENT_TABLE_ENTRY( \
170 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, \
173 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
177 #define EVT_LISTBOOK_PAGE_CHANGING(id, fn) \
178 DECLARE_EVENT_TABLE_ENTRY( \
179 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, \
182 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
186 #endif // wxUSE_LISTBOOK
188 #endif // _WX_LISTBOOK_H_