vcl/inc/salframe.hxx | 6 vcl/inc/svdata.hxx | 49 +++---- vcl/inc/win/salframe.h | 6 vcl/inc/win/salgdi.h | 3 vcl/inc/win/salnativewidgets.h | 55 -------- vcl/source/window/menu.cxx | 105 +++++++++------- vcl/win/source/gdi/salnativewidgets-luna.cxx | 171 ++++++++++++++++++++++----- vcl/win/source/window/salframe.cxx | 44 ------ 8 files changed, 250 insertions(+), 189 deletions(-)
New commits: commit 64c696fc92a860fdbbe490ca503391b964dd646f Author: Jan Holesovsky <ke...@suse.cz> Date: Mon May 14 17:50:43 2012 +0200 aero: Implement a glass menubar on Windows. We need to default to the Aero colors too, in order to this be really beautiful; but hopefully already in the current state it is an improvement :-) Change-Id: I 113039b62320fa76916ba74071e1eebff4d3476c diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx index e726483..e210287 100644 --- a/vcl/inc/salframe.hxx +++ b/vcl/inc/salframe.hxx @@ -279,6 +279,12 @@ public: // (e.g. input methods, printer update handlers). long CallCallback( sal_uInt16 nEvent, const void* pEvent ) const { return m_pProc ? m_pProc( m_pWindow, const_cast<SalFrame*>(this), nEvent, pEvent ) : 0; } + + /// Update the region that is supposed to be handled by the window manager + /// + /// This is primarily for Windows Aero theme in order to be able to draw + /// to the Glass area. + virtual void extendWindowManagerFrameNative( int /*nLeft*/, int /*nRight*/, int /*nTop*/, int /*nBottom*/ ) {} }; diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index 242d58c..c21d580 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -310,6 +310,7 @@ struct ImplSVNWFData bool mbToolboxDropDownSeparate:1; // two adjacent buttons for // toolbox dropdown buttons bool mbFlatMenu:1; // no popup 3D border + bool mbTransparentMenubar:1; //< keep the background of the menubar transparent; needed for the Aero theme bool mbOpenMenuOnF10:1; // on gnome the first menu opens on F10 bool mbNoFocusRects:1; // on Aqua focus rects are not used bool mbNoBoldTabFocus:1; // on Aqua and Gnome the focused tab has not bold text diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h index 0d4e206..b805669 100644 --- a/vcl/inc/win/salframe.h +++ b/vcl/inc/win/salframe.h @@ -144,6 +144,12 @@ public: virtual void BeginSetClipRegion( sal_uIntPtr nRects ); virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ); virtual void EndSetClipRegion(); + + /// Update the region that is supposed to be handled by the window manager + /// + /// This is primarily for Windows Aero theme in order to be able to draw + /// to the Glass area. + virtual void extendWindowManagerFrameNative( int nLeft, int nRight, int nTop, int nBottom ); }; void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect ); diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 965778c..04619eb 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -52,6 +52,7 @@ #include "vcl/toolbox.hxx" #include "vcl/dockingarea.hxx" +#include "salframe.hxx" #include "salinst.hxx" #include "svdata.hxx" #include "svids.hrc" @@ -2673,6 +2674,29 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa nImageStyle |= IMAGE_DRAW_DISABLE; } + // Menubar highlights + if ( bIsMenuBar && pWin->IsNativeControlSupported( CTRL_MENUBAR, PART_MENU_ITEM ) ) + { + bool bHighlight = pThisItemOnly && bHighlighted; + if ( bHighlight || ImplGetSVData()->maNWFData.mbTransparentMenubar ) + { + Rectangle aRect = Rectangle( Point( aTopLeft.X(), 1 ), Size( pData->aSz.Width(), pWin->GetOutputSizePixel().Height()-2 ) ); + pWin->Push( PUSH_CLIPREGION ); + pWin->IntersectClipRegion( aRect ); + + // draw selected item + MenubarValue aControlValue; + aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( pWin ); + pWin->DrawNativeControl( CTRL_MENUBAR, PART_MENU_ITEM, + aRect, + CTRL_STATE_ENABLED | ( bHighlight? CTRL_STATE_SELECTED: 0 ), + aControlValue, + OUString() ); + + pWin->Pop(); + } + } + // Separator if ( !bLayout && !bIsMenuBar && ( pData->eType == MENUITEM_SEPARATOR ) ) { @@ -3331,6 +3355,9 @@ Window* MenuBar::ImplCreate( Window* pParent, Window* pWindow, MenuBar* pMenu ) ( pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar() ) ) nHeight = 0; + if ( pParent ) + pParent->ImplGetFrame()->extendWindowManagerFrameNative( 0, 0, nHeight, 0 ); + pWindow->SetPosSizePixel( 0, 0, 0, nHeight, WINDOW_POSSIZE_HEIGHT ); return pWindow; } @@ -3914,6 +3941,18 @@ static void ImplInitMenuWindow( Window* pWin, sal_Bool bFont, sal_Bool bMenuBar pWin->SetTextColor( rStyleSettings.GetMenuTextColor() ); pWin->SetTextFillColor(); pWin->SetLineColor(); + + // update the window manager frame here too in order to be able to switch + // themes + if ( bMenuBar ) + { + const Window *pParent = pWin->GetParent(); + if ( pParent ) + { + Size aSize = pWin->GetSizePixel(); + pParent->ImplGetFrame()->extendWindowManagerFrameNative( 0, 0, aSize.Height(), 0 ); + } + } } MenuFloatingWindow::MenuFloatingWindow( Menu* pMen, Window* pParent, WinBits nStyle ) : @@ -5537,15 +5576,9 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, sal_Bool bHighlight ) OUString() ); ImplAddNWFSeparator( this, aControlValue ); - if ( bHighlight ) - { - // draw selected item - DrawNativeControl( CTRL_MENUBAR, PART_MENU_ITEM, - aRect, - CTRL_STATE_ENABLED | CTRL_STATE_SELECTED, - aControlValue, - OUString() ); - } + // NWF item highlight is drawn in ImplPaint() instead of + // here, so that we can NWF-paint even the non-higlighted + // items there } else { diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx index 6fdeac6..fbe80ca 100644 --- a/vcl/win/source/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx @@ -35,7 +35,10 @@ // (found at http://stackoverflow.com/questions/4009701/windows-visual-themes-gallery-of-parts-and-states/4009712#4009712) // // Theme subclasses: -// http://msdn.microsoft.com/en-us/library/windows/desktop/bb773218%28v=vs.85%29.aspx +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb773218%28v=vs.85%29.aspx +// +// Drawing in non-client area (general DWM-related info): +// http://msdn.microsoft.com/en-us/library/windows/desktop/bb688195%28v=vs.85%29.aspx #define _SV_SALNATIVEWIDGETS_CXX @@ -48,6 +51,7 @@ #include "win/svsys.h" #include "win/salgdi.h" #include "win/saldata.hxx" +#include "win/salframe.h" #include "uxtheme.h" #include "vssym32.h" @@ -71,6 +75,7 @@ static ThemeMap aThemeMap; class VisualStylesAPI { private: + // uxtheme.dll functions typedef HTHEME (WINAPI * OpenThemeData_Proc_T) ( HWND hwnd, LPCWSTR pszClassList ); typedef HRESULT (WINAPI * CloseThemeData_Proc_T) ( HTHEME hTheme ); typedef HRESULT (WINAPI * GetThemeBackgroundContentRect_Proc_T) ( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect ); @@ -87,12 +92,18 @@ private: GetThemePartSize_Proc_T lpfnGetThemePartSize; IsThemeActive_Proc_T lpfnIsThemeActive; - oslModule mhModule; + // dwmapi.dll functions + typedef HRESULT (WINAPI * DwmExtendFrameIntoClientArea_Proc_T) ( HWND hWnd, const MARGINS *pMarInset ); + + DwmExtendFrameIntoClientArea_Proc_T lpfnDwmExtendFrameIntoClientArea; + + // module handles of the appropriate dll's + oslModule mhUxthemeModule; + oslModule mhDwmapiModule; public: VisualStylesAPI(); ~VisualStylesAPI(); - sal_Bool IsAvailable() { return (mhModule != NULL); } HTHEME OpenThemeData( HWND hwnd, LPCWSTR pszClassList ); HRESULT CloseThemeData( HTHEME hTheme ); @@ -101,40 +112,52 @@ public: 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 ); BOOL IsThemeActive( void ); + + HRESULT DwmExtendFrameIntoClientArea( HWND hWnd, const MARGINS *pMarInset ); }; static VisualStylesAPI vsAPI; VisualStylesAPI::VisualStylesAPI() + : lpfnOpenThemeData( NULL ), + lpfnCloseThemeData( NULL ), + lpfnGetThemeBackgroundContentRect( NULL ), + lpfnDrawThemeBackground( NULL ), + lpfnDrawThemeText( NULL ), + lpfnGetThemePartSize( NULL ), + lpfnIsThemeActive( NULL ), + lpfnDwmExtendFrameIntoClientArea( NULL ) { - OUString aLibraryName( RTL_CONSTASCII_USTRINGPARAM( "uxtheme.dll" ) ); - mhModule = osl_loadModule( aLibraryName.pData, SAL_LOADMODULE_DEFAULT ); + OUString aLibraryName( "uxtheme.dll" ); + mhUxthemeModule = osl_loadModule( aLibraryName.pData, SAL_LOADMODULE_DEFAULT ); - if ( mhModule ) + if ( mhUxthemeModule ) { - lpfnOpenThemeData = (OpenThemeData_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "OpenThemeData" ); - lpfnCloseThemeData = (CloseThemeData_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "CloseThemeData" ); - lpfnGetThemeBackgroundContentRect = (GetThemeBackgroundContentRect_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "GetThemeBackgroundContentRect" ); - lpfnDrawThemeBackground = (DrawThemeBackground_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "DrawThemeBackground" ); - lpfnDrawThemeText = (DrawThemeText_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "DrawThemeText" ); - lpfnGetThemePartSize = (GetThemePartSize_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "GetThemePartSize" ); - lpfnIsThemeActive = (IsThemeActive_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "IsThemeActive" ); + lpfnOpenThemeData = (OpenThemeData_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "OpenThemeData" ); + lpfnCloseThemeData = (CloseThemeData_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "CloseThemeData" ); + lpfnGetThemeBackgroundContentRect = (GetThemeBackgroundContentRect_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "GetThemeBackgroundContentRect" ); + lpfnDrawThemeBackground = (DrawThemeBackground_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "DrawThemeBackground" ); + lpfnDrawThemeText = (DrawThemeText_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "DrawThemeText" ); + lpfnGetThemePartSize = (GetThemePartSize_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "GetThemePartSize" ); + lpfnIsThemeActive = (IsThemeActive_Proc_T)osl_getAsciiFunctionSymbol( mhUxthemeModule, "IsThemeActive" ); } - else + + aLibraryName = "dwmapi.dll"; + mhDwmapiModule = osl_loadModule( aLibraryName.pData, SAL_LOADMODULE_DEFAULT ); + + if ( mhDwmapiModule ) { - lpfnOpenThemeData = NULL; - lpfnCloseThemeData = NULL; - lpfnGetThemeBackgroundContentRect = NULL; - lpfnDrawThemeBackground = NULL; - lpfnDrawThemeText = NULL; - lpfnGetThemePartSize = NULL; + lpfnDwmExtendFrameIntoClientArea = (DwmExtendFrameIntoClientArea_Proc_T)osl_getAsciiFunctionSymbol( mhDwmapiModule, "DwmExtendFrameIntoClientArea" ); } } VisualStylesAPI::~VisualStylesAPI() { - if( mhModule ) - osl_unloadModule( mhModule ); + if( mhUxthemeModule ) + osl_unloadModule( mhUxthemeModule ); + + if( mhDwmapiModule ) + osl_unloadModule( mhDwmapiModule ); } HTHEME VisualStylesAPI::OpenThemeData( HWND hwnd, LPCWSTR pszClassList ) @@ -193,6 +216,14 @@ BOOL VisualStylesAPI::IsThemeActive( void ) return FALSE; } +HRESULT VisualStylesAPI::DwmExtendFrameIntoClientArea( HWND hWnd, const MARGINS *pMarInset ) +{ + if (lpfnDwmExtendFrameIntoClientArea) + return (*lpfnDwmExtendFrameIntoClientArea) ( hWnd, pMarInset ); + else + return S_FALSE; +} + /********************************************************* * Initialize XP theming and local stuff *********************************************************/ @@ -461,7 +492,7 @@ void ImplConvertSpinbuttonValues( int nControlPart, const ControlState& rState, // ---- -sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, +sal_Bool ImplDrawNativeControl( HWND hWnd, HDC hDC, HTHEME hTheme, RECT rc, ControlType nType, ControlPart nPart, ControlState nState, @@ -911,12 +942,22 @@ sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, { if( nPart == PART_ENTIRE_CONTROL ) { - if( aValue.getType() == CTRL_MENUBAR ) + if( ImplGetSVData()->maNWFData.mbTransparentMenubar ) { - const MenubarValue *pValue = static_cast<const MenubarValue*>(&aValue); - rc.bottom += pValue->maTopDockingAreaHeight; // extend potential gradient to cover docking area as well + // When the frame is correctly extended to the client area, + // Aero just needs us to repaint the affected rectangle in black + FillRect( hDC, &rc, static_cast< HBRUSH >( GetStockObject( BLACK_BRUSH ) ) ); + return sal_True; + } + else + { + if( aValue.getType() == CTRL_MENUBAR ) + { + const MenubarValue *pValue = static_cast<const MenubarValue*>(&aValue); + rc.bottom += pValue->maTopDockingAreaHeight; // extend potential gradient to cover docking area as well + } + return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); } - return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); } else if( nPart == PART_MENU_ITEM ) { @@ -924,6 +965,25 @@ sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, iState = (nState & CTRL_STATE_SELECTED) ? MBI_HOT : MBI_NORMAL; else iState = (nState & CTRL_STATE_SELECTED) ? MBI_DISABLEDHOT : MBI_DISABLED; + + // draw the text glow so that the text is better visible + if ( ImplGetSVData()->maNWFData.mbTransparentMenubar ) + { + HTHEME hGlowTheme = getThemeHandle( hWnd, L"TextGlow"); + if ( !hTheme ) + return sal_False; + + // 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 :-( + ImplDrawTheme( hGlowTheme, hDC, 1, MBI_NORMAL, rc, aCaption ); + } + return ImplDrawTheme( hTheme, hDC, MENU_BARITEM, iState, rc, aCaption ); } } @@ -1204,7 +1264,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(mhDC, hTheme, rc, + bOk = ImplDrawNativeControl(mhWnd, mhDC, hTheme, rc, nType, nPart, nState, aValue, aCaptionStr ); @@ -1458,4 +1518,20 @@ void WinSalGraphics::updateSettingsNative( AllSettings& rSettings ) rSettings.SetStyleSettings( aStyleSettings ); } +void WinSalFrame::extendWindowManagerFrameNative( int nLeft, int nRight, int nTop, int nBottom ) +{ + // nothing to do for Windows before Vista + if( aSalShlData.maVersionInfo.dwMajorVersion < 6 || !vsAPI.IsThemeActive() ) + return; + + MARGINS aMargins = { nLeft, nRight, nTop, nBottom }; + HRESULT nRet = vsAPI.DwmExtendFrameIntoClientArea( mhWnd, &aMargins ); + + ImplSVData* pSVData = ImplGetSVData(); + if( nRet == S_OK ) + pSVData->maNWFData.mbTransparentMenubar = true; + else + pSVData->maNWFData.mbTransparentMenubar = false; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 83208da599e46dbba39c9e9a5b503bc4e93d4eea Author: Jan Holesovsky <ke...@suse.cz> Date: Mon May 14 14:58:32 2012 +0200 Reduce copy'n'paste by different nesting of if's. Change-Id: I9a68d585217550c1d229a2bc66d04e506253d747 diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 39536d7..965778c 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -1,4 +1,3 @@ - /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * @@ -5521,56 +5520,45 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, sal_Bool bHighlight ) Rectangle aRect = Rectangle( Point( nX, 1 ), Size( pData->aSz.Width(), GetOutputSizePixel().Height()-2 ) ); Push( PUSH_CLIPREGION ); IntersectClipRegion( aRect ); - if ( bHighlight ) + + if( IsNativeControlSupported( CTRL_MENUBAR, PART_MENU_ITEM ) && + IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) ) { - if( IsNativeControlSupported( CTRL_MENUBAR, PART_MENU_ITEM ) && - IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) ) - { - // draw background (transparency) - MenubarValue aControlValue; - aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); - - Point tmp(0,0); - Rectangle aBgRegion( tmp, GetOutputSizePixel() ); - DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, - aBgRegion, - CTRL_STATE_ENABLED, - aControlValue, - OUString() ); - ImplAddNWFSeparator( this, aControlValue ); + // draw background (transparency) + MenubarValue aControlValue; + aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); + + Point tmp(0,0); + Rectangle aBgRegion( tmp, GetOutputSizePixel() ); + DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, + aBgRegion, + CTRL_STATE_ENABLED, + aControlValue, + OUString() ); + ImplAddNWFSeparator( this, aControlValue ); + if ( bHighlight ) + { // draw selected item DrawNativeControl( CTRL_MENUBAR, PART_MENU_ITEM, - aRect, - CTRL_STATE_ENABLED | CTRL_STATE_SELECTED, - aControlValue, - OUString() ); - } - else - { - SetFillColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() ); - SetLineColor(); - DrawRect( aRect ); + aRect, + CTRL_STATE_ENABLED | CTRL_STATE_SELECTED, + aControlValue, + OUString() ); } } else { - if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) ) + if ( bHighlight ) { - MenubarValue aMenubarValue; - aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); - - // use full window size to get proper gradient - // but clip accordingly - Point aPt; - Rectangle aCtrlRect( aPt, GetOutputSizePixel() ); - - DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, CTRL_STATE_ENABLED, aMenubarValue, rtl::OUString() ); - ImplAddNWFSeparator( this, aMenubarValue ); + SetFillColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() ); + SetLineColor(); + DrawRect( aRect ); } else Erase( aRect ); } + Pop(); pMenu->ImplPaint( this, 0, 0, pData, bHighlight ); } commit edec6d134a4265fe6c69f3e51a173a5cd395c615 Author: Jan Holesovsky <ke...@suse.cz> Date: Fri May 11 14:18:23 2012 +0200 Pack the bools. Change-Id: I71bf94a87f8d7092b472e7a8eb58045a82749c29 diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx index b6a31b0..242d58c 100644 --- a/vcl/inc/svdata.hxx +++ b/vcl/inc/svdata.hxx @@ -300,30 +300,30 @@ struct ImplSVHelpData struct ImplSVNWFData { - bool mbMenuBarDockingAreaCommonBG; // e.g. WinXP default theme - bool mbDockingAreaSeparateTB; // individual toolbar backgrounds - // instead of one for docking area - bool mbToolboxDropDownSeparate; // two adjacent buttons for - // toolbox dropdown buttons - int mnMenuFormatExtraBorder; // inner popup menu border - bool mbFlatMenu; // no popup 3D border - ::Color maMenuBarHighlightTextColor; // override higlight text color - // in menubar if not transparent - bool mbOpenMenuOnF10; // on gnome the first menu opens on F10 - bool mbNoFocusRects; // on Aqua focus rects are not used - bool mbNoBoldTabFocus; // on Aqua and Gnome the focused tab has not bold text - bool mbCenteredTabs; // on Aqua, tabs are centered - bool mbNoActiveTabTextRaise; // on Aqua the text for the selected tab - // should not "jump up" a pixel - bool mbProgressNeedsErase; // set true for platforms that should draw the - // window background before drawing the native - // progress bar - bool mbCheckBoxNeedsErase; // set true for platforms that should draw the - // window background before drawing the native - // checkbox - bool mbScrollbarJumpPage; // true for "jump to here" behavior - int mnStatusBarLowerRightOffset; // amount in pixel to avoid in the lower righthand corner - bool mbCanDrawWidgetAnySize; // set to true currently on gtk + int mnStatusBarLowerRightOffset; // amount in pixel to avoid in the lower righthand corner + int mnMenuFormatExtraBorder; // inner popup menu border + ::Color maMenuBarHighlightTextColor; // override higlight text color + // in menubar if not transparent + bool mbMenuBarDockingAreaCommonBG:1; // e.g. WinXP default theme + bool mbDockingAreaSeparateTB:1; // individual toolbar backgrounds + // instead of one for docking area + bool mbToolboxDropDownSeparate:1; // two adjacent buttons for + // toolbox dropdown buttons + bool mbFlatMenu:1; // no popup 3D border + bool mbOpenMenuOnF10:1; // on gnome the first menu opens on F10 + bool mbNoFocusRects:1; // on Aqua focus rects are not used + bool mbNoBoldTabFocus:1; // on Aqua and Gnome the focused tab has not bold text + bool mbCenteredTabs:1; // on Aqua, tabs are centered + bool mbNoActiveTabTextRaise:1; // on Aqua the text for the selected tab + // should not "jump up" a pixel + bool mbProgressNeedsErase:1; // set true for platforms that should draw the + // window background before drawing the native + // progress bar + bool mbCheckBoxNeedsErase:1; // set true for platforms that should draw the + // window background before drawing the native + // checkbox + bool mbScrollbarJumpPage:1; // true for "jump to here" behavior + bool mbCanDrawWidgetAnySize:1; // set to true currently on gtk }; commit 9d2b1ec8e85b0786eae452198a7f57a3c00ec33b Author: Jan Holesovsky <ke...@suse.cz> Date: Thu May 10 14:01:47 2012 +0200 Don't take the workspace color from system on Windows, it is extremely ugly. [We need to introduce taking colors from theme (instead of system) anyway.] Change-Id: I75037771f2542e924cbff01accf66cfc851ec255 diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx index 3b03868..4b08f62 100644 --- a/vcl/win/source/window/salframe.cxx +++ b/vcl/win/source/window/salframe.cxx @@ -2744,7 +2744,6 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetLightBorderColor( ImplWinColorToSal( GetSysColor( COLOR_3DLIGHT ) ) ); aStyleSettings.SetShadowColor( ImplWinColorToSal( GetSysColor( COLOR_3DSHADOW ) ) ); aStyleSettings.SetDarkShadowColor( ImplWinColorToSal( GetSysColor( COLOR_3DDKSHADOW ) ) ); - aStyleSettings.SetWorkspaceColor( ImplWinColorToSal( GetSysColor( COLOR_APPWORKSPACE ) ) ); aStyleSettings.SetHelpColor( ImplWinColorToSal( GetSysColor( COLOR_INFOBK ) ) ); aStyleSettings.SetHelpTextColor( ImplWinColorToSal( GetSysColor( COLOR_INFOTEXT ) ) ); aStyleSettings.SetDialogColor( aStyleSettings.GetFaceColor() ); commit 23676a74fcf80d2ff35706361c3ddd6711c917f9 Author: Jan Holesovsky <ke...@suse.cz> Date: Thu May 10 13:08:51 2012 +0200 Instead of DwmIsCompositionEnabled, use IsThemeActive from uxtheme.dll. No idea why the DwmIsCompositionEnabled is recommended ~everywhere where you search for how to check if the themes are enabled; it is wrong as eg. over rdesktop, you are still using themes, but for sure not the composition in dwm. Change-Id: I Ib34f2a17809d03f29ccdf7d4a8b94ee7ad996bf5 diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 698bf57..50d1015 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -371,6 +371,9 @@ public: virtual SystemGraphicsData GetGraphicsData() const; virtual SystemFontData GetSysFontData( int nFallbacklevel ) const; + + /// Update settings based on the platform values + static void updateSettingsNative( AllSettings& rSettings ); }; // Init/Deinit Graphics diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx index 1f684b8..6fdeac6 100644 --- a/vcl/win/source/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx @@ -77,6 +77,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 BOOL (WINAPI * IsThemeActive_Proc_T) ( void ); OpenThemeData_Proc_T lpfnOpenThemeData; CloseThemeData_Proc_T lpfnCloseThemeData; @@ -84,6 +85,7 @@ private: DrawThemeBackground_Proc_T lpfnDrawThemeBackground; DrawThemeText_Proc_T lpfnDrawThemeText; GetThemePartSize_Proc_T lpfnGetThemePartSize; + IsThemeActive_Proc_T lpfnIsThemeActive; oslModule mhModule; @@ -98,6 +100,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 ); + BOOL IsThemeActive( void ); }; static VisualStylesAPI vsAPI; @@ -115,6 +118,7 @@ VisualStylesAPI::VisualStylesAPI() lpfnDrawThemeBackground = (DrawThemeBackground_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "DrawThemeBackground" ); lpfnDrawThemeText = (DrawThemeText_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "DrawThemeText" ); lpfnGetThemePartSize = (GetThemePartSize_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "GetThemePartSize" ); + lpfnIsThemeActive = (IsThemeActive_Proc_T)osl_getAsciiFunctionSymbol( mhModule, "IsThemeActive" ); } else { @@ -126,11 +130,13 @@ VisualStylesAPI::VisualStylesAPI() lpfnGetThemePartSize = NULL; } } + VisualStylesAPI::~VisualStylesAPI() { if( mhModule ) osl_unloadModule( mhModule ); } + HTHEME VisualStylesAPI::OpenThemeData( HWND hwnd, LPCWSTR pszClassList ) { if(lpfnOpenThemeData) @@ -146,6 +152,7 @@ HRESULT VisualStylesAPI::CloseThemeData( HTHEME hTheme ) else return S_FALSE; } + HRESULT VisualStylesAPI::GetThemeBackgroundContentRect( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect ) { if(lpfnGetThemeBackgroundContentRect) @@ -153,6 +160,7 @@ HRESULT VisualStylesAPI::GetThemeBackgroundContentRect( HTHEME hTheme, HDC hdc, else return S_FALSE; } + HRESULT VisualStylesAPI::DrawThemeBackground( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect ) { if(lpfnDrawThemeBackground) @@ -160,6 +168,7 @@ HRESULT VisualStylesAPI::DrawThemeBackground( HTHEME hTheme, HDC hdc, int iPartI else return S_FALSE; } + HRESULT VisualStylesAPI::DrawThemeText( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect ) { if(lpfnDrawThemeText) @@ -167,6 +176,7 @@ HRESULT VisualStylesAPI::DrawThemeText( HTHEME hTheme, HDC hdc, int iPartId, int else return S_FALSE; } + HRESULT VisualStylesAPI::GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz ) { if(lpfnGetThemePartSize) @@ -175,6 +185,13 @@ HRESULT VisualStylesAPI::GetThemePartSize( HTHEME hTheme, HDC hdc, int iPartId, return S_FALSE; } +BOOL VisualStylesAPI::IsThemeActive( void ) +{ + if(lpfnIsThemeActive) + return (*lpfnIsThemeActive) (); + else + return FALSE; +} /********************************************************* * Initialize XP theming and local stuff @@ -1417,4 +1434,28 @@ sal_Bool WinSalGraphics::getNativeControlRegion( ControlType nType, return( bRet ); } +void WinSalGraphics::updateSettingsNative( AllSettings& rSettings ) +{ + if ( !vsAPI.IsThemeActive() ) + return; + + StyleSettings aStyleSettings = rSettings.GetStyleSettings(); + ImplSVData* pSVData = ImplGetSVData(); + + // check if vista or newer runs + // in Aero theme (and similar ?) the menu text color does not change + // for selected items; also on WinXP and earlier menus are not themed + // FIXME get the color directly from the theme, not from the settings + if( aSalShlData.maVersionInfo.dwMajorVersion >= 6 ) + { + // in aero menuitem highlight text is drawn in the same color as normal + aStyleSettings.SetMenuHighlightTextColor( aStyleSettings.GetMenuTextColor() ); + pSVData->maNWFData.mnMenuFormatExtraBorder = 2; + pSVData->maNWFData.maMenuBarHighlightTextColor = aStyleSettings.GetMenuTextColor(); + GetSalData()->mbThemeMenuSupport = TRUE; + } + + rSettings.SetStyleSettings( aStyleSettings ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx index aae5999..3b03868 100644 --- a/vcl/win/source/window/salframe.cxx +++ b/vcl/win/source/window/salframe.cxx @@ -2696,33 +2696,6 @@ static long ImplA2I( const BYTE* pStr ) } // ----------------------------------------------------------------------- -static HRESULT WINAPI backwardCompatibleDwmIsCompositionEnabled( BOOL* pOut ) -{ - *pOut = FALSE; - return S_OK; -} - -static BOOL ImplDwmIsCompositionEnabled() -{ - // FIXME It seems that this wrong advice to use 'DwmIsCompositionEnabled' - // is widely spread; causing LO to not theme menus when running in - // rdesktop. We should beter use IsThemeActive() from uxtheme.dll. - // But the entire ::UpdateSettings() need a rework anyway ;-) - SalData* pSalData = GetSalData(); - if( ! pSalData->mpDwmIsCompositionEnabled ) - { - rtl::OUString aLibraryName( RTL_CONSTASCII_USTRINGPARAM( "Dwmapi.dll" ) ); - pSalData->maDwmLib = osl_loadModule( aLibraryName.pData, SAL_LOADMODULE_DEFAULT ); - if( pSalData->maDwmLib ) - pSalData->mpDwmIsCompositionEnabled = (DwmIsCompositionEnabled_ptr)osl_getAsciiFunctionSymbol( pSalData->maDwmLib, "DwmIsCompositionEnabled" ); - if( ! pSalData->mpDwmIsCompositionEnabled ) // something failed - pSalData->mpDwmIsCompositionEnabled = backwardCompatibleDwmIsCompositionEnabled; - } - BOOL aResult = FALSE; - HRESULT nError = pSalData->mpDwmIsCompositionEnabled( &aResult ); - return nError == S_OK && aResult; -} - void WinSalFrame::UpdateSettings( AllSettings& rSettings ) { @@ -2825,19 +2798,6 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) aStyleSettings.SetUseFlatBorders( TRUE ); } } - // check if vista or newer runs - // in Aero theme (and similar ?) the menu text color does not change - // for selected items; also on WinXP and earlier menus are not themed - if( aSalShlData.maVersionInfo.dwMajorVersion >= 6 && - ImplDwmIsCompositionEnabled() - ) - { - // in aero menuitem highlight text is drawn in the same color as normal - aStyleSettings.SetMenuHighlightTextColor( aStyleSettings.GetMenuTextColor() ); - pSVData->maNWFData.mnMenuFormatExtraBorder = 2; - pSVData->maNWFData.maMenuBarHighlightTextColor = aStyleSettings.GetMenuTextColor(); - GetSalData()->mbThemeMenuSupport = TRUE; - } aStyleSettings.SetCheckedColorSpecialCase( ); // caret width @@ -2957,6 +2917,9 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings ) rSettings.SetMouseSettings( aMouseSettings ); rSettings.SetStyleSettings( aStyleSettings ); + + // now apply the values from theming, if available + WinSalGraphics::updateSettingsNative( rSettings ); } // ----------------------------------------------------------------------- commit 1917de4bb409b9b9d3a5c25c5154298b3e29f0a6 Author: Jan Holesovsky <ke...@suse.cz> Date: Thu May 10 10:58:01 2012 +0200 Kill unused file. Change-Id: Id07fce1f1baf7361e16f16af63f54c98a71791f6 diff --git a/vcl/inc/win/salnativewidgets.h b/vcl/inc/win/salnativewidgets.h deleted file mode 100644 index 33ba8de..0000000 --- a/vcl/inc/win/salnativewidgets.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SV_NATIVEWIDGETS_H -#define _SV_NATIVEWIDGETS_H - - -#ifdef __cplusplus - -/* SalControlHandleData: - * - * Holds platform specific theming data. - */ - -class SalControlHandleData -{ - public: - SalControlHandleData( void ); - ~SalControlHandleData( void ); - - public: - // nothing needed on Win32 -}; - - -#endif /* __cplusplus */ - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits