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 // implement base class virtuals
61 virtual int GetSelection() const;
62 virtual bool SetPageText(size_t n
, const wxString
& strText
);
63 virtual wxString
GetPageText(size_t n
) const;
64 virtual int GetPageImage(size_t n
) const;
65 virtual bool SetPageImage(size_t n
, int imageId
);
66 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
67 virtual bool InsertPage(size_t n
,
72 virtual int SetSelection(size_t n
);
73 virtual void SetImageList(wxImageList
*imageList
);
75 virtual bool DeleteAllPages();
76 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
79 // methods which are not part of base wxBookctrl API
81 // get the underlying toolbar
82 wxToolBarBase
* GetToolBar() const { return (wxToolBarBase
*)m_bookctrl
; }
84 // must be called in OnIdle or by application to realize the toolbar and
85 // select the initial page.
89 virtual wxWindow
*DoRemovePage(size_t page
);
91 // get the size which the list control should have
92 virtual wxSize
GetControllerSize() const;
95 void OnToolSelected(wxCommandEvent
& event
);
96 void OnSize(wxSizeEvent
& event
);
97 void OnIdle(wxIdleEvent
& event
);
99 // the currently selected page or wxNOT_FOUND if none
102 // whether the toolbar needs to be realized
103 bool m_needsRealizing
;
105 // maximum bitmap size
106 wxSize m_maxBitmapSize
;
109 // common part of all constructors
112 DECLARE_EVENT_TABLE()
113 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook
)
116 // ----------------------------------------------------------------------------
117 // listbook event class and related stuff
118 // ----------------------------------------------------------------------------
120 class WXDLLEXPORT wxToolbookEvent
: public wxBookCtrlBaseEvent
123 wxToolbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
124 int nSel
= wxNOT_FOUND
, int nOldSel
= wxNOT_FOUND
)
125 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
129 wxToolbookEvent(const wxToolbookEvent
& event
)
130 : wxBookCtrlBaseEvent(event
)
134 virtual wxEvent
*Clone() const { return new wxToolbookEvent(*this); }
137 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent
)
140 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED
;
141 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING
;
143 typedef void (wxEvtHandler::*wxToolbookEventFunction
)(wxToolbookEvent
&);
145 #define wxToolbookEventHandler(func) \
146 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxToolbookEventFunction, &func)
148 #define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
149 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxToolbookEventHandler(fn))
151 #define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
152 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxToolbookEventHandler(fn))
154 #endif // wxUSE_TOOLBOOK
156 #endif // _WX_TOOLBOOK_H_