[Libreoffice-commits] .: Branch 'libreoffice-3-6' - 4 commits - vcl/source vcl/win

Jan Holesovsky kendy at kemper.freedesktop.org
Wed Jun 20 05:29:01 PDT 2012


 vcl/source/window/menu.cxx                   |   11 -
 vcl/win/source/gdi/salnativewidgets-luna.cxx |  273 +++++++++++++++++++--------
 2 files changed, 210 insertions(+), 74 deletions(-)

New commits:
commit 6bc7cc692977431d1873dea0dd4c2636a6735eaa
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Wed Jun 20 14:17:41 2012 +0200

    aero menubar: Make the glow around the entries smaller.
    
    Change-Id: I13e33b0a04c4212aef22499ebf2911aab33ec261

diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx
index a93bdca..0ac78b9 100644
--- a/vcl/win/source/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx
@@ -66,6 +66,40 @@ using ::rtl::OUString;
 typedef map< wstring, HTHEME > ThemeMap;
 static ThemeMap aThemeMap;
 
+#ifdef __MINGW32__
+
+typedef int (WINAPI *DTT_CALLBACK_PROC)
+(
+  HDC hdc,
+  LPWSTR pszText,
+  int cchText,
+  LPRECT prc,
+  UINT dwFlags,
+  LPARAM lParam
+);
+
+typedef struct _DTTOPTS {
+  DWORD             dwSize;
+  DWORD             dwFlags;
+  COLORREF          crText;
+  COLORREF          crBorder;
+  COLORREF          crShadow;
+  int               iTextShadowType;
+  POINT             ptShadowOffset;
+  int               iBorderSize;
+  int               iFontPropId;
+  int               iColorPropId;
+  int               iStateId;
+  BOOL              fApplyOverlay;
+  int               iGlowSize;
+  DTT_CALLBACK_PROC pfnDrawTextCallback;
+  LPARAM            lParam;
+} DTTOPTS, *PDTTOPTS;
+
+#define DTT_GLOWSIZE   (1UL << 11)
+#define DTT_COMPOSITED (1UL << 13)
+
+#endif
 
 /****************************************************
  wrap visual styles API to avoid linking against it
@@ -81,6 +115,7 @@ private:
     typedef HRESULT (WINAPI * GetThemeBackgroundContentRect_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect );
     typedef HRESULT (WINAPI * DrawThemeBackground_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect );
     typedef HRESULT (WINAPI * DrawThemeText_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect );
+    typedef HRESULT (WINAPI * DrawThemeTextEx_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, LPRECT pRect, const DTTOPTS *pOptions );
     typedef HRESULT (WINAPI * GetThemePartSize_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz );
     typedef HRESULT (WINAPI * GetThemeSysFont_Proc_T) ( HTHEME hTheme, int iFontID, LOGFONTW *plf );
     typedef BOOL    (WINAPI * IsThemeActive_Proc_T) ( void );
@@ -90,6 +125,7 @@ private:
     GetThemeBackgroundContentRect_Proc_T    lpfnGetThemeBackgroundContentRect;
     DrawThemeBackground_Proc_T              lpfnDrawThemeBackground;
     DrawThemeText_Proc_T                    lpfnDrawThemeText;
+    DrawThemeTextEx_Proc_T                  lpfnDrawThemeTextEx;
     GetThemePartSize_Proc_T                 lpfnGetThemePartSize;
     GetThemeSysFont_Proc_T                  lpfnGetThemeSysFont;
     IsThemeActive_Proc_T                    lpfnIsThemeActive;
@@ -112,6 +148,7 @@ public:
     HRESULT GetThemeBackgroundContentRect( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect );
     HRESULT DrawThemeBackground( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect );
     HRESULT DrawThemeText( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect );
+    HRESULT DrawThemeTextEx( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, LPRECT pRect, const DTTOPTS *pOptions );
     HRESULT GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz );
     HRESULT GetThemeSysFont( HTHEME hTheme, int iFontID, LOGFONTW *plf );
     BOOL IsThemeActive( void );
@@ -127,6 +164,7 @@ VisualStylesAPI::VisualStylesAPI()
       lpfnGetThemeBackgroundContentRect( NULL ),
       lpfnDrawThemeBackground( NULL ),
       lpfnDrawThemeText( NULL ),
+      lpfnDrawThemeTextEx( NULL ),
       lpfnGetThemePartSize( NULL ),
       lpfnGetThemeSysFont( NULL ),
       lpfnIsThemeActive( NULL ),
@@ -142,6 +180,7 @@ VisualStylesAPI::VisualStylesAPI()
         lpfnGetThemeBackgroundContentRect = (GetThemeBackgroundContentRect_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "GetThemeBackgroundContentRect" );
         lpfnDrawThemeBackground = (DrawThemeBackground_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "DrawThemeBackground" );
         lpfnDrawThemeText = (DrawThemeText_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "DrawThemeText" );
+        lpfnDrawThemeTextEx = (DrawThemeTextEx_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "DrawThemeTextEx" );
         lpfnGetThemePartSize = (GetThemePartSize_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "GetThemePartSize" );
         lpfnGetThemeSysFont = (GetThemeSysFont_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "GetThemeSysFont" );
         lpfnIsThemeActive = (IsThemeActive_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "IsThemeActive" );
@@ -205,6 +244,17 @@ HRESULT VisualStylesAPI::DrawThemeText( HTHEME hTheme, HDC hdc, int iPartId, int
         return S_FALSE;
 }
 
+HRESULT VisualStylesAPI::DrawThemeTextEx( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, LPRECT pRect, const DTTOPTS *pOptions )
+{
+    if(lpfnDrawThemeTextEx)
+        return (*lpfnDrawThemeTextEx) (hTheme, hdc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, pRect, pOptions);
+    else
+    {
+        // try to fallback
+        return DrawThemeText(hTheme, hdc, iPartId, iStateId, pszText, iCharCount, dwTextFlags, 0, pRect);
+    }
+}
+
 HRESULT VisualStylesAPI::GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz )
 {
     if(lpfnGetThemePartSize)
@@ -452,6 +502,12 @@ sal_Bool ImplDrawTheme( HTHEME hTheme, HDC hDC, int iPart, int iState, RECT rc,
                     {
                         HBITMAP hbmOld = (HBITMAP)SelectObject(hdcPaint, hbm);
 
+                        // Setup the theme drawing options.
+                        DTTOPTS DttOpts;
+                        DttOpts.dwSize = sizeof(DTTOPTS);
+                        DttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE;
+                        DttOpts.iGlowSize = 8;
+
                         // Select a font.
                         LOGFONTW lgFont;
                         HFONT hFontOld = NULL;
@@ -469,10 +525,10 @@ sal_Bool ImplDrawTheme( HTHEME hTheme, HDC hDC, int iPart, int iState, RECT rc,
                         rcPaint.left = rcPaint.top = 0;
                         rcPaint.right = cx;
                         rcPaint.bottom = cy;
-                        hr = vsAPI.DrawThemeText( hCompositedTheme, hdcPaint, iPart, iState,
+                        hr = vsAPI.DrawThemeTextEx( hCompositedTheme, hdcPaint, iPart, iState,
                                 reinterpret_cast<LPCWSTR>(aStr.getStr()), -1,
                                 DT_CENTER | DT_VCENTER | DT_SINGLELINE,
-                                0, &rcPaint);
+                                &rcPaint, &DttOpts );
 
                         // Blit text to the frame.
                         BitBlt(hDC, rc.left, rc.top, cx, cy, hdcPaint, 0, 0, SRCCOPY);
commit 2118bed2b560f583246ae1f01a14fc2fe23947e4
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Wed Jun 20 12:01:52 2012 +0200

    aero menubar: Make the text in menu black.
    
    Change-Id: I4d9486ccda091506ad103fa4182cadf810fcd6f2

diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 935d5a9..2bf8202 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2669,11 +2669,17 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa
                         // draw selected item
                         MenubarValue aControlValue;
                         aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( pWin );
+
+                        // transparent menubar needs a trick to write nice text, do it via NWF
+                        OUString aText;
+                        if ( bIsMenuBar && ImplGetSVData()->maNWFData.mbTransparentMenubar )
+                            aText = pData->aText;
+
                         pWin->DrawNativeControl( CTRL_MENUBAR, PART_MENU_ITEM,
                                 aRect,
                                 CTRL_STATE_ENABLED | ( bHighlight? CTRL_STATE_SELECTED: 0 ),
                                 aControlValue,
-                                OUString() );
+                                aText );
 
                         pWin->Pop();
                     }
@@ -2803,7 +2809,8 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa
                 }
 
                 // Text:
-                if ( ( pData->eType == MENUITEM_STRING ) || ( pData->eType == MENUITEM_STRINGIMAGE ) )
+                if ( ( ( pData->eType == MENUITEM_STRING ) || ( pData->eType == MENUITEM_STRINGIMAGE ) ) &&
+                     !(bIsMenuBar && ImplGetSVData()->maNWFData.mbTransparentMenubar) )
                 {
                     aTmpPos.X() = aPos.X() + nTextPos;
                     aTmpPos.Y() = aPos.Y();
diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx
index 99c512f..a93bdca 100644
--- a/vcl/win/source/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx
@@ -82,6 +82,7 @@ private:
     typedef HRESULT (WINAPI * DrawThemeBackground_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect );
     typedef HRESULT (WINAPI * DrawThemeText_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect );
     typedef HRESULT (WINAPI * GetThemePartSize_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz );
+    typedef HRESULT (WINAPI * GetThemeSysFont_Proc_T) ( HTHEME hTheme, int iFontID, LOGFONTW *plf );
     typedef BOOL    (WINAPI * IsThemeActive_Proc_T) ( void );
 
     OpenThemeData_Proc_T                    lpfnOpenThemeData;
@@ -90,6 +91,7 @@ private:
     DrawThemeBackground_Proc_T              lpfnDrawThemeBackground;
     DrawThemeText_Proc_T                    lpfnDrawThemeText;
     GetThemePartSize_Proc_T                 lpfnGetThemePartSize;
+    GetThemeSysFont_Proc_T                  lpfnGetThemeSysFont;
     IsThemeActive_Proc_T                    lpfnIsThemeActive;
 
     // dwmapi.dll functions
@@ -111,6 +113,7 @@ public:
     HRESULT DrawThemeBackground( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect );
     HRESULT DrawThemeText( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect );
     HRESULT GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz );
+    HRESULT GetThemeSysFont( HTHEME hTheme, int iFontID, LOGFONTW *plf );
     BOOL IsThemeActive( void );
 
     HRESULT DwmExtendFrameIntoClientArea( HWND hWnd, const MARGINS *pMarInset );
@@ -125,6 +128,7 @@ VisualStylesAPI::VisualStylesAPI()
       lpfnDrawThemeBackground( NULL ),
       lpfnDrawThemeText( NULL ),
       lpfnGetThemePartSize( NULL ),
+      lpfnGetThemeSysFont( NULL ),
       lpfnIsThemeActive( NULL ),
       lpfnDwmExtendFrameIntoClientArea( NULL )
 {
@@ -139,6 +143,7 @@ VisualStylesAPI::VisualStylesAPI()
         lpfnDrawThemeBackground = (DrawThemeBackground_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "DrawThemeBackground" );
         lpfnDrawThemeText = (DrawThemeText_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "DrawThemeText" );
         lpfnGetThemePartSize = (GetThemePartSize_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "GetThemePartSize" );
+        lpfnGetThemeSysFont = (GetThemeSysFont_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "GetThemeSysFont" );
         lpfnIsThemeActive = (IsThemeActive_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "IsThemeActive" );
     }
 
@@ -208,6 +213,14 @@ HRESULT VisualStylesAPI::GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId,
         return S_FALSE;
 }
 
+HRESULT VisualStylesAPI::GetThemeSysFont( HTHEME hTheme, int iFontID, LOGFONTW *plf )
+{
+    if(lpfnGetThemeSysFont)
+        return (*lpfnGetThemeSysFont) ( hTheme, iFontID, plf );
+    else
+        return S_FALSE;
+}
+
 BOOL VisualStylesAPI::IsThemeActive( void )
 {
     if(lpfnIsThemeActive)
@@ -402,18 +415,89 @@ sal_Bool WinSalGraphics::hitTestNativeControl( ControlType,
     return FALSE;
 }
 
-sal_Bool ImplDrawTheme( HTHEME hTheme, HDC hDC, int iPart, int iState, RECT rc, const OUString& aStr)
+sal_Bool ImplDrawTheme( HTHEME hTheme, HDC hDC, int iPart, int iState, RECT rc, const OUString& aStr, bool bAeroTrick = false )
 {
     HRESULT hr = vsAPI.DrawThemeBackground( hTheme, hDC, iPart, iState, &rc, 0);
 
     if( aStr.getLength() )
     {
-        RECT rcContent;
-        hr = vsAPI.GetThemeBackgroundContentRect( hTheme, hDC, iPart, iState, &rc, &rcContent);
-        hr = vsAPI.DrawThemeText( hTheme, hDC, iPart, iState,
-            reinterpret_cast<LPCWSTR>(aStr.getStr()), -1,
-            DT_CENTER | DT_VCENTER | DT_SINGLELINE,
-            0, &rcContent);
+        // oh well, in order to be able to draw solid text in the Aero border,
+        // we need to do the trick from
+        // http://msdn.microsoft.com/en-us/library/windows/desktop/bb688195%28v=vs.85%29.aspx#appendixb
+        if ( bAeroTrick && ( iPart == MENU_BARITEM ) )
+        {
+            HTHEME hCompositedTheme = vsAPI.OpenThemeData( NULL, L"CompositedWindow::Window" );
+            if ( hCompositedTheme )
+            {
+                HDC hdcPaint = CreateCompatibleDC(hDC);
+                if (hdcPaint)
+                {
+                    int cx = rc.right - rc.left;
+                    int cy = rc.bottom - rc.top;
+
+                    // Define the BITMAPINFO structure used to draw text.
+                    // Note that biHeight is negative. This is done because
+                    // DrawThemeTextEx() needs the bitmap to be in top-to-bottom
+                    // order.
+                    BITMAPINFO dib;
+                    dib.bmiHeader.biSize            = sizeof(BITMAPINFOHEADER);
+                    dib.bmiHeader.biWidth           = cx;
+                    dib.bmiHeader.biHeight          = -cy;
+                    dib.bmiHeader.biPlanes          = 1;
+                    dib.bmiHeader.biBitCount        = 32;
+                    dib.bmiHeader.biCompression     = 0; // BI_RGB - MinGW does not seem to define the contstant
+
+                    HBITMAP hbm = CreateDIBSection(hDC, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
+                    if (hbm)
+                    {
+                        HBITMAP hbmOld = (HBITMAP)SelectObject(hdcPaint, hbm);
+
+                        // Select a font.
+                        LOGFONTW lgFont;
+                        HFONT hFontOld = NULL;
+                        if (SUCCEEDED(vsAPI.GetThemeSysFont(hCompositedTheme, TMT_MENUFONT, &lgFont)))
+                        {
+                            HFONT hFont = CreateFontIndirectW(&lgFont);
+                            hFontOld = (HFONT) SelectObject(hdcPaint, hFont);
+                        }
+
+                        // Blit the background to the bitmap
+                        BitBlt(hdcPaint, 0, 0, cx, cy, hDC, rc.left, rc.top, SRCCOPY);
+
+                        // Draw the title.
+                        RECT rcPaint;
+                        rcPaint.left = rcPaint.top = 0;
+                        rcPaint.right = cx;
+                        rcPaint.bottom = cy;
+                        hr = vsAPI.DrawThemeText( hCompositedTheme, hdcPaint, iPart, iState,
+                                reinterpret_cast<LPCWSTR>(aStr.getStr()), -1,
+                                DT_CENTER | DT_VCENTER | DT_SINGLELINE,
+                                0, &rcPaint);
+
+                        // Blit text to the frame.
+                        BitBlt(hDC, rc.left, rc.top, cx, cy, hdcPaint, 0, 0, SRCCOPY);
+
+                        SelectObject(hdcPaint, hbmOld);
+                        if (hFontOld)
+                        {
+                            SelectObject(hdcPaint, hFontOld);
+                        }
+                        DeleteObject(hbm);
+                    }
+                    DeleteDC(hdcPaint);
+                }
+                vsAPI.CloseThemeData(hCompositedTheme);
+            }
+        }
+        else
+        {
+            RECT rcContent;
+            hr = vsAPI.GetThemeBackgroundContentRect( hTheme, hDC, iPart, iState, &rc, &rcContent);
+            hr = vsAPI.DrawThemeText( hTheme, hDC, iPart, iState,
+                    reinterpret_cast<LPCWSTR>(aStr.getStr()), -1,
+                    DT_CENTER | DT_VCENTER | DT_SINGLELINE,
+                    0, &rcContent);
+        }
     }
     return (hr == S_OK);
 }
@@ -1057,7 +1141,7 @@ sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
             else
                 iState = (nState & CTRL_STATE_SELECTED) ? MBI_DISABLEDHOT : MBI_DISABLED;
 
-            return ImplDrawTheme( hTheme, hDC, MENU_BARITEM, iState, rc, aCaption );
+            return ImplDrawTheme( hTheme, hDC, MENU_BARITEM, iState, rc, aCaption, true );
         }
     }
 
commit e0fda2c12ef99db81dd00e7d54ce4be8d5a99b60
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Wed Jun 20 06:04:00 2012 +0200

    aero toolbar: Use the new toolbar look on Vista+ regardless of glass menu.
    
    Change-Id: Ie6aa7be5c157f1a2b3515097fce4ea81d3ae99af

diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx
index 70189ce..99c512f 100644
--- a/vcl/win/source/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx
@@ -998,7 +998,7 @@ sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
                 if( pValue->mbIsTopDockingArea )
                 {
                     // make it more compatible with Aero
-                    if( ImplGetSVData()->maNWFData.mbTransparentMenubar )
+                    if( ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
                     {
                         const long GRADIENT_HEIGHT = 32;
 
commit 54dbc39cc232bc54fe8bacf9058227649bc99dfd
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Tue Jun 19 11:35:32 2012 +0200

    aero menubar: Improve look according to Mirek M. + Astron's notes.
    
    Change-Id: I0228862da823901b43040c3c22f74d2483e5a6cf

diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx
index 20eb88e..70189ce 100644
--- a/vcl/win/source/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx
@@ -493,81 +493,70 @@ void ImplConvertSpinbuttonValues( int nControlPart, const ControlState& rState,
 // ----
 
 /// Draw an effect under the menubar for better readibility in the non-client area
-static bool impl_drawAeroMenubar( HWND hWnd, HDC hDC, RECT rc )
+static bool impl_drawAeroMenubar( HDC hDC, RECT rc )
 {
-    const long GLOW_OFFSET = 5;
-    const long VISIBLE_FRAME = 2;
-    const long TRIANGLE_WIDTH = rc.bottom - rc.top - GLOW_OFFSET - VISIBLE_FRAME;
-    const COLOR16 FINAL_OPACITY = 0x2000;
+    const long GROWING_WIDTH = 52;
 
-    // the glow effect gives us a nice fade into the gradient
-    HTHEME hGlowTheme = getThemeHandle( hWnd, L"TextGlow");
-    if ( !hGlowTheme )
-        return sal_False;
+    const COLOR16 FINAL_VALUE = 0xf000;
+    const COLOR16 FINAL_OPACITY = 0xff00;
 
-    // first clear everything
-    FillRect( hDC, &rc, static_cast< HBRUSH >( GetStockObject( BLACK_BRUSH ) ) );
+    const long VISIBLE_FRAME = 2;
+    const int FRAME_RATIO = 3;
 
     // gradient under the menu
     TRIVERTEX vert[2] = {
-        { rc.left + GLOW_OFFSET + TRIANGLE_WIDTH,  rc.top + GLOW_OFFSET,      0x0000, 0x0000, 0x0000, 0x0000 },
-        { rc.right - GLOW_OFFSET - TRIANGLE_WIDTH, rc.bottom - VISIBLE_FRAME, 0xff00, 0xff00, 0xff00, FINAL_OPACITY }
+        { rc.left + GROWING_WIDTH,  rc.top,                    0x0000, 0x0000, 0x0000, 0x0000 },
+        { rc.right - GROWING_WIDTH, rc.bottom - VISIBLE_FRAME, FINAL_VALUE, FINAL_VALUE, FINAL_VALUE, FINAL_OPACITY }
     };
     GRADIENT_RECT g_rect[1] = { { 0, 1 } };
     GradientFill( hDC, vert, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
 
-    // left side of the gradient consists of 2 triangles
-    TRIVERTEX vert_left_1[3] = {
-        { rc.left + GLOW_OFFSET, rc.top + GLOW_OFFSET,                       0x0000, 0x0000, 0x0000, 0x0000 },
-        { rc.left + GLOW_OFFSET, rc.bottom - VISIBLE_FRAME,                  0x0000, 0x0000, 0x0000, 0x0000 },
-        { rc.left + GLOW_OFFSET + TRIANGLE_WIDTH, rc.bottom - VISIBLE_FRAME, 0xff00, 0xff00, 0xff00, FINAL_OPACITY }
-    };
-    GRADIENT_TRIANGLE g_triangle[1] = { { 0, 1, 2 } };
-    GradientFill( hDC, vert_left_1, 3, g_triangle, 1, GRADIENT_FILL_TRIANGLE );
-
-    TRIVERTEX vert_left_2[3] = {
-        { rc.left + GLOW_OFFSET, rc.top + GLOW_OFFSET,                       0x0000, 0x0000, 0x0000, 0x0000 },
-        { rc.left + GLOW_OFFSET + TRIANGLE_WIDTH, rc.top + GLOW_OFFSET,      0x0000, 0x0000, 0x0000, 0x0000 },
-        { rc.left + GLOW_OFFSET + TRIANGLE_WIDTH, rc.bottom - VISIBLE_FRAME, 0xff00, 0xff00, 0xff00, FINAL_OPACITY }
+    // gradient in the frame (2 pixels between menu and the toolbars)
+    // [the "gradient" here is not really a gradient, but it is convenient to
+    // draw it this way ;-)]
+    TRIVERTEX vert_2[2] = {
+        { rc.left + GROWING_WIDTH,  rc.bottom - VISIBLE_FRAME, FINAL_VALUE / FRAME_RATIO, FINAL_VALUE / FRAME_RATIO, FINAL_VALUE / FRAME_RATIO, FINAL_OPACITY / FRAME_RATIO },
+        { rc.right - GROWING_WIDTH, rc.bottom,                 FINAL_VALUE / FRAME_RATIO, FINAL_VALUE / FRAME_RATIO, FINAL_VALUE / FRAME_RATIO, FINAL_OPACITY / FRAME_RATIO }
     };
-    GradientFill( hDC, vert_left_2, 3, g_triangle, 1, GRADIENT_FILL_TRIANGLE );
+    GradientFill( hDC, vert_2, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
 
-    // right side of the gradient consists of 2 triangles
-    TRIVERTEX vert_right_1[3] = {
-        { rc.right - GLOW_OFFSET, rc.top + GLOW_OFFSET,                       0x0000, 0x0000, 0x0000, 0x0000 },
-        { rc.right - GLOW_OFFSET, rc.bottom - VISIBLE_FRAME,                  0x0000, 0x0000, 0x0000, 0x0000 },
-        { rc.right - GLOW_OFFSET - TRIANGLE_WIDTH, rc.bottom - VISIBLE_FRAME, 0xff00, 0xff00, 0xff00, FINAL_OPACITY }
-    };
-    GradientFill( hDC, vert_right_1, 3, g_triangle, 1, GRADIENT_FILL_TRIANGLE );
+    const int STEP = 2;
+    for ( int i = 0; i < GROWING_WIDTH; i += STEP )
+    {
+        COLOR16 val = static_cast< double >( FINAL_VALUE ) * sin( ( static_cast< double >( i ) / GROWING_WIDTH ) * M_PI_2 );
+        COLOR16 op = static_cast< double >( FINAL_OPACITY ) * sin( ( static_cast< double >( i ) / GROWING_WIDTH ) * M_PI_2 );
+
+        // "growing" part of the gradient - menu
+        TRIVERTEX vert_left[2] = {
+            { rc.left + i, rc.top,                           0x0000, 0x0000, 0x0000, 0x0000 },
+            { rc.left + i + STEP, rc.bottom - VISIBLE_FRAME, val, val, val, op }
+        };
+        GradientFill( hDC, vert_left, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
+
+        TRIVERTEX vert_right[2] = {
+            { rc.right - i, rc.top,                           0x0000, 0x0000, 0x0000, 0x0000 },
+            { rc.right - i - STEP, rc.bottom - VISIBLE_FRAME, val, val, val, op }
+        };
+        GradientFill( hDC, vert_right, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
+
+        // "growing" part of the gradient - frame
+        TRIVERTEX vert_bottom_l[2] = {
+            { rc.left + i, rc.bottom - VISIBLE_FRAME, val / FRAME_RATIO, val / FRAME_RATIO, val / FRAME_RATIO, op / FRAME_RATIO },
+            { rc.left + i + STEP, rc.bottom,          val / FRAME_RATIO, val / FRAME_RATIO, val / FRAME_RATIO, op / FRAME_RATIO }
+        };
+        GradientFill( hDC, vert_bottom_l, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
+
+        TRIVERTEX vert_bottom_r[2] = {
+            { rc.right - i, rc.bottom - VISIBLE_FRAME, val / FRAME_RATIO, val / FRAME_RATIO, val / FRAME_RATIO, op / FRAME_RATIO },
+            { rc.right - i - STEP, rc.bottom,          val / FRAME_RATIO, val / FRAME_RATIO, val / FRAME_RATIO, op / FRAME_RATIO }
+        };
+        GradientFill( hDC, vert_bottom_r, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
+    }
 
-    TRIVERTEX vert_right_2[3] = {
-        { rc.right - GLOW_OFFSET, rc.top + GLOW_OFFSET,                       0x0000, 0x0000, 0x0000, 0x0000 },
-        { rc.right - GLOW_OFFSET - TRIANGLE_WIDTH, rc.top + GLOW_OFFSET,      0x0000, 0x0000, 0x0000, 0x0000 },
-        { rc.right - GLOW_OFFSET - TRIANGLE_WIDTH, rc.bottom - VISIBLE_FRAME, 0xff00, 0xff00, 0xff00, FINAL_OPACITY }
-    };
-    GradientFill( hDC, vert_right_2, 3, g_triangle, 1, GRADIENT_FILL_TRIANGLE );
-
-    // I have no idea what is the correct name of the contstant
-    // that is represented by '1' below - but that draws the glow
-    // effect
-    // I've found the "TextGlow" theme handle here:
-    //   http://fc01.deviantart.net/fs26/f/2008/154/0/6/Vista_Visual_Style_Classes_by_UkIntel.html
-    // and its rendering here:
-    //   http://deskmodder.de/wiki/index.php/Vista_msstyleImage_900-938
-    // No better documentation on the topic, unfortunately :-(
-    RECT tmp_rc = rc;
-    tmp_rc.bottom += rc.bottom - rc.top; // expand it vertically so that it continues to the window
-    ImplDrawTheme( hGlowTheme, hDC, 1, MBI_NORMAL, tmp_rc, OUString() );
-
-    // make the frame visible, so that it integrates nicely with Aero
-    tmp_rc = rc;
-    tmp_rc.top = rc.bottom - VISIBLE_FRAME;
-    FillRect( hDC, &tmp_rc, static_cast< HBRUSH >( GetStockObject( BLACK_BRUSH ) ) );
-
-    return sal_True;
+    return true;
 }
 
-sal_Bool ImplDrawNativeControl( HWND hWnd, HDC hDC, HTHEME hTheme, RECT rc,
+sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
                             ControlType nType,
                             ControlPart nPart,
                             ControlState nState,
@@ -1031,7 +1020,7 @@ sal_Bool ImplDrawNativeControl( HWND hWnd, HDC hDC, HTHEME hTheme, RECT rc,
                         // gradient at the bottom
                         TRIVERTEX vert[2] = {
                             { rc.left, gradient_break, 0xfa00, 0xfa00, 0xfa00, 0xff00 },
-                            { rc.right, rc.bottom,     0xe500, 0xe900, 0xee00, 0xff00 }
+                            { rc.right, rc.bottom,     0xf000, 0xf000, 0xf000, 0xff00 }
                         };
                         GradientFill( hDC, vert, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
 
@@ -1050,7 +1039,7 @@ sal_Bool ImplDrawNativeControl( HWND hWnd, HDC hDC, HTHEME hTheme, RECT rc,
         if( nPart == PART_ENTIRE_CONTROL )
         {
             // Windows Vista or later?  Try drawing to the non-client area...
-            if( ImplGetSVData()->maNWFData.mbTransparentMenubar && impl_drawAeroMenubar( hWnd, hDC, rc ) )
+            if( ImplGetSVData()->maNWFData.mbTransparentMenubar && impl_drawAeroMenubar( hDC, rc ) )
                 return sal_True;
 
             // ...otherwise use the theme
@@ -1348,7 +1337,7 @@ sal_Bool WinSalGraphics::drawNativeControl( ControlType nType,
     int ta = SetTextAlign( mhDC, TA_LEFT|TA_TOP|TA_NOUPDATECP );
 
     OUString aCaptionStr( aCaption.replace('~', '&') ); // translate mnemonics
-    bOk = ImplDrawNativeControl(mhWnd, mhDC, hTheme, rc,
+    bOk = ImplDrawNativeControl(mhDC, hTheme, rc,
                             nType, nPart, nState, aValue,
                             aCaptionStr );
 


More information about the Libreoffice-commits mailing list