summaryrefslogtreecommitdiffstats
path: root/vcl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2012-06-20 12:01:52 +0200
committerJan Holesovsky <kendy@suse.cz>2012-06-20 14:26:45 +0200
commit9164d135db46be9de56ef60f4b95bbd933fdb57e (patch)
tree51555438e0c74c43d6436adb20d59a7af12d61fc /vcl
parentaero toolbar: Use the new toolbar look on Vista+ regardless of glass menu. (diff)
downloadcore-9164d135db46be9de56ef60f4b95bbd933fdb57e.tar.gz
core-9164d135db46be9de56ef60f4b95bbd933fdb57e.zip
aero menubar: Make the text in menu black.
Change-Id: I4d9486ccda091506ad103fa4182cadf810fcd6f2
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/menu.cxx11
-rw-r--r--vcl/win/source/gdi/salnativewidgets-luna.cxx100
2 files changed, 101 insertions, 10 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 935d5a9ec9ac..2bf8202079f6 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 99c512f8c91c..a93bdcafc2b8 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 );
}
}