]> git.saurik.com Git - wxWidgets.git/blame - include/wx/toolbook.h
Avoid using "do { ... } while ( wxFalse )" pseudo-loop.
[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"
28e42e02 20#include "wx/containr.h"
3c55b365 21
b5dbe15d
VS
22class WXDLLIMPEXP_FWD_CORE wxToolBarBase;
23class WXDLLIMPEXP_FWD_CORE wxCommandEvent;
3c55b365 24
9b11752c
VZ
25wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, wxBookCtrlEvent );
26wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, wxBookCtrlEvent );
1d6fcbcc
VZ
27
28
64d3ed17 29// Use wxButtonToolBar
e3507dd8 30#define wxTBK_BUTTONBAR 0x0100
64d3ed17 31
050d159c
VZ
32// Use wxTB_HORZ_LAYOUT style for the controlling toolbar
33#define wxTBK_HORZ_LAYOUT 0x8000
34
e3507dd8
VZ
35// deprecated synonym, don't use
36#if WXWIN_COMPATIBILITY_2_8
37 #define wxBK_BUTTONBAR wxTBK_BUTTONBAR
38#endif
39
3c55b365
JS
40// ----------------------------------------------------------------------------
41// wxToolbook
42// ----------------------------------------------------------------------------
43
28e42e02 44class WXDLLIMPEXP_CORE wxToolbook : public wxNavigationEnabled<wxBookCtrlBase>
3c55b365
JS
45{
46public:
47 wxToolbook()
48 {
49 Init();
50 }
51
52 wxToolbook(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 Init();
60
61 (void)Create(parent, id, pos, size, style, name);
62 }
63
64 // quasi ctor
65 bool Create(wxWindow *parent,
66 wxWindowID id,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize,
69 long style = 0,
70 const wxString& name = wxEmptyString);
71
72
d0a84b63 73 // implement base class virtuals
3c55b365
JS
74 virtual bool SetPageText(size_t n, const wxString& strText);
75 virtual wxString GetPageText(size_t n) const;
76 virtual int GetPageImage(size_t n) const;
77 virtual bool SetPageImage(size_t n, int imageId);
3c55b365
JS
78 virtual bool InsertPage(size_t n,
79 wxWindow *page,
80 const wxString& text,
81 bool bSelect = false,
1871b9fa 82 int imageId = NO_IMAGE);
1d6fcbcc
VZ
83 virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
84 virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
3c55b365
JS
85 virtual void SetImageList(wxImageList *imageList);
86
87 virtual bool DeleteAllPages();
d0a84b63 88 virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
3c55b365 89
d0a84b63
VZ
90
91 // methods which are not part of base wxBookctrl API
92
93 // get the underlying toolbar
3c55b365
JS
94 wxToolBarBase* GetToolBar() const { return (wxToolBarBase*)m_bookctrl; }
95
d0a84b63
VZ
96 // must be called in OnIdle or by application to realize the toolbar and
97 // select the initial page.
3c55b365
JS
98 void Realize();
99
100protected:
101 virtual wxWindow *DoRemovePage(size_t page);
102
3c55b365
JS
103 // event handlers
104 void OnToolSelected(wxCommandEvent& event);
105 void OnSize(wxSizeEvent& event);
106 void OnIdle(wxIdleEvent& event);
107
8de043bb 108 void UpdateSelectedPage(size_t newsel);
deb325e3 109
3e97a905
VZ
110 wxBookCtrlEvent* CreatePageChangingEvent() const;
111 void MakeChangedEvent(wxBookCtrlEvent &event);
1d6fcbcc 112
3c55b365
JS
113 // whether the toolbar needs to be realized
114 bool m_needsRealizing;
115
116 // maximum bitmap size
d0a84b63 117 wxSize m_maxBitmapSize;
3c55b365
JS
118
119private:
120 // common part of all constructors
121 void Init();
122
123 DECLARE_EVENT_TABLE()
124 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook)
125};
126
127// ----------------------------------------------------------------------------
128// listbook event class and related stuff
129// ----------------------------------------------------------------------------
130
3e97a905 131// wxToolbookEvent is obsolete and defined for compatibility only
586bed94 132#define wxToolbookEvent wxBookCtrlEvent
3e97a905
VZ
133typedef wxBookCtrlEventFunction wxToolbookEventFunction;
134#define wxToolbookEventHandler(func) wxBookCtrlEventHandler(func)
3c55b365 135
3c55b365
JS
136
137#define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
3e97a905 138 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
3c55b365
JS
139
140#define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
3e97a905 141 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
3c55b365
JS
142
143#endif // wxUSE_TOOLBOOK
144
145#endif // _WX_TOOLBOOK_H_