]> git.saurik.com Git - wxWidgets.git/blame - include/wx/toolbook.h
Partly reverted changes to Get(Current)Selection.
[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
64d3ed17
JS
24// Use wxButtonToolBar
25#define wxBK_BUTTONBAR 0x0100
26
3c55b365
JS
27// ----------------------------------------------------------------------------
28// wxToolbook
29// ----------------------------------------------------------------------------
30
31class WXDLLEXPORT wxToolbook : public wxBookCtrlBase
32{
33public:
34 wxToolbook()
35 {
36 Init();
37 }
38
39 wxToolbook(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
d0a84b63 60 // implement base class virtuals
3c55b365
JS
61 virtual int GetSelection() const;
62 virtual bool SetPageText(size_t n, const wxString& strText);
63 virtual wxString GetPageText(size_t n) const;
64 virtual int GetPageImage(size_t n) const;
65 virtual bool SetPageImage(size_t n, int imageId);
66 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
67 virtual bool InsertPage(size_t n,
68 wxWindow *page,
69 const wxString& text,
70 bool bSelect = false,
71 int imageId = -1);
72 virtual int SetSelection(size_t n);
73 virtual void SetImageList(wxImageList *imageList);
74
75 virtual bool DeleteAllPages();
d0a84b63 76 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
3c55b365 77
d0a84b63
VZ
78
79 // methods which are not part of base wxBookctrl API
80
81 // get the underlying toolbar
3c55b365
JS
82 wxToolBarBase* GetToolBar() const { return (wxToolBarBase*)m_bookctrl; }
83
d0a84b63
VZ
84 // must be called in OnIdle or by application to realize the toolbar and
85 // select the initial page.
3c55b365
JS
86 void Realize();
87
88protected:
89 virtual wxWindow *DoRemovePage(size_t page);
90
91 // get the size which the list control should have
92 virtual wxSize GetControllerSize() const;
93
94 // event handlers
95 void OnToolSelected(wxCommandEvent& event);
96 void OnSize(wxSizeEvent& event);
97 void OnIdle(wxIdleEvent& event);
98
99 // the currently selected page or wxNOT_FOUND if none
100 int m_selection;
101
102 // whether the toolbar needs to be realized
103 bool m_needsRealizing;
104
105 // maximum bitmap size
d0a84b63 106 wxSize m_maxBitmapSize;
3c55b365
JS
107
108private:
109 // common part of all constructors
110 void Init();
111
112 DECLARE_EVENT_TABLE()
113 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook)
114};
115
116// ----------------------------------------------------------------------------
117// listbook event class and related stuff
118// ----------------------------------------------------------------------------
119
120class WXDLLEXPORT wxToolbookEvent : public wxBookCtrlBaseEvent
121{
122public:
123 wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
124 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
125 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
126 {
127 }
128
129 wxToolbookEvent(const wxToolbookEvent& event)
130 : wxBookCtrlBaseEvent(event)
131 {
132 }
133
134 virtual wxEvent *Clone() const { return new wxToolbookEvent(*this); }
135
136private:
137 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent)
138};
139
140extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
141extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
142
143typedef void (wxEvtHandler::*wxToolbookEventFunction)(wxToolbookEvent&);
144
145#define wxToolbookEventHandler(func) \
146 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxToolbookEventFunction, &func)
147
148#define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
149 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxToolbookEventHandler(fn))
150
151#define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
152 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxToolbookEventHandler(fn))
153
154#endif // wxUSE_TOOLBOOK
155
156#endif // _WX_TOOLBOOK_H_