]> git.saurik.com Git - wxWidgets.git/blame - include/wx/listbook.h
fixed gcc warnings and reformatted some pieces of code to be a bit readable
[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$
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#include "wx/bookctrl.h"
24
25class WXDLLEXPORT wxListView;
26class WXDLLEXPORT wxListEvent;
27class WXDLLEXPORT wxStaticLine;;
28
29// ----------------------------------------------------------------------------
30// constants
31// ----------------------------------------------------------------------------
32
33// wxListbook styles
34enum
35{
36 // default alignment: left everywhere except Mac where it is top
37 wxLB_DEFAULT = 0,
38
39 // put the list control to the left/right/top/bottom of the page area
40 wxLB_TOP = 0x1,
41 wxLB_BOTTOM = 0x2,
42 wxLB_LEFT = 0x4,
43 wxLB_RIGHT = 0x8,
44
45 // the mask which can be used to extract the alignment from the style
46 wxLB_ALIGN_MASK = 0xf
47};
48
49// ----------------------------------------------------------------------------
50// wxListbook
51// ----------------------------------------------------------------------------
52
53class WXDLLEXPORT wxListbook : public wxBookCtrl
54{
55public:
56 wxListbook()
57 {
58 Init();
59 }
60
61 wxListbook(wxWindow *parent,
62 wxWindowID id,
63 const wxPoint& pos = wxDefaultPosition,
64 const wxSize& size = wxDefaultSize,
65 long style = 0,
66 const wxString& name = wxEmptyString)
67 {
68 Init();
69
70 (void)Create(parent, id, pos, size, style, name);
71 }
72
73 // quasi ctor
74 bool Create(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
82 virtual int GetSelection() const;
83 virtual bool SetPageText(size_t n, const wxString& strText);
84 virtual wxString GetPageText(size_t n) const;
85 virtual int GetPageImage(size_t n) const;
86 virtual bool SetPageImage(size_t n, int imageId);
87 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
88 virtual bool InsertPage(size_t n,
89 wxWindow *page,
90 const wxString& text,
91 bool bSelect = false,
92 int imageId = -1);
93 virtual int SetSelection(size_t n);
94 virtual void SetImageList(wxImageList *imageList);
95
96 // returns true if we have wxLB_TOP or wxLB_BOTTOM style
97 bool IsVertical() const { return HasFlag(wxLB_BOTTOM | wxLB_TOP); }
98
99protected:
100 virtual wxWindow *DoRemovePage(size_t page);
101
102private:
103 // common part of all constructors
104 void Init();
105
106 // get the size which the list control should have
107 wxSize GetListSize() const;
108
109 // get the page area
110 wxRect GetPageRect() const;
111
112 // event handlers
113 void OnSize(wxSizeEvent& event);
114 void OnListSelected(wxListEvent& event);
115
116
117 // the list control we use for showing the pages index
118 wxListView *m_list;
119
120 // the line separating it from the page area
121 wxStaticLine *m_line;
122
123 // the currently selected page or wxNOT_FOUND if none
124 int m_selection;
125
126
127 DECLARE_EVENT_TABLE()
128 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
129};
130
131// ----------------------------------------------------------------------------
132// listbook event class and related stuff
133// ----------------------------------------------------------------------------
134
135class WXDLLEXPORT wxListbookEvent : public wxBookCtrlEvent
136{
137public:
138 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
139 int nSel = -1, int nOldSel = -1)
140 : wxBookCtrlEvent(commandType, id, nSel, nOldSel)
141 {
142 }
143
144private:
145 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent)
146};
147
148extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
149extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
150
151typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
152
153#define EVT_LISTBOOK_PAGE_CHANGED(id, fn) \
154 DECLARE_EVENT_TABLE_ENTRY( \
155 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, \
156 id, \
157 -1, \
158 (wxObjectEventFunction)(wxEventFunction)(wxListbookEventFunction) &fn, \
159 NULL \
160 ),
161
162#define EVT_LISTBOOK_PAGE_CHANGING(id, fn) \
163 DECLARE_EVENT_TABLE_ENTRY( \
164 wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, \
165 id, \
166 -1, \
167 (wxObjectEventFunction)(wxEventFunction)(wxListbookEventFunction) &fn, \
168 NULL \
169 ),
170
171#endif // wxUSE_LISTBOOK
172
173#endif // _WX_LISTBOOK_H_