]> git.saurik.com Git - wxWidgets.git/blob - include/wx/listbook.h
Fixed compilation problem.
[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@wxwindows.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 protected:
113 virtual wxWindow *DoRemovePage(size_t page);
114
115 private:
116 // common part of all constructors
117 void Init();
118
119 // get the size which the list control should have
120 wxSize GetListSize() const;
121
122 // get the page area
123 wxRect GetPageRect() const;
124
125 // event handlers
126 void OnSize(wxSizeEvent& event);
127 void OnListSelected(wxListEvent& event);
128
129
130 // the list control we use for showing the pages index
131 wxListView *m_list;
132
133 #if wxUSE_LINE_IN_LISTBOOK
134 // the line separating it from the page area
135 wxStaticLine *m_line;
136 #endif // wxUSE_LINE_IN_LISTBOOK
137
138 // the currently selected page or wxNOT_FOUND if none
139 int m_selection;
140
141
142 DECLARE_EVENT_TABLE()
143 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
144 };
145
146 // ----------------------------------------------------------------------------
147 // listbook event class and related stuff
148 // ----------------------------------------------------------------------------
149
150 class WXDLLEXPORT wxListbookEvent : public wxBookCtrlEvent
151 {
152 public:
153 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
154 int nSel = -1, int nOldSel = -1)
155 : wxBookCtrlEvent(commandType, id, nSel, nOldSel)
156 {
157 }
158
159 private:
160 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent)
161 };
162
163 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
164 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
165
166 typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
167
168 #define EVT_LISTBOOK_PAGE_CHANGED(id, fn) \
169 DECLARE_EVENT_TABLE_ENTRY( \
170 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, \
171 id, \
172 -1, \
173 (wxObjectEventFunction)(wxEventFunction)(wxListbookEventFunction) &fn, \
174 NULL \
175 ),
176
177 #define EVT_LISTBOOK_PAGE_CHANGING(id, fn) \
178 DECLARE_EVENT_TABLE_ENTRY( \
179 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, \
180 id, \
181 -1, \
182 (wxObjectEventFunction)(wxEventFunction)(wxListbookEventFunction) &fn, \
183 NULL \
184 ),
185
186 #endif // wxUSE_LISTBOOK
187
188 #endif // _WX_LISTBOOK_H_