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
60 // aui notebook event class
62 class WXDLLIMPEXP_AUI wxAuiNotebookEvent
: public wxNotifyEvent
65 wxAuiNotebookEvent(wxEventType command_type
= wxEVT_NULL
,
67 : wxNotifyEvent(command_type
, win_id
)
74 wxAuiNotebookEvent(const wxAuiNotebookEvent
& c
) : wxNotifyEvent(c
)
76 old_selection
= c
.old_selection
;
77 selection
= c
.selection
;
78 drag_source
= c
.drag_source
;
81 wxEvent
*Clone() const { return new wxAuiNotebookEvent(*this); }
83 void SetSelection(int s
) { selection
= s
; m_commandInt
= s
; }
84 int GetSelection() const { return selection
; }
86 void SetOldSelection(int s
) { old_selection
= s
; }
87 int GetOldSelection() const { return old_selection
; }
89 void SetDragSource(wxAuiNotebook
* s
) { drag_source
= s
; }
90 wxAuiNotebook
* GetDragSource() const { return drag_source
; }
95 wxAuiNotebook
* drag_source
;
99 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxAuiNotebookEvent
)
104 class WXDLLIMPEXP_AUI wxAuiNotebookPage
107 wxWindow
* window
; // page's associated window
108 wxString caption
; // caption displayed on the tab
109 wxBitmap bitmap
; // tab's bitmap
110 wxRect rect
; // tab's hit rectangle
111 bool active
; // true if the page is currently active
114 class WXDLLIMPEXP_AUI wxAuiTabContainerButton
118 int id
; // button's id
119 int cur_state
; // current state (normal, hover, pressed, etc.)
120 int location
; // buttons location (wxLEFT, wxRIGHT, or wxCENTER)
121 wxBitmap bitmap
; // button's hover bitmap
122 wxBitmap dis_bitmap
; // button's disabled bitmap
123 wxRect rect
; // button's hit rectangle
128 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiNotebookPage
, wxAuiNotebookPageArray
, WXDLLIMPEXP_AUI
);
129 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxAuiTabContainerButton
, wxAuiTabContainerButtonArray
, WXDLLIMPEXP_AUI
);
135 class WXDLLIMPEXP_AUI wxAuiTabArt
140 virtual ~wxAuiTabArt() { }
142 virtual wxAuiTabArt
* Clone() = 0;
143 virtual void SetFlags(unsigned int flags
) = 0;
145 virtual void SetSizingInfo(const wxSize
& tab_ctrl_size
,
146 size_t tab_count
) = 0;
148 virtual void SetNormalFont(const wxFont
& font
) = 0;
149 virtual void SetSelectedFont(const wxFont
& font
) = 0;
150 virtual void SetMeasuringFont(const wxFont
& font
) = 0;
152 virtual void DrawBackground(
155 const wxRect
& rect
) = 0;
157 virtual void DrawTab(wxDC
& dc
,
159 const wxRect
& in_rect
,
160 const wxString
& caption
,
161 const wxBitmap
& bitmap
,
163 int close_button_state
,
164 wxRect
* out_tab_rect
,
165 wxRect
* out_button_rect
,
168 virtual void DrawButton(
171 const wxRect
& in_rect
,
175 const wxBitmap
& bitmap_override
,
176 wxRect
* out_rect
) = 0;
178 virtual int GetIndentSize() = 0;
180 virtual wxSize
GetTabSize(
183 const wxString
& caption
,
184 const wxBitmap
& bitmap
,
186 int close_button_state
,
189 virtual int ShowWindowList(
191 const wxArrayString
& items
,
194 virtual int GetBestTabCtrlSize(wxWindow
* wnd
,
195 wxAuiNotebookPageArray
& pages
) = 0;
199 class WXDLLIMPEXP_AUI wxAuiDefaultTabArt
: public wxAuiTabArt
204 wxAuiDefaultTabArt();
205 virtual ~wxAuiDefaultTabArt();
207 wxAuiTabArt
* Clone();
208 void SetFlags(unsigned int flags
);
209 void SetSizingInfo(const wxSize
& tab_ctrl_size
,
212 void SetNormalFont(const wxFont
& font
);
213 void SetSelectedFont(const wxFont
& font
);
214 void SetMeasuringFont(const wxFont
& font
);
221 void DrawTab(wxDC
& dc
,
223 const wxRect
& in_rect
,
224 const wxString
& caption
,
225 const wxBitmap
& bitmap
,
227 int close_button_state
,
228 wxRect
* out_tab_rect
,
229 wxRect
* out_button_rect
,
235 const wxRect
& in_rect
,
239 const wxBitmap
& bitmap_override
,
247 const wxString
& caption
,
248 const wxBitmap
& bitmap
,
250 int close_button_state
,
255 const wxArrayString
& items
,
258 int GetBestTabCtrlSize(wxWindow
* wnd
,
259 wxAuiNotebookPageArray
& pages
);
263 wxFont m_normal_font
;
264 wxFont m_selected_font
;
265 wxFont m_measuring_font
;
266 wxColour m_base_colour
;
267 wxPen m_base_colour_pen
;
269 wxBrush m_base_colour_brush
;
270 wxBitmap m_active_close_bmp
;
271 wxBitmap m_disabled_close_bmp
;
272 wxBitmap m_active_left_bmp
;
273 wxBitmap m_disabled_left_bmp
;
274 wxBitmap m_active_right_bmp
;
275 wxBitmap m_disabled_right_bmp
;
276 wxBitmap m_active_windowlist_bmp
;
277 wxBitmap m_disabled_windowlist_bmp
;
279 int m_fixed_tab_width
;
280 int m_tab_ctrl_height
;
281 unsigned int m_flags
;
285 class WXDLLIMPEXP_AUI wxAuiSimpleTabArt
: public wxAuiTabArt
291 virtual ~wxAuiSimpleTabArt();
293 wxAuiTabArt
* Clone();
294 void SetFlags(unsigned int flags
);
296 void SetSizingInfo(const wxSize
& tab_ctrl_size
,
299 void SetNormalFont(const wxFont
& font
);
300 void SetSelectedFont(const wxFont
& font
);
301 void SetMeasuringFont(const wxFont
& font
);
308 void DrawTab(wxDC
& dc
,
310 const wxRect
& in_rect
,
311 const wxString
& caption
,
312 const wxBitmap
& bitmap
,
314 int close_button_state
,
315 wxRect
* out_tab_rect
,
316 wxRect
* out_button_rect
,
322 const wxRect
& in_rect
,
326 const wxBitmap
& bitmap_override
,
334 const wxString
& caption
,
335 const wxBitmap
& bitmap
,
337 int close_button_state
,
342 const wxArrayString
& items
,
345 int GetBestTabCtrlSize(wxWindow
* wnd
,
346 wxAuiNotebookPageArray
& pages
);
350 wxFont m_normal_font
;
351 wxFont m_selected_font
;
352 wxFont m_measuring_font
;
353 wxPen m_normal_bkpen
;
354 wxPen m_selected_bkpen
;
355 wxBrush m_normal_bkbrush
;
356 wxBrush m_selected_bkbrush
;
358 wxBitmap m_active_close_bmp
;
359 wxBitmap m_disabled_close_bmp
;
360 wxBitmap m_active_left_bmp
;
361 wxBitmap m_disabled_left_bmp
;
362 wxBitmap m_active_right_bmp
;
363 wxBitmap m_disabled_right_bmp
;
364 wxBitmap m_active_windowlist_bmp
;
365 wxBitmap m_disabled_windowlist_bmp
;
367 int m_fixed_tab_width
;
368 unsigned int m_flags
;
379 class WXDLLIMPEXP_AUI wxAuiTabContainer
384 virtual ~wxAuiTabContainer();
386 void SetArtProvider(wxAuiTabArt
* art
);
387 wxAuiTabArt
* GetArtProvider() const;
389 void SetFlags(unsigned int flags
);
390 unsigned int GetFlags() const;
392 bool AddPage(wxWindow
* page
, const wxAuiNotebookPage
& info
);
393 bool InsertPage(wxWindow
* page
, const wxAuiNotebookPage
& info
, size_t idx
);
394 bool MovePage(wxWindow
* page
, size_t new_idx
);
395 bool RemovePage(wxWindow
* page
);
396 bool SetActivePage(wxWindow
* page
);
397 bool SetActivePage(size_t page
);
398 void SetNoneActive();
399 int GetActivePage() const;
400 bool TabHitTest(int x
, int y
, wxWindow
** hit
) const;
401 bool ButtonHitTest(int x
, int y
, wxAuiTabContainerButton
** hit
) const;
402 wxWindow
* GetWindowFromIdx(size_t idx
) const;
403 int GetIdxFromWindow(wxWindow
* page
) const;
404 size_t GetPageCount() const;
405 wxAuiNotebookPage
& GetPage(size_t idx
);
406 wxAuiNotebookPageArray
& GetPages();
407 void SetNormalFont(const wxFont
& normal_font
);
408 void SetSelectedFont(const wxFont
& selected_font
);
409 void SetMeasuringFont(const wxFont
& measuring_font
);
411 void SetRect(const wxRect
& rect
);
413 void RemoveButton(int id
);
414 void AddButton(int id
,
416 const wxBitmap
& normal_bitmap
= wxNullBitmap
,
417 const wxBitmap
& disabled_bitmap
= wxNullBitmap
);
419 size_t GetTabOffset() const;
420 void SetTabOffset(size_t offset
);
424 virtual void Render(wxDC
* dc
, wxWindow
* wnd
);
429 wxAuiNotebookPageArray m_pages
;
430 wxAuiTabContainerButtonArray m_buttons
;
431 wxAuiTabContainerButtonArray m_tab_close_buttons
;
434 unsigned int m_flags
;
439 class WXDLLIMPEXP_AUI wxAuiTabCtrl
: public wxControl
,
440 public wxAuiTabContainer
444 wxAuiTabCtrl(wxWindow
* parent
,
445 wxWindowID id
= wxID_ANY
,
446 const wxPoint
& pos
= wxDefaultPosition
,
447 const wxSize
& size
= wxDefaultSize
,
454 void OnPaint(wxPaintEvent
& evt
);
455 void OnEraseBackground(wxEraseEvent
& evt
);
456 void OnSize(wxSizeEvent
& evt
);
457 void OnLeftDown(wxMouseEvent
& evt
);
458 void OnLeftUp(wxMouseEvent
& evt
);
459 void OnMotion(wxMouseEvent
& evt
);
460 void OnLeaveWindow(wxMouseEvent
& evt
);
461 void OnButton(wxAuiNotebookEvent
& evt
);
467 wxWindow
* m_click_tab
;
469 wxAuiTabContainerButton
* m_hover_button
;
470 wxAuiTabContainerButton
* m_pressed_button
;
473 DECLARE_CLASS(wxAuiTabCtrl
)
474 DECLARE_EVENT_TABLE()
481 class WXDLLIMPEXP_AUI wxAuiNotebook
: public wxControl
488 wxAuiNotebook(wxWindow
* parent
,
489 wxWindowID id
= wxID_ANY
,
490 const wxPoint
& pos
= wxDefaultPosition
,
491 const wxSize
& size
= wxDefaultSize
,
492 long style
= wxAUI_NB_DEFAULT_STYLE
);
494 virtual ~wxAuiNotebook();
496 bool Create(wxWindow
* parent
,
497 wxWindowID id
= wxID_ANY
,
498 const wxPoint
& pos
= wxDefaultPosition
,
499 const wxSize
& size
= wxDefaultSize
,
502 bool AddPage(wxWindow
* page
,
503 const wxString
& caption
,
505 const wxBitmap
& bitmap
= wxNullBitmap
);
507 bool InsertPage(size_t page_idx
,
509 const wxString
& caption
,
511 const wxBitmap
& bitmap
= wxNullBitmap
);
513 bool DeletePage(size_t page
);
514 bool RemovePage(size_t page
);
516 void SetWindowStyleFlag(long style
);
518 bool SetPageText(size_t page
, const wxString
& text
);
519 bool SetPageBitmap(size_t page
, const wxBitmap
& bitmap
);
520 size_t SetSelection(size_t new_page
);
521 int GetSelection() const;
522 size_t GetPageCount() const;
523 wxWindow
* GetPage(size_t page_idx
) const;
525 int GetPageIndex(wxWindow
* page_wnd
) const;
527 void SetArtProvider(wxAuiTabArt
* art
);
528 wxAuiTabArt
* GetArtProvider() const;
532 // these can be overridden
533 virtual void SetTabCtrlHeight(int height
);
534 virtual int CalculateTabCtrlHeight();
539 void InitNotebook(long style
);
540 wxAuiTabCtrl
* GetTabCtrlFromPoint(const wxPoint
& pt
);
541 wxWindow
* GetTabFrameFromTabCtrl(wxWindow
* tab_ctrl
);
542 wxAuiTabCtrl
* GetActiveTabCtrl();
543 bool FindTab(wxWindow
* page
, wxAuiTabCtrl
** ctrl
, int* idx
);
544 void RemoveEmptyTabFrames();
549 void OnChildFocus(wxChildFocusEvent
& evt
);
550 void OnRender(wxAuiManagerEvent
& evt
);
551 void OnEraseBackground(wxEraseEvent
& evt
);
552 void OnSize(wxSizeEvent
& evt
);
553 void OnTabClicked(wxCommandEvent
& evt
);
554 void OnTabBeginDrag(wxCommandEvent
& evt
);
555 void OnTabDragMotion(wxCommandEvent
& evt
);
556 void OnTabEndDrag(wxCommandEvent
& evt
);
557 void OnTabButton(wxCommandEvent
& evt
);
562 wxAuiTabContainer m_tabs
;
564 int m_tab_id_counter
;
565 wxWindow
* m_dummy_wnd
;
567 wxFont m_selected_font
;
568 wxFont m_normal_font
;
569 int m_tab_ctrl_height
;
572 unsigned int m_flags
;
575 DECLARE_CLASS(wxAuiNotebook
)
576 DECLARE_EVENT_TABLE()
583 // wx event machinery
587 BEGIN_DECLARE_EVENT_TYPES()
588 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE
, 0)
589 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 0)
590 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 0)
591 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 0)
592 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 0)
593 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 0)
594 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 0)
595 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI
, wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND
, 0)
596 END_DECLARE_EVENT_TYPES()
598 typedef void (wxEvtHandler
::*wxAuiNotebookEventFunction
)(wxAuiNotebookEvent
&);
600 #define wxAuiNotebookEventHandler(func) \
601 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxAuiNotebookEventFunction, &func)
603 #define EVT_AUINOTEBOOK_PAGE_CLOSE(winid, fn) \
604 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, winid, wxAuiNotebookEventHandler(fn))
605 #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \
606 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn))
607 #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \
608 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, winid, wxAuiNotebookEventHandler(fn))
609 #define EVT_AUINOTEBOOK_BUTTON(winid, fn) \
610 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, winid, wxAuiNotebookEventHandler(fn))
611 #define EVT_AUINOTEBOOK_BEGIN_DRAG(winid, fn) \
612 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, winid, wxAuiNotebookEventHandler(fn))
613 #define EVT_AUINOTEBOOK_END_DRAG(winid, fn) \
614 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, winid, wxAuiNotebookEventHandler(fn))
615 #define EVT_AUINOTEBOOK_DRAG_MOTION(winid, fn) \
616 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn))
617 #define EVT_AUINOTEBOOK_ALLOW_DND(winid, fn) \
618 wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, winid, wxAuiNotebookEventHandler(fn))
622 // wxpython/swig event work
623 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE
;
624 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
;
625 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
;
626 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON
;
627 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
;
628 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
;
629 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
;
630 %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND
;
633 EVT_AUINOTEBOOK_PAGE_CLOSE
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE
, 1 )
634 EVT_AUINOTEBOOK_PAGE_CHANGED
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED
, 1 )
635 EVT_AUINOTEBOOK_PAGE_CHANGING
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING
, 1 )
636 EVT_AUINOTEBOOK_BUTTON
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON
, 1 )
637 EVT_AUINOTEBOOK_BEGIN_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG
, 1 )
638 EVT_AUINOTEBOOK_END_DRAG
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG
, 1 )
639 EVT_AUINOTEBOOK_DRAG_MOTION
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION
, 1 )
640 EVT_AUINOTEBOOK_ALLOW_DND
= wx
.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND
, 1 )
646 #endif // _WX_AUINOTEBOOK_H_