]> git.saurik.com Git - wxWidgets.git/blame - include/wx/aui/auibook.h
replaced wxCint() with wxRound() (which is exactly the same) in Rotate(); small code...
[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;
4953f8cf
BW
50
51 virtual void DrawButton(
52 wxDC* dc,
53 const wxRect& in_rect,
54 int bitmap_id,
55 int button_state,
56 int orientation,
57 const wxBitmap& bitmap_override,
58 wxRect* out_rect) = 0;
59
60 virtual wxSize GetTabSize(
61 wxDC* dc,
62 const wxString& caption,
63 bool active,
64 int* x_extent) = 0;
65
3f69756e
BW
66 virtual void SetNormalFont(const wxFont& font) = 0;
67 virtual void SetSelectedFont(const wxFont& font) = 0;
68 virtual void SetMeasuringFont(const wxFont& font) = 0;
69};
70
71
0b13400f 72class WXDLLIMPEXP_AUI wxDefaultTabArt : public wxTabArt
3f69756e
BW
73{
74
75public:
76
77 wxDefaultTabArt();
488e50ee 78 virtual ~wxDefaultTabArt();
3f69756e
BW
79
80 void DrawBackground(
81 wxDC* dc,
82 const wxRect& rect);
83
84 void DrawTab(wxDC* dc,
85 const wxRect& in_rect,
86 const wxString& caption,
87 bool active,
88 wxRect* out_rect,
89 int* x_extent);
4953f8cf
BW
90
91 void DrawButton(
92 wxDC* dc,
93 const wxRect& in_rect,
94 int bitmap_id,
95 int button_state,
96 int orientation,
97 const wxBitmap& bitmap_override,
98 wxRect* out_rect);
99
100 wxSize GetTabSize(
101 wxDC* dc,
102 const wxString& caption,
103 bool active,
104 int* x_extent);
105
3f69756e
BW
106 void SetNormalFont(const wxFont& font);
107 void SetSelectedFont(const wxFont& font);
108 void SetMeasuringFont(const wxFont& font);
109
110private:
111
112 wxFont m_normal_font;
113 wxFont m_selected_font;
114 wxFont m_measuring_font;
115 wxPen m_normal_bkpen;
116 wxPen m_selected_bkpen;
117 wxBrush m_normal_bkbrush;
118 wxBrush m_selected_bkbrush;
119 wxBrush m_bkbrush;
4953f8cf
BW
120 wxBitmap m_active_close_bmp;
121 wxBitmap m_disabled_close_bmp;
122 wxBitmap m_active_left_bmp;
123 wxBitmap m_disabled_left_bmp;
124 wxBitmap m_active_right_bmp;
125 wxBitmap m_disabled_right_bmp;
3f69756e
BW
126};
127
128
129
a3219eea
BW
130// event declarations/classes
131
132class WXDLLIMPEXP_AUI wxAuiNotebookEvent : public wxNotifyEvent
133{
134public:
135 wxAuiNotebookEvent(wxEventType command_type = wxEVT_NULL,
136 int win_id = 0)
137 : wxNotifyEvent(command_type, win_id)
138 {
139 }
140#ifndef SWIG
141 wxAuiNotebookEvent(const wxAuiNotebookEvent& c) : wxNotifyEvent(c)
142 {
143 old_selection = c.old_selection;
144 selection = c.selection;
145 }
146#endif
147 wxEvent *Clone() const { return new wxAuiNotebookEvent(*this); }
148
149 void SetSelection(int s) { selection = s; }
150 void SetOldSelection(int s) { old_selection = s; }
151 int GetSelection() const { return selection; }
152 int GetOldSelection() const { return old_selection; }
4444d148 153
a3219eea
BW
154public:
155 int old_selection;
156 int selection;
4444d148 157
a3219eea
BW
158#ifndef SWIG
159private:
160 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent)
161#endif
162};
163
164
165
166
167
168class WXDLLIMPEXP_AUI wxAuiNotebookPage
169{
170public:
171 wxWindow* window; // page's associated window
172 wxString caption; // caption displayed on the tab
173 wxBitmap bitmap; // tab's bitmap
174 wxRect rect; // tab's hit rectangle
175 bool active; // true if the page is currently active
176};
177
178class WXDLLIMPEXP_AUI wxAuiTabContainerButton
179{
180public:
181 int id; // button's id
4953f8cf 182 int cur_state; // current state (normal, hover, pressed, etc.)
b6418695 183 int location; // buttons location (wxLEFT or wxRIGHT)
4953f8cf
BW
184 wxBitmap bitmap; // button's hover bitmap
185 wxBitmap dis_bitmap; // button's disabled bitmap
a3219eea
BW
186 wxRect rect; // button's hit rectangle
187};
188
189
d91fa282 190#ifndef SWIG
a3219eea
BW
191WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage, wxAuiNotebookPageArray, WXDLLIMPEXP_AUI);
192WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton, wxAuiTabContainerButtonArray, WXDLLIMPEXP_AUI);
d91fa282 193#endif
a3219eea
BW
194
195
196class WXDLLIMPEXP_AUI wxAuiTabContainer
197{
198public:
199
200 wxAuiTabContainer();
9fabaac4 201 virtual ~wxAuiTabContainer();
a3219eea 202
3f69756e
BW
203 void SetArtProvider(wxTabArt* art);
204 wxTabArt* GetArtProvider();
205
a3219eea
BW
206 bool AddPage(wxWindow* page, const wxAuiNotebookPage& info);
207 bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx);
208 bool RemovePage(wxWindow* page);
209 bool SetActivePage(wxWindow* page);
210 bool SetActivePage(size_t page);
211 void SetNoneActive();
212 int GetActivePage() const;
213 bool TabHitTest(int x, int y, wxWindow** hit) const;
214 bool ButtonHitTest(int x, int y, wxAuiTabContainerButton** hit) const;
215 wxWindow* GetWindowFromIdx(size_t idx) const;
216 int GetIdxFromWindow(wxWindow* page) const;
217 size_t GetPageCount() const;
218 wxAuiNotebookPage& GetPage(size_t idx);
219 wxAuiNotebookPageArray& GetPages();
220 void SetNormalFont(const wxFont& normal_font);
221 void SetSelectedFont(const wxFont& selected_font);
222 void SetMeasuringFont(const wxFont& measuring_font);
223 void DoShowHide();
224 void SetRect(const wxRect& rect);
4953f8cf
BW
225 void AddButton(int id,
226 int location,
227 const wxBitmap& normal_bitmap = wxNullBitmap,
228 const wxBitmap& disabled_bitmap = wxNullBitmap);
4444d148 229
4953f8cf
BW
230 size_t GetTabOffset() const;
231 void SetTabOffset(size_t offset);
232
a3219eea
BW
233protected:
234
4444d148 235 virtual void Render(wxDC* dc);
a3219eea 236
a3219eea
BW
237private:
238
3f69756e 239 wxTabArt* m_art;
a3219eea
BW
240 wxAuiNotebookPageArray m_pages;
241 wxAuiTabContainerButtonArray m_buttons;
242 wxRect m_rect;
4953f8cf 243 size_t m_tab_offset;
a3219eea
BW
244};
245
246
247
248class WXDLLIMPEXP_AUI wxAuiTabCtrl : public wxControl,
249 public wxAuiTabContainer
250{
251public:
252
253 wxAuiTabCtrl(wxWindow* parent,
d91fa282 254 wxWindowID id = wxID_ANY,
a3219eea
BW
255 const wxPoint& pos = wxDefaultPosition,
256 const wxSize& size = wxDefaultSize,
257 long style = 0);
4444d148 258
a3219eea
BW
259protected:
260
261 void OnPaint(wxPaintEvent& evt);
262 void OnEraseBackground(wxEraseEvent& evt);
263 void OnSize(wxSizeEvent& evt);
264 void OnLeftDown(wxMouseEvent& evt);
265 void OnLeftUp(wxMouseEvent& evt);
266 void OnMotion(wxMouseEvent& evt);
267 void OnLeaveWindow(wxMouseEvent& evt);
4953f8cf 268 void OnButton(wxAuiNotebookEvent& evt);
4444d148 269
4953f8cf 270
a3219eea 271protected:
4444d148 272
a3219eea
BW
273 wxPoint m_click_pt;
274 int m_click_tab;
275 bool m_is_dragging;
276 wxAuiTabContainerButton* m_hover_button;
277
d91fa282 278#ifndef SWIG
a3219eea 279 DECLARE_EVENT_TABLE()
d91fa282 280#endif
a3219eea
BW
281};
282
283
284
285
286class WXDLLIMPEXP_AUI wxAuiMultiNotebook : public wxControl
287{
288
289public:
290
291 wxAuiMultiNotebook();
4444d148 292
a3219eea 293 wxAuiMultiNotebook(wxWindow* parent,
d91fa282 294 wxWindowID id = wxID_ANY,
a3219eea
BW
295 const wxPoint& pos = wxDefaultPosition,
296 const wxSize& size = wxDefaultSize,
297 long style = 0);
4444d148 298
a3219eea
BW
299 virtual ~wxAuiMultiNotebook();
300
301 bool Create(wxWindow* parent,
d91fa282 302 wxWindowID id = wxID_ANY,
a3219eea
BW
303 const wxPoint& pos = wxDefaultPosition,
304 const wxSize& size = wxDefaultSize,
4444d148 305 long style = 0);
a3219eea
BW
306
307 bool AddPage(wxWindow* page,
308 const wxString& caption,
309 bool select = false,
310 const wxBitmap& bitmap = wxNullBitmap);
4444d148 311
a3219eea
BW
312 bool InsertPage(size_t page_idx,
313 wxWindow* page,
314 const wxString& caption,
315 bool select = false,
316 const wxBitmap& bitmap = wxNullBitmap);
4444d148 317
a3219eea
BW
318 bool DeletePage(size_t page);
319 bool RemovePage(size_t page);
4444d148 320
a3219eea
BW
321 bool SetPageText(size_t page, const wxString& text);
322 size_t SetSelection(size_t new_page);
323 int GetSelection() const;
324 size_t GetPageCount() const;
325 wxWindow* GetPage(size_t page_idx) const;
4444d148 326
3f69756e
BW
327 void SetArtProvider(wxTabArt* art);
328 wxTabArt* GetArtProvider();
329
a3219eea 330protected:
4444d148 331
a3219eea
BW
332 wxAuiTabCtrl* GetTabCtrlFromPoint(const wxPoint& pt);
333 wxWindow* GetTabFrameFromTabCtrl(wxWindow* tab_ctrl);
334 wxAuiTabCtrl* GetActiveTabCtrl();
335 bool FindTab(wxWindow* page, wxAuiTabCtrl** ctrl, int* idx);
336 void RemoveEmptyTabFrames();
4444d148 337
a3219eea
BW
338protected:
339
340 void DoSizing();
341 void InitNotebook();
4444d148 342
a3219eea
BW
343 void OnChildFocus(wxChildFocusEvent& evt);
344 void OnRender(wxFrameManagerEvent& evt);
345 void OnEraseBackground(wxEraseEvent& evt);
346 void OnSize(wxSizeEvent& evt);
347 void OnTabClicked(wxCommandEvent& evt);
348 void OnTabBeginDrag(wxCommandEvent& evt);
349 void OnTabDragMotion(wxCommandEvent& evt);
350 void OnTabEndDrag(wxCommandEvent& evt);
351 void OnTabButton(wxCommandEvent& evt);
4953f8cf 352
a3219eea
BW
353protected:
354
355 wxFrameManager m_mgr;
356 wxAuiTabContainer m_tabs;
357 int m_curpage;
358 int m_tab_id_counter;
359 wxWindow* m_dummy_wnd;
4444d148 360
a3219eea
BW
361 wxFont m_selected_font;
362 wxFont m_normal_font;
da5e85d9 363 int m_tab_ctrl_height;
4444d148 364
d91fa282 365#ifndef SWIG
a3219eea 366 DECLARE_EVENT_TABLE()
d91fa282 367#endif
a3219eea
BW
368};
369
370
371
372
373// wx event machinery
374
375#ifndef SWIG
376
377BEGIN_DECLARE_EVENT_TYPES()
378 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0)
379 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0)
380 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0)
381 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0)
382 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0)
383 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 0)
384END_DECLARE_EVENT_TYPES()
385
386typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&);
387
388#define wxAuiNotebookEventHandler(func) \
389 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
390
391#define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
392 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
393#define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
394 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
4953f8cf 395#define EVT_AUINOTEBOOK_BUTTON(winid, fn) \
a3219eea
BW
396 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
397#define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
398 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
399#define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
400 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
401#define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
402 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
4444d148 403
a3219eea
BW
404#else
405
406// wxpython/swig event work
d91fa282
RD
407%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED;
408%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING;
409%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON;
410%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG;
411%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG;
412%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION;
413
414%pythoncode {
415 EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 )
416 EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 )
417 EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 )
418 EVT_AUINOTEBOOK_BEGIN_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 1 )
419 EVT_AUINOTEBOOK_END_DRAG = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 1 )
4444d148 420 EVT_AUINOTEBOOK_DRAG_MOTION = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, 1 )
d91fa282 421}
a3219eea
BW
422#endif
423
424
425#endif // wxUSE_AUI
426#endif // _WX_AUINOTEBOOK_H_