]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/listbook.h
don't use a floating point value as a boolean flag; gcc4 (correctly) complains when...
[wxWidgets.git] / include / wx / listbook.h
... / ...
CommitLineData
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// 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
22#define wxUSE_LINE_IN_LISTBOOK 0
23
24#if !wxUSE_STATLINE
25 #undef wxUSE_LINE_IN_LISTBOOK
26 #define wxUSE_LINE_IN_LISTBOOK 0
27#endif
28
29#include "wx/bookctrl.h"
30
31class WXDLLEXPORT wxListView;
32class WXDLLEXPORT wxListEvent;
33
34#if wxUSE_LINE_IN_LISTBOOK
35class WXDLLEXPORT wxStaticLine;
36#endif // wxUSE_LINE_IN_LISTBOOK
37
38// ----------------------------------------------------------------------------
39// wxListbook
40// ----------------------------------------------------------------------------
41
42class WXDLLEXPORT wxListbook : public wxBookCtrlBase
43{
44public:
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
88 virtual bool DeleteAllPages();
89
90 wxListView* GetListView() { return m_list; }
91
92protected:
93 virtual wxWindow *DoRemovePage(size_t page);
94
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
105 // the list control we use for showing the pages index
106 wxListView *m_list;
107
108#if wxUSE_LINE_IN_LISTBOOK
109 // the line separating it from the page area
110 wxStaticLine *m_line;
111#endif // wxUSE_LINE_IN_LISTBOOK
112
113 // the currently selected page or wxNOT_FOUND if none
114 int m_selection;
115
116private:
117 // common part of all constructors
118 void Init();
119
120 DECLARE_EVENT_TABLE()
121 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbook)
122};
123
124// ----------------------------------------------------------------------------
125// listbook event class and related stuff
126// ----------------------------------------------------------------------------
127
128class WXDLLEXPORT wxListbookEvent : public wxBookCtrlBaseEvent
129{
130public:
131 wxListbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
132 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
133 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
134 {
135 }
136
137private:
138 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListbookEvent)
139};
140
141extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED;
142extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING;
143
144typedef void (wxEvtHandler::*wxListbookEventFunction)(wxListbookEvent&);
145
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))
154
155#endif // wxUSE_LISTBOOK
156
157#endif // _WX_LISTBOOK_H_