]>
Commit | Line | Data |
---|---|---|
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$ | |
77ffb593 | 8 | // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org> |
65571936 | 9 | // Licence: wxWindows licence |
e9c0df38 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_LISTBOOK_H_ | |
13 | #define _WX_LISTBOOK_H_ | |
14 | ||
e9c0df38 VZ |
15 | #include "wx/defs.h" |
16 | ||
17 | #if wxUSE_LISTBOOK | |
18 | ||
ef0120c1 VZ |
19 | // this can be defined to put a static line as separator between the list |
20 | // control and the page area; but I think it finally looks better without it so | |
21 | // it is not enabled by default | |
39de6d6c | 22 | #define wxUSE_LINE_IN_LISTBOOK 0 |
ef0120c1 VZ |
23 | |
24 | #if !wxUSE_STATLINE | |
25 | #undef wxUSE_LINE_IN_LISTBOOK | |
26 | #define wxUSE_LINE_IN_LISTBOOK 0 | |
27 | #endif | |
28 | ||
e9c0df38 VZ |
29 | #include "wx/bookctrl.h" |
30 | ||
31 | class WXDLLEXPORT wxListView; | |
32 | class WXDLLEXPORT wxListEvent; | |
ef0120c1 VZ |
33 | |
34 | #if wxUSE_LINE_IN_LISTBOOK | |
35 | class WXDLLEXPORT wxStaticLine; | |
36 | #endif // wxUSE_LINE_IN_LISTBOOK | |
e9c0df38 | 37 | |
e9c0df38 VZ |
38 | // ---------------------------------------------------------------------------- |
39 | // wxListbook | |
40 | // ---------------------------------------------------------------------------- | |
41 | ||
61c083e7 | 42 | class WXDLLEXPORT wxListbook : public wxBookCtrlBase |
e9c0df38 VZ |
43 | { |
44 | public: | |
45 | wxListbook() | |
46 | { | |
47 | Init(); | |
48 | } | |
49 | ||
50 | wxListbook(wxWindow *parent, | |
51 | wxWindowID id, | |
52 | const wxPoint& pos = wxDefaultPosition, | |
53 | const wxSize& size = wxDefaultSize, | |
54 | long style = 0, | |
55 | const wxString& name = wxEmptyString) | |
56 | { | |
57 | Init(); | |
58 | ||
59 | (void)Create(parent, id, pos, size, style, name); | |
60 | } | |
61 | ||
62 | // quasi ctor | |
63 | bool Create(wxWindow *parent, | |
64 | wxWindowID id, | |
65 | const wxPoint& pos = wxDefaultPosition, | |
66 | const wxSize& size = wxDefaultSize, | |
67 | long style = 0, | |
68 | const wxString& name = wxEmptyString); | |
69 | ||
70 | ||
71 | virtual int GetSelection() const; | |
72 | virtual bool SetPageText(size_t n, const wxString& strText); | |
73 | virtual wxString GetPageText(size_t n) const; | |
74 | virtual int GetPageImage(size_t n) const; | |
75 | virtual bool SetPageImage(size_t n, int imageId); | |
76 | virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; | |
77 | virtual bool InsertPage(size_t n, | |
78 | wxWindow *page, | |
79 | const wxString& text, | |
80 | bool bSelect = false, | |
81 | int imageId = -1); | |
82 | virtual int SetSelection(size_t n); | |
83 | virtual void SetImageList(wxImageList *imageList); | |
84 | ||
85 | // returns true if we have wxLB_TOP or wxLB_BOTTOM style | |
86 | bool IsVertical() const { return HasFlag(wxLB_BOTTOM | wxLB_TOP); } | |
87 | ||
fbd11d30 RD |
88 | virtual bool DeleteAllPages(); |
89 | ||
e572631f RD |
90 | wxListView* GetListView() { return m_list; } |
91 | ||
e9c0df38 VZ |
92 | protected: |
93 | virtual wxWindow *DoRemovePage(size_t page); | |
94 | ||
e9c0df38 VZ |
95 | // get the size which the list control should have |
96 | wxSize GetListSize() const; | |
97 | ||
98 | // get the page area | |
99 | wxRect GetPageRect() const; | |
100 | ||
101 | // event handlers | |
102 | void OnSize(wxSizeEvent& event); | |
103 | void OnListSelected(wxListEvent& event); | |
104 | ||
e9c0df38 VZ |
105 | // the list control we use for showing the pages index |
106 | wxListView *m_list; | |
107 | ||
ef0120c1 | 108 | #if wxUSE_LINE_IN_LISTBOOK |
e9c0df38 VZ |
109 | // the line separating it from the page area |
110 | wxStaticLine *m_line; | |
ef0120c1 | 111 | #endif // wxUSE_LINE_IN_LISTBOOK |
e9c0df38 VZ |
112 | |
113 | // the currently selected page or wxNOT_FOUND if none | |
114 | int m_selection; | |
115 | ||
33ebfc3b VZ |
116 | private: |
117 | // common part of all constructors | |
118 | void Init(); | |
e9c0df38 VZ |
119 | |
120 | DECLARE_EVENT_TABLE() | |
121 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook) | |
122 | }; | |
123 | ||
124 | // ---------------------------------------------------------------------------- | |
125 | // listbook event class and related stuff | |
126 | // ---------------------------------------------------------------------------- | |
127 | ||
61c083e7 | 128 | class WXDLLEXPORT wxListbookEvent : public wxBookCtrlBaseEvent |
e9c0df38 VZ |
129 | { |
130 | public: | |
131 | wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, | |
bb08a4a1 | 132 | int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND) |
61c083e7 | 133 | : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel) |
e9c0df38 VZ |
134 | { |
135 | } | |
136 | ||
137 | private: | |
138 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent) | |
139 | }; | |
140 | ||
141 | extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED; | |
142 | extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING; | |
143 | ||
144 | typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&); | |
145 | ||
8bc3ec1f WS |
146 | #define wxListbookEventHandler(func) \ |
147 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func) | |
148 | ||
149 | #define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \ | |
150 | wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn)) | |
151 | ||
152 | #define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \ | |
153 | wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn)) | |
e9c0df38 VZ |
154 | |
155 | #endif // wxUSE_LISTBOOK | |
156 | ||
157 | #endif // _WX_LISTBOOK_H_ |