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 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 class WXDLLEXPORT wxToolbook
: public wxBookCtrlBase
36 wxToolbook(wxWindow
*parent
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
41 const wxString
& name
= wxEmptyString
)
45 (void)Create(parent
, id
, pos
, size
, style
, name
);
49 bool Create(wxWindow
*parent
,
51 const wxPoint
& pos
= wxDefaultPosition
,
52 const wxSize
& size
= wxDefaultSize
,
54 const wxString
& name
= wxEmptyString
);
57 virtual int GetSelection() const;
58 virtual bool SetPageText(size_t n
, const wxString
& strText
);
59 virtual wxString
GetPageText(size_t n
) const;
60 virtual int GetPageImage(size_t n
) const;
61 virtual bool SetPageImage(size_t n
, int imageId
);
62 virtual wxSize
CalcSizeFromPage(const wxSize
& sizePage
) const;
63 virtual bool InsertPage(size_t n
,
68 virtual int SetSelection(size_t n
);
69 virtual void SetImageList(wxImageList
*imageList
);
71 virtual bool DeleteAllPages();
73 wxToolBarBase
* GetToolBar() const { return (wxToolBarBase
*)m_bookctrl
; }
75 // Not part of the wxBookctrl API, but must be called in OnIdle or
76 // by application to realize the toolbar and select the initial page.
80 virtual wxWindow
*DoRemovePage(size_t page
);
82 // get the size which the list control should have
83 virtual wxSize
GetControllerSize() const;
86 void OnToolSelected(wxCommandEvent
& event
);
87 void OnSize(wxSizeEvent
& event
);
88 void OnIdle(wxIdleEvent
& event
);
90 // the currently selected page or wxNOT_FOUND if none
93 // whether the toolbar needs to be realized
94 bool m_needsRealizing
;
96 // maximum bitmap size
97 wxSize m_maxBitmapSize
;
100 // common part of all constructors
103 DECLARE_EVENT_TABLE()
104 DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook
)
107 // ----------------------------------------------------------------------------
108 // listbook event class and related stuff
109 // ----------------------------------------------------------------------------
111 class WXDLLEXPORT wxToolbookEvent
: public wxBookCtrlBaseEvent
114 wxToolbookEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0,
115 int nSel
= wxNOT_FOUND
, int nOldSel
= wxNOT_FOUND
)
116 : wxBookCtrlBaseEvent(commandType
, id
, nSel
, nOldSel
)
120 wxToolbookEvent(const wxToolbookEvent
& event
)
121 : wxBookCtrlBaseEvent(event
)
125 virtual wxEvent
*Clone() const { return new wxToolbookEvent(*this); }
128 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxToolbookEvent
)
131 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED
;
132 extern WXDLLIMPEXP_CORE
const wxEventType wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING
;
134 typedef void (wxEvtHandler::*wxToolbookEventFunction
)(wxToolbookEvent
&);
136 #define wxToolbookEventHandler(func) \
137 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxToolbookEventFunction, &func)
139 #define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
140 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxToolbookEventHandler(fn))
142 #define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
143 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxToolbookEventHandler(fn))
145 #endif // wxUSE_TOOLBOOK
147 #endif // _WX_TOOLBOOK_H_