From 134198f1b773199b5506c302bf9510831d0319f5 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 21 Aug 2007 10:51:47 +0000 Subject: [PATCH] Applied patch [ 1747059 ] wxAUIDefaultTabArt wxAUI_NB_BOTTOM Langhammer git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48271 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/auinotebook.tex | 5 +- include/wx/aui/auibook.h | 19 +++++- src/aui/auibook.cpp | 105 +++++++++++++++++++++++++++------- 3 files changed, 105 insertions(+), 24 deletions(-) diff --git a/docs/latex/wx/auinotebook.tex b/docs/latex/wx/auinotebook.tex index 60686ef4ff..0a5809a624 100644 --- a/docs/latex/wx/auinotebook.tex +++ b/docs/latex/wx/auinotebook.tex @@ -38,8 +38,7 @@ The theme can be changed by calling \helpref{wxAuiNotebook::SetArtProvider}{wxau \twocolwidtha{5cm}% \begin{twocollist}\itemsep=0pt -\twocolitem{\windowstyle{wxAUI\_NB\_DEFAULT\_STYLE}}{Defined as wxAUI\_NB\_TOP | wxAUI\_NB\_TAB\_SPLIT | wxAUI\_NB\_TAB\_MOVE | wxAUI\_NB\_SCROLL\_BUTTONS | wxAUI\_NB\_CLOSE\_ON\_ACTIVE\_TAB -.} +\twocolitem{\windowstyle{wxAUI\_NB\_DEFAULT\_STYLE}}{Defined as wxAUI\_NB\_TOP | wxAUI\_NB\_TAB\_SPLIT | wxAUI\_NB\_TAB\_MOVE | wxAUI\_NB\_SCROLL\_BUTTONS | wxAUI\_NB\_CLOSE\_ON\_ACTIVE\_TAB.} \twocolitem{\windowstyle{wxAUI\_NB\_TAB\_SPLIT}}{Allows the tab control to be split by dragging a tab.} \twocolitem{\windowstyle{wxAUI\_NB\_TAB\_MOVE}}{Allows a tab to be moved horizontally by dragging.} \twocolitem{\windowstyle{wxAUI\_NB\_TAB\_EXTERNAL\_MOVE}}{Allows a tab to be moved to another tab control.} @@ -49,6 +48,8 @@ The theme can be changed by calling \helpref{wxAuiNotebook::SetArtProvider}{wxau \twocolitem{\windowstyle{wxAUI\_NB\_CLOSE\_BUTTON}}{With this style, a close button is available on the tab bar.} \twocolitem{\windowstyle{wxAUI\_NB\_CLOSE\_ON\_ACTIVE\_TAB}}{With this style, the close button is visible on the active tab.} \twocolitem{\windowstyle{wxAUI\_NB\_CLOSE\_ON\_ALL\_TABS}}{With this style, the close button is visible on all tabs.} +\twocolitem{\windowstyle{wxAUI\_NB\_TOP}}{With this style, tabs are drawn along the top of the notebook.} +\twocolitem{\windowstyle{wxAUI\_NB\_BOTTOM}}{With this style, tabs are drawn along the bottom of the notebook.} \end{twocollist} diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index 26398867a3..cd63a9f516 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -35,7 +35,7 @@ enum wxAuiNotebookOption wxAUI_NB_TOP = 1 << 0, wxAUI_NB_LEFT = 1 << 1, // not implemented yet wxAUI_NB_RIGHT = 1 << 2, // not implemented yet - wxAUI_NB_BOTTOM = 1 << 3, // not implemented yet + wxAUI_NB_BOTTOM = 1 << 3, wxAUI_NB_TAB_SPLIT = 1 << 4, wxAUI_NB_TAB_MOVE = 1 << 5, wxAUI_NB_TAB_EXTERNAL_MOVE = 1 << 6, @@ -460,6 +460,7 @@ protected: void OnEraseBackground(wxEraseEvent& evt); void OnSize(wxSizeEvent& evt); void OnLeftDown(wxMouseEvent& evt); + void OnLeftDClick(wxMouseEvent& evt); void OnLeftUp(wxMouseEvent& evt); void OnMiddleDown(wxMouseEvent& evt); void OnMiddleUp(wxMouseEvent& evt); @@ -610,6 +611,7 @@ protected: void OnTabMiddleUp(wxCommandEvent& evt); void OnTabRightDown(wxCommandEvent& evt); void OnTabRightUp(wxCommandEvent& evt); + void OnTabBgDClick(wxCommandEvent& evt); void OnNavigationKeyNotebook(wxNavigationKeyEvent& event); // set selection to the given window (which must be non-NULL and be one of @@ -657,6 +659,7 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 0) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, 0) @@ -666,6 +669,8 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, 0) DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, 0) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, 0) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_AUI, wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, 0) END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); @@ -675,6 +680,8 @@ typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); #define EVT_AUINOTEBOOK_PAGE_CLOSE(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, winid, wxAuiNotebookEventHandler(fn)) +#define EVT_AUINOTEBOOK_PAGE_CLOSED(winid, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, winid, wxAuiNotebookEventHandler(fn)) #define EVT_AUINOTEBOOK_PAGE_CHANGED(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, winid, wxAuiNotebookEventHandler(fn)) #define EVT_AUINOTEBOOK_PAGE_CHANGING(winid, fn) \ @@ -689,6 +696,8 @@ typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, winid, wxAuiNotebookEventHandler(fn)) #define EVT_AUINOTEBOOK_ALLOW_DND(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, winid, wxAuiNotebookEventHandler(fn)) +#define EVT_AUINOTEBOOK_DRAG_DONE(winid, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, winid, wxAuiNotebookEventHandler(fn)) #define EVT_AUINOTEBOOK_TAB_MIDDLE_DOWN(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, winid, wxAuiNotebookEventHandler(fn)) #define EVT_AUINOTEBOOK_TAB_MIDDLE_UP(winid, fn) \ @@ -697,10 +706,13 @@ typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, winid, wxAuiNotebookEventHandler(fn)) #define EVT_AUINOTEBOOK_TAB_RIGHT_UP(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, winid, wxAuiNotebookEventHandler(fn)) +#define EVT_AUINOTEBOOK_BG_DCLICK(winid, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, winid, wxAuiNotebookEventHandler(fn)) #else // wxpython/swig event work %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE; +%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED; %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED; %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING; %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BUTTON; @@ -708,8 +720,11 @@ typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_END_DRAG; %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION; %constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND; +%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE; +%constant wxEventType wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK; %pythoncode { EVT_AUINOTEBOOK_PAGE_CLOSE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, 1 ) + EVT_AUINOTEBOOK_PAGE_CLOSED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, 1 ) EVT_AUINOTEBOOK_PAGE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, 1 ) EVT_AUINOTEBOOK_PAGE_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, 1 ) EVT_AUINOTEBOOK_BUTTON = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BUTTON, 1 ) @@ -719,6 +734,8 @@ typedef void (wxEvtHandler::*wxAuiNotebookEventFunction)(wxAuiNotebookEvent&); EVT_AUINOTEBOOK_ALLOW_DND = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, 1 ) EVT_AUINOTEBOOK_NAVIGATE_FORWARD = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_NAVIGATE_FORWARD, 1 ) EVT_AUINOTEBOOK_NAVIGATE_BACK = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_NAVIGATE_BACK, 1 ) + EVT_AUINOTEBOOK_DRAG_DONE = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, 1 ) + EVT_AUINOTEBOOK_BG_DCLICK = wx.PyEventBinder( wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, 1 ) } #endif diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index e1b60c3e02..f387d6ed67 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -287,17 +287,39 @@ void wxAuiDefaultTabArt::DrawBackground(wxDC& dc, const wxRect& rect) { // draw background - wxRect r(rect.x, rect.y, rect.width+2, rect.height-3); - wxColor top_color = wxAuiStepColour(m_base_colour, 90); - wxColor bottom_color = wxAuiStepColour(m_base_colour, 170); + + wxColor top_color = wxAuiStepColour(m_base_colour, 90); + wxColor bottom_color = wxAuiStepColour(m_base_colour, 170); + wxRect r; + + if (m_flags &wxAUI_NB_BOTTOM) + r = wxRect(rect.x, rect.y, rect.width+2, rect.height); + // TODO: else if (m_flags &wxAUI_NB_LEFT) {} + // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} + else //for wxAUI_NB_TOP + r = wxRect(rect.x, rect.y, rect.width+2, rect.height-3); + dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); - // draw base lines - int y = rect.GetHeight(); - int w = rect.GetWidth(); - dc.SetPen(m_border_pen); - dc.SetBrush(m_base_colour_brush); - dc.DrawRectangle(-1, y-4, w+2, 4); + + // draw base lines + + dc.SetPen(m_border_pen); + int y = rect.GetHeight(); + int w = rect.GetWidth(); + + if (m_flags &wxAUI_NB_BOTTOM) + { + dc.SetBrush(wxBrush(bottom_color)); + dc.DrawRectangle(-1, 0, w+2, 4); + } + // TODO: else if (m_flags &wxAUI_NB_LEFT) {} + // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} + else //for wxAUI_NB_TOP + { + dc.SetBrush(m_base_colour_brush); + dc.DrawRectangle(-1, y-4, w+2, 4); + } } @@ -394,13 +416,26 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc, wxPoint border_points[6]; - border_points[0] = wxPoint(tab_x, tab_y+tab_height-4); - border_points[1] = wxPoint(tab_x, tab_y+2); - border_points[2] = wxPoint(tab_x+2, tab_y); - border_points[3] = wxPoint(tab_x+tab_width-2, tab_y); - border_points[4] = wxPoint(tab_x+tab_width, tab_y+2); - border_points[5] = wxPoint(tab_x+tab_width, tab_y+tab_height-4); - + if (m_flags &wxAUI_NB_BOTTOM) + { + border_points[0] = wxPoint(tab_x, tab_y); + border_points[1] = wxPoint(tab_x, tab_y+tab_height-6); + border_points[2] = wxPoint(tab_x+2, tab_y+tab_height-4); + border_points[3] = wxPoint(tab_x+tab_width-2, tab_y+tab_height-4); + border_points[4] = wxPoint(tab_x+tab_width, tab_y+tab_height-6); + border_points[5] = wxPoint(tab_x+tab_width, tab_y); + } + else //if (m_flags & wxAUI_NB_TOP) {} + { + border_points[0] = wxPoint(tab_x, tab_y+tab_height-4); + border_points[1] = wxPoint(tab_x, tab_y+2); + border_points[2] = wxPoint(tab_x+2, tab_y); + border_points[3] = wxPoint(tab_x+tab_width-2, tab_y); + border_points[4] = wxPoint(tab_x+tab_width, tab_y+2); + border_points[5] = wxPoint(tab_x+tab_width, tab_y+tab_height-4); + } + // TODO: else if (m_flags &wxAUI_NB_LEFT) {} + // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} int drawn_tab_yoff = border_points[1].y; int drawn_tab_height = border_points[0].y - border_points[1].y; @@ -476,7 +511,12 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc, // this gets rid of the top one of those lines in the tab control if (page.active) { - dc.SetPen(m_base_colour_pen); + if (m_flags &wxAUI_NB_BOTTOM) + dc.SetPen(wxPen(wxColour(wxAuiStepColour(m_base_colour, 170)))); + // TODO: else if (m_flags &wxAUI_NB_LEFT) {} + // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} + else //for wxAUI_NB_TOP + dc.SetPen(m_base_colour_pen); dc.DrawLine(border_points[0].x+1, border_points[0].y, border_points[5].x, @@ -2634,8 +2674,21 @@ public: return; m_tab_rect = wxRect(m_rect.x, m_rect.y, m_rect.width, m_tab_ctrl_height); - m_tabs->SetSize(m_rect.x, m_rect.y, m_rect.width, m_tab_ctrl_height); - m_tabs->SetRect(wxRect(0, 0, m_rect.width, m_tab_ctrl_height)); + if (m_tabs->GetFlags() & wxAUI_NB_BOTTOM) + { + m_tab_rect = wxRect (m_rect.x, m_rect.y + m_rect.height - m_tab_ctrl_height, m_rect.width, m_tab_ctrl_height); + m_tabs->SetSize (m_rect.x, m_rect.y + m_rect.height - m_tab_ctrl_height, m_rect.width, m_tab_ctrl_height); + m_tabs->SetRect (wxRect(0, 0, m_rect.width, m_tab_ctrl_height)); + } + else //TODO: if (GetFlags() & wxAUI_NB_TOP) + { + m_tab_rect = wxRect (m_rect.x, m_rect.y, m_rect.width, m_tab_ctrl_height); + m_tabs->SetSize (m_rect.x, m_rect.y, m_rect.width, m_tab_ctrl_height); + m_tabs->SetRect (wxRect(0, 0, m_rect.width, m_tab_ctrl_height)); + } + // TODO: else if (GetFlags() & wxAUI_NB_LEFT){} + // TODO: else if (GetFlags() & wxAUI_NB_RIGHT){} + m_tabs->Refresh(); m_tabs->Update(); @@ -2645,8 +2698,18 @@ public: for (i = 0; i < page_count; ++i) { wxAuiNotebookPage& page = pages.Item(i); - page.window->SetSize(m_rect.x, m_rect.y + m_tab_ctrl_height, - m_rect.width, m_rect.height - m_tab_ctrl_height); + if (m_tabs->GetFlags() & wxAUI_NB_BOTTOM) + { + page.window->SetSize(m_rect.x, m_rect.y, + m_rect.width, m_rect.height - m_tab_ctrl_height); + } + else //TODO: if (GetFlags() & wxAUI_NB_TOP) + { + page.window->SetSize(m_rect.x, m_rect.y + m_tab_ctrl_height, + m_rect.width, m_rect.height - m_tab_ctrl_height); + } + // TODO: else if (GetFlags() & wxAUI_NB_LEFT){} + // TODO: else if (GetFlags() & wxAUI_NB_RIGHT){} #if wxUSE_MDI if (page.window->IsKindOf(CLASSINFO(wxAuiMDIChildFrame))) -- 2.45.2