]> git.saurik.com Git - wxWidgets.git/blame - include/wx/toolbook.h
cleanup - added whitespace around operators, some blank lines, fixed comment typos...
[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
24// ----------------------------------------------------------------------------
25// wxToolbook
26// ----------------------------------------------------------------------------
27
28class WXDLLEXPORT wxToolbook : public wxBookCtrlBase
29{
30public:
31 wxToolbook()
32 {
33 Init();
34 }
35
36 wxToolbook(wxWindow *parent,
37 wxWindowID id,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 long style = 0,
41 const wxString& name = wxEmptyString)
42 {
43 Init();
44
45 (void)Create(parent, id, pos, size, style, name);
46 }
47
48 // quasi ctor
49 bool Create(wxWindow *parent,
50 wxWindowID id,
51 const wxPoint& pos = wxDefaultPosition,
52 const wxSize& size = wxDefaultSize,
53 long style = 0,
54 const wxString& name = wxEmptyString);
55
56
57 virtual int GetSelection() const;
58 virtual bool SetPageText(size_t n, const wxString& strText);
59 virtual wxString GetPageText(size_t n) const;
60 virtual int GetPageImage(size_t n) const;
61 virtual bool SetPageImage(size_t n, int imageId);
62 virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
63 virtual bool InsertPage(size_t n,
64 wxWindow *page,
65 const wxString& text,
66 bool bSelect = false,
67 int imageId = -1);
68 virtual int SetSelection(size_t n);
69 virtual void SetImageList(wxImageList *imageList);
70
71 virtual bool DeleteAllPages();
72
73 wxToolBarBase* GetToolBar() const { return (wxToolBarBase*)m_bookctrl; }
74
75 // Not part of the wxBookctrl API, but must be called in OnIdle or
76 // by application to realize the toolbar and select the initial page.
77 void Realize();
78
79protected:
80 virtual wxWindow *DoRemovePage(size_t page);
81
82 // get the size which the list control should have
83 virtual wxSize GetControllerSize() const;
84
85 // event handlers
86 void OnToolSelected(wxCommandEvent& event);
87 void OnSize(wxSizeEvent& event);
88 void OnIdle(wxIdleEvent& event);
89
90 // the currently selected page or wxNOT_FOUND if none
91 int m_selection;
92
93 // whether the toolbar needs to be realized
94 bool m_needsRealizing;
95
96 // maximum bitmap size
97 wxSize m_maxBitmapSize;
98
99private:
100 // common part of all constructors
101 void Init();
102
103 DECLARE_EVENT_TABLE()
104 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook)
105};
106
107// ----------------------------------------------------------------------------
108// listbook event class and related stuff
109// ----------------------------------------------------------------------------
110
111class WXDLLEXPORT wxToolbookEvent : public wxBookCtrlBaseEvent
112{
113public:
114 wxToolbookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
115 int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
116 : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
117 {
118 }
119
120 wxToolbookEvent(const wxToolbookEvent& event)
121 : wxBookCtrlBaseEvent(event)
122 {
123 }
124
125 virtual wxEvent *Clone() const { return new wxToolbookEvent(*this); }
126
127private:
128 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent)
129};
130
131extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED;
132extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING;
133
134typedef void (wxEvtHandler::*wxToolbookEventFunction)(wxToolbookEvent&);
135
136#define wxToolbookEventHandler(func) \
137 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxToolbookEventFunction, &func)
138
139#define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
140 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxToolbookEventHandler(fn))
141
142#define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
143 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxToolbookEventHandler(fn))
144
145#endif // wxUSE_TOOLBOOK
146
147#endif // _WX_TOOLBOOK_H_