]> git.saurik.com Git - wxWidgets.git/blame - include/wx/listbook.h
[ 1573855 ] Improved appearance of wxComboCtrl's wxTextCtrl
[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$
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
19#include "wx/bookctrl.h"
20
21class WXDLLEXPORT wxListView;
22class WXDLLEXPORT wxListEvent;
ef0120c1 23
1d6fcbcc
VZ
24extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
25extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
26
e9c0df38
VZ
27// ----------------------------------------------------------------------------
28// wxListbook
29// ----------------------------------------------------------------------------
30
61c083e7 31class WXDLLEXPORT wxListbook : public wxBookCtrlBase
e9c0df38
VZ
32{
33public:
34 wxListbook()
35 {
36 Init();
37 }
38
39 wxListbook(wxWindow *parent,
40 wxWindowID id,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = 0,
44 const wxString& name = wxEmptyString)
45 {
46 Init();
47
48 (void)Create(parent, id, pos, size, style, name);
49 }
50
51 // quasi ctor
52 bool Create(wxWindow *parent,
53 wxWindowID id,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 long style = 0,
57 const wxString& name = wxEmptyString);
58
59
60 virtual int GetSelection() const;
61 virtual bool SetPageText(size_t n, const wxString& strText);
62 virtual wxString GetPageText(size_t n) const;
63 virtual int GetPageImage(size_t n) const;
64 virtual bool SetPageImage(size_t n, int imageId);
65 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
66 virtual bool InsertPage(size_t n,
67 wxWindow *page,
68 const wxString& text,
69 bool bSelect = false,
70 int imageId = -1);
1d6fcbcc
VZ
71 virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
72 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
e9c0df38
VZ
73 virtual void SetImageList(wxImageList *imageList);
74
fbd11d30
RD
75 virtual bool DeleteAllPages();
76
d8fd7acb 77 wxListView* GetListView() const { return (wxListView*)m_bookctrl; }
e572631f 78
e9c0df38
VZ
79protected:
80 virtual wxWindow *DoRemovePage(size_t page);
81
e9c0df38 82 // get the size which the list control should have
d8fd7acb 83 virtual wxSize GetControllerSize() const;
e9c0df38 84
851b88c3
VZ
85 // return the page corresponding to the tab at the specified position
86 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
87
1d6fcbcc
VZ
88 int DoSetSelection(size_t nPage, int flags = 0);
89
90 void UpdateSelectedPage(size_t newsel);
91
92 void MakeChangedEvent(wxBookCtrlBaseEvent &event)
93 {
94 event.SetEventType(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED);
95 }
96
e9c0df38 97 // event handlers
e9c0df38 98 void OnListSelected(wxListEvent& event);
d8fd7acb 99 void OnSize(wxSizeEvent& event);
e9c0df38
VZ
100
101 // the currently selected page or wxNOT_FOUND if none
102 int m_selection;
103
33ebfc3b
VZ
104private:
105 // common part of all constructors
106 void Init();
e9c0df38
VZ
107
108 DECLARE_EVENT_TABLE()
109 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
110};
111
112// ----------------------------------------------------------------------------
113// listbook event class and related stuff
114// ----------------------------------------------------------------------------
115
61c083e7 116class WXDLLEXPORT wxListbookEvent : public wxBookCtrlBaseEvent
e9c0df38
VZ
117{
118public:
119 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
bb08a4a1 120 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
61c083e7 121 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
e9c0df38
VZ
122 {
123 }
124
75865c8d
VZ
125 wxListbookEvent(const wxListbookEvent& event)
126 : wxBookCtrlBaseEvent(event)
127 {
128 }
129
130 virtual wxEvent *Clone() const { return new wxListbookEvent(*this); }
131
e9c0df38 132private:
75865c8d 133 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxListbookEvent)
e9c0df38
VZ
134};
135
e9c0df38
VZ
136typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
137
8bc3ec1f
WS
138#define wxListbookEventHandler(func) \
139 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxListbookEventFunction, &func)
140
141#define EVT_LISTBOOK_PAGE_CHANGED(winid, fn) \
142 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED, winid, wxListbookEventHandler(fn))
143
144#define EVT_LISTBOOK_PAGE_CHANGING(winid, fn) \
145 wx__DECLARE_EVT1(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, winid, wxListbookEventHandler(fn))
e9c0df38
VZ
146
147#endif // wxUSE_LISTBOOK
148
149#endif // _WX_LISTBOOK_H_