]> git.saurik.com Git - wxWidgets.git/blame - include/wx/toolbook.h
added wxString::rbegin() and rend()
[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
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);
71 virtual int SetSelection(size_t n);
72 virtual void SetImageList(wxImageList *imageList);
73
74 virtual bool DeleteAllPages();
75
76 wxToolBarBase* GetToolBar() const { return (wxToolBarBase*)m_bookctrl; }
77
78 // Not part of the wxBookctrl API, but must be called in OnIdle or
79 // by application to realize the toolbar and select the initial page.
80 void Realize();
81
82protected:
83 virtual wxWindow *DoRemovePage(size_t page);
84
85 // get the size which the list control should have
86 virtual wxSize GetControllerSize() const;
87
88 // event handlers
89 void OnToolSelected(wxCommandEvent& event);
90 void OnSize(wxSizeEvent& event);
91 void OnIdle(wxIdleEvent& event);
92
93 // the currently selected page or wxNOT_FOUND if none
94 int m_selection;
95
96 // whether the toolbar needs to be realized
97 bool m_needsRealizing;
98
99 // maximum bitmap size
100 wxSize m_maxBitmapSize;
101
102private:
103 // common part of all constructors
104 void Init();
105
106 DECLARE_EVENT_TABLE()
107 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook)
108};
109
110// ----------------------------------------------------------------------------
111// listbook event class and related stuff
112// ----------------------------------------------------------------------------
113
114class WXDLLEXPORT wxToolbookEvent : public wxBookCtrlBaseEvent
115{
116public:
117 wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
118 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
119 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
120 {
121 }
122
123 wxToolbookEvent(const wxToolbookEvent& event)
124 : wxBookCtrlBaseEvent(event)
125 {
126 }
127
128 virtual wxEvent *Clone() const { return new wxToolbookEvent(*this); }
129
130private:
131 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent)
132};
133
134extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
135extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
136
137typedef void (wxEvtHandler::*wxToolbookEventFunction)(wxToolbookEvent&);
138
139#define wxToolbookEventHandler(func) \
140 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxToolbookEventFunction, &func)
141
142#define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
143 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxToolbookEventHandler(fn))
144
145#define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
146 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxToolbookEventHandler(fn))
147
148#endif // wxUSE_TOOLBOOK
149
150#endif // _WX_TOOLBOOK_H_