summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/source/gdi/salnativewidgets-luna.cxx132
1 files changed, 104 insertions, 28 deletions
diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx
index 6fdeac639c9a..fbe80ca41ddb 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: */