]> git.saurik.com Git - wxWidgets.git/blame - include/wx/listbook.h
Compilation fix for old GCC versions.
[wxWidgets.git] / include / wx / listbook.h
CommitLineData
e9c0df38
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/listbook.h
3// Purpose: wxListbook: wxListCtrl and wxNotebook combination
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 19.08.03
7// RCS-ID: $Id$
77ffb593 8// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
65571936 9// Licence: wxWindows licence
e9c0df38
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_LISTBOOK_H_
13#define _WX_LISTBOOK_H_
14
e9c0df38
VZ
15#include "wx/defs.h"
16
17#if wxUSE_LISTBOOK
18
19#include "wx/bookctrl.h"
20
21class WXDLLEXPORT wxListView;
22class WXDLLEXPORT wxListEvent;
ef0120c1 23
1d6fcbcc
VZ
24extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
25extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
26
90c0f63a
VZ
27// wxListbook flags
28#define wxLB_DEFAULT wxBK_DEFAULT
29#define wxLB_TOP wxBK_TOP
30#define wxLB_BOTTOM wxBK_BOTTOM
31#define wxLB_LEFT wxBK_LEFT
32#define wxLB_RIGHT wxBK_RIGHT
33#define wxLB_ALIGN_MASK wxBK_ALIGN_MASK
34
e9c0df38
VZ
35// ----------------------------------------------------------------------------
36// wxListbook
37// ----------------------------------------------------------------------------
38
61c083e7 39class WXDLLEXPORT wxListbook : public wxBookCtrlBase
e9c0df38
VZ
40{
41public:
42 wxListbook()
43 {
44 Init();
45 }
46
47 wxListbook(wxWindow *parent,
48 wxWindowID id,
49 const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize,
51 long style = 0,
52 const wxString& name = wxEmptyString)
53 {
54 Init();
55
56 (void)Create(parent, id, pos, size, style, name);
57 }
58
59 // quasi ctor
60 bool Create(wxWindow *parent,
61 wxWindowID id,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = 0,
65 const wxString& name = wxEmptyString);
66
67
68 virtual int GetSelection() const;
69 virtual bool SetPageText(size_t n, const wxString& strText);
70 virtual wxString GetPageText(size_t n) const;
71 virtual int GetPageImage(size_t n) const;
72 virtual bool SetPageImage(size_t n, int imageId);
73 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
74 virtual bool InsertPage(size_t n,
75 wxWindow *page,
76 const wxString& text,
77 bool bSelect = false,
78 int imageId = -1);
1d6fcbcc
VZ
79 virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
80 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
e9c0df38
VZ
81 virtual void SetImageList(wxImageList *imageList);
82
fbd11d30
RD
83 virtual bool DeleteAllPages();
84
d8fd7acb 85 wxListView* GetListView() const { return (wxListView*)m_bookctrl; }
e572631f 86
e9c0df38
VZ
87protected:
88 virtual wxWindow *DoRemovePage(size_t page);
89
e9c0df38 90 // get the size which the list control should have
d8fd7acb 91 virtual wxSize GetControllerSize() const;
e9c0df38 92
851b88c3
VZ
93 // return the page corresponding to the tab at the specified position
94 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
95
1d6fcbcc
VZ
96 void UpdateSelectedPage(size_t newsel);
97
deb325e3
VZ
98 wxBookCtrlBaseEvent* CreatePageChangingEvent() const;
99 void MakeChangedEvent(wxBookCtrlBaseEvent &event);
1d6fcbcc 100
e9c0df38 101 // event handlers
e9c0df38 102 void OnListSelected(wxListEvent& event);
d8fd7acb 103 void OnSize(wxSizeEvent& event);
e9c0df38
VZ
104
105 // the currently selected page or wxNOT_FOUND if none
106 int m_selection;
107
33ebfc3b
VZ
108private:
109 // common part of all constructors
110 void Init();
e9c0df38
VZ
111
112 DECLARE_EVENT_TABLE()
113 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
114};
115
116// ----------------------------------------------------------------------------
117// listbook event class and related stuff
118// ----------------------------------------------------------------------------
119
61c083e7 120class WXDLLEXPORT wxListbookEvent : public wxBookCtrlBaseEvent
e9c0df38
VZ
121{
122public:
123 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
bb08a4a1 124 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
61c083e7 125 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
e9c0df38
VZ
126 {
127 }
128
75865c8d
VZ
129 wxListbookEvent(const wxListbookEvent& event)
130 : wxBookCtrlBaseEvent(event)
131 {
132 }
133
134 virtual wxEvent *Clone() const { return new wxListbookEvent(*this); }
135
e9c0df38 136private:
75865c8d 137 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxListbookEvent)
e9c0df38
VZ
138};
139
e9c0df38
VZ
140typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
141
8bc3ec1f
WS
142#define wxListbookEventHandler(func) \
143 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func)
144
145#define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
146 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn))
147
148#define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
149 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn))
e9c0df38
VZ
150
151#endif // wxUSE_LISTBOOK
152
153#endif // _WX_LISTBOOK_H_