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 // this can be defined to put a static line as separator between the list
20 // control and the page area; but I think it finally looks better without it so
21 // it is not enabled by default
22 #define wxUSE_LINE_IN_LISTBOOK 0
25 #undef wxUSE_LINE_IN_LISTBOOK
26 #define wxUSE_LINE_IN_LISTBOOK 0
29 #include "wx/bookctrl.h"
31 class WXDLLEXPORT wxListView
;
32 class WXDLLEXPORT wxListEvent
;
34 #if wxUSE_LINE_IN_LISTBOOK
35 class WXDLLEXPORT wxStaticLine
;
36 #endif // wxUSE_LINE_IN_LISTBOOK
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 class WXDLLEXPORT wxListbook
: public wxBookCtrlBase
50 wxListbook(wxWindow
*parent
,
52 const wxPoint
& pos
= wxDefaultPosition
,
53 const wxSize
& size
= wxDefaultSize
,
55 const wxString
& name
= wxEmptyString
)
59 (void)Create(parent
, id
, pos
, size
, style
, name
);
63 bool Create(wxWindow
*parent
,
65 const wxPoint
& pos
= wxDefaultPosition
,
66 const wxSize
& size
= wxDefaultSize
,
68 const wxString
& name
= wxEmptyString
);
71 virtual int GetSelection() const;
72 virtual bool SetPageText(size_t n
, const wxString
& strText
);
73 virtual wxString
GetPageText(size_t n
) const;
74 virtual int GetPageImage(size_t n
) const;
75 virtual bool SetPageImage(size_t n
, int imageId
);
76 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
77 virtual bool InsertPage(size_t n
,
82 virtual int SetSelection(size_t n
);
83 virtual void SetImageList(wxImageList
*imageList
);
85 // returns true if we have wxLB_TOP or wxLB_BOTTOM style
86 bool IsVertical() const { return HasFlag(wxLB_BOTTOM
| wxLB_TOP
); }
88 virtual bool DeleteAllPages();
90 wxListView
* GetListView() { return m_list
; }
93 virtual wxWindow
*DoRemovePage(size_t page
);
95 // get the size which the list control should have
96 wxSize
GetListSize() const;
99 wxRect
GetPageRect() const;
102 void OnSize(wxSizeEvent
& event
);
103 void OnListSelected(wxListEvent
& event
);
105 // the list control we use for showing the pages index
108 #if wxUSE_LINE_IN_LISTBOOK
109 // the line separating it from the page area
110 wxStaticLine
*m_line
;
111 #endif // wxUSE_LINE_IN_LISTBOOK
113 // the currently selected page or wxNOT_FOUND if none
117 // common part of all constructors
120 DECLARE_EVENT_TABLE()
121 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook
)
124 // ----------------------------------------------------------------------------
125 // listbook event class and related stuff
126 // ----------------------------------------------------------------------------
128 class WXDLLEXPORT wxListbookEvent
: public wxBookCtrlBaseEvent
131 wxListbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
132 int nSel
= wxNOT_FOUND
, int nOldSel
= wxNOT_FOUND
)
133 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
138 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent
)
141 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED
;
142 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING
;
144 typedef void (wxEvtHandler::*wxListbookEventFunction
)(wxListbookEvent
&);
146 #define wxListbookEventHandler(func) \
147 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func)
149 #define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
150 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn))
152 #define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
153 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn))
155 #endif // wxUSE_LISTBOOK
157 #endif // _WX_LISTBOOK_H_