]> git.saurik.com Git - wxWidgets.git/blob - include/wx/listbook.h
Unrevert Cygwin changes after discussion. Cygwin will be unix with the new
[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 wxBookCtrlBase
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 wxBookCtrlBaseEvent
133 {
134 public:
135 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
136 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
137 : wxBookCtrlBaseEvent(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 wxListbookEventHandler(func) \
151 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func)
152
153 #define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
154 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn))
155
156 #define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
157 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn))
158
159 #endif // wxUSE_LISTBOOK
160
161 #endif // _WX_LISTBOOK_H_