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 WXDLLIMPEXP_FWD_CORE wxToolBarBase
;
22 class WXDLLIMPEXP_FWD_CORE wxCommandEvent
;
24 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED
;
25 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING
;
28 // Use wxButtonToolBar
29 #define wxBK_BUTTONBAR 0x0100
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 class WXDLLEXPORT wxToolbook
: public wxBookCtrlBase
43 wxToolbook(wxWindow
*parent
,
45 const wxPoint
& pos
= wxDefaultPosition
,
46 const wxSize
& size
= wxDefaultSize
,
48 const wxString
& name
= wxEmptyString
)
52 (void)Create(parent
, id
, pos
, size
, style
, name
);
56 bool Create(wxWindow
*parent
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
61 const wxString
& name
= wxEmptyString
);
64 // implement base class virtuals
65 virtual int GetSelection() const;
66 virtual bool SetPageText(size_t n
, const wxString
& strText
);
67 virtual wxString
GetPageText(size_t n
) const;
68 virtual int GetPageImage(size_t n
) const;
69 virtual bool SetPageImage(size_t n
, int imageId
);
70 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
71 virtual bool InsertPage(size_t n
,
76 virtual int SetSelection(size_t n
) { return DoSetSelection(n
, SetSelection_SendEvent
); }
77 virtual int ChangeSelection(size_t n
) { return DoSetSelection(n
); }
78 virtual void SetImageList(wxImageList
*imageList
);
80 virtual bool DeleteAllPages();
81 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
84 // methods which are not part of base wxBookctrl API
86 // get the underlying toolbar
87 wxToolBarBase
* GetToolBar() const { return (wxToolBarBase
*)m_bookctrl
; }
89 // must be called in OnIdle or by application to realize the toolbar and
90 // select the initial page.
94 virtual wxWindow
*DoRemovePage(size_t page
);
96 // get the size which the list control should have
97 virtual wxSize
GetControllerSize() const;
100 void OnToolSelected(wxCommandEvent
& event
);
101 void OnSize(wxSizeEvent
& event
);
102 void OnIdle(wxIdleEvent
& event
);
104 void UpdateSelectedPage(size_t newsel
);
106 wxBookCtrlBaseEvent
* CreatePageChangingEvent() const;
107 void MakeChangedEvent(wxBookCtrlBaseEvent
&event
);
109 // the currently selected page or wxNOT_FOUND if none
112 // whether the toolbar needs to be realized
113 bool m_needsRealizing
;
115 // maximum bitmap size
116 wxSize m_maxBitmapSize
;
119 // common part of all constructors
122 DECLARE_EVENT_TABLE()
123 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook
)
126 // ----------------------------------------------------------------------------
127 // listbook event class and related stuff
128 // ----------------------------------------------------------------------------
130 class WXDLLEXPORT wxToolbookEvent
: public wxBookCtrlBaseEvent
133 wxToolbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
134 int nSel
= wxNOT_FOUND
, int nOldSel
= wxNOT_FOUND
)
135 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
139 wxToolbookEvent(const wxToolbookEvent
& event
)
140 : wxBookCtrlBaseEvent(event
)
144 virtual wxEvent
*Clone() const { return new wxToolbookEvent(*this); }
147 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent
)
150 typedef void (wxEvtHandler::*wxToolbookEventFunction
)(wxToolbookEvent
&);
152 #define wxToolbookEventHandler(func) \
153 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxToolbookEventFunction, &func)
155 #define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
156 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxToolbookEventHandler(fn))
158 #define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
159 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxToolbookEventHandler(fn))
161 #endif // wxUSE_TOOLBOOK
163 #endif // _WX_TOOLBOOK_H_