]> git.saurik.com Git - wxWidgets.git/blame - include/wx/aui/auibook.h
Compilation fix for old GCC versions.
[wxWidgets.git] / include / wx / aui / auibook.h
CommitLineData
a3219eea 1///////////////////////////////////////////////////////////////////////////////
4444d148 2// Name: wx/aui/auibook.h
a3219eea
BW
3// Purpose: wxaui: wx advanced user interface - notebook
4// Author: Benjamin I. Williams
5// Modified by:
6// Created: 2006-06-28
7// Copyright: (C) Copyright 2006, Kirix Corporation, All Rights Reserved.
8// Licence: wxWindows Library Licence, Version 3.1
9///////////////////////////////////////////////////////////////////////////////
10
11
12
13#ifndef _WX_AUINOTEBOOK_H_
14#define _WX_AUINOTEBOOK_H_
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#include "wx/defs.h"
a3219eea
BW
21
22#if wxUSE_AUI
23
4444d148
WS
24#include "wx/aui/framemanager.h"
25#include "wx/aui/dockart.h"
26#include "wx/aui/floatpane.h"
4107600f 27#include "wx/control.h"
a3219eea
BW
28
29
3f69756e
BW
30// tab art class
31
32
0b13400f 33class WXDLLIMPEXP_AUI wxTabArt
3f69756e
BW
34{
35public:
36
488e50ee
BW
37 wxTabArt() { }
38 virtual ~wxTabArt() { }
39
3f69756e
BW
40 virtual void DrawBackground(
41 wxDC* dc,
42 const wxRect& rect) = 0;
43
44 virtual void DrawTab(wxDC* dc,
45 const wxRect& in_rect,
46 const wxString& caption,
47 bool active,
48 wxRect* out_rect,
49 int* x_extent) = 0;
50
51 virtual void SetNormalFont(const wxFont& font) = 0;
52 virtual void SetSelectedFont(const wxFont& font) = 0;
53 virtual void SetMeasuringFont(const wxFont& font) = 0;
54};
55
56
0b13400f 57class WXDLLIMPEXP_AUI wxDefaultTabArt : public wxTabArt
3f69756e
BW
58{
59
60public:
61
62 wxDefaultTabArt();
488e50ee 63 virtual ~wxDefaultTabArt();
3f69756e
BW
64
65 void DrawBackground(
66 wxDC* dc,
67 const wxRect& rect);
68
69 void DrawTab(wxDC* dc,
70 const wxRect& in_rect,
71 const wxString& caption,
72 bool active,
73 wxRect* out_rect,
74 int* x_extent);
75
76 void SetNormalFont(const wxFont& font);
77 void SetSelectedFont(const wxFont& font);
78 void SetMeasuringFont(const wxFont& font);
79
80private:
81
82 wxFont m_normal_font;
83 wxFont m_selected_font;
84 wxFont m_measuring_font;
85 wxPen m_normal_bkpen;
86 wxPen m_selected_bkpen;
87 wxBrush m_normal_bkbrush;
88 wxBrush m_selected_bkbrush;
89 wxBrush m_bkbrush;
90};
91
92
93
a3219eea
BW
94// event declarations/classes
95
96class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxNotifyEvent
97{
98public:
99 wxAuiNotebookEvent(wxEventType command_type = wxEVT_NULL,
100 int win_id = 0)
101 : wxNotifyEvent(command_type, win_id)
102 {
103 }
104#ifndef SWIG
105 wxAuiNotebookEvent(const wxAuiNotebookEvent& c) : wxNotifyEvent(c)
106 {
107 old_selection = c.old_selection;
108 selection = c.selection;
109 }
110#endif
111 wxEvent *Clone() const { return new wxAuiNotebookEvent(*this); }
112
113 void SetSelection(int s) { selection = s; }
114 void SetOldSelection(int s) { old_selection = s; }
115 int GetSelection() const { return selection; }
116 int GetOldSelection() const { return old_selection; }
4444d148 117
a3219eea
BW
118public:
119 int old_selection;
120 int selection;
4444d148 121
a3219eea
BW
122#ifndef SWIG
123private:
124 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent)
125#endif
126};
127
128
129
130
131
132class WXDLLIMPEXP_AUI wxAuiNotebookPage
133{
134public:
135 wxWindow* window; // page's associated window
136 wxString caption; // caption displayed on the tab
137 wxBitmap bitmap; // tab's bitmap
138 wxRect rect; // tab's hit rectangle
139 bool active; // true if the page is currently active
140};
141
142class WXDLLIMPEXP_AUI wxAuiTabContainerButton
143{
144public:
145 int id; // button's id
146 int cur_state; // current state (normal, hover, pressed)
b6418695 147 int location; // buttons location (wxLEFT or wxRIGHT)
a3219eea
BW
148 wxBitmap bitmap; // button's bitmap
149 wxRect rect; // button's hit rectangle
150};
151
152
d91fa282 153#ifndef SWIG
a3219eea
BW
154WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI);
155WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI);
d91fa282 156#endif
a3219eea
BW
157
158
159class WXDLLIMPEXP_AUI wxAuiTabContainer
160{
161public:
162
163 wxAuiTabContainer();
9fabaac4 164 virtual ~wxAuiTabContainer();
a3219eea 165
3f69756e
BW
166 void SetArtProvider(wxTabArt* art);
167 wxTabArt* GetArtProvider();
168
a3219eea
BW
169 bool AddPage(wxWindow* page, const wxAuiNotebookPage& info);
170 bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx);
171 bool RemovePage(wxWindow* page);
172 bool SetActivePage(wxWindow* page);
173 bool SetActivePage(size_t page);
174 void SetNoneActive();
175 int GetActivePage() const;
176 bool TabHitTest(int x, int y, wxWindow** hit) const;
177 bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const;
178 wxWindow* GetWindowFromIdx(size_t idx) const;
179 int GetIdxFromWindow(wxWindow* page) const;
180 size_t GetPageCount() const;
181 wxAuiNotebookPage& GetPage(size_t idx);
182 wxAuiNotebookPageArray& GetPages();
183 void SetNormalFont(const wxFont& normal_font);
184 void SetSelectedFont(const wxFont& selected_font);
185 void SetMeasuringFont(const wxFont& measuring_font);
186 void DoShowHide();
187 void SetRect(const wxRect& rect);
b6418695 188 void AddButton(int id, int location, const wxBitmap& bmp);
4444d148 189
a3219eea
BW
190protected:
191
4444d148 192 virtual void Render(wxDC* dc);
a3219eea 193
a3219eea
BW
194private:
195
3f69756e 196 wxTabArt* m_art;
a3219eea
BW
197 wxAuiNotebookPageArray m_pages;
198 wxAuiTabContainerButtonArray m_buttons;
199 wxRect m_rect;
a3219eea
BW
200};
201
202
203
204class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl,
205 public wxAuiTabContainer
206{
207public:
208
209 wxAuiTabCtrl(wxWindow* parent,
d91fa282 210 wxWindowID id = wxID_ANY,
a3219eea
BW
211 const wxPoint& pos = wxDefaultPosition,
212 const wxSize& size = wxDefaultSize,
213 long style = 0);
4444d148 214
a3219eea
BW
215protected:
216
217 void OnPaint(wxPaintEvent& evt);
218 void OnEraseBackground(wxEraseEvent& evt);
219 void OnSize(wxSizeEvent& evt);
220 void OnLeftDown(wxMouseEvent& evt);
221 void OnLeftUp(wxMouseEvent& evt);
222 void OnMotion(wxMouseEvent& evt);
223 void OnLeaveWindow(wxMouseEvent& evt);
4444d148 224
a3219eea 225protected:
4444d148 226
a3219eea
BW
227 wxPoint m_click_pt;
228 int m_click_tab;
229 bool m_is_dragging;
230 wxAuiTabContainerButton* m_hover_button;
231
d91fa282 232#ifndef SWIG
a3219eea 233 DECLARE_EVENT_TABLE()
d91fa282 234#endif
a3219eea
BW
235};
236
237
238
239
240class WXDLLIMPEXP_AUI wxAuiMultiNotebook : public wxControl
241{
242
243public:
244
245 wxAuiMultiNotebook();
4444d148 246
a3219eea 247 wxAuiMultiNotebook(wxWindow* parent,
d91fa282 248 wxWindowID id = wxID_ANY,
a3219eea
BW
249 const wxPoint& pos = wxDefaultPosition,
250 const wxSize& size = wxDefaultSize,
251 long style = 0);
4444d148 252
a3219eea
BW
253 virtual ~wxAuiMultiNotebook();
254
255 bool Create(wxWindow* parent,
d91fa282 256 wxWindowID id = wxID_ANY,
a3219eea
BW
257 const wxPoint& pos = wxDefaultPosition,
258 const wxSize& size = wxDefaultSize,
4444d148 259 long style = 0);
a3219eea
BW
260
261 bool AddPage(wxWindow* page,
262 const wxString& caption,
263 bool select = false,
264 const wxBitmap& bitmap = wxNullBitmap);
4444d148 265
a3219eea
BW
266 bool InsertPage(size_t page_idx,
267 wxWindow* page,
268 const wxString& caption,
269 bool select = false,
270 const wxBitmap& bitmap = wxNullBitmap);
4444d148 271
a3219eea
BW
272 bool DeletePage(size_t page);
273 bool RemovePage(size_t page);
4444d148 274
a3219eea
BW
275 bool SetPageText(size_t page, const wxString& text);
276 size_t SetSelection(size_t new_page);
277 int GetSelection() const;
278 size_t GetPageCount() const;
279 wxWindow* GetPage(size_t page_idx) const;
4444d148 280
3f69756e
BW
281 void SetArtProvider(wxTabArt* art);
282 wxTabArt* GetArtProvider();
283
a3219eea 284protected:
4444d148 285
a3219eea
BW
286 wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt);
287 wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl);
288 wxAuiTabCtrl* GetActiveTabCtrl();
289 bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx);
290 void RemoveEmptyTabFrames();
4444d148 291
a3219eea
BW
292protected:
293
294 void DoSizing();
295 void InitNotebook();
4444d148 296
a3219eea
BW
297 void OnChildFocus(wxChildFocusEvent& evt);
298 void OnRender(wxFrameManagerEvent& evt);
299 void OnEraseBackground(wxEraseEvent& evt);
300 void OnSize(wxSizeEvent& evt);
301 void OnTabClicked(wxCommandEvent& evt);
302 void OnTabBeginDrag(wxCommandEvent& evt);
303 void OnTabDragMotion(wxCommandEvent& evt);
304 void OnTabEndDrag(wxCommandEvent& evt);
305 void OnTabButton(wxCommandEvent& evt);
306
307protected:
308
309 wxFrameManager m_mgr;
310 wxAuiTabContainer m_tabs;
311 int m_curpage;
312 int m_tab_id_counter;
313 wxWindow* m_dummy_wnd;
4444d148 314
a3219eea
BW
315 wxFont m_selected_font;
316 wxFont m_normal_font;
da5e85d9 317 int m_tab_ctrl_height;
4444d148 318
d91fa282 319#ifndef SWIG
a3219eea 320 DECLARE_EVENT_TABLE()
d91fa282 321#endif
a3219eea
BW
322};
323
324
325
326
327// wx event machinery
328
329#ifndef SWIG
330
331BEGIN_DECLARE_EVENT_TYPES()
332 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0)
333 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0)
334 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0)
335 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0)
336 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0)
337 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 0)
338END_DECLARE_EVENT_TYPES()
339
340typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
341
342#define wxAuiNotebookEventHandler(func) \
343 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
344
345#define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
346 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
347#define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
348 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
349#define EVT_AUINOTEBOOK_PAGE_BUTTON(winid, fn) \
350 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
351#define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
352 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
353#define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
354 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
355#define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
356 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
4444d148 357
a3219eea
BW
358#else
359
360// wxpython/swig event work
d91fa282
RD
361%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED;
362%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING;
363%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON;
364%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG;
365%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG;
366%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION;
367
368%pythoncode {
369 EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 )
370 EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 )
371 EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 )
372 EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 )
373 EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 )
4444d148 374 EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 )
d91fa282 375}
a3219eea
BW
376#endif
377
378
379#endif // wxUSE_AUI
380#endif // _WX_AUINOTEBOOK_H_