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 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED
, wxBookCtrlEvent
);
25 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING
, wxBookCtrlEvent
);
28 // Use wxButtonToolBar
29 #define wxTBK_BUTTONBAR 0x0100
31 // Use wxTB_HORZ_LAYOUT style for the controlling toolbar
32 #define wxTBK_HORZ_LAYOUT 0x8000
34 // deprecated synonym, don't use
35 #if WXWIN_COMPATIBILITY_2_8
36 #define wxBK_BUTTONBAR wxTBK_BUTTONBAR
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 class WXDLLIMPEXP_CORE wxToolbook
: public wxBookCtrlBase
51 wxToolbook(wxWindow
*parent
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
56 const wxString
& name
= wxEmptyString
)
60 (void)Create(parent
, id
, pos
, size
, style
, name
);
64 bool Create(wxWindow
*parent
,
66 const wxPoint
& pos
= wxDefaultPosition
,
67 const wxSize
& size
= wxDefaultSize
,
69 const wxString
& name
= wxEmptyString
);
72 // implement base class virtuals
73 virtual bool SetPageText(size_t n
, const wxString
& strText
);
74 virtual wxString
GetPageText(size_t n
) const;
75 virtual int GetPageImage(size_t n
) const;
76 virtual bool SetPageImage(size_t n
, int imageId
);
77 virtual bool InsertPage(size_t n
,
81 int imageId
= NO_IMAGE
);
82 virtual int SetSelection(size_t n
) { return DoSetSelection(n
, SetSelection_SendEvent
); }
83 virtual int ChangeSelection(size_t n
) { return DoSetSelection(n
); }
84 virtual void SetImageList(wxImageList
*imageList
);
86 virtual bool DeleteAllPages();
87 virtual int HitTest(const wxPoint
& pt
, long *flags
= NULL
) const;
90 // methods which are not part of base wxBookctrl API
92 // get the underlying toolbar
93 wxToolBarBase
* GetToolBar() const { return (wxToolBarBase
*)m_bookctrl
; }
95 // must be called in OnIdle or by application to realize the toolbar and
96 // select the initial page.
100 virtual wxWindow
*DoRemovePage(size_t page
);
103 void OnToolSelected(wxCommandEvent
& event
);
104 void OnSize(wxSizeEvent
& event
);
105 void OnIdle(wxIdleEvent
& event
);
107 void UpdateSelectedPage(size_t newsel
);
109 wxBookCtrlEvent
* CreatePageChangingEvent() const;
110 void MakeChangedEvent(wxBookCtrlEvent
&event
);
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 // wxToolbookEvent is obsolete and defined for compatibility only
131 typedef wxBookCtrlEvent wxToolbookEvent
;
132 typedef wxBookCtrlEventFunction wxToolbookEventFunction
;
133 #define wxToolbookEventHandler(func) wxBookCtrlEventHandler(func)
136 #define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \
137 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
139 #define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \
140 wx__DECLARE_EVT1(wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
142 #endif // wxUSE_TOOLBOOK
144 #endif // _WX_TOOLBOOK_H_