summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2012-05-10 13:08:51 +0200
committerJan Holesovsky <kendy@suse.cz>2012-05-15 08:39:31 +0200
commit23676a74fcf80d2ff35706361c3ddd6711c917f9 (patch)
tree9f39066ed757e11307539c1cbee2094ed2c5eb7e /vcl/win
parent1917de4bb409b9b9d3a5c25c5154298b3e29f0a6 (diff)
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
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/source/gdi/salnativewidgets-luna.cxx41
-rw-r--r--vcl/win/source/window/salframe.cxx43
2 files changed, 44 insertions, 40 deletions
diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx
index 1f684b806863..6fdeac639c9a 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 aae5999896fd..3b038682202c 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 );
}
// -----------------------------------------------------------------------