1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListbook: wxListCtrl and wxNotebook combination
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.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 #include "wx/bookctrl.h"
25 class WXDLLEXPORT wxListView
;
26 class WXDLLEXPORT wxListEvent
;
27 class WXDLLEXPORT wxStaticLine
;;
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
36 // default alignment: left everywhere except Mac where it is top
39 // put the list control to the left/right/top/bottom of the page area
45 // the mask which can be used to extract the alignment from the style
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
53 class WXDLLEXPORT wxListbook
: public wxBookCtrl
61 wxListbook(wxWindow
*parent
,
63 const wxPoint
& pos
= wxDefaultPosition
,
64 const wxSize
& size
= wxDefaultSize
,
66 const wxString
& name
= wxEmptyString
)
70 (void)Create(parent
, id
, pos
, size
, style
, name
);
74 bool Create(wxWindow
*parent
,
76 const wxPoint
& pos
= wxDefaultPosition
,
77 const wxSize
& size
= wxDefaultSize
,
79 const wxString
& name
= wxEmptyString
);
82 virtual int GetSelection() const;
83 virtual bool SetPageText(size_t n
, const wxString
& strText
);
84 virtual wxString
GetPageText(size_t n
) const;
85 virtual int GetPageImage(size_t n
) const;
86 virtual bool SetPageImage(size_t n
, int imageId
);
87 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
88 virtual bool InsertPage(size_t n
,
93 virtual int SetSelection(size_t n
);
94 virtual void SetImageList(wxImageList
*imageList
);
96 // returns true if we have wxLB_TOP or wxLB_BOTTOM style
97 bool IsVertical() const { return HasFlag(wxLB_BOTTOM
| wxLB_TOP
); }
100 virtual wxWindow
*DoRemovePage(size_t page
);
103 // common part of all constructors
106 // get the size which the list control should have
107 wxSize
GetListSize() const;
110 wxRect
GetPageRect() const;
113 void OnSize(wxSizeEvent
& event
);
114 void OnListSelected(wxListEvent
& event
);
117 // the list control we use for showing the pages index
120 // the line separating it from the page area
121 wxStaticLine
*m_line
;
123 // the currently selected page or wxNOT_FOUND if none
127 DECLARE_EVENT_TABLE()
128 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook
)
131 // ----------------------------------------------------------------------------
132 // listbook event class and related stuff
133 // ----------------------------------------------------------------------------
135 class WXDLLEXPORT wxListbookEvent
: public wxBookCtrlEvent
138 wxListbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
139 int nSel
= -1, int nOldSel
= -1)
140 : wxBookCtrlEvent(commandType
, id
, nSel
, nOldSel
)
145 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent
)
148 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
;
149 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
;
151 typedef void (wxEvtHandler::*wxListbookEventFunction
)(wxListbookEvent
&);
153 #define EVT_LISTBOOK_PAGE_CHANGED(id, fn) \
154 DECLARE_EVENT_TABLE_ENTRY( \
155 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, \
158 (wxObjectEventFunction)(wxEventFunction)(wxListbookEventFunction) &fn, \
162 #define EVT_LISTBOOK_PAGE_CHANGING(id, fn) \
163 DECLARE_EVENT_TABLE_ENTRY( \
164 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, \
167 (wxObjectEventFunction)(wxEventFunction)(wxListbookEventFunction) &fn, \
171 #endif // wxUSE_LISTBOOK
173 #endif // _WX_LISTBOOK_H_