]> git.saurik.com Git - wxWidgets.git/blob - include/wx/listbook.h
clear up wxStringBuffer docs a bit
[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 // wxListbook
44 // ----------------------------------------------------------------------------
45
46 class WXDLLEXPORT wxListbook : public wxBookCtrl
47 {
48 public:
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
92 virtual bool DeleteAllPages();
93
94 wxListView* GetListView() { return m_list; }
95
96 protected:
97 virtual wxWindow *DoRemovePage(size_t page);
98
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
109 // the list control we use for showing the pages index
110 wxListView *m_list;
111
112 #if wxUSE_LINE_IN_LISTBOOK
113 // the line separating it from the page area
114 wxStaticLine *m_line;
115 #endif // wxUSE_LINE_IN_LISTBOOK
116
117 // the currently selected page or wxNOT_FOUND if none
118 int m_selection;
119
120 private:
121 // common part of all constructors
122 void Init();
123
124 DECLARE_EVENT_TABLE()
125 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
126 };
127
128 // ----------------------------------------------------------------------------
129 // listbook event class and related stuff
130 // ----------------------------------------------------------------------------
131
132 class WXDLLEXPORT wxListbookEvent : public wxBookCtrlEvent
133 {
134 public:
135 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
136 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
137 : wxBookCtrlEvent(commandType, id, nSel, nOldSel)
138 {
139 }
140
141 private:
142 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent)
143 };
144
145 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
146 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
147
148 typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
149
150 #define EVT_LISTBOOK_PAGE_CHANGED(id, fn) \
151 DECLARE_EVENT_TABLE_ENTRY( \
152 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, \
153 id, \
154 wxID_ANY, \
155 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
156 NULL \
157 ),
158
159 #define EVT_LISTBOOK_PAGE_CHANGING(id, fn) \
160 DECLARE_EVENT_TABLE_ENTRY( \
161 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, \
162 id, \
163 wxID_ANY, \
164 (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxListbookEventFunction, &fn ), \
165 NULL \
166 ),
167
168 #endif // wxUSE_LISTBOOK
169
170 #endif // _WX_LISTBOOK_H_