]> git.saurik.com Git - wxWidgets.git/blame - include/wx/listbook.h
corrected library order to make the sample link
[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
15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "listbook.h"
17#endif
18
19#include "wx/defs.h"
20
21#if wxUSE_LISTBOOK
22
ef0120c1
VZ
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
27
28#if !wxUSE_STATLINE
29 #undef wxUSE_LINE_IN_LISTBOOK
30 #define wxUSE_LINE_IN_LISTBOOK 0
31#endif
32
e9c0df38
VZ
33#include "wx/bookctrl.h"
34
35class WXDLLEXPORT wxListView;
36class WXDLLEXPORT wxListEvent;
ef0120c1
VZ
37
38#if wxUSE_LINE_IN_LISTBOOK
39class WXDLLEXPORT wxStaticLine;
40#endif // wxUSE_LINE_IN_LISTBOOK
e9c0df38 41
e9c0df38
VZ
42// ----------------------------------------------------------------------------
43// wxListbook
44// ----------------------------------------------------------------------------
45
61c083e7 46class WXDLLEXPORT wxListbook : public wxBookCtrlBase
e9c0df38
VZ
47{
48public:
49 wxListbook()
50 {
51 Init();
52 }
53
54 wxListbook(wxWindow *parent,
55 wxWindowID id,
56 const wxPoint& pos = wxDefaultPosition,
57 const wxSize& size = wxDefaultSize,
58 long style = 0,
59 const wxString& name = wxEmptyString)
60 {
61 Init();
62
63 (void)Create(parent, id, pos, size, style, name);
64 }
65
66 // quasi ctor
67 bool Create(wxWindow *parent,
68 wxWindowID id,
69 const wxPoint& pos = wxDefaultPosition,
70 const wxSize& size = wxDefaultSize,
71 long style = 0,
72 const wxString& name = wxEmptyString);
73
74
75 virtual int GetSelection() const;
76 virtual bool SetPageText(size_t n, const wxString& strText);
77 virtual wxString GetPageText(size_t n) const;
78 virtual int GetPageImage(size_t n) const;
79 virtual bool SetPageImage(size_t n, int imageId);
80 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
81 virtual bool InsertPage(size_t n,
82 wxWindow *page,
83 const wxString& text,
84 bool bSelect = false,
85 int imageId = -1);
86 virtual int SetSelection(size_t n);
87 virtual void SetImageList(wxImageList *imageList);
88
89 // returns true if we have wxLB_TOP or wxLB_BOTTOM style
90 bool IsVertical() const { return HasFlag(wxLB_BOTTOM | wxLB_TOP); }
91
fbd11d30
RD
92 virtual bool DeleteAllPages();
93
e572631f
RD
94 wxListView* GetListView() { return m_list; }
95
e9c0df38
VZ
96protected:
97 virtual wxWindow *DoRemovePage(size_t page);
98
e9c0df38
VZ
99 // get the size which the list control should have
100 wxSize GetListSize() const;
101
102 // get the page area
103 wxRect GetPageRect() const;
104
105 // event handlers
106 void OnSize(wxSizeEvent& event);
107 void OnListSelected(wxListEvent& event);
108
e9c0df38
VZ
109 // the list control we use for showing the pages index
110 wxListView *m_list;
111
ef0120c1 112#if wxUSE_LINE_IN_LISTBOOK
e9c0df38
VZ
113 // the line separating it from the page area
114 wxStaticLine *m_line;
ef0120c1 115#endif // wxUSE_LINE_IN_LISTBOOK
e9c0df38
VZ
116
117 // the currently selected page or wxNOT_FOUND if none
118 int m_selection;
119
33ebfc3b
VZ
120private:
121 // common part of all constructors
122 void Init();
e9c0df38
VZ
123
124 DECLARE_EVENT_TABLE()
125 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
126};
127
128// ----------------------------------------------------------------------------
129// listbook event class and related stuff
130// ----------------------------------------------------------------------------
131
61c083e7 132class WXDLLEXPORT wxListbookEvent : public wxBookCtrlBaseEvent
e9c0df38
VZ
133{
134public:
135 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
bb08a4a1 136 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
61c083e7 137 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
e9c0df38
VZ
138 {
139 }
140
141private:
142 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent)
143};
144
145extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
146extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
147
148typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
149
8bc3ec1f
WS
150#define wxListbookEventHandler(func) \
151 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func)
152
153#define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
154 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn))
155
156#define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
157 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn))
e9c0df38
VZ
158
159#endif // wxUSE_LISTBOOK
160
161#endif // _WX_LISTBOOK_H_