]> git.saurik.com Git - wxWidgets.git/blame - include/wx/toolbook.h
compilation fix after last commit (apparently patch was misapplied)
[wxWidgets.git] / include / wx / toolbook.h
CommitLineData
3c55b365
JS
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/toolbook.h
3// Purpose: wxToolbook: wxToolBar and wxNotebook combination
4// Author: Julian Smart
5// Modified by:
6// Created: 2006-01-29
7// RCS-ID: $Id$
8// Copyright: (c) 2006 Julian Smart
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_TOOLBOOK_H_
13#define _WX_TOOLBOOK_H_
14
15#include "wx/defs.h"
16
17#if wxUSE_TOOLBOOK
18
19#include "wx/bookctrl.h"
20
21class WXDLLEXPORT wxToolBarBase;
22class WXDLLEXPORT wxCommandEvent;
23
1d6fcbcc
VZ
24extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
25extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
26
27
64d3ed17
JS
28// Use wxButtonToolBar
29#define wxBK_BUTTONBAR 0x0100
30
3c55b365
JS
31// ----------------------------------------------------------------------------
32// wxToolbook
33// ----------------------------------------------------------------------------
34
35class WXDLLEXPORT wxToolbook : public wxBookCtrlBase
36{
37public:
38 wxToolbook()
39 {
40 Init();
41 }
42
43 wxToolbook(wxWindow *parent,
44 wxWindowID id,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = 0,
48 const wxString& name = wxEmptyString)
49 {
50 Init();
51
52 (void)Create(parent, id, pos, size, style, name);
53 }
54
55 // quasi ctor
56 bool Create(wxWindow *parent,
57 wxWindowID id,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 long style = 0,
61 const wxString& name = wxEmptyString);
62
63
d0a84b63 64 // implement base class virtuals
3c55b365
JS
65 virtual int GetSelection() const;
66 virtual bool SetPageText(size_t n, const wxString& strText);
67 virtual wxString GetPageText(size_t n) const;
68 virtual int GetPageImage(size_t n) const;
69 virtual bool SetPageImage(size_t n, int imageId);
70 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
71 virtual bool InsertPage(size_t n,
72 wxWindow *page,
73 const wxString& text,
74 bool bSelect = false,
75 int imageId = -1);
1d6fcbcc
VZ
76 virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
77 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
3c55b365
JS
78 virtual void SetImageList(wxImageList *imageList);
79
80 virtual bool DeleteAllPages();
d0a84b63 81 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
3c55b365 82
d0a84b63
VZ
83
84 // methods which are not part of base wxBookctrl API
85
86 // get the underlying toolbar
3c55b365
JS
87 wxToolBarBase* GetToolBar() const { return (wxToolBarBase*)m_bookctrl; }
88
d0a84b63
VZ
89 // must be called in OnIdle or by application to realize the toolbar and
90 // select the initial page.
3c55b365
JS
91 void Realize();
92
93protected:
94 virtual wxWindow *DoRemovePage(size_t page);
95
96 // get the size which the list control should have
97 virtual wxSize GetControllerSize() const;
98
99 // event handlers
100 void OnToolSelected(wxCommandEvent& event);
101 void OnSize(wxSizeEvent& event);
102 void OnIdle(wxIdleEvent& event);
103
1d6fcbcc
VZ
104 int DoSetSelection(size_t nPage, int flags = 0);
105
106 void UpdateSelectedPage(size_t newsel)
107 {
108 m_selection = newsel;
109 GetToolBar()->ToggleTool(newsel + 1, true);
110 }
111
112 void MakeChangedEvent(wxBookCtrlBaseEvent &event)
113 {
114 event.SetEventType(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED);
115 }
116
3c55b365
JS
117 // the currently selected page or wxNOT_FOUND if none
118 int m_selection;
119
120 // whether the toolbar needs to be realized
121 bool m_needsRealizing;
122
123 // maximum bitmap size
d0a84b63 124 wxSize m_maxBitmapSize;
3c55b365
JS
125
126private:
127 // common part of all constructors
128 void Init();
129
130 DECLARE_EVENT_TABLE()
131 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook)
132};
133
134// ----------------------------------------------------------------------------
135// listbook event class and related stuff
136// ----------------------------------------------------------------------------
137
138class WXDLLEXPORT wxToolbookEvent : public wxBookCtrlBaseEvent
139{
140public:
141 wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
142 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
143 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
144 {
145 }
146
147 wxToolbookEvent(const wxToolbookEvent& event)
148 : wxBookCtrlBaseEvent(event)
149 {
150 }
151
152 virtual wxEvent *Clone() const { return new wxToolbookEvent(*this); }
153
154private:
155 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent)
156};
157
3c55b365
JS
158typedef void (wxEvtHandler::*wxToolbookEventFunction)(wxToolbookEvent&);
159
160#define wxToolbookEventHandler(func) \
161 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxToolbookEventFunction, &func)
162
163#define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
164 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxToolbookEventHandler(fn))
165
166#define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
167 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxToolbookEventHandler(fn))
168
169#endif // wxUSE_TOOLBOOK
170
171#endif // _WX_TOOLBOOK_H_