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"
21 class WXDLLEXPORT wxToolBarBase
;
22 class WXDLLEXPORT wxCommandEvent
;
24 // Use wxButtonToolBar
25 #define wxBK_BUTTONBAR 0x0100
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
31 class WXDLLEXPORT wxToolbook
: public wxBookCtrlBase
39 wxToolbook(wxWindow
*parent
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
44 const wxString
& name
= wxEmptyString
)
48 (void)Create(parent
, id
, pos
, size
, style
, name
);
52 bool Create(wxWindow
*parent
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
57 const wxString
& name
= wxEmptyString
);
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
,
71 virtual int SetSelection(size_t n
);
72 virtual void SetImageList(wxImageList
*imageList
);
74 virtual bool DeleteAllPages();
76 wxToolBarBase
* GetToolBar() const { return (wxToolBarBase
*)m_bookctrl
; }
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.
83 virtual wxWindow
*DoRemovePage(size_t page
);
85 // get the size which the list control should have
86 virtual wxSize
GetControllerSize() const;
89 void OnToolSelected(wxCommandEvent
& event
);
90 void OnSize(wxSizeEvent
& event
);
91 void OnIdle(wxIdleEvent
& event
);
93 // the currently selected page or wxNOT_FOUND if none
96 // whether the toolbar needs to be realized
97 bool m_needsRealizing
;
99 // maximum bitmap size
100 wxSize m_maxBitmapSize
;
103 // common part of all constructors
106 DECLARE_EVENT_TABLE()
107 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook
)
110 // ----------------------------------------------------------------------------
111 // listbook event class and related stuff
112 // ----------------------------------------------------------------------------
114 class WXDLLEXPORT wxToolbookEvent
: public wxBookCtrlBaseEvent
117 wxToolbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
118 int nSel
= wxNOT_FOUND
, int nOldSel
= wxNOT_FOUND
)
119 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
123 wxToolbookEvent(const wxToolbookEvent
& event
)
124 : wxBookCtrlBaseEvent(event
)
128 virtual wxEvent
*Clone() const { return new wxToolbookEvent(*this); }
131 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent
)
134 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED
;
135 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING
;
137 typedef void (wxEvtHandler::*wxToolbookEventFunction
)(wxToolbookEvent
&);
139 #define wxToolbookEventHandler(func) \
140 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxToolbookEventFunction, &func)
142 #define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
143 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxToolbookEventHandler(fn))
145 #define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
146 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxToolbookEventHandler(fn))
148 #endif // wxUSE_TOOLBOOK
150 #endif // _WX_TOOLBOOK_H_