1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/aui/auibook.h
3 // Purpose: wxaui: wx advanced user interface - notebook
4 // Author: Benjamin I. Williams
7 // Copyright: (C) Copyright 2006, Kirix Corporation, All Rights Reserved.
8 // Licence: wxWindows Library Licence, Version 3.1
9 ///////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_AUINOTEBOOK_H_
14 #define _WX_AUINOTEBOOK_H_
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
24 #include "wx/aui/framemanager.h"
25 #include "wx/aui/dockart.h"
26 #include "wx/aui/floatpane.h"
27 #include "wx/control.h"
33 enum wxAuiNotebookOption
35 wxAUI_NB_TOP
= 1 << 0,
36 wxAUI_NB_LEFT
= 1 << 1, // not implemented yet
37 wxAUI_NB_RIGHT
= 1 << 2, // not implemented yet
38 wxAUI_NB_BOTTOM
= 1 << 3, // not implemented yet
39 wxAUI_NB_TAB_SPLIT
= 1 << 4,
40 wxAUI_NB_TAB_MOVE
= 1 << 5,
41 wxAUI_NB_TAB_EXTERNAL_MOVE
= 1 << 6,
42 wxAUI_NB_TAB_FIXED_WIDTH
= 1 << 7,
43 wxAUI_NB_SCROLL_BUTTONS
= 1 << 8,
44 wxAUI_NB_WINDOWLIST_BUTTON
= 1 << 9,
45 wxAUI_NB_CLOSE_BUTTON
= 1 << 10,
46 wxAUI_NB_CLOSE_ON_ACTIVE_TAB
= 1 << 11,
47 wxAUI_NB_CLOSE_ON_ALL_TABS
= 1 << 12,
50 wxAUI_NB_DEFAULT_STYLE
= wxAUI_NB_TOP
|
53 wxAUI_NB_SCROLL_BUTTONS
|
54 wxAUI_NB_CLOSE_ON_ACTIVE_TAB
62 class WXDLLIMPEXP_AUI wxAuiTabArt
67 virtual ~wxAuiTabArt() { }
69 virtual wxAuiTabArt
* Clone() = 0;
70 virtual void SetFlags(unsigned int flags
) = 0;
72 virtual void SetSizingInfo(const wxSize
& tab_ctrl_size
,
73 size_t tab_count
) = 0;
75 virtual void SetNormalFont(const wxFont
& font
) = 0;
76 virtual void SetSelectedFont(const wxFont
& font
) = 0;
77 virtual void SetMeasuringFont(const wxFont
& font
) = 0;
79 virtual void DrawBackground(
82 const wxRect
& rect
) = 0;
84 virtual void DrawTab(wxDC
& dc
,
86 const wxRect
& in_rect
,
87 const wxString
& caption
,
89 int close_button_state
,
91 wxRect
* out_button_rect
,
94 virtual void DrawButton(
97 const wxRect
& in_rect
,
101 const wxBitmap
& bitmap_override
,
102 wxRect
* out_rect
) = 0;
104 virtual int GetIndentSize() = 0;
106 virtual wxSize
GetTabSize(
109 const wxString
& caption
,
111 int close_button_state
,
114 virtual int ShowWindowList(
116 const wxArrayString
& items
,
119 virtual int GetBestTabCtrlSize(wxWindow
* wnd
) = 0;
123 class WXDLLIMPEXP_AUI wxAuiSimpleTabArt
: public wxAuiTabArt
129 virtual ~wxAuiSimpleTabArt();
131 wxAuiTabArt
* Clone();
132 void SetFlags(unsigned int flags
);
134 void SetSizingInfo(const wxSize
& tab_ctrl_size
,
137 void SetNormalFont(const wxFont
& font
);
138 void SetSelectedFont(const wxFont
& font
);
139 void SetMeasuringFont(const wxFont
& font
);
146 void DrawTab(wxDC
& dc
,
148 const wxRect
& in_rect
,
149 const wxString
& caption
,
151 int close_button_state
,
152 wxRect
* out_tab_rect
,
153 wxRect
* out_button_rect
,
159 const wxRect
& in_rect
,
163 const wxBitmap
& bitmap_override
,
171 const wxString
& caption
,
173 int close_button_state
,
178 const wxArrayString
& items
,
181 int GetBestTabCtrlSize(wxWindow
* wnd
);
185 wxFont m_normal_font
;
186 wxFont m_selected_font
;
187 wxFont m_measuring_font
;
188 wxPen m_normal_bkpen
;
189 wxPen m_selected_bkpen
;
190 wxBrush m_normal_bkbrush
;
191 wxBrush m_selected_bkbrush
;
193 wxBitmap m_active_close_bmp
;
194 wxBitmap m_disabled_close_bmp
;
195 wxBitmap m_active_left_bmp
;
196 wxBitmap m_disabled_left_bmp
;
197 wxBitmap m_active_right_bmp
;
198 wxBitmap m_disabled_right_bmp
;
199 wxBitmap m_active_windowlist_bmp
;
200 wxBitmap m_disabled_windowlist_bmp
;
202 int m_fixed_tab_width
;
203 unsigned int m_flags
;
207 class WXDLLIMPEXP_AUI wxAuiDefaultTabArt
: public wxAuiTabArt
212 wxAuiDefaultTabArt();
213 virtual ~wxAuiDefaultTabArt();
215 wxAuiTabArt
* Clone();
216 void SetFlags(unsigned int flags
);
217 void SetSizingInfo(const wxSize
& tab_ctrl_size
,
220 void SetNormalFont(const wxFont
& font
);
221 void SetSelectedFont(const wxFont
& font
);
222 void SetMeasuringFont(const wxFont
& font
);
229 void DrawTab(wxDC
& dc
,
231 const wxRect
& in_rect
,
232 const wxString
& caption
,
234 int close_button_state
,
235 wxRect
* out_tab_rect
,
236 wxRect
* out_button_rect
,
242 const wxRect
& in_rect
,
246 const wxBitmap
& bitmap_override
,
254 const wxString
& caption
,
256 int close_button_state
,
261 const wxArrayString
& items
,
264 int GetBestTabCtrlSize(wxWindow
* wnd
);
268 wxFont m_normal_font
;
269 wxFont m_selected_font
;
270 wxFont m_measuring_font
;
271 wxPen m_normal_bkpen
;
272 wxPen m_selected_bkpen
;
273 wxBrush m_normal_bkbrush
;
274 wxBrush m_selected_bkbrush
;
276 wxBitmap m_active_close_bmp
;
277 wxBitmap m_disabled_close_bmp
;
278 wxBitmap m_active_left_bmp
;
279 wxBitmap m_disabled_left_bmp
;
280 wxBitmap m_active_right_bmp
;
281 wxBitmap m_disabled_right_bmp
;
282 wxBitmap m_active_windowlist_bmp
;
283 wxBitmap m_disabled_windowlist_bmp
;
285 int m_fixed_tab_width
;
286 unsigned int m_flags
;
292 // event declarations/classes
294 class WXDLLIMPEXP_AUI wxAuiNotebookEvent
: public wxNotifyEvent
297 wxAuiNotebookEvent(wxEventType command_type
= wxEVT_NULL
,
299 : wxNotifyEvent(command_type
, win_id
)
306 wxAuiNotebookEvent(const wxAuiNotebookEvent
& c
) : wxNotifyEvent(c
)
308 old_selection
= c
.old_selection
;
309 selection
= c
.selection
;
310 drag_source
= c
.drag_source
;
313 wxEvent
*Clone() const { return new wxAuiNotebookEvent(*this); }
315 void SetSelection(int s
) { selection
= s
; m_commandInt
= s
; }
316 int GetSelection() const { return selection
; }
318 void SetOldSelection(int s
) { old_selection
= s
; }
319 int GetOldSelection() const { return old_selection
; }
321 void SetDragSource(wxAuiNotebook
* s
) { drag_source
= s
; }
322 wxAuiNotebook
* GetDragSource() const { return drag_source
; }
327 wxAuiNotebook
* drag_source
;
331 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent
)
339 class WXDLLIMPEXP_AUI wxAuiNotebookPage
342 wxWindow
* window
; // page's associated window
343 wxString caption
; // caption displayed on the tab
344 wxBitmap bitmap
; // tab's bitmap
345 wxRect rect
; // tab's hit rectangle
346 bool active
; // true if the page is currently active
349 class WXDLLIMPEXP_AUI wxAuiTabContainerButton
353 int id
; // button's id
354 int cur_state
; // current state (normal, hover, pressed, etc.)
355 int location
; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
356 wxBitmap bitmap
; // button's hover bitmap
357 wxBitmap dis_bitmap
; // button's disabled bitmap
358 wxRect rect
; // button's hit rectangle
363 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage
, wxAuiNotebookPageArray
, WXDLLIMPEXP_AUI
);
364 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton
, wxAuiTabContainerButtonArray
, WXDLLIMPEXP_AUI
);
368 class WXDLLIMPEXP_AUI wxAuiTabContainer
373 virtual ~wxAuiTabContainer();
375 void SetArtProvider(wxAuiTabArt
* art
);
376 wxAuiTabArt
* GetArtProvider();
378 void SetFlags(unsigned int flags
);
379 unsigned int GetFlags() const;
381 bool AddPage(wxWindow
* page
, const wxAuiNotebookPage
& info
);
382 bool InsertPage(wxWindow
* page
, const wxAuiNotebookPage
& info
, size_t idx
);
383 bool MovePage(wxWindow
* page
, size_t new_idx
);
384 bool RemovePage(wxWindow
* page
);
385 bool SetActivePage(wxWindow
* page
);
386 bool SetActivePage(size_t page
);
387 void SetNoneActive();
388 int GetActivePage() const;
389 bool TabHitTest(int x
, int y
, wxWindow
** hit
) const;
390 bool ButtonHitTest(int x
, int y
, wxAuiTabContainerButton
** hit
) const;
391 wxWindow
* GetWindowFromIdx(size_t idx
) const;
392 int GetIdxFromWindow(wxWindow
* page
) const;
393 size_t GetPageCount() const;
394 wxAuiNotebookPage
& GetPage(size_t idx
);
395 wxAuiNotebookPageArray
& GetPages();
396 void SetNormalFont(const wxFont
& normal_font
);
397 void SetSelectedFont(const wxFont
& selected_font
);
398 void SetMeasuringFont(const wxFont
& measuring_font
);
400 void SetRect(const wxRect
& rect
);
402 void RemoveButton(int id
);
403 void AddButton(int id
,
405 const wxBitmap
& normal_bitmap
= wxNullBitmap
,
406 const wxBitmap
& disabled_bitmap
= wxNullBitmap
);
408 size_t GetTabOffset() const;
409 void SetTabOffset(size_t offset
);
413 virtual void Render(wxDC
* dc
, wxWindow
* wnd
);
418 wxAuiNotebookPageArray m_pages
;
419 wxAuiTabContainerButtonArray m_buttons
;
420 wxAuiTabContainerButtonArray m_tab_close_buttons
;
423 unsigned int m_flags
;
428 class WXDLLIMPEXP_AUI wxAuiTabCtrl
: public wxControl
,
429 public wxAuiTabContainer
433 wxAuiTabCtrl(wxWindow
* parent
,
434 wxWindowID id
= wxID_ANY
,
435 const wxPoint
& pos
= wxDefaultPosition
,
436 const wxSize
& size
= wxDefaultSize
,
443 void OnPaint(wxPaintEvent
& evt
);
444 void OnEraseBackground(wxEraseEvent
& evt
);
445 void OnSize(wxSizeEvent
& evt
);
446 void OnLeftDown(wxMouseEvent
& evt
);
447 void OnLeftUp(wxMouseEvent
& evt
);
448 void OnMotion(wxMouseEvent
& evt
);
449 void OnLeaveWindow(wxMouseEvent
& evt
);
450 void OnButton(wxAuiNotebookEvent
& evt
);
456 wxWindow
* m_click_tab
;
458 wxAuiTabContainerButton
* m_hover_button
;
461 DECLARE_CLASS(wxAuiTabCtrl
)
462 DECLARE_EVENT_TABLE()
469 class WXDLLIMPEXP_AUI wxAuiNotebook
: public wxControl
476 wxAuiNotebook(wxWindow
* parent
,
477 wxWindowID id
= wxID_ANY
,
478 const wxPoint
& pos
= wxDefaultPosition
,
479 const wxSize
& size
= wxDefaultSize
,
480 long style
= wxAUI_NB_DEFAULT_STYLE
);
482 virtual ~wxAuiNotebook();
484 bool Create(wxWindow
* parent
,
485 wxWindowID id
= wxID_ANY
,
486 const wxPoint
& pos
= wxDefaultPosition
,
487 const wxSize
& size
= wxDefaultSize
,
490 bool AddPage(wxWindow
* page
,
491 const wxString
& caption
,
493 const wxBitmap
& bitmap
= wxNullBitmap
);
495 bool InsertPage(size_t page_idx
,
497 const wxString
& caption
,
499 const wxBitmap
& bitmap
= wxNullBitmap
);
501 bool DeletePage(size_t page
);
502 bool RemovePage(size_t page
);
504 void SetWindowStyleFlag(long style
);
506 bool SetPageText(size_t page
, const wxString
& text
);
507 size_t SetSelection(size_t new_page
);
508 int GetSelection() const;
509 size_t GetPageCount() const;
510 wxWindow
* GetPage(size_t page_idx
) const;
513 void SetArtProvider(wxAuiTabArt
* art
);
514 wxAuiTabArt
* GetArtProvider();
518 wxAuiTabCtrl
* GetTabCtrlFromPoint(const wxPoint
& pt
);
519 wxWindow
* GetTabFrameFromTabCtrl(wxWindow
* tab_ctrl
);
520 wxAuiTabCtrl
* GetActiveTabCtrl();
521 bool FindTab(wxWindow
* page
, wxAuiTabCtrl
** ctrl
, int* idx
);
522 void RemoveEmptyTabFrames();
527 void InitNotebook(long style
);
529 void OnChildFocus(wxChildFocusEvent
& evt
);
530 void OnRender(wxAuiManagerEvent
& evt
);
531 void OnEraseBackground(wxEraseEvent
& evt
);
532 void OnSize(wxSizeEvent
& evt
);
533 void OnTabClicked(wxCommandEvent
& evt
);
534 void OnTabBeginDrag(wxCommandEvent
& evt
);
535 void OnTabDragMotion(wxCommandEvent
& evt
);
536 void OnTabEndDrag(wxCommandEvent
& evt
);
537 void OnTabButton(wxCommandEvent
& evt
);
542 wxAuiTabContainer m_tabs
;
544 int m_tab_id_counter
;
545 wxWindow
* m_dummy_wnd
;
547 wxFont m_selected_font
;
548 wxFont m_normal_font
;
549 int m_tab_ctrl_height
;
552 unsigned int m_flags
;
555 DECLARE_CLASS(wxAuiNotebook
)
556 DECLARE_EVENT_TABLE()
563 // wx event machinery
567 BEGIN_DECLARE_EVENT_TYPES()
568 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE
, 0)
569 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 0)
570 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 0)
571 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 0)
572 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 0)
573 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 0)
574 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 0)
575 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND
, 0)
576 END_DECLARE_EVENT_TYPES()
578 typedef void (wxEvtHandler::*wxAuiNotebookEventFunction
)(wxAuiNotebookEvent
&);
580 #define wxAuiNotebookEventHandler(func) \
581 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
583 #define EVT_AUINOTEBOOK_PAGE_CLOSE(winid, fn) \
584 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, winid, wxAuiNotebookEventHandler(fn))
585 #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
586 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
587 #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
588 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
589 #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \
590 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
591 #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
592 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
593 #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
594 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
595 #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
596 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
597 #define EVT_AUINOTEBOOK_ALLOW_DND(winid, fn) \
598 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, winid, wxAuiNotebookEventHandler(fn))
602 // wxpython/swig event work
603 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE
;
604 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
;
605 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
;
606 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON
;
607 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
;
608 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
;
609 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
;
610 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND
;
613 EVT_AUINOTEBOOK_PAGE_CLOSE
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE
, 1 )
614 EVT_AUINOTEBOOK_PAGE_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 1 )
615 EVT_AUINOTEBOOK_PAGE_CHANGING
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 1 )
616 EVT_AUINOTEBOOK_BUTTON
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 1 )
617 EVT_AUINOTEBOOK_BEGIN_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 1 )
618 EVT_AUINOTEBOOK_END_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 1 )
619 EVT_AUINOTEBOOK_DRAG_MOTION
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 1 )
620 EVT_AUINOTEBOOK_ALLOW_DND
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND
, 1 )
626 #endif // _WX_AUINOTEBOOK_H_