]> git.saurik.com Git - wxWidgets.git/blame - include/wx/listbook.h
Source cleaning: whitespaces, tabs, TRUE/true, FALSE/false, -1/wxID_ANY/wxDefaultCoor...
[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
VZ
41
42// ----------------------------------------------------------------------------
43// constants
44// ----------------------------------------------------------------------------
45
46// wxListbook styles
47enum
48{
49 // default alignment: left everywhere except Mac where it is top
50 wxLB_DEFAULT = 0,
51
52 // put the list control to the left/right/top/bottom of the page area
53 wxLB_TOP = 0x1,
54 wxLB_BOTTOM = 0x2,
55 wxLB_LEFT = 0x4,
56 wxLB_RIGHT = 0x8,
57
58 // the mask which can be used to extract the alignment from the style
59 wxLB_ALIGN_MASK = 0xf
60};
61
62// ----------------------------------------------------------------------------
63// wxListbook
64// ----------------------------------------------------------------------------
65
66class WXDLLEXPORT wxListbook : public wxBookCtrl
67{
68public:
69 wxListbook()
70 {
71 Init();
72 }
73
74 wxListbook(wxWindow *parent,
75 wxWindowID id,
76 const wxPoint& pos = wxDefaultPosition,
77 const wxSize& size = wxDefaultSize,
78 long style = 0,
79 const wxString& name = wxEmptyString)
80 {
81 Init();
82
83 (void)Create(parent, id, pos, size, style, name);
84 }
85
86 // quasi ctor
87 bool Create(wxWindow *parent,
88 wxWindowID id,
89 const wxPoint& pos = wxDefaultPosition,
90 const wxSize& size = wxDefaultSize,
91 long style = 0,
92 const wxString& name = wxEmptyString);
93
94
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,
102 wxWindow *page,
103 const wxString& text,
104 bool bSelect = false,
105 int imageId = -1);
106 virtual int SetSelection(size_t n);
107 virtual void SetImageList(wxImageList *imageList);
108
109 // returns true if we have wxLB_TOP or wxLB_BOTTOM style
110 bool IsVertical() const { return HasFlag(wxLB_BOTTOM | wxLB_TOP); }
111
fbd11d30
RD
112 virtual bool DeleteAllPages();
113
e9c0df38
VZ
114protected:
115 virtual wxWindow *DoRemovePage(size_t page);
116
117private:
118 // common part of all constructors
119 void Init();
120
121 // get the size which the list control should have
122 wxSize GetListSize() const;
123
124 // get the page area
125 wxRect GetPageRect() const;
126
127 // event handlers
128 void OnSize(wxSizeEvent& event);
129 void OnListSelected(wxListEvent& event);
130
131
132 // the list control we use for showing the pages index
133 wxListView *m_list;
134
ef0120c1 135#if wxUSE_LINE_IN_LISTBOOK
e9c0df38
VZ
136 // the line separating it from the page area
137 wxStaticLine *m_line;
ef0120c1 138#endif // wxUSE_LINE_IN_LISTBOOK
e9c0df38
VZ
139
140 // the currently selected page or wxNOT_FOUND if none
141 int m_selection;
142
143
144 DECLARE_EVENT_TABLE()
145 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
146};
147
148// ----------------------------------------------------------------------------
149// listbook event class and related stuff
150// ----------------------------------------------------------------------------
151
152class WXDLLEXPORT wxListbookEvent : public wxBookCtrlEvent
153{
154public:
155 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
156 int nSel = -1, int nOldSel = -1)
157 : wxBookCtrlEvent(commandType, id, nSel, nOldSel)
158 {
159 }
160
161private:
162 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent)
163};
164
165extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
166extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
167
168typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
169
170#define EVT_LISTBOOK_PAGE_CHANGED(id, fn) \
171 DECLARE_EVENT_TABLE_ENTRY( \
172 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, \
173 id, \
174 -1, \
3a818b15 175 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
e9c0df38
VZ
176 NULL \
177 ),
178
179#define EVT_LISTBOOK_PAGE_CHANGING(id, fn) \
180 DECLARE_EVENT_TABLE_ENTRY( \
181 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, \
182 id, \
183 -1, \
3a818b15 184 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
e9c0df38
VZ
185 NULL \
186 ),
187
188#endif // wxUSE_LISTBOOK
189
190#endif // _WX_LISTBOOK_H_