1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxToolbook: wxToolBar and wxNotebook combination
4 // Author: Julian Smart
8 // Copyright: (c) 2006 Julian Smart
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TOOLBOOK_H_
13 #define _WX_TOOLBOOK_H_
19 #include "wx/bookctrl.h"
20 #include "wx/containr.h"
22 class WXDLLIMPEXP_FWD_CORE wxToolBarBase
;
23 class WXDLLIMPEXP_FWD_CORE wxCommandEvent
;
25 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED
, wxBookCtrlEvent
);
26 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING
, wxBookCtrlEvent
);
29 // Use wxButtonToolBar
30 #define wxTBK_BUTTONBAR 0x0100
32 // Use wxTB_HORZ_LAYOUT style for the controlling toolbar
33 #define wxTBK_HORZ_LAYOUT 0x8000
35 // deprecated synonym, don't use
36 #if WXWIN_COMPATIBILITY_2_8
37 #define wxBK_BUTTONBAR wxTBK_BUTTONBAR
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 class WXDLLIMPEXP_CORE wxToolbook
: public wxNavigationEnabled
<wxBookCtrlBase
>
52 wxToolbook(wxWindow
*parent
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
57 const wxString
& name
= wxEmptyString
)
61 (void)Create(parent
, id
, pos
, size
, style
, name
);
65 bool Create(wxWindow
*parent
,
67 const wxPoint
& pos
= wxDefaultPosition
,
68 const wxSize
& size
= wxDefaultSize
,
70 const wxString
& name
= wxEmptyString
);
73 // implement base class virtuals
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
);
78 virtual bool InsertPage(size_t n
,
82 int imageId
= NO_IMAGE
);
83 virtual int SetSelection(size_t n
) { return DoSetSelection(n
, SetSelection_SendEvent
); }
84 virtual int ChangeSelection(size_t n
) { return DoSetSelection(n
); }
85 virtual void SetImageList(wxImageList
*imageList
);
87 virtual bool DeleteAllPages();
88 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
91 // methods which are not part of base wxBookctrl API
93 // get the underlying toolbar
94 wxToolBarBase
* GetToolBar() const { return (wxToolBarBase
*)m_bookctrl
; }
96 // must be called in OnIdle or by application to realize the toolbar and
97 // select the initial page.
101 virtual wxWindow
*DoRemovePage(size_t page
);
104 void OnToolSelected(wxCommandEvent
& event
);
105 void OnSize(wxSizeEvent
& event
);
106 void OnIdle(wxIdleEvent
& event
);
108 void UpdateSelectedPage(size_t newsel
);
110 wxBookCtrlEvent
* CreatePageChangingEvent() const;
111 void MakeChangedEvent(wxBookCtrlEvent
&event
);
113 // whether the toolbar needs to be realized
114 bool m_needsRealizing
;
116 // maximum bitmap size
117 wxSize m_maxBitmapSize
;
120 // common part of all constructors
123 DECLARE_EVENT_TABLE()
124 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook
)
127 // ----------------------------------------------------------------------------
128 // listbook event class and related stuff
129 // ----------------------------------------------------------------------------
131 // wxToolbookEvent is obsolete and defined for compatibility only
132 #define wxToolbookEvent wxBookCtrlEvent
133 typedef wxBookCtrlEventFunction wxToolbookEventFunction
;
134 #define wxToolbookEventHandler(func) wxBookCtrlEventHandler(func)
137 #define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
138 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
140 #define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
141 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
143 #endif // wxUSE_TOOLBOOK
145 #endif // _WX_TOOLBOOK_H_