]>
Commit | Line | Data |
---|---|---|
3c55b365 JS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/toolbook.h | |
3 | // Purpose: wxToolbook: wxToolBar and wxNotebook combination | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 2006-01-29 | |
3c55b365 JS |
7 | // Copyright: (c) 2006 Julian Smart |
8 | // Licence: wxWindows licence | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_TOOLBOOK_H_ | |
12 | #define _WX_TOOLBOOK_H_ | |
13 | ||
14 | #include "wx/defs.h" | |
15 | ||
16 | #if wxUSE_TOOLBOOK | |
17 | ||
18 | #include "wx/bookctrl.h" | |
28e42e02 | 19 | #include "wx/containr.h" |
3c55b365 | 20 | |
b5dbe15d VS |
21 | class WXDLLIMPEXP_FWD_CORE wxToolBarBase; |
22 | class WXDLLIMPEXP_FWD_CORE wxCommandEvent; | |
3c55b365 | 23 | |
ce7fe42e VZ |
24 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TOOLBOOK_PAGE_CHANGED, wxBookCtrlEvent ); |
25 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_TOOLBOOK_PAGE_CHANGING, wxBookCtrlEvent ); | |
1d6fcbcc VZ |
26 | |
27 | ||
64d3ed17 | 28 | // Use wxButtonToolBar |
e3507dd8 | 29 | #define wxTBK_BUTTONBAR 0x0100 |
64d3ed17 | 30 | |
050d159c VZ |
31 | // Use wxTB_HORZ_LAYOUT style for the controlling toolbar |
32 | #define wxTBK_HORZ_LAYOUT 0x8000 | |
33 | ||
e3507dd8 VZ |
34 | // deprecated synonym, don't use |
35 | #if WXWIN_COMPATIBILITY_2_8 | |
36 | #define wxBK_BUTTONBAR wxTBK_BUTTONBAR | |
37 | #endif | |
38 | ||
3c55b365 JS |
39 | // ---------------------------------------------------------------------------- |
40 | // wxToolbook | |
41 | // ---------------------------------------------------------------------------- | |
42 | ||
28e42e02 | 43 | class WXDLLIMPEXP_CORE wxToolbook : public wxNavigationEnabled<wxBookCtrlBase> |
3c55b365 JS |
44 | { |
45 | public: | |
46 | wxToolbook() | |
47 | { | |
48 | Init(); | |
49 | } | |
50 | ||
51 | wxToolbook(wxWindow *parent, | |
52 | wxWindowID id, | |
53 | const wxPoint& pos = wxDefaultPosition, | |
54 | const wxSize& size = wxDefaultSize, | |
55 | long style = 0, | |
56 | const wxString& name = wxEmptyString) | |
57 | { | |
58 | Init(); | |
59 | ||
60 | (void)Create(parent, id, pos, size, style, name); | |
61 | } | |
62 | ||
63 | // quasi ctor | |
64 | bool Create(wxWindow *parent, | |
65 | wxWindowID id, | |
66 | const wxPoint& pos = wxDefaultPosition, | |
67 | const wxSize& size = wxDefaultSize, | |
68 | long style = 0, | |
69 | const wxString& name = wxEmptyString); | |
70 | ||
71 | ||
d0a84b63 | 72 | // implement base class virtuals |
3c55b365 JS |
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); | |
3c55b365 JS |
77 | virtual bool InsertPage(size_t n, |
78 | wxWindow *page, | |
79 | const wxString& text, | |
80 | bool bSelect = false, | |
1871b9fa | 81 | int imageId = NO_IMAGE); |
1d6fcbcc VZ |
82 | virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); } |
83 | virtual int ChangeSelection(size_t n) { return DoSetSelection(n); } | |
3c55b365 JS |
84 | virtual void SetImageList(wxImageList *imageList); |
85 | ||
86 | virtual bool DeleteAllPages(); | |
d0a84b63 | 87 | virtual int HitTest(const wxPoint& pt, long *flags = NULL) const; |
3c55b365 | 88 | |
d0a84b63 VZ |
89 | |
90 | // methods which are not part of base wxBookctrl API | |
91 | ||
92 | // get the underlying toolbar | |
3c55b365 JS |
93 | wxToolBarBase* GetToolBar() const { return (wxToolBarBase*)m_bookctrl; } |
94 | ||
d0a84b63 VZ |
95 | // must be called in OnIdle or by application to realize the toolbar and |
96 | // select the initial page. | |
3c55b365 JS |
97 | void Realize(); |
98 | ||
99 | protected: | |
100 | virtual wxWindow *DoRemovePage(size_t page); | |
101 | ||
3c55b365 JS |
102 | // event handlers |
103 | void OnToolSelected(wxCommandEvent& event); | |
104 | void OnSize(wxSizeEvent& event); | |
105 | void OnIdle(wxIdleEvent& event); | |
106 | ||
8de043bb | 107 | void UpdateSelectedPage(size_t newsel); |
deb325e3 | 108 | |
3e97a905 VZ |
109 | wxBookCtrlEvent* CreatePageChangingEvent() const; |
110 | void MakeChangedEvent(wxBookCtrlEvent &event); | |
1d6fcbcc | 111 | |
3c55b365 JS |
112 | // whether the toolbar needs to be realized |
113 | bool m_needsRealizing; | |
114 | ||
115 | // maximum bitmap size | |
d0a84b63 | 116 | wxSize m_maxBitmapSize; |
3c55b365 JS |
117 | |
118 | private: | |
119 | // common part of all constructors | |
120 | void Init(); | |
121 | ||
122 | DECLARE_EVENT_TABLE() | |
123 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxToolbook) | |
124 | }; | |
125 | ||
126 | // ---------------------------------------------------------------------------- | |
127 | // listbook event class and related stuff | |
128 | // ---------------------------------------------------------------------------- | |
129 | ||
3e97a905 | 130 | // wxToolbookEvent is obsolete and defined for compatibility only |
586bed94 | 131 | #define wxToolbookEvent wxBookCtrlEvent |
3e97a905 VZ |
132 | typedef wxBookCtrlEventFunction wxToolbookEventFunction; |
133 | #define wxToolbookEventHandler(func) wxBookCtrlEventHandler(func) | |
3c55b365 | 134 | |
3c55b365 JS |
135 | |
136 | #define EVT_TOOLBOOK_PAGE_CHANGED(winid, fn) \ | |
ce7fe42e | 137 | wx__DECLARE_EVT1(wxEVT_TOOLBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn)) |
3c55b365 JS |
138 | |
139 | #define EVT_TOOLBOOK_PAGE_CHANGING(winid, fn) \ | |
ce7fe42e VZ |
140 | wx__DECLARE_EVT1(wxEVT_TOOLBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn)) |
141 | ||
142 | // old wxEVT_COMMAND_* constants | |
143 | #define wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGED wxEVT_TOOLBOOK_PAGE_CHANGED | |
144 | #define wxEVT_COMMAND_TOOLBOOK_PAGE_CHANGING wxEVT_TOOLBOOK_PAGE_CHANGING | |
3c55b365 JS |
145 | |
146 | #endif // wxUSE_TOOLBOOK | |
147 | ||
148 | #endif // _WX_TOOLBOOK_H_ |