]> git.saurik.com Git - wxWidgets.git/blob - include/wx/listbook.h
Source cleaning: tabs, whitespaces, -1/wxID_ANY, TRUE/true, FALSE/false.
[wxWidgets.git] / include / wx / listbook.h
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$
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
9 // Licence: wxWindows licence
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
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
33 #include "wx/bookctrl.h"
34
35 class WXDLLEXPORT wxListView;
36 class WXDLLEXPORT wxListEvent;
37
38 #if wxUSE_LINE_IN_LISTBOOK
39 class WXDLLEXPORT wxStaticLine;
40 #endif // wxUSE_LINE_IN_LISTBOOK
41
42 // ----------------------------------------------------------------------------
43 // constants
44 // ----------------------------------------------------------------------------
45
46 // wxListbook styles
47 enum
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
66 class WXDLLEXPORT wxListbook : public wxBookCtrl
67 {
68 public:
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
112 virtual bool DeleteAllPages();
113
114 wxListView* GetListView() { return m_list; }
115
116 protected:
117 virtual wxWindow *DoRemovePage(size_t page);
118
119 private:
120 // common part of all constructors
121 void Init();
122
123 // get the size which the list control should have
124 wxSize GetListSize() const;
125
126 // get the page area
127 wxRect GetPageRect() const;
128
129 // event handlers
130 void OnSize(wxSizeEvent& event);
131 void OnListSelected(wxListEvent& event);
132
133
134 // the list control we use for showing the pages index
135 wxListView *m_list;
136
137 #if wxUSE_LINE_IN_LISTBOOK
138 // the line separating it from the page area
139 wxStaticLine *m_line;
140 #endif // wxUSE_LINE_IN_LISTBOOK
141
142 // the currently selected page or wxNOT_FOUND if none
143 int m_selection;
144
145
146 DECLARE_EVENT_TABLE()
147 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
148 };
149
150 // ----------------------------------------------------------------------------
151 // listbook event class and related stuff
152 // ----------------------------------------------------------------------------
153
154 class WXDLLEXPORT wxListbookEvent : public wxBookCtrlEvent
155 {
156 public:
157 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
158 int nSel = -1, int nOldSel = -1)
159 : wxBookCtrlEvent(commandType, id, nSel, nOldSel)
160 {
161 }
162
163 private:
164 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent)
165 };
166
167 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
168 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
169
170 typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
171
172 #define EVT_LISTBOOK_PAGE_CHANGED(id, fn) \
173 DECLARE_EVENT_TABLE_ENTRY( \
174 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, \
175 id, \
176 -1, \
177 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
178 NULL \
179 ),
180
181 #define EVT_LISTBOOK_PAGE_CHANGING(id, fn) \
182 DECLARE_EVENT_TABLE_ENTRY( \
183 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, \
184 id, \
185 -1, \
186 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
187 NULL \
188 ),
189
190 #endif // wxUSE_LISTBOOK
191
192 #endif // _WX_LISTBOOK_H_