diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-05-07 16:12:22 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-05-07 16:12:22 +0200 |
commit | 1779568f6610dd93a2eeb637dabaed3476dc04ca (patch) | |
tree | 1f08005ecb1c907c4c62678ade7e3e1eff8f7937 | |
parent | 7ad4e562b462af22a1c29c955293238cdb30267b (diff) |
Revert "Tackle Menu with RenderContext refactoring, Invalidate"
This reverts 5485ef70cee1e3a743047f95ce94533024004b7c, which breaks
JunitTest_toolkit_unoapi (toolkit.AccessibleMenu)
Change-Id: Ic9021c23178f1598c08186e5cb24fde13a866579
-rw-r--r-- | include/vcl/menu.hxx | 6 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 205 | ||||
-rw-r--r-- | vcl/source/window/menubarwindow.cxx | 155 | ||||
-rw-r--r-- | vcl/source/window/menubarwindow.hxx | 2 | ||||
-rw-r--r-- | vcl/source/window/menufloatingwindow.cxx | 143 | ||||
-rw-r--r-- | vcl/source/window/menufloatingwindow.hxx | 4 |
6 files changed, 275 insertions, 240 deletions
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 6c5316c385e9..2af6a530cb27 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -165,7 +165,7 @@ protected: SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const; SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const; SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( sal_uInt16 nPos ) const; - SAL_DLLPRIVATE void ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const; + SAL_DLLPRIVATE void ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const; SAL_DLLPRIVATE void ImplSelect(); SAL_DLLPRIVATE void ImplCallHighlight( sal_uInt16 nHighlightItem ); SAL_DLLPRIVATE void ImplCallEventListeners( sal_uLong nEvent, sal_uInt16 nPos ); @@ -178,11 +178,11 @@ protected: // returns native check and option menu symbol height in rCheckHeight and rRadioHeight // return value is maximum width and height of checkboxes and radiobuttons - SAL_DLLPRIVATE Size ImplGetNativeCheckAndRadioSize(vcl::RenderContext& rRenderContext, long& rCheckHeight, long& rRadioHeight) const; + SAL_DLLPRIVATE Size ImplGetNativeCheckAndRadioSize( const vcl::Window*, long& rCheckHeight, long& rRadioHeight ) const; // returns native submenu arrow size and spacing from right border // return value is whether it's supported natively - SAL_DLLPRIVATE bool ImplGetNativeSubmenuArrowSize(vcl::RenderContext& rRenderContext, Size& rArrowSize, long& rArrowSpacing ) const; + SAL_DLLPRIVATE bool ImplGetNativeSubmenuArrowSize( vcl::Window* pWin, Size& rArrowSize, long& rArrowSpacing ) const; SAL_DLLPRIVATE void ImplAddDel( ImplMenuDelData &rDel ); SAL_DLLPRIVATE void ImplRemoveDel( ImplMenuDelData &rDel ); diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 94df528151ac..3560c6c48dd6 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -1393,7 +1393,7 @@ void Menu::SetAccessible( const ::com::sun::star::uno::Reference< ::com::sun::st mxAccessible = rxAccessible; } -Size Menu::ImplGetNativeCheckAndRadioSize(vcl::RenderContext& rRenderContext, long& rCheckHeight, long& rRadioHeight) const +Size Menu::ImplGetNativeCheckAndRadioSize( const vcl::Window* pWin, long& rCheckHeight, long& rRadioHeight ) const { long nCheckWidth = 0, nRadioWidth = 0; rCheckHeight = rRadioHeight = 0; @@ -1405,21 +1405,32 @@ Size Menu::ImplGetNativeCheckAndRadioSize(vcl::RenderContext& rRenderContext, lo Rectangle aNativeContent; Point tmp( 0, 0 ); Rectangle aCtrlRegion( Rectangle( tmp, Size( 100, 15 ) ) ); - if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK) ) + if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK ) ) { - if (rRenderContext.GetNativeControlRegion(ControlType(CTRL_MENU_POPUP), ControlPart(PART_MENU_ITEM_CHECK_MARK), - aCtrlRegion, ControlState(ControlState::ENABLED), aVal, OUString(), - aNativeBounds, aNativeContent)) + if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), + ControlPart(PART_MENU_ITEM_CHECK_MARK), + aCtrlRegion, + ControlState(ControlState::ENABLED), + aVal, + OUString(), + aNativeBounds, + aNativeContent ) + ) { rCheckHeight = aNativeBounds.GetHeight(); nCheckWidth = aNativeContent.GetWidth(); } } - if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK)) + if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK ) ) { - if (rRenderContext.GetNativeControlRegion(ControlType(CTRL_MENU_POPUP), ControlPart(PART_MENU_ITEM_RADIO_MARK), - aCtrlRegion, ControlState(ControlState::ENABLED), aVal, OUString(), - aNativeBounds, aNativeContent) + if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), + ControlPart(PART_MENU_ITEM_RADIO_MARK), + aCtrlRegion, + ControlState(ControlState::ENABLED), + aVal, + OUString(), + aNativeBounds, + aNativeContent ) ) { rRadioHeight = aNativeBounds.GetHeight(); @@ -1430,24 +1441,34 @@ Size Menu::ImplGetNativeCheckAndRadioSize(vcl::RenderContext& rRenderContext, lo return Size(std::max(nCheckWidth, nRadioWidth), std::max(rCheckHeight, rRadioHeight)); } -bool Menu::ImplGetNativeSubmenuArrowSize(vcl::RenderContext& rRenderContext, Size& rArrowSize, long& rArrowSpacing) const +bool Menu::ImplGetNativeSubmenuArrowSize( vcl::Window* pWin, Size& rArrowSize, long& rArrowSpacing ) const { ImplControlValue aVal; Rectangle aNativeBounds; Rectangle aNativeContent; - Rectangle aCtrlRegion(Rectangle(Point(), Size(100, 15))); - if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_SUBMENU_ARROW)) - { - if (rRenderContext.GetNativeControlRegion(ControlType(CTRL_MENU_POPUP), ControlPart(PART_MENU_SUBMENU_ARROW), - aCtrlRegion, ControlState(ControlState::ENABLED), - aVal, OUString(), aNativeBounds, aNativeContent)) + Point tmp( 0, 0 ); + Rectangle aCtrlRegion( Rectangle( tmp, Size( 100, 15 ) ) ); + if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, + PART_MENU_SUBMENU_ARROW ) ) { - Size aSize(aNativeContent.GetWidth(), aNativeContent.GetHeight()); - rArrowSize = aSize; - rArrowSpacing = aNativeBounds.GetWidth() - aNativeContent.GetWidth(); - return true; + if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP), + ControlPart(PART_MENU_SUBMENU_ARROW), + aCtrlRegion, + ControlState(ControlState::ENABLED), + aVal, + OUString(), + aNativeBounds, + aNativeContent ) + ) + { + Size aSize( Size ( aNativeContent.GetWidth(), + aNativeContent.GetHeight() ) ); + rArrowSize = aSize; + rArrowSpacing = aNativeBounds.GetWidth() - aNativeContent.GetWidth(); + + return true; + } } - } return false; } @@ -1491,7 +1512,7 @@ Size Menu::ImplCalcSize( const vcl::Window* pWin ) long nMinMenuItemHeight = nFontHeight; long nCheckHeight = 0, nRadioHeight = 0; - Size aMaxSize = ImplGetNativeCheckAndRadioSize(const_cast<vcl::Window&>(*pWin), nCheckHeight, nRadioHeight); // FIXME + Size aMaxSize = ImplGetNativeCheckAndRadioSize(pWin, nCheckHeight, nRadioHeight); if( aMaxSize.Height() > nMinMenuItemHeight ) nMinMenuItemHeight = aMaxSize.Height(); @@ -1691,7 +1712,7 @@ Size Menu::ImplCalcSize( const vcl::Window* pWin ) return aSz; } -static void ImplPaintCheckBackground(vcl::Window* i_pWindow, const Rectangle& i_rRect, bool i_bHighlight ) // FIXME +static void ImplPaintCheckBackground( vcl::Window* i_pWindow, const Rectangle& i_rRect, bool i_bHighlight ) { bool bNativeOk = false; if( i_pWindow->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) ) @@ -1715,11 +1736,11 @@ static void ImplPaintCheckBackground(vcl::Window* i_pWindow, const Rectangle& i_ } } -static OUString getShortenedString(const OUString& i_rLong, vcl::RenderContext& rRenderContext, long i_nMaxWidth) +static OUString getShortenedString( const OUString& i_rLong, vcl::Window* i_pWin, long i_nMaxWidth ) { sal_Int32 nPos = -1; - OUString aNonMnem(OutputDevice::GetNonMnemonicString(i_rLong, nPos)); - aNonMnem = rRenderContext.GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS ); + OUString aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) ); + aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS ); // re-insert mnemonic if( nPos != -1 ) { @@ -1735,17 +1756,17 @@ static OUString getShortenedString(const OUString& i_rLong, vcl::RenderContext& return aNonMnem; } -void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly, bool bHighlighted, bool bLayout, bool bRollover ) const +void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly, bool bHighlighted, bool bLayout, bool bRollover ) const { // for symbols: nFontHeight x nFontHeight - long nFontHeight = rRenderContext.GetTextHeight(); - long nExtra = nFontHeight / 4; + long nFontHeight = pWin->GetTextHeight(); + long nExtra = nFontHeight/4; long nCheckHeight = 0, nRadioHeight = 0; - ImplGetNativeCheckAndRadioSize(rRenderContext, nCheckHeight, nRadioHeight); + ImplGetNativeCheckAndRadioSize( pWin, nCheckHeight, nRadioHeight ); - DecorationView aDecoView(&rRenderContext); - const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings(); + DecorationView aDecoView( pWin ); + const StyleSettings& rSettings = pWin->GetSettings().GetStyleSettings(); Point aTopLeft, aTmpPos; @@ -1760,7 +1781,7 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon aTopLeft.Y() += ImplGetSVData()->maNWFData.mnMenuFormatBorderY; } - Size aOutSz = rRenderContext.GetOutputSizePixel(); + Size aOutSz = pWin->GetOutputSizePixel(); size_t nCount = pItemList->size(); if( bLayout ) mpLayoutData->m_aVisibleItemBoundRects.clear(); @@ -1773,9 +1794,9 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon if ( pThisItemOnly ) { if (IsMenuBar()&& bRollover ) - rRenderContext.SetTextColor( rSettings.GetMenuBarRolloverTextColor() ); + pWin->SetTextColor( rSettings.GetMenuBarRolloverTextColor() ); else if ( bHighlighted ) - rRenderContext.SetTextColor( rSettings.GetMenuHighlightTextColor() ); + pWin->SetTextColor( rSettings.GetMenuHighlightTextColor() ); } Point aPos( aTopLeft ); @@ -1806,7 +1827,8 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon if (!bLayout && !IsMenuBar() && (pData->eType == MenuItemType::SEPARATOR)) { bool bNativeOk = false; - if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_SEPARATOR)) + if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, + PART_MENU_SEPARATOR ) ) { ControlState nState = ControlState::NONE; if ( pData->bEnabled ) @@ -1817,19 +1839,22 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon aSz.Width() = aOutSz.Width() - 2*nOuterSpaceX; Rectangle aItemRect( aPos, aSz ); MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect ); - bNativeOk = rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_MENU_SEPARATOR, - aItemRect, nState, aVal, OUString()); + bNativeOk = pWin->DrawNativeControl( CTRL_MENU_POPUP, PART_MENU_SEPARATOR, + aItemRect, + nState, + aVal, + OUString() ); } - if (!bNativeOk) + if( ! bNativeOk ) { aTmpPos.Y() = aPos.Y() + ((pData->aSz.Height()-2)/2); aTmpPos.X() = aPos.X() + 2 + nOuterSpaceX; - rRenderContext.SetLineColor( rSettings.GetShadowColor() ); - rRenderContext.DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) ); + pWin->SetLineColor( rSettings.GetShadowColor() ); + pWin->DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) ); aTmpPos.Y()++; - rRenderContext.SetLineColor( rSettings.GetLightColor() ); - rRenderContext.DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) ); - rRenderContext.SetLineColor(); + pWin->SetLineColor( rSettings.GetLightColor() ); + pWin->DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) ); + pWin->SetLineColor(); } } @@ -1848,12 +1873,12 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon // however do not do this if native checks will be painted since // the selection color too often does not fit the theme's check and/or radio - if (!((pData->eType == MenuItemType::IMAGE) || (pData->eType == MenuItemType::STRINGIMAGE))) + if( ! ( ( pData->eType == MenuItemType::IMAGE ) || ( pData->eType == MenuItemType::STRINGIMAGE ) ) ) { - if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, + if ( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, (pData->nBits & MenuItemBits::RADIOCHECK) ? PART_MENU_ITEM_CHECK_MARK - : PART_MENU_ITEM_RADIO_MARK)) + : PART_MENU_ITEM_RADIO_MARK ) ) { ControlPart nPart = ((pData->nBits & MenuItemBits::RADIOCHECK) ? PART_MENU_ITEM_RADIO_MARK @@ -1879,12 +1904,15 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon aSz.Width() = aOutSz.Width() - 2*nOuterSpaceX; Rectangle aItemRect( aPos, aSz ); MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect ); - rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, nPart, aCheckRect, - nState, aVal, OUString()); + pWin->DrawNativeControl( CTRL_MENU_POPUP, nPart, + aCheckRect, + nState, + aVal, + OUString() ); } else if ( pData->bChecked ) // by default do nothing for unchecked items { - ImplPaintCheckBackground(pWindow, aOuterCheckRect, pThisItemOnly && bHighlighted); + ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted ); SymbolType eSymbol; Size aSymbolSize; @@ -1901,7 +1929,7 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon aTmpPos.X() = aOuterCheckRect.Left() + (aOuterCheckRect.GetWidth() - aSymbolSize.Width())/2; aTmpPos.Y() = aOuterCheckRect.Top() + (aOuterCheckRect.GetHeight() - aSymbolSize.Height())/2; Rectangle aRect( aTmpPos, aSymbolSize ); - aDecoView.DrawSymbol( aRect, eSymbol, rRenderContext.GetTextColor(), nSymbolStyle ); + aDecoView.DrawSymbol( aRect, eSymbol, pWin->GetTextColor(), nSymbolStyle ); } } } @@ -1911,11 +1939,11 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon { // Don't render an image for a check thing if( pData->bChecked ) - ImplPaintCheckBackground(pWindow, aOuterCheckRect, pThisItemOnly && bHighlighted); + ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted ); Image aImage = pData->aImage; - sal_Int32 nScaleFactor = rRenderContext.GetDPIScaleFactor(); + sal_Int32 nScaleFactor = pWindow->GetDPIScaleFactor(); if (nScaleFactor != 1) { BitmapEx aBitmap = aImage.GetBitmapEx(); @@ -1925,7 +1953,7 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon aTmpPos = aOuterCheckRect.TopLeft(); aTmpPos.X() += (aOuterCheckRect.GetWidth() - aImage.GetSizePixel().Width()) / 2; aTmpPos.Y() += (aOuterCheckRect.GetHeight() - aImage.GetSizePixel().Height()) / 2; - rRenderContext.DrawImage(aTmpPos, aImage, nImageStyle); + pWin->DrawImage(aTmpPos, aImage, nImageStyle); } // Text: @@ -1950,55 +1978,57 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon // TEXT_DRAW_DISABLE), temporarily set a background which // hopefully matches the NWF background since it is read // from the system style settings - bool bSetTmpBackground = !rRenderContext.IsBackground() && rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL); - if (bSetTmpBackground) + bool bSetTmpBackground = !pWin->IsBackground() && pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ); + if( bSetTmpBackground ) { Color aBg = IsMenuBar()? - rRenderContext.GetSettings().GetStyleSettings().GetMenuBarColor() : - rRenderContext.GetSettings().GetStyleSettings().GetMenuColor(); - rRenderContext.SetBackground( Wallpaper( aBg ) ); + pWin->GetSettings().GetStyleSettings().GetMenuBarColor() : + pWin->GetSettings().GetStyleSettings().GetMenuColor(); + pWin->SetBackground( Wallpaper( aBg ) ); } // how much space is there for the text ? long nMaxItemTextWidth = aOutSz.Width() - aTmpPos.X() - nExtra - nOuterSpaceX; if (!IsMenuBar() && pData->aAccelKey.GetCode() && !ImplAccelDisabled()) { OUString aAccText = pData->aAccelKey.GetName(); - nMaxItemTextWidth -= rRenderContext.GetTextWidth(aAccText) + 3 * nExtra; + nMaxItemTextWidth -= pWin->GetTextWidth( aAccText ) + 3*nExtra; } if (!IsMenuBar() && pData->pSubMenu) { nMaxItemTextWidth -= nFontHeight - nExtra; } - OUString aItemText(getShortenedString(pData->aText, rRenderContext, nMaxItemTextWidth)); - rRenderContext.DrawCtrlText(aTmpPos, aItemText, 0, aItemText.getLength(), nStyle, pVector, pDisplayText); - if (bSetTmpBackground) - rRenderContext.SetBackground(); + OUString aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) ); + pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.getLength(), nStyle, pVector, pDisplayText ); + if( bSetTmpBackground ) + pWin->SetBackground(); } // Accel if (!bLayout && !IsMenuBar() && pData->aAccelKey.GetCode() && !ImplAccelDisabled()) { OUString aAccText = pData->aAccelKey.GetName(); - aTmpPos.X() = aOutSz.Width() - rRenderContext.GetTextWidth(aAccText); + aTmpPos.X() = aOutSz.Width() - pWin->GetTextWidth( aAccText ); aTmpPos.X() -= 4*nExtra; aTmpPos.X() -= nOuterSpaceX; aTmpPos.Y() = aPos.Y(); aTmpPos.Y() += nTextOffsetY; - rRenderContext.DrawCtrlText(aTmpPos, aAccText, 0, aAccText.getLength(), nTextStyle); + pWin->DrawCtrlText( aTmpPos, aAccText, 0, aAccText.getLength(), nTextStyle ); } // SubMenu? if (!bLayout && !IsMenuBar() && pData->pSubMenu) { bool bNativeOk = false; - if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_SUBMENU_ARROW)) + if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, + PART_MENU_SUBMENU_ARROW ) ) { ControlState nState = ControlState::NONE; Size aTmpSz( 0, 0 ); long aSpacing = 0; - if (!ImplGetNativeSubmenuArrowSize(rRenderContext, aTmpSz, aSpacing)) + if( !ImplGetNativeSubmenuArrowSize( pWin, + aTmpSz, aSpacing ) ) { aTmpSz = Size( nFontHeight, nFontHeight ); aSpacing = nOuterSpaceX; @@ -2015,10 +2045,14 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon Rectangle aItemRect( aTmpPos, aTmpSz ); MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect ); - bNativeOk = rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_MENU_SUBMENU_ARROW, - aItemRect, nState, aVal, OUString()); + bNativeOk = pWin->DrawNativeControl( CTRL_MENU_POPUP, + PART_MENU_SUBMENU_ARROW, + aItemRect, + nState, + aVal, + OUString() ); } - if (!bNativeOk) + if( ! bNativeOk ) { aTmpPos.X() = aOutSz.Width() - nFontHeight + nExtra - nOuterSpaceX; aTmpPos.Y() = aPos.Y(); @@ -2026,15 +2060,15 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon aTmpPos.Y() += ( pData->aSz.Height() / 2 ) - ( nFontHeight/4 ); if ( pData->nBits & MenuItemBits::POPUPSELECT ) { - rRenderContext.SetTextColor( rSettings.GetMenuTextColor() ); + pWin->SetTextColor( rSettings.GetMenuTextColor() ); Point aTmpPos2( aPos ); aTmpPos2.X() = aOutSz.Width() - nFontHeight - nFontHeight/4; aDecoView.DrawFrame( Rectangle( aTmpPos2, Size( nFontHeight+nFontHeight/4, pData->aSz.Height() ) ), FRAME_DRAW_GROUP ); } aDecoView.DrawSymbol( - Rectangle(aTmpPos, Size(nFontHeight / 2, nFontHeight / 2)), - SymbolType::SPIN_RIGHT, rRenderContext.GetTextColor(), nSymbolStyle); + Rectangle( aTmpPos, Size( nFontHeight/2, nFontHeight/2 ) ), + SymbolType::SPIN_RIGHT, pWin->GetTextColor(), nSymbolStyle ); } } @@ -2043,9 +2077,9 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon // This restores the normal menu or menu bar text // color for when it is no longer highlighted. if (IsMenuBar()) - rRenderContext.SetTextColor(rSettings.GetMenuBarTextColor()); + pWin->SetTextColor( rSettings.GetMenuBarTextColor() ); else - rRenderContext.SetTextColor(rSettings.GetMenuTextColor()); + pWin->SetTextColor( rSettings.GetMenuTextColor() ); } } if( bLayout ) @@ -2072,21 +2106,21 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, lon Size aLogoSz = pLogo->aBitmap.GetSizePixel(); Rectangle aRect( Point( 0, 0 ), Point( aLogoSz.Width()-1, aOutSz.Height() ) ); - if (rRenderContext.GetColorCount() >= 256) + if ( pWin->GetColorCount() >= 256 ) { Gradient aGrad( GradientStyle_LINEAR, pLogo->aStartColor, pLogo->aEndColor ); aGrad.SetAngle( 1800 ); aGrad.SetBorder( 15 ); - rRenderContext.DrawGradient(aRect, aGrad); + pWin->DrawGradient( aRect, aGrad ); } else { - rRenderContext.SetFillColor(pLogo->aStartColor); - rRenderContext.DrawRect(aRect); + pWin->SetFillColor( pLogo->aStartColor ); + pWin->DrawRect( aRect ); } Point aLogoPos( 0, aOutSz.Height() - aLogoSz.Height() ); - pLogo->aBitmap.Draw(&rRenderContext, aLogoPos); + pLogo->aBitmap.Draw( pWin, aLogoPos ); } } @@ -2226,15 +2260,14 @@ void Menu::ImplFillLayoutData() const if( pWindow && pWindow->IsReallyVisible() ) { mpLayoutData = new MenuLayoutData(); - pWindow->Invalidate(); - if (IsMenuBar()) // FIXME + if (IsMenuBar()) { - //ImplPaint(pWindow, 0, 0, 0, false, true); + ImplPaint( pWindow, 0, 0, 0, false, true ); } else { - //MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get()); // FIXME - //ImplPaint(pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), 0, false, true); + MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get()); + ImplPaint( pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), 0, false, true ); } } } diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx index 0a55e012b651..9acf9f742e7e 100644 --- a/vcl/source/window/menubarwindow.cxx +++ b/vcl/source/window/menubarwindow.cxx @@ -408,7 +408,7 @@ void MenuBarWindow::MouseMove( const MouseEvent& rMEvt ) if ( rMEvt.IsLeaveWindow() ) { if ( nRolloveredItem != ITEMPOS_INVALID && nRolloveredItem != nHighlightedItem ) - Invalidate(); + HighlightItem( nRolloveredItem, false ); nRolloveredItem = ITEMPOS_INVALID; return; @@ -420,10 +420,10 @@ void MenuBarWindow::MouseMove( const MouseEvent& rMEvt ) if ( nRolloveredItem != nEntry ) { if ( nRolloveredItem != ITEMPOS_INVALID ) - Invalidate(); + HighlightItem( nRolloveredItem, false ); nRolloveredItem = nEntry; - Invalidate(); + HighlightItem( nRolloveredItem, true ); } return; } @@ -507,7 +507,7 @@ void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool b if ( nHighlightedItem != ITEMPOS_INVALID ) { if ( nHighlightedItem != nRolloveredItem ) - Invalidate(); + HighlightItem( nHighlightedItem, false ); pMenu->ImplCallEventListeners( VCLEVENT_MENU_DEHIGHLIGHT, nHighlightedItem ); } @@ -515,9 +515,9 @@ void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool b nHighlightedItem = (sal_uInt16)n; DBG_ASSERT( ( nHighlightedItem == ITEMPOS_INVALID ) || pMenu->ImplIsVisible( nHighlightedItem ), "ChangeHighlightItem: Not visible!" ); if ( nHighlightedItem != ITEMPOS_INVALID ) - Invalidate(); + HighlightItem( nHighlightedItem, true ); else if ( nRolloveredItem != ITEMPOS_INVALID ) - Invalidate(); + HighlightItem( nRolloveredItem, true ); pMenu->ImplCallHighlight(nHighlightedItem); if( mbAutoPopup ) @@ -563,111 +563,113 @@ static int ImplGetTopDockingAreaHeight( vcl::Window *pWindow ) return 0; } -static void ImplAddNWFSeparator(vcl::RenderContext& rRenderContext, const MenubarValue& rMenubarValue ) +static void ImplAddNWFSeparator( vcl::Window *pThis, const MenubarValue& rMenubarValue ) { // add a separator if // - we have an adjacent docking area // - and if toolbars would draw them as well (mbDockingAreaSeparateTB must not be set, see dockingarea.cxx) - if (rMenubarValue.maTopDockingAreaHeight - && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB - && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames) + if( rMenubarValue.maTopDockingAreaHeight && !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB && !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames ) { // note: the menubar only provides the upper (dark) half of it, the rest (bright part) is drawn by the docking area - rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor()); + pThis->SetLineColor( pThis->GetSettings().GetStyleSettings().GetSeparatorColor() ); Point aPt; - Rectangle aRect(aPt, rRenderContext.GetOutputSizePixel()); - rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight()); + Rectangle aRect( aPt, pThis->GetOutputSizePixel() ); + pThis->DrawLine( aRect.BottomLeft(), aRect.BottomRight() ); } } -void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHighlight) +void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight ) { - if (!pMenu) + if( ! pMenu ) return; long nX = 0; size_t nCount = pMenu->pItemList->size(); - for (size_t n = 0; n < nCount; n++) + for ( size_t n = 0; n < nCount; n++ ) { - MenuItemData* pData = pMenu->pItemList->GetDataFromPos(n); - if (n == nPos) + MenuItemData* pData = pMenu->pItemList->GetDataFromPos( n ); + if ( n == nPos ) { - if (pData->eType != MenuItemType::SEPARATOR) + if ( pData->eType != MenuItemType::SEPARATOR ) { // #107747# give menuitems the height of the menubar - Rectangle aRect = Rectangle(Point(nX, 1), Size(pData->aSz.Width(), GetOutputSizePixel().Height() - 2)); - rRenderContext.Push(PushFlags::CLIPREGION); - IntersectClipRegion(aRect); + Rectangle aRect = Rectangle( Point( nX, 1 ), Size( pData->aSz.Width(), GetOutputSizePixel().Height()-2 ) ); + Push( PushFlags::CLIPREGION ); + IntersectClipRegion( aRect ); bool bRollover = bHighlight && nPos != nHighlightedItem; - if (bHighlight) + if ( bHighlight ) { - if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_MENU_ITEM) && - rRenderContext.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); + aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); - if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty()) - rRenderContext.Erase(); + if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() ) + Erase(); else { - Rectangle aBgRegion(Point(), GetOutputSizePixel()); - rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL, aBgRegion, - ControlState::ENABLED, aControlValue, OUString() ); + Point tmp(0,0); + Rectangle aBgRegion( tmp, GetOutputSizePixel() ); + DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, + aBgRegion, + ControlState::ENABLED, + aControlValue, + OUString() ); } - ImplAddNWFSeparator(rRenderContext, aControlValue); + ImplAddNWFSeparator( this, aControlValue ); // draw selected item ControlState nState = ControlState::ENABLED; - if (bRollover) + if ( bRollover ) nState |= ControlState::ROLLOVER; else nState |= ControlState::SELECTED; - rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_MENU_ITEM, aRect, - nState, aControlValue, OUString()); + DrawNativeControl( CTRL_MENUBAR, PART_MENU_ITEM, + aRect, + nState, + aControlValue, + OUString() ); } else { - if (bRollover) - rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuBarRolloverColor()); + if ( bRollover ) + SetFillColor( GetSettings().GetStyleSettings().GetMenuBarRolloverColor() ); else - rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor()); - rRenderContext.SetLineColor(); - rRenderContext.DrawRect(aRect); + SetFillColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() ); + SetLineColor(); + DrawRect( aRect ); } } else { - if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL)) + if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) ) { MenubarValue aMenubarValue; - aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight(this); + aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); - if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty()) - { - rRenderContext.Erase(aRect); - } + if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() ) + Erase( aRect ); else { // use full window size to get proper gradient // but clip accordingly Point aPt; - Rectangle aCtrlRect(aPt, rRenderContext.GetOutputSizePixel()); - rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString()); + Rectangle aCtrlRect( aPt, GetOutputSizePixel() ); + + DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString() ); } - ImplAddNWFSeparator(rRenderContext, aMenubarValue); + ImplAddNWFSeparator( this, aMenubarValue ); } else - { - rRenderContext.Erase(aRect); - } + Erase( aRect ); } - rRenderContext.Pop(); - pMenu->ImplPaint(rRenderContext, 0, 0, pData, bHighlight, false, bRollover); + Pop(); + pMenu->ImplPaint( this, 0, 0, pData, bHighlight, false, bRollover ); } return; } @@ -868,53 +870,52 @@ bool MenuBarWindow::HandleKeyEvent( const KeyEvent& rKEvent, bool bFromMenu ) return bDone; } -void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&) +void MenuBarWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) { - if (!pMenu) + if( ! pMenu ) return; // no VCL paint if native menus - if (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar()) + if( pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar() ) { ImplGetFrame()->DrawMenuBar(); return; } - if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL)) + if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) ) { MenubarValue aMenubarValue; aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this ); - if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty()) - { - rRenderContext.Erase(); - } + if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() ) + Erase(); else { Point aPt; - Rectangle aCtrlRegion(aPt, rRenderContext.GetOutputSizePixel()); - rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion, - ControlState::ENABLED, aMenubarValue, OUString()); + Rectangle aCtrlRegion( aPt, GetOutputSizePixel() ); + + DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion, ControlState::ENABLED, aMenubarValue, OUString() ); } - ImplAddNWFSeparator(rRenderContext, aMenubarValue); + ImplAddNWFSeparator( this, aMenubarValue ); } - rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor()); - pMenu->ImplPaint(rRenderContext, 0); - if (nHighlightedItem != ITEMPOS_INVALID) - HighlightItem(rRenderContext, nHighlightedItem, true); + SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() ); + pMenu->ImplPaint( this, 0 ); + if ( nHighlightedItem != ITEMPOS_INVALID ) + HighlightItem( nHighlightedItem, true ); // in high contrast mode draw a separating line on the lower edge - if (!rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL) && - rRenderContext.GetSettings().GetStyleSettings().GetHighContrastMode()) + if( ! IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) && + GetSettings().GetStyleSettings().GetHighContrastMode() ) { - rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::MAPMODE); - rRenderContext.SetLineColor(Color(COL_WHITE)); - rRenderContext.SetMapMode(MapMode(MAP_PIXEL)); + Push( PushFlags::LINECOLOR | PushFlags::MAPMODE ); + SetLineColor( Color( COL_WHITE ) ); + SetMapMode( MapMode( MAP_PIXEL ) ); Size aSize = GetSizePixel(); - rRenderContext.DrawLine(Point(0, aSize.Height() - 1), Point(aSize.Width() - 1, aSize.Height() - 1)); - rRenderContext.Pop(); + DrawLine( Point( 0, aSize.Height()-1 ), Point( aSize.Width()-1, aSize.Height()-1 ) ); + Pop(); } + } void MenuBarWindow::Resize() diff --git a/vcl/source/window/menubarwindow.hxx b/vcl/source/window/menubarwindow.hxx index a248bca7093b..5a6f2e92f7ec 100644 --- a/vcl/source/window/menubarwindow.hxx +++ b/vcl/source/window/menubarwindow.hxx @@ -87,7 +87,7 @@ private: std::map< sal_uInt16, AddButtonEntry > m_aAddButtons; - void HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHighlight); + void HighlightItem( sal_uInt16 nPos, bool bHighlight ); virtual void ChangeHighlightItem(sal_uInt16 n, bool bSelectPopupEntry, bool bAllowRestoreFocus = true, bool bDefaultToDocument = true) SAL_OVERRIDE; sal_uInt16 ImplFindEntry( const Point& rMousePos ) const; diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx index 26ef5586564e..247821ce6639 100644 --- a/vcl/source/window/menufloatingwindow.cxx +++ b/vcl/source/window/menufloatingwindow.cxx @@ -61,7 +61,7 @@ MenuFloatingWindow::MenuFloatingWindow( Menu* pMen, vcl::Window* pParent, WinBit void MenuFloatingWindow::doShutdown() { - if (pMenu) + if( pMenu ) { // #105373# notify toolkit that highlight was removed // otherwise the entry will not be read when the menu is opened again @@ -77,11 +77,11 @@ void MenuFloatingWindow::doShutdown() if( pData && ( pData->pSubMenu == pMenu ) ) break; } - if (i < nCount) + if( i < nCount ) { MenuFloatingWindow* pPWin = static_cast<MenuFloatingWindow*>(pMenu->pStartedFrom->ImplGetWindow()); - if (pPWin) - pPWin->Invalidate(); + if( pPWin ) + pPWin->HighlightItem( i, false ); } } @@ -162,7 +162,7 @@ void MenuFloatingWindow::InitMenuClipRegion() void MenuFloatingWindow::ImplHighlightItem( const MouseEvent& rMEvt, bool bMBDown ) { - if (!pMenu) + if( ! pMenu ) return; long nY = nScrollerHeight + ImplGetSVData()->maNWFData.mnMenuFormatBorderY; @@ -558,7 +558,7 @@ void MenuFloatingWindow::ImplScroll( bool bUp ) if( ! pMenu ) return; - Invalidate(); + HighlightItem( nHighlightedItem, false ); pMenu->ImplKillLayoutData(); @@ -608,7 +608,7 @@ void MenuFloatingWindow::ImplScroll( bool bUp ) Scroll( 0, -nScrollEntryHeight, ImplCalcClipRegion( false ).GetBoundRect(), SCROLL_CLIP ); } - Invalidate(); + HighlightItem( nHighlightedItem, true ); } void MenuFloatingWindow::ImplScroll( const Point& rMousePos ) @@ -663,7 +663,7 @@ void MenuFloatingWindow::ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTime if ( nHighlightedItem != ITEMPOS_INVALID ) { - Invalidate(); + HighlightItem( nHighlightedItem, false ); pMenu->ImplCallEventListeners( VCLEVENT_MENU_DEHIGHLIGHT, nHighlightedItem ); } @@ -686,12 +686,12 @@ void MenuFloatingWindow::ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTime MenuFloatingWindow* pPWin = static_cast<MenuFloatingWindow*>(pMenu->pStartedFrom->ImplGetWindow()); if( pPWin && pPWin->nHighlightedItem != i ) { - pPWin->Invalidate(); + pPWin->HighlightItem( i, true ); pPWin->nHighlightedItem = i; } } } - Invalidate(); + HighlightItem( nHighlightedItem, true ); pMenu->ImplCallHighlight( nHighlightedItem ); } else @@ -710,26 +710,26 @@ void MenuFloatingWindow::ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTime } } -void MenuFloatingWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHighlight) +void MenuFloatingWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight ) { - if (!pMenu) + if( ! pMenu ) return; - Size aSz = GetOutputSizePixel(); - long nStartY = ImplGetStartY(); - long nY = nScrollerHeight + nStartY + ImplGetSVData()->maNWFData.mnMenuFormatBorderY; - long nX = 0; + Size aSz = GetOutputSizePixel(); + long nStartY = ImplGetStartY(); + long nY = nScrollerHeight + nStartY + ImplGetSVData()->maNWFData.mnMenuFormatBorderY; + long nX = 0; - if (pMenu->pLogo) + if ( pMenu->pLogo ) nX = pMenu->pLogo->aBitmap.GetSizePixel().Width(); int nOuterSpaceX = ImplGetSVData()->maNWFData.mnMenuFormatBorderX; size_t nCount = pMenu->pItemList->size(); - for (size_t n = 0; n < nCount; n++) + for ( size_t n = 0; n < nCount; n++ ) { - MenuItemData* pData = pMenu->pItemList->GetDataFromPos(n); - if (n == nPos) + MenuItemData* pData = pMenu->pItemList->GetDataFromPos( n ); + if ( n == nPos ) { DBG_ASSERT( pMenu->ImplIsVisible( n ), "Highlight: Item not visible!" ); if ( pData->eType != MenuItemType::SEPARATOR ) @@ -738,65 +738,64 @@ void MenuFloatingWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_u Color oldLineColor; bool bDrawItemRect = true; - Rectangle aItemRect(Point(nX + nOuterSpaceX, nY), Size(aSz.Width() - 2 * nOuterSpaceX, pData->aSz.Height())); - if (pData->nBits & MenuItemBits::POPUPSELECT) + Rectangle aItemRect( Point( nX+nOuterSpaceX, nY ), Size( aSz.Width()-2*nOuterSpaceX, pData->aSz.Height() ) ); + if ( pData->nBits & MenuItemBits::POPUPSELECT ) { - long nFontHeight = rRenderContext.GetTextHeight(); - aItemRect.Right() -= nFontHeight + nFontHeight / 4; + long nFontHeight = GetTextHeight(); + aItemRect.Right() -= nFontHeight + nFontHeight/4; } - if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL)) + if( IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ) ) { - Size aPxSize(rRenderContext.GetOutputSizePixel()); - rRenderContext.Push(PushFlags::CLIPREGION); - rRenderContext.IntersectClipRegion(Rectangle(Point(nX, nY), Size(aSz.Width(), pData->aSz.Height()))); - Rectangle aCtrlRect(Point(nX, 0), Size(aPxSize.Width() - nX, aPxSize.Height())); - MenupopupValue aVal(pMenu->nTextPos - GUTTERBORDER, aItemRect); - rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, aCtrlRect, - ControlState::ENABLED, aVal, OUString()); - if (bHighlight && - rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM)) + Size aPxSize( GetOutputSizePixel() ); + Push( PushFlags::CLIPREGION ); + IntersectClipRegion( Rectangle( Point( nX, nY ), Size( aSz.Width(), pData->aSz.Height() ) ) ); + Rectangle aCtrlRect( Point( nX, 0 ), Size( aPxSize.Width()-nX, aPxSize.Height() ) ); + MenupopupValue aVal( pMenu->nTextPos-GUTTERBORDER, aItemRect ); + DrawNativeControl( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, + aCtrlRect, + ControlState::ENABLED, + aVal, + OUString() ); + if( bHighlight && + IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM ) ) { bDrawItemRect = false; - if (!rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, PART_MENU_ITEM, + if( !DrawNativeControl( CTRL_MENU_POPUP, PART_MENU_ITEM, aItemRect, ControlState::SELECTED | ( pData->bEnabled? ControlState::ENABLED: ControlState::NONE ), - aVal, OUString())) + aVal, + OUString() ) ) { bDrawItemRect = bHighlight; } } else - { bDrawItemRect = bHighlight; - } - rRenderContext.Pop(); + Pop(); } - if (bDrawItemRect) + if( bDrawItemRect ) { - if (bHighlight) + if ( bHighlight ) { - if (pData->bEnabled) - { - rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor()); - } + if( pData->bEnabled ) + SetFillColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() ); else { - rRenderContext.SetFillColor(); - oldLineColor = rRenderContext.GetLineColor(); - rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor()); + SetFillColor(); + oldLineColor = GetLineColor(); + SetLineColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() ); bRestoreLineColor = true; } } else - { - rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor()); - } - rRenderContext.DrawRect(aItemRect); + SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() ); + + DrawRect( aItemRect ); } - pMenu->ImplPaint(rRenderContext, nScrollerHeight, nStartY, pData, bHighlight); - if (bRestoreLineColor) - rRenderContext.SetLineColor(oldLineColor); + pMenu->ImplPaint( this, nScrollerHeight, nStartY, pData, bHighlight ); + if( bRestoreLineColor ) + SetLineColor( oldLineColor ); } return; } @@ -1083,32 +1082,34 @@ void MenuFloatingWindow::KeyInput( const KeyEvent& rKEvent ) } } -void MenuFloatingWindow::Paint( vcl::RenderContext& rRenderContext, const Rectangle& ) +void MenuFloatingWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) { - if (!pMenu) + if( ! pMenu ) return; - if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL)) + if( IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ) ) { - rRenderContext.SetClipRegion(); + SetClipRegion(); long nX = pMenu->pLogo ? pMenu->pLogo->aBitmap.GetSizePixel().Width() : 0; - Size aPxSize(rRenderContext.GetOutputSizePixel()); + Size aPxSize( GetOutputSizePixel() ); aPxSize.Width() -= nX; - ImplControlValue aVal(pMenu->nTextPos - GUTTERBORDER); - DrawNativeControl(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, - Rectangle(Point(nX, 0), aPxSize), - ControlState::ENABLED, aVal, OUString()); + ImplControlValue aVal( pMenu->nTextPos-GUTTERBORDER ); + DrawNativeControl( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, + Rectangle( Point( nX, 0 ), aPxSize ), + ControlState::ENABLED, + aVal, + OUString() ); InitMenuClipRegion(); } - if (IsScrollMenu()) + if ( IsScrollMenu() ) { - ImplDrawScroller(true); - ImplDrawScroller(false); + ImplDrawScroller( true ); + ImplDrawScroller( false ); } - rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor()); - pMenu->ImplPaint(rRenderContext, nScrollerHeight, ImplGetStartY()); - if (nHighlightedItem != ITEMPOS_INVALID) - HighlightItem(rRenderContext, nHighlightedItem, true); + SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() ); + pMenu->ImplPaint( this, nScrollerHeight, ImplGetStartY() ); + if ( nHighlightedItem != ITEMPOS_INVALID ) + HighlightItem( nHighlightedItem, true ); } void MenuFloatingWindow::ImplDrawScroller( bool bUp ) diff --git a/vcl/source/window/menufloatingwindow.hxx b/vcl/source/window/menufloatingwindow.hxx index d0748e0b7fcd..030fde0ba427 100644 --- a/vcl/source/window/menufloatingwindow.hxx +++ b/vcl/source/window/menufloatingwindow.hxx @@ -90,7 +90,7 @@ public: virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual void KeyInput( const KeyEvent& rKEvent ) SAL_OVERRIDE; virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE; - virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE; + virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) SAL_OVERRIDE; virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE; virtual void Resize() SAL_OVERRIDE; @@ -109,7 +109,7 @@ public: PopupMenu* GetActivePopup() const { return pActivePopup; } void KillActivePopup( PopupMenu* pThisOnly = NULL ); - void HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHighlight); + void HighlightItem( sal_uInt16 nPos, bool bHighlight ); void ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTimer ); sal_uInt16 GetHighlightedItem() const { return nHighlightedItem; } |