]> git.saurik.com Git - wxWidgets.git/blob - include/wx/listbook.h
define {first,second}_type in the struct declared by _WX_DECLARE_PAIR too for compati...
[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 #include "wx/defs.h"
16
17 #if wxUSE_LISTBOOK
18
19 #include "wx/bookctrl.h"
20
21 class WXDLLIMPEXP_FWD_CORE wxListView;
22 class WXDLLIMPEXP_FWD_CORE wxListEvent;
23
24 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
25 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
26
27 // wxListbook flags
28 #define wxLB_DEFAULT wxBK_DEFAULT
29 #define wxLB_TOP wxBK_TOP
30 #define wxLB_BOTTOM wxBK_BOTTOM
31 #define wxLB_LEFT wxBK_LEFT
32 #define wxLB_RIGHT wxBK_RIGHT
33 #define wxLB_ALIGN_MASK wxBK_ALIGN_MASK
34
35 // ----------------------------------------------------------------------------
36 // wxListbook
37 // ----------------------------------------------------------------------------
38
39 class WXDLLIMPEXP_CORE wxListbook : public wxBookCtrlBase
40 {
41 public:
42 wxListbook()
43 {
44 Init();
45 }
46
47 wxListbook(wxWindow *parent,
48 wxWindowID id,
49 const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize,
51 long style = 0,
52 const wxString& name = wxEmptyString)
53 {
54 Init();
55
56 (void)Create(parent, id, pos, size, style, name);
57 }
58
59 // quasi ctor
60 bool Create(wxWindow *parent,
61 wxWindowID id,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = 0,
65 const wxString& name = wxEmptyString);
66
67
68 // overridden base class methods
69 virtual int GetSelection() const;
70 virtual bool SetPageText(size_t n, const wxString& strText);
71 virtual wxString GetPageText(size_t n) const;
72 virtual int GetPageImage(size_t n) const;
73 virtual bool SetPageImage(size_t n, int imageId);
74 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
75 virtual bool InsertPage(size_t n,
76 wxWindow *page,
77 const wxString& text,
78 bool bSelect = false,
79 int imageId = -1);
80 virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
81 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
82 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
83 virtual void SetImageList(wxImageList *imageList);
84
85 virtual bool DeleteAllPages();
86
87 wxListView* GetListView() const { return (wxListView*)m_bookctrl; }
88
89 protected:
90 virtual wxWindow *DoRemovePage(size_t page);
91
92 // get the size which the list control should have
93 virtual wxSize GetControllerSize() const;
94
95 void UpdateSelectedPage(size_t newsel);
96
97 wxBookCtrlBaseEvent* CreatePageChangingEvent() const;
98 void MakeChangedEvent(wxBookCtrlBaseEvent &event);
99
100 // get flags for different list control modes
101 long GetListCtrlIconViewFlags() const;
102 long GetListCtrlReportViewFlags() const;
103
104 // event handlers
105 void OnListSelected(wxListEvent& event);
106 void OnSize(wxSizeEvent& event);
107
108 // the currently selected page or wxNOT_FOUND if none
109 int m_selection;
110
111 private:
112 // common part of all constructors
113 void Init();
114
115 DECLARE_EVENT_TABLE()
116 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
117 };
118
119 // ----------------------------------------------------------------------------
120 // listbook event class and related stuff
121 // ----------------------------------------------------------------------------
122
123 class WXDLLIMPEXP_CORE wxListbookEvent : public wxBookCtrlBaseEvent
124 {
125 public:
126 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
127 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
128 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
129 {
130 }
131
132 wxListbookEvent(const wxListbookEvent& event)
133 : wxBookCtrlBaseEvent(event)
134 {
135 }
136
137 virtual wxEvent *Clone() const { return new wxListbookEvent(*this); }
138
139 private:
140 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxListbookEvent)
141 };
142
143 typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
144
145 #define wxListbookEventHandler(func) \
146 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func)
147
148 #define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
149 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn))
150
151 #define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
152 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn))
153
154 #endif // wxUSE_LISTBOOK
155
156 #endif // _WX_LISTBOOK_H_