diff options
Diffstat (limited to 'vcl/win/source/gdi/salnativewidgets-luna.cxx')
-rwxr-xr-x[-rw-r--r--] | vcl/win/source/gdi/salnativewidgets-luna.cxx | 245 |
1 files changed, 187 insertions, 58 deletions
diff --git a/vcl/win/source/gdi/salnativewidgets-luna.cxx b/vcl/win/source/gdi/salnativewidgets-luna.cxx index be5d7f8360bc..97e3e1b48c79 100644..100755 --- a/vcl/win/source/gdi/salnativewidgets-luna.cxx +++ b/vcl/win/source/gdi/salnativewidgets-luna.cxx @@ -188,6 +188,8 @@ void SalData::deInitNWF( void ) iter++; } aThemeMap.clear(); + if( maDwmLib ) + osl_unloadModule( maDwmLib ); } static HTHEME getThemeHandle( HWND hWnd, LPCWSTR name ) @@ -286,6 +288,22 @@ BOOL WinSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP case CTRL_MENUBAR: if( nPart == PART_ENTIRE_CONTROL ) hTheme = getThemeHandle( mhWnd, L"Rebar"); + else if( GetSalData()->mbThemeMenuSupport ) + { + if( nPart == PART_MENU_ITEM ) + hTheme = getThemeHandle( mhWnd, L"Menu" ); + } + break; + case CTRL_MENU_POPUP: + if( GetSalData()->mbThemeMenuSupport ) + { + if( nPart == PART_ENTIRE_CONTROL || + nPart == PART_MENU_ITEM || + nPart == PART_MENU_ITEM_CHECK_MARK || + nPart == PART_MENU_ITEM_RADIO_MARK || + nPart == PART_MENU_SEPARATOR ) + hTheme = getThemeHandle( mhWnd, L"Menu" ); + } break; case CTRL_PROGRESS: if( nPart == PART_ENTIRE_CONTROL ) @@ -317,7 +335,7 @@ BOOL WinSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP */ BOOL WinSalGraphics::hitTestNativeControl( ControlType, ControlPart, - const Region&, + const Rectangle&, const Point&, BOOL& ) { @@ -553,9 +571,9 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, } if( nType == CTRL_SPINBUTTONS && nPart == PART_ALL_BUTTONS ) { - SpinbuttonValue *pValue = (SpinbuttonValue*) aValue.getOptionalVal(); - if( pValue ) + if( aValue.getType() == CTRL_SPINBUTTONS ) { + const SpinbuttonValue *pValue = static_cast<const SpinbuttonValue*>(&aValue); BOOL bOk = FALSE; RECT rect; @@ -578,9 +596,9 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, //rc.bottom--; if( nPart == PART_ALL_BUTTONS ) { - SpinbuttonValue *pValue = (SpinbuttonValue*) aValue.getOptionalVal(); - if( pValue ) + if( aValue.getType() == CTRL_SPINBUTTONS ) { + const SpinbuttonValue *pValue = static_cast<const SpinbuttonValue*>(&aValue); BOOL bOk = FALSE; RECT rect; @@ -787,20 +805,19 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, iPart = TABP_TABITEMLEFTEDGE; rc.bottom--; - TabitemValue *pValue = (TabitemValue*) aValue.getOptionalVal(); - if( pValue ) + OSL_ASSERT( aValue.getType() == CTRL_TAB_ITEM ); + + const TabitemValue *pValue = static_cast<const TabitemValue*>(&aValue); + if( pValue->isBothAligned() ) { - if( pValue->isBothAligned() ) - { - iPart = TABP_TABITEMLEFTEDGE; - rc.right--; - } - else if( pValue->isLeftAligned() ) - iPart = TABP_TABITEMLEFTEDGE; - else if( pValue->isRightAligned() ) - iPart = TABP_TABITEMRIGHTEDGE; - else iPart = TABP_TABITEM; + iPart = TABP_TABITEMLEFTEDGE; + rc.right--; } + else if( pValue->isLeftAligned() ) + iPart = TABP_TABITEMLEFTEDGE; + else if( pValue->isRightAligned() ) + iPart = TABP_TABITEMRIGHTEDGE; + else iPart = TABP_TABITEM; if( !(nState & CTRL_STATE_ENABLED) ) iState = TILES_DISABLED; @@ -856,22 +873,35 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, } else if( nPart == PART_DRAW_BACKGROUND_HORZ || nPart == PART_DRAW_BACKGROUND_VERT ) { - ToolbarValue *pValue = (ToolbarValue*) aValue.getOptionalVal(); - if( pValue && pValue->mbIsTopDockingArea ) - rc.top = 0; // extend potential gradient to cover menu bar as well + if( aValue.getType() == CTRL_TOOLBAR ) + { + const ToolbarValue *pValue = static_cast<const ToolbarValue*>(&aValue); + if( pValue->mbIsTopDockingArea ) + rc.top = 0; // extend potential gradient to cover menu bar as well + } return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); } } if( nType == CTRL_MENUBAR ) { - if( nPart != PART_ENTIRE_CONTROL ) - return FALSE; - - MenubarValue *pValue = (MenubarValue*) aValue.getOptionalVal(); - if( pValue ) - rc.bottom += pValue->maTopDockingAreaHeight; // extend potential gradient to cover docking area as well - return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption); + if( nPart == PART_ENTIRE_CONTROL ) + { + 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); + } + else if( nPart == PART_MENU_ITEM ) + { + if( (nState & CTRL_STATE_ENABLED) ) + iState = (nState & CTRL_STATE_SELECTED) ? MBI_HOT : MBI_NORMAL; + else + iState = (nState & CTRL_STATE_SELECTED) ? MBI_DISABLEDHOT : MBI_DISABLED; + return ImplDrawTheme( hTheme, hDC, MENU_BARITEM, iState, rc, aCaption ); + } } if( nType == CTRL_PROGRESS ) @@ -918,7 +948,8 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, ImplDrawTheme( hTheme, hDC, iPart, iState, aTRect, aCaption ); RECT aThumbRect; - SliderValue* pVal = (SliderValue*)aValue.getOptionalVal(); + OSL_ASSERT( aValue.getType() == CTRL_SLIDER ); + const SliderValue* pVal = static_cast<const SliderValue*>(&aValue); aThumbRect.left = pVal->maThumbRect.Left(); aThumbRect.top = pVal->maThumbRect.Top(); aThumbRect.right = pVal->maThumbRect.Right(); @@ -949,6 +980,69 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, return ImplDrawTheme( hTheme, hDC, iPart, iState, rc, aCaption ); } + if( GetSalData()->mbThemeMenuSupport ) + { + if( nType == CTRL_MENU_POPUP ) + { + if( nPart == PART_ENTIRE_CONTROL ) + { + RECT aGutterRC = rc; + aGutterRC.left += aValue.getNumericVal(); + aGutterRC.right = aGutterRC.left+3; + return + ImplDrawTheme( hTheme, hDC, MENU_POPUPBACKGROUND, 0, rc, aCaption ) && + ImplDrawTheme( hTheme, hDC, MENU_POPUPGUTTER, 0, aGutterRC, aCaption ) + ; + } + else if( nPart == PART_MENU_ITEM ) + { + if( (nState & CTRL_STATE_ENABLED) ) + iState = (nState & CTRL_STATE_SELECTED) ? MPI_HOT : MPI_NORMAL; + else + iState = (nState & CTRL_STATE_SELECTED) ? MPI_DISABLEDHOT : MPI_DISABLED; + return ImplDrawTheme( hTheme, hDC, MENU_POPUPITEM, iState, rc, aCaption ); + } + else if( nPart == PART_MENU_ITEM_CHECK_MARK || nPart == PART_MENU_ITEM_RADIO_MARK ) + { + if( (nState & CTRL_STATE_PRESSED) ) + { + RECT aBGRect = rc; + if( aValue.getType() == CTRL_MENU_POPUP ) + { + const MenupopupValue& rMVal( static_cast<const MenupopupValue&>(aValue) ); + aBGRect.left = rMVal.maItemRect.Left(); + aBGRect.top = rMVal.maItemRect.Top(); + aBGRect.bottom = rMVal.maItemRect.Bottom()+1; // see below in drawNativeControl + aBGRect.right = rMVal.getNumericVal(); + + // FIXME: magic + aBGRect.left += 1; aBGRect.top += 1; aBGRect.bottom +=1; + } + iState = (nState & CTRL_STATE_ENABLED) ? MCB_NORMAL : MCB_DISABLED; + ImplDrawTheme( hTheme, hDC, MENU_POPUPCHECKBACKGROUND, iState, aBGRect, aCaption ); + if( nPart == PART_MENU_ITEM_CHECK_MARK ) + iState = (nState & CTRL_STATE_ENABLED) ? MC_CHECKMARKNORMAL : MC_CHECKMARKDISABLED; + else + iState = (nState & CTRL_STATE_ENABLED) ? MC_BULLETNORMAL : MC_BULLETDISABLED; + return ImplDrawTheme( hTheme, hDC, MENU_POPUPCHECK, iState, rc, aCaption ); + } + else + return true; // unchecked: do nothing + } + else if( nPart == PART_MENU_SEPARATOR ) + { + rc.left += aValue.getNumericVal(); // adjust for gutter position + Rectangle aRect( ImplGetThemeRect( hTheme, hDC, + MENU_POPUPSEPARATOR, 0, Rectangle( rc.left, rc.top, rc.right, rc.bottom ) ) ); + // center the separator inside the passed rectangle + long nDY = ((rc.bottom - rc.top + 1) - aRect.GetHeight()) / 2; + rc.top += nDY; + rc.bottom = rc.top+aRect.GetHeight()-1; + return ImplDrawTheme( hTheme, hDC, MENU_POPUPSEPARATOR, 0, rc, aCaption ); + } + } + } + return false; } @@ -963,7 +1057,7 @@ BOOL ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc, */ BOOL WinSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, - const Region& rControlRegion, + const Rectangle& rControlRegion, ControlState nState, const ImplControlValue& aValue, const OUString& aCaption ) @@ -1022,6 +1116,11 @@ BOOL WinSalGraphics::drawNativeControl( ControlType nType, case CTRL_MENUBAR: if( nPart == PART_ENTIRE_CONTROL ) hTheme = getThemeHandle( mhWnd, L"Rebar"); + else if( GetSalData()->mbThemeMenuSupport ) + { + if( nPart == PART_MENU_ITEM ) + hTheme = getThemeHandle( mhWnd, L"Menu" ); + } break; case CTRL_PROGRESS: if( nPart == PART_ENTIRE_CONTROL ) @@ -1035,6 +1134,16 @@ BOOL WinSalGraphics::drawNativeControl( ControlType nType, if( nPart == PART_TRACK_HORZ_AREA || nPart == PART_TRACK_VERT_AREA ) hTheme = getThemeHandle( mhWnd, L"Trackbar" ); break; + case CTRL_MENU_POPUP: + if( GetSalData()->mbThemeMenuSupport ) + { + if( nPart == PART_ENTIRE_CONTROL || nPart == PART_MENU_ITEM || + nPart == PART_MENU_ITEM_CHECK_MARK || nPart == PART_MENU_ITEM_RADIO_MARK || + nPart == PART_MENU_SEPARATOR + ) + hTheme = getThemeHandle( mhWnd, L"Menu" ); + } + break; default: hTheme = NULL; break; @@ -1043,7 +1152,7 @@ BOOL WinSalGraphics::drawNativeControl( ControlType nType, if( !hTheme ) return false; - Rectangle buttonRect = rControlRegion.GetBoundRect(); + Rectangle buttonRect = rControlRegion; RECT rc; rc.left = buttonRect.Left(); rc.right = buttonRect.Right()+1; @@ -1080,7 +1189,7 @@ BOOL WinSalGraphics::drawNativeControl( ControlType nType, */ BOOL WinSalGraphics::drawNativeControlText( ControlType, ControlPart, - const Region&, + const Rectangle&, ControlState, const ImplControlValue&, const OUString& ) @@ -1104,12 +1213,12 @@ BOOL WinSalGraphics::drawNativeControlText( ControlType, */ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, - const Region& rControlRegion, + const Rectangle& rControlRegion, ControlState nState, const ImplControlValue& rControlValue, const OUString&, - Region &rNativeBoundingRegion, - Region &rNativeContentRegion ) + Rectangle &rNativeBoundingRegion, + Rectangle &rNativeContentRegion ) { BOOL bRet = FALSE; @@ -1146,7 +1255,7 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, if( hTheme ) { Rectangle aRect( ImplGetThemeRect( hTheme, hDC, TP_SPLITBUTTONDROPDOWN, - TS_HOT, rControlRegion.GetBoundRect() ) ); + TS_HOT, rControlRegion ) ); rNativeContentRegion = aRect; rNativeBoundingRegion = rNativeContentRegion; if( !rNativeContentRegion.IsEmpty() ) @@ -1160,7 +1269,7 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, if( hTheme ) { Rectangle aRect( ImplGetThemeRect( hTheme, hDC, PP_BAR, - 0, rControlRegion.GetBoundRect() ) ); + 0, rControlRegion ) ); rNativeContentRegion = aRect; rNativeBoundingRegion = rNativeContentRegion; if( !rNativeContentRegion.IsEmpty() ) @@ -1172,12 +1281,9 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, HTHEME hTheme = getThemeHandle( mhWnd, L"Combobox"); if( hTheme ) { - Rectangle aBoxRect( rControlRegion.GetBoundRect() ); + Rectangle aBoxRect( rControlRegion ); Rectangle aRect( ImplGetThemeRect( hTheme, hDC, CP_DROPDOWNBUTTON, CBXS_NORMAL, aBoxRect ) ); - Rectangle aBrdRect( ImplGetThemeRect( hTheme, hDC, CP_BORDER, - CBB_HOT, aBoxRect ) ); - aRect.Top() -= aBrdRect.GetHeight(); if( aRect.GetHeight() > aBoxRect.GetHeight() ) aBoxRect.Bottom() = aBoxRect.Top() + aRect.GetHeight(); if( aRect.GetWidth() > aBoxRect.GetWidth() ) @@ -1194,8 +1300,8 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, HTHEME hTheme = getThemeHandle( mhWnd, L"Edit"); if( hTheme ) { - // get borderr size - Rectangle aBoxRect( rControlRegion.GetBoundRect() ); + // get border size + Rectangle aBoxRect( rControlRegion ); Rectangle aRect( ImplGetThemeRect( hTheme, hDC, EP_BACKGROUNDWITHBORDER, EBWBS_HOT, aBoxRect ) ); // ad app font height @@ -1223,6 +1329,29 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, } } + if( GetSalData()->mbThemeMenuSupport ) + { + if( nType == CTRL_MENU_POPUP ) + { + if( nPart == PART_MENU_ITEM_CHECK_MARK || + nPart == PART_MENU_ITEM_RADIO_MARK ) + { + HTHEME hTheme = getThemeHandle( mhWnd, L"Menu"); + Rectangle aBoxRect( rControlRegion ); + Rectangle aRect( ImplGetThemeRect( hTheme, hDC, + MENU_POPUPCHECK, + MC_CHECKMARKNORMAL, + aBoxRect ) ); + if( aBoxRect.GetWidth() && aBoxRect.GetHeight() ) + { + rNativeContentRegion = aRect; + rNativeBoundingRegion = rNativeContentRegion; + bRet = TRUE; + } + } + } + } + if( nType == CTRL_SLIDER && ( (nPart == PART_THUMB_HORZ) || (nPart == PART_THUMB_VERT) ) ) { HTHEME hTheme = getThemeHandle( mhWnd, L"Trackbar"); @@ -1234,7 +1363,7 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, if( nPart == PART_THUMB_HORZ ) { long nW = aThumbRect.GetWidth(); - Rectangle aRect( rControlRegion.GetBoundRect() ); + Rectangle aRect( rControlRegion ); aRect.Right() = aRect.Left() + nW - 1; rNativeContentRegion = aRect; rNativeBoundingRegion = rNativeContentRegion; @@ -1242,7 +1371,7 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, else { long nH = aThumbRect.GetHeight(); - Rectangle aRect( rControlRegion.GetBoundRect() ); + Rectangle aRect( rControlRegion ); aRect.Bottom() = aRect.Top() + nH - 1; rNativeContentRegion = aRect; rNativeBoundingRegion = rNativeContentRegion; @@ -1253,30 +1382,30 @@ BOOL WinSalGraphics::getNativeControlRegion( ControlType nType, if ( ( nType == CTRL_TAB_ITEM ) && ( nPart == PART_ENTIRE_CONTROL ) ) { - Rectangle aControlRect( rControlRegion.GetBoundRect() ); + Rectangle aControlRect( rControlRegion ); rNativeContentRegion = aControlRect; --aControlRect.Bottom(); - TabitemValue *pValue = static_cast< TabitemValue* >( rControlValue.getOptionalVal() ); - if ( pValue ) + if( rControlValue.getType() == CTRL_TAB_ITEM ) { + const TabitemValue *pValue = static_cast<const TabitemValue*>(&rControlValue); if ( pValue->isBothAligned() ) --aControlRect.Right(); - } - if ( nState & CTRL_STATE_SELECTED ) - { - aControlRect.Left() -= 2; - if ( pValue && !pValue->isBothAligned() ) + if ( nState & CTRL_STATE_SELECTED ) { - if ( pValue->isLeftAligned() || pValue->isNotAligned() ) - aControlRect.Right() += 2; - if ( pValue->isRightAligned() ) - aControlRect.Right() += 1; + aControlRect.Left() -= 2; + if ( pValue && !pValue->isBothAligned() ) + { + if ( pValue->isLeftAligned() || pValue->isNotAligned() ) + aControlRect.Right() += 2; + if ( pValue->isRightAligned() ) + aControlRect.Right() += 1; + } + aControlRect.Top() -= 2; + aControlRect.Bottom() += 2; } - aControlRect.Top() -= 2; - aControlRect.Bottom() += 2; } rNativeBoundingRegion = aControlRect; bRet = TRUE; |