From 9c5a22d19708eae17ad9880422bd03e81ea48c5d Mon Sep 17 00:00:00 2001
From: Jan Holesovsky <kendy@suse.cz>
Date: Thu, 21 Jun 2012 17:55:53 +0200
Subject: aero toolbar: Extend the drawing of the toolbar to the menubar area.

Fix the maTopDockingAreaHeight computation too, it did not work.

Change-Id: I788c96960a5607482b750d536e522644e236f052
---
 vcl/source/window/menu.cxx                   | 29 ++++++-------
 vcl/win/source/gdi/salnativewidgets-luna.cxx | 63 ++++++++++++++++------------
 2 files changed, 49 insertions(+), 43 deletions(-)

(limited to 'vcl')

diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 5f543c9c0f31..0fff3c32daf0 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -754,7 +754,7 @@ static void ImplAddNWFSeparator( Window *pThis, const MenubarValue& rMenubarValu
     // add a separator if
     // - we have an adjacent docking area
     // - and if toolbars would draw them as well (mbDockingAreaSeparateTB must not be set, see dockingarea.cxx)
-    if( rMenubarValue.maTopDockingAreaHeight && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB )
+    if( rMenubarValue.maTopDockingAreaHeight && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
     {
         // note: the menubar only provides the upper (dark) half of it, the rest (bright part) is drawn by the docking area
 
@@ -861,27 +861,24 @@ static int ImplGetTopDockingAreaHeight( Window *pWindow )
 {
     // find docking area that is top aligned and return its height
     // note: dockingareas are direct children of the SystemWindow
-    int height=0;
-    sal_Bool bDone = sal_False;
     if( pWindow->ImplGetFrameWindow() )
     {
-        Window *pWin = pWindow->ImplGetFrameWindow()->GetWindow( WINDOW_FIRSTCHILD); //mpWindowImpl->mpFirstChild;
-        while( pWin && !bDone )
+        Window *pWin = pWindow->ImplGetFrameWindow()->GetWindow( WINDOW_FIRSTCHILD ); //mpWindowImpl->mpFirstChild;
+        while( pWin )
         {
             if( pWin->IsSystemWindow() )
             {
-                pWin = pWin->GetWindow( WINDOW_FIRSTCHILD); //mpWindowImpl->mpFirstChild;
-                while( pWin && !bDone )
+                Window *pChildWin = pWin->GetWindow( WINDOW_FIRSTCHILD ); //mpWindowImpl->mpFirstChild;
+                while( pChildWin )
                 {
-                    DockingAreaWindow *pDockingArea = dynamic_cast< DockingAreaWindow* >( pWin );
-                    if( pDockingArea && pDockingArea->GetAlign() == WINDOWALIGN_TOP )
-                    {
-                        bDone = sal_True;
-                        if( pDockingArea->IsVisible() )
-                            height = pDockingArea->GetOutputSizePixel().Height();
-                    }
+                    DockingAreaWindow *pDockingArea = NULL;
+                    if ( pChildWin->GetType() == WINDOW_DOCKINGAREA )
+                        pDockingArea = static_cast< DockingAreaWindow* >( pChildWin );
+
+                    if( pDockingArea && pDockingArea->GetAlign() == WINDOWALIGN_TOP && pDockingArea->IsVisible() )
+                        return pDockingArea->GetOutputSizePixel().Height();
                     else
-                        pWin = pWin->GetWindow( WINDOW_NEXT ); //mpWindowImpl->mpNext;
+                        pChildWin = pChildWin->GetWindow( WINDOW_NEXT ); //mpWindowImpl->mpNext;
                 }
 
             }
@@ -889,7 +886,7 @@ static int ImplGetTopDockingAreaHeight( Window *pWindow )
                 pWin = pWin->GetWindow( WINDOW_NEXT ); //mpWindowImpl->mpNext;
         }
     }
-    return height;
+    return 0;
 }
 
 Menu::Menu()
diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx
index ed39620c6f61..eed2cc0e3b77 100644
--- a/vcl/win/source/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx
@@ -459,7 +459,32 @@ void ImplConvertSpinbuttonValues( int nControlPart, const ControlState& rState,
     pRect->bottom = rRect.Bottom()+1;
 }
 
-// ----
+void impl_drawAeroToolbar( HDC hDC, RECT rc )
+{
+    const long GRADIENT_HEIGHT = 32;
+
+    long gradient_break = rc.top;
+    GRADIENT_RECT g_rect[1] = { { 0, 1 } };
+
+    // very slow gradient at the top (if we have space for that)
+    if ( rc.bottom - rc.top > GRADIENT_HEIGHT )
+    {
+        gradient_break = rc.bottom - GRADIENT_HEIGHT;
+
+        TRIVERTEX vert[2] = {
+            { rc.left, rc.top,          0xff00, 0xff00, 0xff00, 0xff00 },
+            { rc.right, gradient_break, 0xfa00, 0xfa00, 0xfa00, 0xff00 },
+        };
+        GradientFill( hDC, vert, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
+    }
+
+    // gradient at the bottom
+    TRIVERTEX vert[2] = {
+        { rc.left, gradient_break, 0xfa00, 0xfa00, 0xfa00, 0xff00 },
+        { rc.right, rc.bottom,     0xe500, 0xe900, 0xee00, 0xff00 }
+    };
+    GradientFill( hDC, vert, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
+}
 
 sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
                             ControlType nType,
@@ -902,37 +927,14 @@ sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
                 const ToolbarValue *pValue = static_cast<const ToolbarValue*>(&aValue);
                 if( pValue->mbIsTopDockingArea )
                 {
+                    rc.top = 0; // extend potential gradient to cover menu bar as well
+
                     // make it more compatible with Aero
                     if( ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
                     {
-                        const long GRADIENT_HEIGHT = 32;
-
-                        long gradient_break = rc.top;
-                        GRADIENT_RECT g_rect[1] = { { 0, 1 } };
-
-                        // very slow gradient at the top (if we have space for that)
-                        if ( rc.bottom - rc.top > GRADIENT_HEIGHT )
-                        {
-                            gradient_break = rc.bottom - GRADIENT_HEIGHT;
-
-                            TRIVERTEX vert[2] = {
-                                { rc.left, rc.top,          0xff00, 0xff00, 0xff00, 0xff00 },
-                                { rc.right, gradient_break, 0xfa00, 0xfa00, 0xfa00, 0xff00 },
-                            };
-                            GradientFill( hDC, vert, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
-                        }
-
-                        // gradient at the bottom
-                        TRIVERTEX vert[2] = {
-                            { rc.left, gradient_break, 0xfa00, 0xfa00, 0xfa00, 0xff00 },
-                            { rc.right, rc.bottom,     0xe500, 0xe900, 0xee00, 0xff00 }
-                        };
-                        GradientFill( hDC, vert, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
-
+                        impl_drawAeroToolbar( hDC, rc );
                         return sal_True;
                     }
-                    else
-                        rc.top = 0; // extend potential gradient to cover menu bar as well
                 }
             }
             return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption);
@@ -947,6 +949,13 @@ sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
             {
                 const MenubarValue *pValue = static_cast<const MenubarValue*>(&aValue);
                 rc.bottom += pValue->maTopDockingAreaHeight;    // extend potential gradient to cover docking area as well
+
+                // make it more compatible with Aero
+                if( ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
+                {
+                    impl_drawAeroToolbar( hDC, rc );
+                    return sal_True;
+                }
             }
             return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption);
         }
-- 
cgit