[Libreoffice-commits] core.git: Branch 'feature/rendercontext' - 2 commits - include/vcl vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Tue May 5 15:58:52 PDT 2015
include/vcl/edit.hxx | 4
include/vcl/menu.hxx | 6
vcl/source/control/edit.cxx | 256 +++++++++++++++----------------
vcl/source/window/menu.cxx | 205 ++++++++++--------------
vcl/source/window/menubarwindow.cxx | 155 +++++++++---------
vcl/source/window/menubarwindow.hxx | 2
vcl/source/window/menufloatingwindow.cxx | 143 ++++++++---------
vcl/source/window/menufloatingwindow.hxx | 4
8 files changed, 372 insertions(+), 403 deletions(-)
New commits:
commit 0aec75d301b2d3d260efef2ff18b249383097dbc
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Wed May 6 07:57:01 2015 +0900
Tackle Menu with RenderContext refactoring, Invalidate
Change-Id: Ib2812723141c5dfe39b30c95f12d1aeca9c367bd
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 32dfd5a..2227b91 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::Window* pWin, sal_uInt16 nBorder, long nOffY = 0, MenuItemData* pThisDataOnly = 0, bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) 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 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( const vcl::Window*, long& rCheckHeight, long& rRadioHeight ) const;
+ SAL_DLLPRIVATE Size ImplGetNativeCheckAndRadioSize(vcl::RenderContext& rRenderContext, 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::Window* pWin, Size& rArrowSize, long& rArrowSpacing ) const;
+ SAL_DLLPRIVATE bool ImplGetNativeSubmenuArrowSize(vcl::RenderContext& rRenderContext, 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 e972321..a230cdc 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( const vcl::Window* pWin, long& rCheckHeight, long& rRadioHeight ) const
+Size Menu::ImplGetNativeCheckAndRadioSize(vcl::RenderContext& rRenderContext, long& rCheckHeight, long& rRadioHeight) const
{
long nCheckWidth = 0, nRadioWidth = 0;
rCheckHeight = rRadioHeight = 0;
@@ -1405,32 +1405,21 @@ Size Menu::ImplGetNativeCheckAndRadioSize( const vcl::Window* pWin, long& rCheck
Rectangle aNativeContent;
Point tmp( 0, 0 );
Rectangle aCtrlRegion( Rectangle( tmp, Size( 100, 15 ) ) );
- if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK ) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM_CHECK_MARK) )
{
- if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP),
- ControlPart(PART_MENU_ITEM_CHECK_MARK),
- aCtrlRegion,
- ControlState(ControlState::ENABLED),
- aVal,
- OUString(),
- aNativeBounds,
- aNativeContent )
- )
+ if (rRenderContext.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( pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK ) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM_RADIO_MARK))
{
- if( pWin->GetNativeControlRegion( ControlType(CTRL_MENU_POPUP),
- ControlPart(PART_MENU_ITEM_RADIO_MARK),
- aCtrlRegion,
- ControlState(ControlState::ENABLED),
- aVal,
- OUString(),
- aNativeBounds,
- aNativeContent )
+ if (rRenderContext.GetNativeControlRegion(ControlType(CTRL_MENU_POPUP), ControlPart(PART_MENU_ITEM_RADIO_MARK),
+ aCtrlRegion, ControlState(ControlState::ENABLED), aVal, OUString(),
+ aNativeBounds, aNativeContent)
)
{
rRadioHeight = aNativeBounds.GetHeight();
@@ -1441,34 +1430,24 @@ Size Menu::ImplGetNativeCheckAndRadioSize( const vcl::Window* pWin, long& rCheck
return Size(std::max(nCheckWidth, nRadioWidth), std::max(rCheckHeight, rRadioHeight));
}
-bool Menu::ImplGetNativeSubmenuArrowSize( vcl::Window* pWin, Size& rArrowSize, long& rArrowSpacing ) const
+bool Menu::ImplGetNativeSubmenuArrowSize(vcl::RenderContext& rRenderContext, Size& rArrowSize, long& rArrowSpacing) const
{
ImplControlValue aVal;
Rectangle aNativeBounds;
Rectangle aNativeContent;
- Point tmp( 0, 0 );
- Rectangle aCtrlRegion( Rectangle( tmp, Size( 100, 15 ) ) );
- if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP,
- PART_MENU_SUBMENU_ARROW ) )
+ 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))
{
- 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;
- }
+ Size aSize(aNativeContent.GetWidth(), aNativeContent.GetHeight());
+ rArrowSize = aSize;
+ rArrowSpacing = aNativeBounds.GetWidth() - aNativeContent.GetWidth();
+ return true;
}
+ }
return false;
}
@@ -1512,7 +1491,7 @@ Size Menu::ImplCalcSize( const vcl::Window* pWin )
long nMinMenuItemHeight = nFontHeight;
long nCheckHeight = 0, nRadioHeight = 0;
- Size aMaxSize = ImplGetNativeCheckAndRadioSize(pWin, nCheckHeight, nRadioHeight);
+ Size aMaxSize = ImplGetNativeCheckAndRadioSize(const_cast<vcl::Window&>(*pWin), nCheckHeight, nRadioHeight); // FIXME
if( aMaxSize.Height() > nMinMenuItemHeight )
nMinMenuItemHeight = aMaxSize.Height();
@@ -1712,7 +1691,7 @@ Size Menu::ImplCalcSize( const vcl::Window* pWin )
return aSz;
}
-static void ImplPaintCheckBackground( vcl::Window* i_pWindow, const Rectangle& i_rRect, bool i_bHighlight )
+static void ImplPaintCheckBackground(vcl::Window* i_pWindow, const Rectangle& i_rRect, bool i_bHighlight ) // FIXME
{
bool bNativeOk = false;
if( i_pWindow->IsNativeControlSupported( CTRL_TOOLBAR, PART_BUTTON ) )
@@ -1736,11 +1715,11 @@ static void ImplPaintCheckBackground( vcl::Window* i_pWindow, const Rectangle& i
}
}
-static OUString getShortenedString( const OUString& i_rLong, vcl::Window* i_pWin, long i_nMaxWidth )
+static OUString getShortenedString(const OUString& i_rLong, vcl::RenderContext& rRenderContext, long i_nMaxWidth)
{
sal_Int32 nPos = -1;
- OUString aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) );
- aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS );
+ OUString aNonMnem(OutputDevice::GetNonMnemonicString(i_rLong, nPos));
+ aNonMnem = rRenderContext.GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS );
// re-insert mnemonic
if( nPos != -1 )
{
@@ -1756,17 +1735,17 @@ static OUString getShortenedString( const OUString& i_rLong, vcl::Window* i_pWin
return aNonMnem;
}
-void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly, bool bHighlighted, bool bLayout, bool bRollover ) const
+void Menu::ImplPaint(vcl::RenderContext& rRenderContext, sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly, bool bHighlighted, bool bLayout, bool bRollover ) const
{
// for symbols: nFontHeight x nFontHeight
- long nFontHeight = pWin->GetTextHeight();
- long nExtra = nFontHeight/4;
+ long nFontHeight = rRenderContext.GetTextHeight();
+ long nExtra = nFontHeight / 4;
long nCheckHeight = 0, nRadioHeight = 0;
- ImplGetNativeCheckAndRadioSize( pWin, nCheckHeight, nRadioHeight );
+ ImplGetNativeCheckAndRadioSize(rRenderContext, nCheckHeight, nRadioHeight);
- DecorationView aDecoView( pWin );
- const StyleSettings& rSettings = pWin->GetSettings().GetStyleSettings();
+ DecorationView aDecoView(&rRenderContext);
+ const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings();
Point aTopLeft, aTmpPos;
@@ -1781,7 +1760,7 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
aTopLeft.Y() += ImplGetSVData()->maNWFData.mnMenuFormatBorderY;
}
- Size aOutSz = pWin->GetOutputSizePixel();
+ Size aOutSz = rRenderContext.GetOutputSizePixel();
size_t nCount = pItemList->size();
if( bLayout )
mpLayoutData->m_aVisibleItemBoundRects.clear();
@@ -1794,9 +1773,9 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
if ( pThisItemOnly )
{
if (IsMenuBar()&& bRollover )
- pWin->SetTextColor( rSettings.GetMenuBarRolloverTextColor() );
+ rRenderContext.SetTextColor( rSettings.GetMenuBarRolloverTextColor() );
else if ( bHighlighted )
- pWin->SetTextColor( rSettings.GetMenuHighlightTextColor() );
+ rRenderContext.SetTextColor( rSettings.GetMenuHighlightTextColor() );
}
Point aPos( aTopLeft );
@@ -1827,8 +1806,7 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
if (!bLayout && !IsMenuBar() && (pData->eType == MenuItemType::SEPARATOR))
{
bool bNativeOk = false;
- if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP,
- PART_MENU_SEPARATOR ) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_SEPARATOR))
{
ControlState nState = ControlState::NONE;
if ( pData->bEnabled )
@@ -1839,22 +1817,19 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
aSz.Width() = aOutSz.Width() - 2*nOuterSpaceX;
Rectangle aItemRect( aPos, aSz );
MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect );
- bNativeOk = pWin->DrawNativeControl( CTRL_MENU_POPUP, PART_MENU_SEPARATOR,
- aItemRect,
- nState,
- aVal,
- OUString() );
+ bNativeOk = rRenderContext.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;
- pWin->SetLineColor( rSettings.GetShadowColor() );
- pWin->DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) );
+ rRenderContext.SetLineColor( rSettings.GetShadowColor() );
+ rRenderContext.DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) );
aTmpPos.Y()++;
- pWin->SetLineColor( rSettings.GetLightColor() );
- pWin->DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) );
- pWin->SetLineColor();
+ rRenderContext.SetLineColor( rSettings.GetLightColor() );
+ rRenderContext.DrawLine( aTmpPos, Point( aOutSz.Width() - 3 - 2*nOuterSpaceX, aTmpPos.Y() ) );
+ rRenderContext.SetLineColor();
}
}
@@ -1873,12 +1848,12 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
// 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 ( pWin->IsNativeControlSupported( CTRL_MENU_POPUP,
+ if (rRenderContext.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
@@ -1904,15 +1879,12 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
aSz.Width() = aOutSz.Width() - 2*nOuterSpaceX;
Rectangle aItemRect( aPos, aSz );
MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect );
- pWin->DrawNativeControl( CTRL_MENU_POPUP, nPart,
- aCheckRect,
- nState,
- aVal,
- OUString() );
+ rRenderContext.DrawNativeControl(CTRL_MENU_POPUP, nPart, aCheckRect,
+ nState, aVal, OUString());
}
else if ( pData->bChecked ) // by default do nothing for unchecked items
{
- ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted );
+ ImplPaintCheckBackground(pWindow, aOuterCheckRect, pThisItemOnly && bHighlighted);
SymbolType eSymbol;
Size aSymbolSize;
@@ -1929,7 +1901,7 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
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, pWin->GetTextColor(), nSymbolStyle );
+ aDecoView.DrawSymbol( aRect, eSymbol, rRenderContext.GetTextColor(), nSymbolStyle );
}
}
}
@@ -1939,11 +1911,11 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
{
// Don't render an image for a check thing
if( pData->bChecked )
- ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted );
+ ImplPaintCheckBackground(pWindow, aOuterCheckRect, pThisItemOnly && bHighlighted);
Image aImage = pData->aImage;
- sal_Int32 nScaleFactor = pWindow->GetDPIScaleFactor();
+ sal_Int32 nScaleFactor = rRenderContext.GetDPIScaleFactor();
if (nScaleFactor != 1)
{
BitmapEx aBitmap = aImage.GetBitmapEx();
@@ -1953,7 +1925,7 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
aTmpPos = aOuterCheckRect.TopLeft();
aTmpPos.X() += (aOuterCheckRect.GetWidth() - aImage.GetSizePixel().Width()) / 2;
aTmpPos.Y() += (aOuterCheckRect.GetHeight() - aImage.GetSizePixel().Height()) / 2;
- pWin->DrawImage(aTmpPos, aImage, nImageStyle);
+ rRenderContext.DrawImage(aTmpPos, aImage, nImageStyle);
}
// Text:
@@ -1978,57 +1950,55 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
// TEXT_DRAW_DISABLE), temporarily set a background which
// hopefully matches the NWF background since it is read
// from the system style settings
- bool bSetTmpBackground = !pWin->IsBackground() && pWin->IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL );
- if( bSetTmpBackground )
+ bool bSetTmpBackground = !rRenderContext.IsBackground() && rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL);
+ if (bSetTmpBackground)
{
Color aBg = IsMenuBar()?
- pWin->GetSettings().GetStyleSettings().GetMenuBarColor() :
- pWin->GetSettings().GetStyleSettings().GetMenuColor();
- pWin->SetBackground( Wallpaper( aBg ) );
+ rRenderContext.GetSettings().GetStyleSettings().GetMenuBarColor() :
+ rRenderContext.GetSettings().GetStyleSettings().GetMenuColor();
+ rRenderContext.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 -= pWin->GetTextWidth( aAccText ) + 3*nExtra;
+ nMaxItemTextWidth -= rRenderContext.GetTextWidth(aAccText) + 3 * nExtra;
}
if (!IsMenuBar() && pData->pSubMenu)
{
nMaxItemTextWidth -= nFontHeight - nExtra;
}
- OUString aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) );
- pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.getLength(), nStyle, pVector, pDisplayText );
- if( bSetTmpBackground )
- pWin->SetBackground();
+ OUString aItemText(getShortenedString(pData->aText, rRenderContext, nMaxItemTextWidth));
+ rRenderContext.DrawCtrlText(aTmpPos, aItemText, 0, aItemText.getLength(), nStyle, pVector, pDisplayText);
+ if (bSetTmpBackground)
+ rRenderContext.SetBackground();
}
// Accel
if (!bLayout && !IsMenuBar() && pData->aAccelKey.GetCode() && !ImplAccelDisabled())
{
OUString aAccText = pData->aAccelKey.GetName();
- aTmpPos.X() = aOutSz.Width() - pWin->GetTextWidth( aAccText );
+ aTmpPos.X() = aOutSz.Width() - rRenderContext.GetTextWidth(aAccText);
aTmpPos.X() -= 4*nExtra;
aTmpPos.X() -= nOuterSpaceX;
aTmpPos.Y() = aPos.Y();
aTmpPos.Y() += nTextOffsetY;
- pWin->DrawCtrlText( aTmpPos, aAccText, 0, aAccText.getLength(), nTextStyle );
+ rRenderContext.DrawCtrlText(aTmpPos, aAccText, 0, aAccText.getLength(), nTextStyle);
}
// SubMenu?
if (!bLayout && !IsMenuBar() && pData->pSubMenu)
{
bool bNativeOk = false;
- if( pWin->IsNativeControlSupported( CTRL_MENU_POPUP,
- PART_MENU_SUBMENU_ARROW ) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_SUBMENU_ARROW))
{
ControlState nState = ControlState::NONE;
Size aTmpSz( 0, 0 );
long aSpacing = 0;
- if( !ImplGetNativeSubmenuArrowSize( pWin,
- aTmpSz, aSpacing ) )
+ if (!ImplGetNativeSubmenuArrowSize(rRenderContext, aTmpSz, aSpacing))
{
aTmpSz = Size( nFontHeight, nFontHeight );
aSpacing = nOuterSpaceX;
@@ -2045,14 +2015,10 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
Rectangle aItemRect( aTmpPos, aTmpSz );
MenupopupValue aVal( nTextPos-GUTTERBORDER, aItemRect );
- bNativeOk = pWin->DrawNativeControl( CTRL_MENU_POPUP,
- PART_MENU_SUBMENU_ARROW,
- aItemRect,
- nState,
- aVal,
- OUString() );
+ bNativeOk = rRenderContext.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();
@@ -2060,15 +2026,15 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
aTmpPos.Y() += ( pData->aSz.Height() / 2 ) - ( nFontHeight/4 );
if ( pData->nBits & MenuItemBits::POPUPSELECT )
{
- pWin->SetTextColor( rSettings.GetMenuTextColor() );
+ rRenderContext.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, pWin->GetTextColor(), nSymbolStyle );
+ Rectangle(aTmpPos, Size(nFontHeight / 2, nFontHeight / 2)),
+ SymbolType::SPIN_RIGHT, rRenderContext.GetTextColor(), nSymbolStyle);
}
}
@@ -2077,9 +2043,9 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
// This restores the normal menu or menu bar text
// color for when it is no longer highlighted.
if (IsMenuBar())
- pWin->SetTextColor( rSettings.GetMenuBarTextColor() );
+ rRenderContext.SetTextColor(rSettings.GetMenuBarTextColor());
else
- pWin->SetTextColor( rSettings.GetMenuTextColor() );
+ rRenderContext.SetTextColor(rSettings.GetMenuTextColor());
}
}
if( bLayout )
@@ -2106,21 +2072,21 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI
Size aLogoSz = pLogo->aBitmap.GetSizePixel();
Rectangle aRect( Point( 0, 0 ), Point( aLogoSz.Width()-1, aOutSz.Height() ) );
- if ( pWin->GetColorCount() >= 256 )
+ if (rRenderContext.GetColorCount() >= 256)
{
Gradient aGrad( GradientStyle_LINEAR, pLogo->aStartColor, pLogo->aEndColor );
aGrad.SetAngle( 1800 );
aGrad.SetBorder( 15 );
- pWin->DrawGradient( aRect, aGrad );
+ rRenderContext.DrawGradient(aRect, aGrad);
}
else
{
- pWin->SetFillColor( pLogo->aStartColor );
- pWin->DrawRect( aRect );
+ rRenderContext.SetFillColor(pLogo->aStartColor);
+ rRenderContext.DrawRect(aRect);
}
Point aLogoPos( 0, aOutSz.Height() - aLogoSz.Height() );
- pLogo->aBitmap.Draw( pWin, aLogoPos );
+ pLogo->aBitmap.Draw(&rRenderContext, aLogoPos);
}
}
@@ -2260,14 +2226,15 @@ void Menu::ImplFillLayoutData() const
if( pWindow && pWindow->IsReallyVisible() )
{
mpLayoutData = new MenuLayoutData();
- if (IsMenuBar())
+ pWindow->Invalidate();
+ if (IsMenuBar()) // FIXME
{
- ImplPaint( pWindow, 0, 0, 0, false, true );
+ //ImplPaint(pWindow, 0, 0, 0, false, true);
}
else
{
- MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get());
- ImplPaint( pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), 0, false, true );
+ //MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get()); // FIXME
+ //ImplPaint(pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), 0, false, true);
}
}
}
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index ef83cac..ac9f6c8 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -409,7 +409,7 @@ void MenuBarWindow::MouseMove( const MouseEvent& rMEvt )
if ( rMEvt.IsLeaveWindow() )
{
if ( nRolloveredItem != ITEMPOS_INVALID && nRolloveredItem != nHighlightedItem )
- HighlightItem( nRolloveredItem, false );
+ Invalidate();
nRolloveredItem = ITEMPOS_INVALID;
return;
@@ -421,10 +421,10 @@ void MenuBarWindow::MouseMove( const MouseEvent& rMEvt )
if ( nRolloveredItem != nEntry )
{
if ( nRolloveredItem != ITEMPOS_INVALID )
- HighlightItem( nRolloveredItem, false );
+ Invalidate();
nRolloveredItem = nEntry;
- HighlightItem( nRolloveredItem, true );
+ Invalidate();
}
return;
}
@@ -508,7 +508,7 @@ void MenuBarWindow::ChangeHighlightItem( sal_uInt16 n, bool bSelectEntry, bool b
if ( nHighlightedItem != ITEMPOS_INVALID )
{
if ( nHighlightedItem != nRolloveredItem )
- HighlightItem( nHighlightedItem, false );
+ Invalidate();
pMenu->ImplCallEventListeners( VCLEVENT_MENU_DEHIGHLIGHT, nHighlightedItem );
}
@@ -516,9 +516,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 )
- HighlightItem( nHighlightedItem, true );
+ Invalidate();
else if ( nRolloveredItem != ITEMPOS_INVALID )
- HighlightItem( nRolloveredItem, true );
+ Invalidate();
pMenu->ImplCallHighlight(nHighlightedItem);
if( mbAutoPopup )
@@ -564,113 +564,111 @@ static int ImplGetTopDockingAreaHeight( vcl::Window *pWindow )
return 0;
}
-static void ImplAddNWFSeparator( vcl::Window *pThis, const MenubarValue& rMenubarValue )
+static void ImplAddNWFSeparator(vcl::RenderContext& rRenderContext, 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
- pThis->SetLineColor( pThis->GetSettings().GetStyleSettings().GetSeparatorColor() );
+ rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor());
Point aPt;
- Rectangle aRect( aPt, pThis->GetOutputSizePixel() );
- pThis->DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
+ Rectangle aRect(aPt, rRenderContext.GetOutputSizePixel());
+ rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
}
}
-void MenuBarWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
+void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, 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 ) );
- Push( PushFlags::CLIPREGION );
- IntersectClipRegion( aRect );
+ Rectangle aRect = Rectangle(Point(nX, 1), Size(pData->aSz.Width(), GetOutputSizePixel().Height() - 2));
+ rRenderContext.Push(PushFlags::CLIPREGION);
+ IntersectClipRegion(aRect);
bool bRollover = bHighlight && nPos != nHighlightedItem;
- if ( bHighlight )
+ if (bHighlight)
{
- if( IsNativeControlSupported( CTRL_MENUBAR, PART_MENU_ITEM ) &&
- IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL ) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_MENU_ITEM) &&
+ rRenderContext.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() )
- Erase();
+ if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty())
+ rRenderContext.Erase();
else
{
- Point tmp(0,0);
- Rectangle aBgRegion( tmp, GetOutputSizePixel() );
- DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL,
- aBgRegion,
- ControlState::ENABLED,
- aControlValue,
- OUString() );
+ Rectangle aBgRegion(Point(), GetOutputSizePixel());
+ rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL, aBgRegion,
+ ControlState::ENABLED, aControlValue, OUString() );
}
- ImplAddNWFSeparator( this, aControlValue );
+ ImplAddNWFSeparator(rRenderContext, aControlValue);
// draw selected item
ControlState nState = ControlState::ENABLED;
- if ( bRollover )
+ if (bRollover)
nState |= ControlState::ROLLOVER;
else
nState |= ControlState::SELECTED;
- DrawNativeControl( CTRL_MENUBAR, PART_MENU_ITEM,
- aRect,
- nState,
- aControlValue,
- OUString() );
+ rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_MENU_ITEM, aRect,
+ nState, aControlValue, OUString());
}
else
{
- if ( bRollover )
- SetFillColor( GetSettings().GetStyleSettings().GetMenuBarRolloverColor() );
+ if (bRollover)
+ rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuBarRolloverColor());
else
- SetFillColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() );
- SetLineColor();
- DrawRect( aRect );
+ rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor());
+ rRenderContext.SetLineColor();
+ rRenderContext.DrawRect(aRect);
}
}
else
{
- if( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL))
{
MenubarValue aMenubarValue;
- aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
+ aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight(this);
- if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
- Erase( aRect );
+ if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty())
+ {
+ rRenderContext.Erase(aRect);
+ }
else
{
// use full window size to get proper gradient
// but clip accordingly
Point aPt;
- Rectangle aCtrlRect( aPt, GetOutputSizePixel() );
-
- DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString() );
+ Rectangle aCtrlRect(aPt, rRenderContext.GetOutputSizePixel());
+ rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRect, ControlState::ENABLED, aMenubarValue, OUString());
}
- ImplAddNWFSeparator( this, aMenubarValue );
+ ImplAddNWFSeparator(rRenderContext, aMenubarValue);
}
else
- Erase( aRect );
+ {
+ rRenderContext.Erase(aRect);
+ }
}
- Pop();
- pMenu->ImplPaint( this, 0, 0, pData, bHighlight, false, bRollover );
+ rRenderContext.Pop();
+ pMenu->ImplPaint(rRenderContext, 0, 0, pData, bHighlight, false, bRollover);
}
return;
}
@@ -871,52 +869,53 @@ 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( IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL))
{
MenubarValue aMenubarValue;
aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
- if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
- Erase();
+ if (!Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty())
+ {
+ rRenderContext.Erase();
+ }
else
{
Point aPt;
- Rectangle aCtrlRegion( aPt, GetOutputSizePixel() );
-
- DrawNativeControl( CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion, ControlState::ENABLED, aMenubarValue, OUString() );
+ Rectangle aCtrlRegion(aPt, rRenderContext.GetOutputSizePixel());
+ rRenderContext.DrawNativeControl(CTRL_MENUBAR, PART_ENTIRE_CONTROL, aCtrlRegion,
+ ControlState::ENABLED, aMenubarValue, OUString());
}
- ImplAddNWFSeparator( this, aMenubarValue );
+ ImplAddNWFSeparator(rRenderContext, aMenubarValue);
}
- SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() );
- pMenu->ImplPaint( this, 0 );
- if ( nHighlightedItem != ITEMPOS_INVALID )
- HighlightItem( nHighlightedItem, true );
+ rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
+ pMenu->ImplPaint(rRenderContext, 0);
+ if (nHighlightedItem != ITEMPOS_INVALID)
+ HighlightItem(rRenderContext, nHighlightedItem, true);
// in high contrast mode draw a separating line on the lower edge
- if( ! IsNativeControlSupported( CTRL_MENUBAR, PART_ENTIRE_CONTROL) &&
- GetSettings().GetStyleSettings().GetHighContrastMode() )
+ if (!rRenderContext.IsNativeControlSupported(CTRL_MENUBAR, PART_ENTIRE_CONTROL) &&
+ rRenderContext.GetSettings().GetStyleSettings().GetHighContrastMode())
{
- Push( PushFlags::LINECOLOR | PushFlags::MAPMODE );
- SetLineColor( Color( COL_WHITE ) );
- SetMapMode( MapMode( MAP_PIXEL ) );
+ rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::MAPMODE);
+ rRenderContext.SetLineColor(Color(COL_WHITE));
+ rRenderContext.SetMapMode(MapMode(MAP_PIXEL));
Size aSize = GetSizePixel();
- DrawLine( Point( 0, aSize.Height()-1 ), Point( aSize.Width()-1, aSize.Height()-1 ) );
- Pop();
+ rRenderContext.DrawLine(Point(0, aSize.Height() - 1), Point(aSize.Width() - 1, aSize.Height() - 1));
+ rRenderContext.Pop();
}
-
}
void MenuBarWindow::Resize()
diff --git a/vcl/source/window/menubarwindow.hxx b/vcl/source/window/menubarwindow.hxx
index 348d167..c917d12 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( sal_uInt16 nPos, bool bHighlight );
+ void HighlightItem(vcl::RenderContext& rRenderContext, 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 a48152e..d3f7a2b 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->HighlightItem( i, false );
+ if (pPWin)
+ pPWin->Invalidate();
}
}
@@ -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;
@@ -562,7 +562,7 @@ void MenuFloatingWindow::ImplScroll( bool bUp )
if( ! pMenu )
return;
- HighlightItem( nHighlightedItem, false );
+ Invalidate();
pMenu->ImplKillLayoutData();
@@ -612,7 +612,7 @@ void MenuFloatingWindow::ImplScroll( bool bUp )
Scroll( 0, -nScrollEntryHeight, ImplCalcClipRegion( false ).GetBoundRect(), SCROLL_CLIP );
}
- HighlightItem( nHighlightedItem, true );
+ Invalidate();
}
void MenuFloatingWindow::ImplScroll( const Point& rMousePos )
@@ -667,7 +667,7 @@ void MenuFloatingWindow::ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTime
if ( nHighlightedItem != ITEMPOS_INVALID )
{
- HighlightItem( nHighlightedItem, false );
+ Invalidate();
pMenu->ImplCallEventListeners( VCLEVENT_MENU_DEHIGHLIGHT, nHighlightedItem );
}
@@ -690,12 +690,12 @@ void MenuFloatingWindow::ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTime
MenuFloatingWindow* pPWin = static_cast<MenuFloatingWindow*>(pMenu->pStartedFrom->ImplGetWindow());
if( pPWin && pPWin->nHighlightedItem != i )
{
- pPWin->HighlightItem( i, true );
+ pPWin->Invalidate();
pPWin->nHighlightedItem = i;
}
}
}
- HighlightItem( nHighlightedItem, true );
+ Invalidate();
pMenu->ImplCallHighlight( nHighlightedItem );
}
else
@@ -714,26 +714,26 @@ void MenuFloatingWindow::ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTime
}
}
-void MenuFloatingWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
+void MenuFloatingWindow::HighlightItem(vcl::RenderContext& rRenderContext, 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 )
@@ -742,64 +742,65 @@ void MenuFloatingWindow::HighlightItem( sal_uInt16 nPos, bool bHighlight )
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 = GetTextHeight();
- aItemRect.Right() -= nFontHeight + nFontHeight/4;
+ long nFontHeight = rRenderContext.GetTextHeight();
+ aItemRect.Right() -= nFontHeight + nFontHeight / 4;
}
- if( IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL))
{
- 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 ) )
+ 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))
{
bDrawItemRect = false;
- if( !DrawNativeControl( CTRL_MENU_POPUP, PART_MENU_ITEM,
+ if (!rRenderContext.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;
- Pop();
+ }
+ rRenderContext.Pop();
}
- if( bDrawItemRect )
+ if (bDrawItemRect)
{
- if ( bHighlight )
+ if (bHighlight)
{
- if( pData->bEnabled )
- SetFillColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() );
+ if (pData->bEnabled)
+ {
+ rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor());
+ }
else
{
- SetFillColor();
- oldLineColor = GetLineColor();
- SetLineColor( GetSettings().GetStyleSettings().GetMenuHighlightColor() );
+ rRenderContext.SetFillColor();
+ oldLineColor = rRenderContext.GetLineColor();
+ rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuHighlightColor());
bRestoreLineColor = true;
}
}
else
- SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() );
-
- DrawRect( aItemRect );
+ {
+ rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
+ }
+ rRenderContext.DrawRect(aItemRect);
}
- pMenu->ImplPaint( this, nScrollerHeight, nStartY, pData, bHighlight );
- if( bRestoreLineColor )
- SetLineColor( oldLineColor );
+ pMenu->ImplPaint(rRenderContext, nScrollerHeight, nStartY, pData, bHighlight);
+ if (bRestoreLineColor)
+ rRenderContext.SetLineColor(oldLineColor);
}
return;
}
@@ -1086,34 +1087,32 @@ 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( IsNativeControlSupported( CTRL_MENU_POPUP, PART_ENTIRE_CONTROL ) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL))
{
- SetClipRegion();
+ rRenderContext.SetClipRegion();
long nX = pMenu->pLogo ? pMenu->pLogo->aBitmap.GetSizePixel().Width() : 0;
- Size aPxSize( GetOutputSizePixel() );
+ Size aPxSize(rRenderContext.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);
}
- SetFillColor( GetSettings().GetStyleSettings().GetMenuColor() );
- pMenu->ImplPaint( this, nScrollerHeight, ImplGetStartY() );
- if ( nHighlightedItem != ITEMPOS_INVALID )
- HighlightItem( nHighlightedItem, true );
+ rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
+ pMenu->ImplPaint(rRenderContext, nScrollerHeight, ImplGetStartY());
+ if (nHighlightedItem != ITEMPOS_INVALID)
+ HighlightItem(rRenderContext, nHighlightedItem, true);
}
void MenuFloatingWindow::ImplDrawScroller( bool bUp )
diff --git a/vcl/source/window/menufloatingwindow.hxx b/vcl/source/window/menufloatingwindow.hxx
index 021247a..efc38467 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( sal_uInt16 nPos, bool bHighlight );
+ void HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHighlight);
void ChangeHighlightItem( sal_uInt16 n, bool bStartPopupTimer );
sal_uInt16 GetHighlightedItem() const { return nHighlightedItem; }
commit ac6c725167797c15f1dd5b7de4bf63ddeae0ada7
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Wed May 6 07:48:16 2015 +0900
Refactor "Edit" to use RenderContext when painting
Change-Id: I41f3fa14ee06339685b608d1081466d4622999da
diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx
index dde925f..fdcbad1 100644
--- a/include/vcl/edit.hxx
+++ b/include/vcl/edit.hxx
@@ -111,8 +111,8 @@ private:
SAL_DLLPRIVATE void ImplSetText( const OUString& rStr, const Selection* pNewSelection = 0 );
SAL_DLLPRIVATE void ImplInsertText( const OUString& rStr, const Selection* pNewSelection = 0, bool bIsUserInput = false );
SAL_DLLPRIVATE OUString ImplGetValidString( const OUString& rString ) const;
- SAL_DLLPRIVATE void ImplClearBackground( long nXStart, long nXEnd );
- SAL_DLLPRIVATE void ImplPaintBorder( long nXStart, long nXEnd );
+ SAL_DLLPRIVATE void ImplClearBackground(vcl::RenderContext& rRenderContext, long nXStart, long nXEnd);
+ SAL_DLLPRIVATE void ImplPaintBorder(vcl::RenderContext& rRenderContext, long nXStart, long nXEnd);
SAL_DLLPRIVATE void ImplShowCursor( bool bOnlyIfVisible = true );
SAL_DLLPRIVATE void ImplAlign();
SAL_DLLPRIVATE void ImplAlignAndPaint();
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index ece4f56..90a88fb 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -487,220 +487,223 @@ long Edit::ImplGetTextYPosition() const
return ( GetOutputSizePixel().Height() - GetTextHeight() ) / 2;
}
-void Edit::ImplRepaint(vcl::RenderContext& /*rRenderContext*/, bool bLayout)
+void Edit::ImplRepaint(vcl::RenderContext& rRenderContext, bool bLayout)
{
- if ( !IsReallyVisible() )
+ if (!IsReallyVisible())
return;
OUString aText = ImplGetText();
sal_Int32 nLen = aText.getLength();
- long nDXBuffer[256];
+ long nDXBuffer[256];
boost::scoped_array<long> pDXBuffer;
- long* pDX = nDXBuffer;
+ long* pDX = nDXBuffer;
- if( !aText.isEmpty() )
+ if (!aText.isEmpty())
{
- if( (size_t) (2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) )
+ if ((size_t) (2 * aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer))
{
- pDXBuffer.reset(new long[2*(aText.getLength()+1)]);
+ pDXBuffer.reset(new long[2 * (aText.getLength() + 1)]);
pDX = pDXBuffer.get();
}
- GetCaretPositions( aText, pDX, 0, nLen );
+ GetCaretPositions(aText, pDX, 0, nLen);
}
- long nTH = GetTextHeight();
- Point aPos( mnXOffset, ImplGetTextYPosition() );
+ long nTH = GetTextHeight();
+ Point aPos(mnXOffset, ImplGetTextYPosition());
- if( bLayout )
+ if (bLayout)
{
aPos.X() = mnXOffset + ImplGetExtraOffset();
MetricVector* pVector = &mpControlData->mpLayoutData->m_aUnicodeBoundRects;
OUString* pDisplayText = &mpControlData->mpLayoutData->m_aDisplayText;
- DrawText( aPos, aText, 0, nLen, pVector, pDisplayText );
-
+ rRenderContext.DrawText(aPos, aText, 0, nLen, pVector, pDisplayText);
return;
}
vcl::Cursor* pCursor = GetCursor();
bool bVisCursor = pCursor && pCursor->IsVisible();
- if ( pCursor )
+ if (pCursor)
pCursor->Hide();
- ImplClearBackground( 0, GetOutputSizePixel().Width() );
+ ImplClearBackground(rRenderContext, 0, GetOutputSizePixel().Width());
bool bPaintPlaceholderText = aText.isEmpty() && !maPlaceholderText.isEmpty();
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- if ( IsEnabled() )
- ImplInitSettings( false, true, false );
- if ( !IsEnabled() || bPaintPlaceholderText )
- SetTextColor( rStyleSettings.GetDisableColor() );
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ if (IsEnabled())
+ ImplInitSettings(false, true, false);
+ if (!IsEnabled() || bPaintPlaceholderText)
+ rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
// Set background color of the normal text
- if( (GetStyle() & WB_FORCECTRLBACKGROUND) != 0 && IsControlBackground() )
+ if ((GetStyle() & WB_FORCECTRLBACKGROUND) != 0 && IsControlBackground())
{
// check if we need to set ControlBackground even in NWF case
- Push( PushFlags::FILLCOLOR | PushFlags::LINECOLOR );
- SetLineColor();
- SetFillColor( GetControlBackground() );
- DrawRect( Rectangle( aPos, Size( GetOutputSizePixel().Width() - 2*mnXOffset, GetOutputSizePixel().Height() ) ) );
- Pop();
+ rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
+ rRenderContext.SetLineColor();
+ rRenderContext.SetFillColor(GetControlBackground());
+ rRenderContext.DrawRect(Rectangle(aPos, Size(GetOutputSizePixel().Width() - 2 * mnXOffset, GetOutputSizePixel().Height())));
+ rRenderContext.Pop();
- SetTextFillColor( GetControlBackground() );
+ SetTextFillColor(GetControlBackground());
}
- else if( IsPaintTransparent() || ImplUseNativeBorder( GetStyle() ) )
- SetTextFillColor();
+ else if (IsPaintTransparent() || ImplUseNativeBorder(GetStyle()))
+ rRenderContext.SetTextFillColor();
else
- SetTextFillColor( IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor() );
+ rRenderContext.SetTextFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
- ImplPaintBorder( 0, GetOutputSizePixel().Width() );
+ ImplPaintBorder(rRenderContext, 0, GetOutputSizePixel().Width());
- bool bDrawSelection = maSelection.Len() && ( HasFocus() || ( GetStyle() & WB_NOHIDESELECTION ) || mbActivePopup );
+ bool bDrawSelection = maSelection.Len() && (HasFocus() || (GetStyle() & WB_NOHIDESELECTION) || mbActivePopup);
aPos.X() = mnXOffset + ImplGetExtraOffset();
- if ( bPaintPlaceholderText )
+ if (bPaintPlaceholderText)
{
- DrawText( aPos, maPlaceholderText );
+ rRenderContext.DrawText(aPos, maPlaceholderText);
}
- else if ( !bDrawSelection && !mpIMEInfos )
+ else if (!bDrawSelection && !mpIMEInfos)
{
- DrawText( aPos, aText, 0, nLen );
+ rRenderContext.DrawText(aPos, aText, 0, nLen);
}
else
{
// save graphics state
- Push();
+ rRenderContext.Push();
// first calculate higlighted and non highlighted clip regions
vcl::Region aHiglightClipRegion;
vcl::Region aNormalClipRegion;
- Selection aTmpSel( maSelection );
+ Selection aTmpSel(maSelection);
aTmpSel.Justify();
// selection is highlighted
int i;
- for( i = 0; i < aText.getLength(); i++ )
+ for(i = 0; i < aText.getLength(); i++)
{
- Rectangle aRect( aPos, Size( 10, nTH ) );
- aRect.Left() = pDX[2*i] + mnXOffset + ImplGetExtraOffset();
- aRect.Right() = pDX[2*i+1] + mnXOffset + ImplGetExtraOffset();
+ Rectangle aRect(aPos, Size(10, nTH));
+ aRect.Left() = pDX[2 * i] + mnXOffset + ImplGetExtraOffset();
+ aRect.Right() = pDX[2 * i + 1] + mnXOffset + ImplGetExtraOffset();
aRect.Justify();
bool bHighlight = false;
- if( i >= aTmpSel.Min() && i < aTmpSel.Max() )
+ if (i >= aTmpSel.Min() && i < aTmpSel.Max())
bHighlight = true;
- if( mpIMEInfos && mpIMEInfos->pAttribs &&
- i >= mpIMEInfos->nPos && i < (mpIMEInfos->nPos+mpIMEInfos->nLen ) &&
- ( mpIMEInfos->pAttribs[i-mpIMEInfos->nPos] & EXTTEXTINPUT_ATTR_HIGHLIGHT) )
+ if (mpIMEInfos && mpIMEInfos->pAttribs &&
+ i >= mpIMEInfos->nPos && i < (mpIMEInfos->nPos+mpIMEInfos->nLen) &&
+ (mpIMEInfos->pAttribs[i - mpIMEInfos->nPos] & EXTTEXTINPUT_ATTR_HIGHLIGHT))
+ {
bHighlight = true;
+ }
- if( bHighlight )
- aHiglightClipRegion.Union( aRect );
+ if (bHighlight)
+ aHiglightClipRegion.Union(aRect);
else
- aNormalClipRegion.Union( aRect );
+ aNormalClipRegion.Union(aRect);
}
// draw normal text
- Color aNormalTextColor = GetTextColor();
- SetClipRegion( aNormalClipRegion );
+ Color aNormalTextColor = rRenderContext.GetTextColor();
+ SetClipRegion(aNormalClipRegion);
- if( IsPaintTransparent() )
- SetTextFillColor();
+ if (IsPaintTransparent())
+ rRenderContext.SetTextFillColor();
else
{
// Set background color when part of the text is selected
- if ( ImplUseNativeBorder( GetStyle() ) )
+ if (ImplUseNativeBorder(GetStyle()))
{
if( (GetStyle() & WB_FORCECTRLBACKGROUND) != 0 && IsControlBackground() )
- SetTextFillColor( GetControlBackground() );
+ rRenderContext.SetTextFillColor(GetControlBackground());
else
- SetTextFillColor();
+ rRenderContext.SetTextFillColor();
}
else
- SetTextFillColor( IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor() );
+ {
+ rRenderContext.SetTextFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
+ }
}
- DrawText( aPos, aText, 0, nLen );
+ rRenderContext.DrawText(aPos, aText, 0, nLen);
// draw highlighted text
- SetClipRegion( aHiglightClipRegion );
- SetTextColor( rStyleSettings.GetHighlightTextColor() );
- SetTextFillColor( rStyleSettings.GetHighlightColor() );
- DrawText( aPos, aText, 0, nLen );
+ rRenderContext.SetClipRegion(aHiglightClipRegion);
+ rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
+ rRenderContext.SetTextFillColor(rStyleSettings.GetHighlightColor());
+ rRenderContext.DrawText(aPos, aText, 0, nLen);
// if IME info exists loop over portions and output different font attributes
- if( mpIMEInfos && mpIMEInfos->pAttribs )
+ if (mpIMEInfos && mpIMEInfos->pAttribs)
{
- for( int n = 0; n < 2; n++ )
+ for(int n = 0; n < 2; n++)
{
vcl::Region aRegion;
- if( n == 0 )
+ if (n == 0)
{
- SetTextColor( aNormalTextColor );
- if( IsPaintTransparent() )
- SetTextFillColor();
+ rRenderContext.SetTextColor(aNormalTextColor);
+ if (IsPaintTransparent())
+ rRenderContext.SetTextFillColor();
else
- SetTextFillColor( IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor() );
+ rRenderContext.SetTextFillColor(IsControlBackground() ? GetControlBackground() : rStyleSettings.GetFieldColor());
aRegion = aNormalClipRegion;
}
else
{
- SetTextColor( rStyleSettings.GetHighlightTextColor() );
- SetTextFillColor( rStyleSettings.GetHighlightColor() );
+ rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor());
+ rRenderContext.SetTextFillColor(rStyleSettings.GetHighlightColor());
aRegion = aHiglightClipRegion;
}
- for( i = 0; i < mpIMEInfos->nLen; )
+ for(i = 0; i < mpIMEInfos->nLen; )
{
sal_uInt16 nAttr = mpIMEInfos->pAttribs[i];
vcl::Region aClip;
int nIndex = i;
- while( nIndex < mpIMEInfos->nLen && mpIMEInfos->pAttribs[nIndex] == nAttr) // #112631# check nIndex before using it
+ while (nIndex < mpIMEInfos->nLen && mpIMEInfos->pAttribs[nIndex] == nAttr) // #112631# check nIndex before using it
{
Rectangle aRect( aPos, Size( 10, nTH ) );
- aRect.Left() = pDX[2*(nIndex+mpIMEInfos->nPos)] + mnXOffset + ImplGetExtraOffset();
- aRect.Right() = pDX[2*(nIndex+mpIMEInfos->nPos)+1] + mnXOffset + ImplGetExtraOffset();
+ aRect.Left() = pDX[2 * (nIndex + mpIMEInfos->nPos)] + mnXOffset + ImplGetExtraOffset();
+ aRect.Right() = pDX[2 * (nIndex + mpIMEInfos->nPos) + 1] + mnXOffset + ImplGetExtraOffset();
aRect.Justify();
- aClip.Union( aRect );
+ aClip.Union(aRect);
nIndex++;
}
i = nIndex;
aClip.Intersect(aRegion);
- if( !aClip.IsEmpty() && nAttr )
+ if (!aClip.IsEmpty() && nAttr)
{
- vcl::Font aFont = GetFont();
- if ( nAttr & EXTTEXTINPUT_ATTR_UNDERLINE )
- aFont.SetUnderline( UNDERLINE_SINGLE );
- else if ( nAttr & EXTTEXTINPUT_ATTR_BOLDUNDERLINE )
- aFont.SetUnderline( UNDERLINE_BOLD );
- else if ( nAttr & EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE )
- aFont.SetUnderline( UNDERLINE_DOTTED );
- else if ( nAttr & EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE )
- aFont.SetUnderline( UNDERLINE_DASHDOT );
- else if ( nAttr & EXTTEXTINPUT_ATTR_GRAYWAVELINE )
+ vcl::Font aFont = rRenderContext.GetFont();
+ if (nAttr & EXTTEXTINPUT_ATTR_UNDERLINE)
+ aFont.SetUnderline(UNDERLINE_SINGLE);
+ else if (nAttr & EXTTEXTINPUT_ATTR_BOLDUNDERLINE)
+ aFont.SetUnderline( UNDERLINE_BOLD);
+ else if (nAttr & EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE)
+ aFont.SetUnderline( UNDERLINE_DOTTED);
+ else if (nAttr & EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE)
+ aFont.SetUnderline( UNDERLINE_DASHDOT);
+ else if (nAttr & EXTTEXTINPUT_ATTR_GRAYWAVELINE)
{
- aFont.SetUnderline( UNDERLINE_WAVE );
- SetTextLineColor( Color( COL_LIGHTGRAY ) );
+ aFont.SetUnderline(UNDERLINE_WAVE);
+ rRenderContext.SetTextLineColor(Color(COL_LIGHTGRAY));
}
- SetFont( aFont );
+ rRenderContext.SetFont(aFont);
- if ( nAttr & EXTTEXTINPUT_ATTR_REDTEXT )
- SetTextColor( Color( COL_RED ) );
- else if ( nAttr & EXTTEXTINPUT_ATTR_HALFTONETEXT )
- SetTextColor( Color( COL_LIGHTGRAY ) );
+ if (nAttr & EXTTEXTINPUT_ATTR_REDTEXT)
+ rRenderContext.SetTextColor(Color(COL_RED));
+ else if (nAttr & EXTTEXTINPUT_ATTR_HALFTONETEXT)
+ rRenderContext.SetTextColor(Color(COL_LIGHTGRAY));
- SetClipRegion( aClip );
- DrawText( aPos, aText, 0, nLen );
+ rRenderContext.SetClipRegion(aClip);
+ rRenderContext.DrawText(aPos, aText, 0, nLen);
}
}
}
}
// restore graphics state
- Pop();
+ rRenderContext.Pop();
}
- if ( bVisCursor && ( !mpIMEInfos || mpIMEInfos->bCursor ) )
+ if (bVisCursor && (!mpIMEInfos || mpIMEInfos->bCursor))
pCursor->Show();
}
@@ -1006,79 +1009,80 @@ int Edit::ImplGetNativeControlType() const
return nCtrl;
}
-void Edit::ImplClearBackground( long nXStart, long nXEnd )
+void Edit::ImplClearBackground(vcl::RenderContext& rRenderContext, long nXStart, long nXEnd )
{
/*
* note: at this point the cursor must be switched off already
*/
Point aTmpPoint;
- Rectangle aRect( aTmpPoint, GetOutputSizePixel() );
+ Rectangle aRect(aTmpPoint, GetOutputSizePixel());
aRect.Left() = nXStart;
aRect.Right() = nXEnd;
- if( !(ImplUseNativeBorder( GetStyle() ) || IsPaintTransparent()) )
- Erase( aRect );
+ if( !(ImplUseNativeBorder(GetStyle() ) || IsPaintTransparent()))
+ rRenderContext.Erase(aRect);
}
-void Edit::ImplPaintBorder( long nXStart, long nXEnd )
+void Edit::ImplPaintBorder(vcl::RenderContext& rRenderContext, long nXStart, long nXEnd)
{
Point aTmpPoint;
- Rectangle aRect( aTmpPoint, GetOutputSizePixel() );
+ Rectangle aRect(aTmpPoint, GetOutputSizePixel());
aRect.Left() = nXStart;
aRect.Right() = nXEnd;
- if( ImplUseNativeBorder( GetStyle() ) || IsPaintTransparent() )
+ if (ImplUseNativeBorder(GetStyle()) || IsPaintTransparent())
{
// draw the inner part by painting the whole control using its border window
- vcl::Window *pBorder = GetWindow( WINDOW_BORDER );
- if( pBorder == this )
+ vcl::Window* pBorder = GetWindow(WINDOW_BORDER);
+ if (pBorder == this)
{
// we have no border, use parent
- vcl::Window *pControl = mbIsSubEdit ? GetParent() : this;
- pBorder = pControl->GetWindow( WINDOW_BORDER );
- if( pBorder == this )
+ vcl::Window* pControl = mbIsSubEdit ? GetParent() : this;
+ pBorder = pControl->GetWindow(WINDOW_BORDER);
+ if (pBorder == this)
pBorder = GetParent();
}
- if( pBorder )
+ if (pBorder)
{
// set proper clipping region to not overdraw the whole control
vcl::Region aClipRgn = GetPaintRegion();
- if( !aClipRgn.IsNull() )
+ if (!aClipRgn.IsNull())
{
// transform clipping region to border window's coordinate system
- if( IsRTLEnabled() != pBorder->IsRTLEnabled() && AllSettings::GetLayoutRTL() )
+ if (IsRTLEnabled() != pBorder->IsRTLEnabled() && AllSettings::GetLayoutRTL())
{
// need to mirror in case border is not RTL but edit is (or vice versa)
// mirror
- Rectangle aBounds( aClipRgn.GetBoundRect() );
- int xNew = GetOutputSizePixel().Width() - aBounds.GetWidth() - aBounds.Left();
- aClipRgn.Move( xNew - aBounds.Left(), 0 );
+ Rectangle aBounds(aClipRgn.GetBoundRect());
+ int xNew = rRenderContext.GetOutputSizePixel().Width() - aBounds.GetWidth() - aBounds.Left();
+ aClipRgn.Move(xNew - aBounds.Left(), 0);
// move offset of border window
Point aBorderOffs;
- aBorderOffs = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aBorderOffs ) );
- aClipRgn.Move( aBorderOffs.X(), aBorderOffs.Y() );
+ aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(aBorderOffs));
+ aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y());
}
else
{
// normal case
Point aBorderOffs;
- aBorderOffs = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aBorderOffs ) );
- aClipRgn.Move( aBorderOffs.X(), aBorderOffs.Y() );
+ aBorderOffs = pBorder->ScreenToOutputPixel(OutputToScreenPixel(aBorderOffs));
+ aClipRgn.Move(aBorderOffs.X(), aBorderOffs.Y());
}
- vcl::Region oldRgn( pBorder->GetClipRegion() );
- pBorder->SetClipRegion( aClipRgn );
+ vcl::Region oldRgn(pBorder->GetClipRegion());
+ pBorder->SetClipRegion(aClipRgn);
- pBorder->Paint(*pBorder, Rectangle());
+ pBorder->Paint(*pBorder, Rectangle()); // FIXME
- pBorder->SetClipRegion( oldRgn );
+ pBorder->SetClipRegion(oldRgn);
}
else
- pBorder->Paint(*pBorder, Rectangle());
-
+ {
+ pBorder->Paint(*pBorder, Rectangle()); // FIXME
+ }
}
}
}
More information about the Libreoffice-commits
mailing list