]> git.saurik.com Git - wxWidgets.git/blobdiff - src/aui/tabartgtk.cpp
Fix printing in landscape mode in wxGTK.
[wxWidgets.git] / src / aui / tabartgtk.cpp
index a7bc5e455118a03ffe77e39dc8c42d13443c927a..28bfaa6aafbf6851f8235ad82826c61a3f38fee3 100644 (file)
@@ -50,11 +50,7 @@ static int s_CloseIconSize = 16; // default size
 
 }
 
-wxAuiGtkTabArt::wxAuiGtkTabArt()//:
-//    m_Xthickness(0),
-//    m_Ythickness(0),
-//    m_TabHBorder(0),
-//    m_TabVBorder(0)
+wxAuiGtkTabArt::wxAuiGtkTabArt()
 
 {
 }
@@ -83,6 +79,23 @@ void wxAuiGtkTabArt::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxR
                                        rect.x, rect.y, rect.width, rect.height);
 }
 
+void wxAuiGtkTabArt::DrawBorder(wxDC& WXUNUSED(dc), wxWindow* wnd, const wxRect& rect)
+{
+    int generic_border_width = wxAuiGenericTabArt::GetBorderWidth(wnd);
+
+    if (!wnd) return;
+    if (!wnd->m_wxwindow) return;
+    if (!gtk_widget_is_drawable(wnd->m_wxwindow)) return;
+
+    GtkStyle *style_notebook = gtk_widget_get_style(wxGTKPrivate::GetNotebookWidget());
+
+    gtk_paint_box(style_notebook, wnd->GTKGetDrawingWindow(), GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+                  NULL, wnd->m_wxwindow,
+                  const_cast<char*>("notebook"),
+                  rect.x + generic_border_width + 1, rect.y + generic_border_width + 1,
+                  rect.width - (generic_border_width + 1), rect.height - (generic_border_width + 1));
+}
+
 void ButtonStateAndShadow(int button_state, GtkStateType &state, GtkShadowType &shadow)
 {
 
@@ -178,7 +191,6 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
                          "focus-line-width", &focus_width,
                          NULL);
 
-    int gap_x = 0, gap_width = 0;
     int tab_pos;
     if (m_flags &wxAUI_NB_BOTTOM)
         tab_pos = wxAUI_NB_BOTTOM;
@@ -199,12 +211,11 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
 
     if (page.active)
         tab_rect.height += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
-    // if no bitmap is set, we need a tiny correction
-    if (! page.bitmap.IsOk())
-        tab_rect.height += 1;
 
-    int gap_height = 6 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
-    int gap_y = tab_rect.y - gap_height;
+    int gap_rect_height = 10 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
+    int gap_rect_x = 1, gap_start = 0, gap_width = 0;
+    int gap_rect_y = tab_rect.y - gap_rect_height;
+    int gap_rect_width = window_rect.width;
 
     switch (tab_pos)
     {
@@ -212,15 +223,17 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
             tab_rect.y -= 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
             if (!page.active)
                 tab_rect.y += 2 * GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
-            gap_y = tab_rect.y + tab_rect.height;
+            gap_rect_y = tab_rect.y + tab_rect.height - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2;
             // fall through
         case wxAUI_NB_BOTTOM:
-            gap_x = tab_rect.x - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder / 2;
+            gap_start = tab_rect.x - GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder / 2;
             gap_width = tab_rect.width;
             break;
+        // TODO: case wxAUI_NB_LEFT: break;
+        // TODO: case wxAUI_NB_RIGHT: break;
     }
     tab_rect.y += GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2;
-    gap_y += GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2;
+    gap_rect_y += GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder / 2;
 
     int padding = focus_width + GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder;
 
@@ -239,6 +252,15 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
     wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
     GdkWindow* window = impldc->GetGDKWindow();
 
+    // Before drawing the active tab itself, draw a box without border, because some themes
+    // have transparent gaps and a line would be visible at the bottom of the tab
+    if (page.active)
+        gtk_paint_box(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_NONE,
+                      NULL, widget,
+                      const_cast<char*>("notebook"),
+                      gap_rect_x, gap_rect_y,
+                      gap_rect_width, gap_rect_height);
+
     if (tab_pos == wxAUI_NB_BOTTOM)
     {
         if (page.active)
@@ -246,9 +268,9 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
             gtk_paint_box_gap(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
                               NULL, widget,
                               const_cast<char*>("notebook"),
-                              window_rect.x, gap_y,
-                              window_rect.width, gap_height,
-                              GTK_POS_BOTTOM, gap_x , gap_width);
+                              gap_rect_x, gap_rect_y,
+                              gap_rect_width, gap_rect_height,
+                              GTK_POS_BOTTOM, gap_start , gap_width);
         }
         gtk_paint_extension(style_notebook, window,
                            page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
@@ -265,9 +287,9 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
             gtk_paint_box_gap(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
                               NULL, widget,
                               const_cast<char*>("notebook"),
-                              window_rect.x, gap_y,
-                              window_rect.width, gap_height,
-                              GTK_POS_TOP, gap_x , gap_width);
+                              gap_rect_x, gap_rect_y,
+                              gap_rect_width, gap_rect_height,
+                              GTK_POS_TOP, gap_start , gap_width);
         }
         gtk_paint_extension(style_notebook, window,
                            page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
@@ -278,6 +300,15 @@ void wxAuiGtkTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& p
                            GTK_POS_BOTTOM);
     }
 
+    // After drawing the inactive tab itself, draw a box with the same dimensions as the gap-box,
+    // otherwise we don't get a gap-box, if the active tab is invisible
+    if (!page.active)
+        gtk_paint_box(style_notebook, window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+                      NULL, widget,
+                      const_cast<char*>("notebook"),
+                      gap_rect_x, gap_rect_y,
+                      gap_rect_width, gap_rect_height);
+
     wxCoord textX = tab_rect.x + padding + style_notebook->xthickness;
 
     int bitmap_offset = 0;
@@ -450,6 +481,12 @@ int wxAuiGtkTabArt::GetBestTabCtrlSize(wxWindow* wnd,
     return tab_height;
 }
 
+int wxAuiGtkTabArt::GetBorderWidth(wxWindow* wnd)
+{
+    return wxAuiGenericTabArt::GetBorderWidth(wnd) + wxMax(GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_hborder,
+                                                           GTK_NOTEBOOK (wxGTKPrivate::GetNotebookWidget())->tab_vborder);
+}
+
 wxSize wxAuiGtkTabArt::GetTabSize(wxDC& dc,
                               wxWindow* wnd,
                               const wxString& caption,