[Libreoffice-commits] core.git: Branch 'feature/rendercontext' - 454 commits - accessibility/inc accessibility/source android/Bootstrap android/experimental animations/source avmedia/inc avmedia/source basctl/source basegfx/source basic/qa basic/source canvas/source chart2/inc chart2/qa chart2/source comphelper/source compilerplugins/clang connectivity/source cppcanvas/source cppuhelper/source cui/source cui/uiconfig dbaccess/source desktop/CppunitTest_desktop_version.mk desktop/inc desktop/Module_desktop.mk desktop/source drawinglayer/source dtrans/source editeng/source embeddedobj/source embeddedobj/test embedserv/source extensions/source external/harfbuzz external/icu extras/source filter/source forms/source formula/source fpicker/source framework/inc framework/source hwpfilter/source i18nlangtag/source i18npool/CustomTarget_collator.mk i18npool/Library_localedata_euro.mk i18npool/Library_localedata_others.mk i18npool/source icon-themes/breeze icon-themes/sifr icon-themes/tango icon-themes/tan go_testing include/basebmp include/basegfx include/basic include/comphelper include/connectivity include/dbaccess include/drawinglayer include/editeng include/filter include/formula include/framework include/i18nlangtag include/LibreOfficeKit include/o3tl include/oox include/postwin.h include/sal include/sfx2 include/svl include/svtools include/svx include/test include/toolkit include/tools include/unotools include/vcl include/xmloff linguistic/source lotuswordpro/source officecfg/registry oox/inc oox/source postprocess/CustomTarget_registry.mk reportdesign/inc reportdesign/source rsc/inc rsc/Module_rsc.mk rsc/source sal/cppunittester sal/osl sal/workben sax/source scaddins/source sc/AllLangResTarget_sc.mk sc/inc scp2/source sc/qa sc/sdi sc/source sc/uiconfig sc/util sc/workben sdext/source sd/inc sd/qa sd/sdi sd/source sfx2/inc sfx2/source shell/source slideshow/source solenv/bin solenv/gbuild sot/source starmath/inc starmath/qa starmath/source starmath/util stoc/source stoc/test s vgio/inc svgio/source svl/source svtools/inc svtools/source svx/inc svx/sdi svx/source svx/uiconfig svx/workben sw/inc sw/qa sw/sdi sw/source sw/uiconfig test/source toolkit/source toolkit/test tools/Library_tl.mk tools/qa tools/source ucb/source UnoControls/source unotools/source uui/source vbahelper/source vcl/generic vcl/headless vcl/inc vcl/opengl vcl/osx vcl/qa vcl/quartz vcl/README.lifecycle vcl/source vcl/unx vcl/win vcl/workben writerfilter/source xmlhelp/source xmloff/inc xmloff/source xmlscript/source xmlsecurity/inc xmlsecurity/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Thu May 7 01:02:28 PDT 2015
Rebased ref, commits from common ancestor:
commit 2da59aafde97fa509a0e91afce1eebb68a3779d9
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu May 7 15:26:25 2015 +0900
refactor BorderWindowView to use RenderContext
Change-Id: Ib2aeae77ab7a570c4113f9767515e4f5833040b2
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index b54914f..bc6b8ef 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -1182,26 +1182,27 @@ long ImplSmallBorderWindowView::CalcTitleWidth() const
return 0;
}
-void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*, const Point* )
+void ImplSmallBorderWindowView::DrawWindow(sal_uInt16 nDrawFlags, OutputDevice*, const Point* )
{
WindowBorderStyle nBorderStyle = mpBorderWindow->GetBorderStyle();
- if ( nBorderStyle & WindowBorderStyle::NOBORDER )
+ if (nBorderStyle & WindowBorderStyle::NOBORDER)
return;
bool bNativeOK = false;
// for native widget drawing we must find out what
// control this border belongs to
- vcl::Window *pWin = NULL, *pCtrl = NULL;
- if( mpOutDev->GetOutDevType() == OUTDEV_WINDOW )
+ vcl::Window* pWin = NULL;
+ vcl::Window* pCtrl = NULL;
+ if (mpOutDev->GetOutDevType() == OUTDEV_WINDOW)
pWin = static_cast<vcl::Window*>(mpOutDev.get());
ControlType aCtrlType = 0;
ControlPart aCtrlPart = PART_ENTIRE_CONTROL;
std::unique_ptr<ImplControlValue> xControlValue(new ImplControlValue());
- if( pWin && (pCtrl = mpBorderWindow->GetWindow( WINDOW_CLIENT )) != NULL )
+ if (pWin && (pCtrl = mpBorderWindow->GetWindow(WINDOW_CLIENT)) != NULL)
{
xControlValue.reset(new EditBoxValue(pCtrl->GetTextHeight()));
- switch( pCtrl->GetType() )
+ switch (pCtrl->GetType())
{
case WINDOW_MULTILINEEDIT:
aCtrlType = CTRL_MULTILINE_EDITBOX;
@@ -1216,7 +1217,7 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
case WINDOW_NUMERICFIELD:
case WINDOW_SPINFIELD:
case WINDOW_CALCINPUTLINE:
- if( pCtrl->GetStyle() & WB_SPIN )
+ if (pCtrl->GetStyle() & WB_SPIN)
aCtrlType = CTRL_SPINBOX;
else
aCtrlType = CTRL_EDITBOX;
@@ -1226,7 +1227,7 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
case WINDOW_MULTILISTBOX:
case WINDOW_TREELISTBOX:
aCtrlType = CTRL_LISTBOX;
- if( pCtrl->GetStyle() & WB_DROPDOWN )
+ if (pCtrl->GetStyle() & WB_DROPDOWN)
aCtrlPart = PART_ENTIRE_CONTROL;
else
aCtrlPart = PART_WINDOW;
@@ -1245,7 +1246,7 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
case WINDOW_DATEBOX:
case WINDOW_TIMEBOX:
case WINDOW_LONGCURRENCYBOX:
- if( pCtrl->GetStyle() & WB_DROPDOWN )
+ if (pCtrl->GetStyle() & WB_DROPDOWN)
{
aCtrlType = CTRL_COMBOBOX;
aCtrlPart = PART_ENTIRE_CONTROL;
@@ -1262,83 +1263,84 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
}
}
- if ( aCtrlType && pCtrl->IsNativeControlSupported(aCtrlType, aCtrlPart) )
+ if (aCtrlType && pCtrl->IsNativeControlSupported(aCtrlType, aCtrlPart))
{
- ControlState nState = ControlState::ENABLED;
+ ControlState nState = ControlState::ENABLED;
- if ( !pWin->IsEnabled() )
+ if (!pWin->IsEnabled())
nState &= ~ControlState::ENABLED;
- if ( pWin->HasFocus() )
+ if (pWin->HasFocus())
nState |= ControlState::FOCUSED;
- else if( mbNWFBorder )
+ else if(mbNWFBorder)
{
// FIXME: this is currently only on OS X, see if other platforms can profit
// FIXME: for OS X focus rings all controls need to support GetNativeControlRegion
// for the dropdown style
- if( pCtrl->HasFocus() || pCtrl->HasChildPathFocus() )
+ if (pCtrl->HasFocus() || pCtrl->HasChildPathFocus())
nState |= ControlState::FOCUSED;
}
bool bMouseOver = false;
- vcl::Window *pCtrlChild = pCtrl->GetWindow( WINDOW_FIRSTCHILD );
- while( pCtrlChild && !(bMouseOver = pCtrlChild->IsMouseOver()) )
- pCtrlChild = pCtrlChild->GetWindow( WINDOW_NEXT );
+ vcl::Window *pCtrlChild = pCtrl->GetWindow(WINDOW_FIRSTCHILD);
+ while(pCtrlChild && !(bMouseOver = pCtrlChild->IsMouseOver()))
+ {
+ pCtrlChild = pCtrlChild->GetWindow(WINDOW_NEXT);
+ }
- if( bMouseOver )
+ if (bMouseOver)
nState |= ControlState::ROLLOVER;
Point aPoint;
- Rectangle aCtrlRegion( aPoint, Size( mnWidth, mnHeight ) );
-
- Rectangle aBoundingRgn( aPoint, Size( mnWidth, mnHeight ) );
- Rectangle aContentRgn( aCtrlRegion );
- if( ! ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize &&
- pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion,
- nState, *xControlValue, OUString(),
- aBoundingRgn, aContentRgn ))
+ Rectangle aCtrlRegion(aPoint, Size(mnWidth, mnHeight));
+
+ Rectangle aBoundingRgn(aPoint, Size(mnWidth, mnHeight));
+ Rectangle aContentRgn(aCtrlRegion);
+ if (!ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize &&
+ pWin->GetNativeControlRegion(aCtrlType, aCtrlPart, aCtrlRegion,
+ nState, *xControlValue, OUString(),
+ aBoundingRgn, aContentRgn))
{
aCtrlRegion=aContentRgn;
}
- bNativeOK = pWin->DrawNativeControl( aCtrlType, aCtrlPart, aCtrlRegion, nState,
- *xControlValue, OUString() );
+ bNativeOK = pWin->DrawNativeControl(aCtrlType, aCtrlPart, aCtrlRegion, nState, *xControlValue, OUString());
// if the native theme draws the spinbuttons in one call, make sure the proper settings
// are passed, this might force a redraw though.... (TODO: improve)
- if ( (aCtrlType == CTRL_SPINBOX) && !pCtrl->IsNativeControlSupported( CTRL_SPINBOX, PART_BUTTON_UP ) )
+ if ((aCtrlType == CTRL_SPINBOX) && !pCtrl->IsNativeControlSupported(CTRL_SPINBOX, PART_BUTTON_UP))
{
- Edit *pEdit = static_cast<Edit*>(pCtrl)->GetSubEdit();
+ Edit* pEdit = static_cast<Edit*>(pCtrl)->GetSubEdit();
if (pEdit)
pCtrl->Paint(*pCtrl, Rectangle()); // make sure the buttons are also drawn as they might overwrite the border
}
}
- if( bNativeOK )
+ if (bNativeOK)
return;
- if ( nDrawFlags & BORDERWINDOW_DRAW_FRAME )
+ if (nDrawFlags & BORDERWINDOW_DRAW_FRAME)
{
sal_uInt16 nStyle = 0;
// move border outside if border was converted or if the border window is a frame window,
- if ( mpBorderWindow->mbSmallOutBorder )
+ if (mpBorderWindow->mbSmallOutBorder)
nStyle |= FRAME_DRAW_DOUBLEOUT;
- else if ( nBorderStyle & WindowBorderStyle::NWF )
+ else if (nBorderStyle & WindowBorderStyle::NWF)
nStyle |= FRAME_DRAW_NWF;
else
nStyle |= FRAME_DRAW_DOUBLEIN;
- if ( nBorderStyle & WindowBorderStyle::MONO )
+ if (nBorderStyle & WindowBorderStyle::MONO)
nStyle |= FRAME_DRAW_MONO;
- if ( nBorderStyle & WindowBorderStyle::MENU )
+ if (nBorderStyle & WindowBorderStyle::MENU)
nStyle |= FRAME_DRAW_MENU;
// tell DrawFrame that we're drawing a window border of a frame window to avoid round corners
- if( pWin && pWin == pWin->ImplGetFrameWindow() )
+ if (pWin && pWin == pWin->ImplGetFrameWindow())
nStyle |= FRAME_DRAW_WINDOWBORDER;
- DecorationView aDecoView( mpOutDev );
- Point aTmpPoint;
- Rectangle aInRect( aTmpPoint, Size( mnWidth, mnHeight ) );
- aDecoView.DrawFrame( aInRect, nStyle );
+ DecorationView aDecoView(mpOutDev);
+ Point aTmpPoint;
+ Rectangle aInRect(aTmpPoint, Size(mnWidth, mnHeight));
+ aDecoView.DrawFrame(aInRect, nStyle);
}
}
@@ -1555,196 +1557,196 @@ long ImplStdBorderWindowView::CalcTitleWidth() const
void ImplStdBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice* pOutDev, const Point* pOffset )
{
- ImplBorderFrameData* pData = &maFrameData;
- OutputDevice* pDev = pOutDev ? pOutDev : pData->mpOutDev.get();
- ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
- Point aTmpPoint = pOffset ? Point(*pOffset) : Point();
- Rectangle aInRect( aTmpPoint, Size( pData->mnWidth, pData->mnHeight ) );
- const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings();
- DecorationView aDecoView( pDev );
- Color aFaceColor( rStyleSettings.GetFaceColor() );
- Color aFrameColor( aFaceColor );
+ ImplBorderFrameData* pData = &maFrameData;
+ OutputDevice* pDev = pOutDev ? pOutDev : pData->mpOutDev.get();
+ ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
+ Point aTmpPoint = pOffset ? Point(*pOffset) : Point();
+ Rectangle aInRect( aTmpPoint, Size( pData->mnWidth, pData->mnHeight ) );
+ const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings();
+ DecorationView aDecoView(pDev);
+ Color aFaceColor(rStyleSettings.GetFaceColor());
+ Color aFrameColor(aFaceColor);
- aFrameColor.DecreaseContrast( (sal_uInt8) (0.50 * 255));
+ aFrameColor.DecreaseContrast(sal_uInt8(0.5 * 255));
// Draw Frame
- if ( nDrawFlags & BORDERWINDOW_DRAW_FRAME )
+ if (nDrawFlags & BORDERWINDOW_DRAW_FRAME)
{
- vcl::Region oldClipRgn( pDev->GetClipRegion( ) );
+ vcl::Region oldClipRgn(pDev->GetClipRegion());
// for popups, don't draw part of the frame
- if ( pData->mnTitleType == BORDERWINDOW_TITLE_POPUP )
+ if (pData->mnTitleType == BORDERWINDOW_TITLE_POPUP)
{
- FloatingWindow *pWin = dynamic_cast< FloatingWindow* >( pData->mpBorderWindow->GetWindow( WINDOW_CLIENT ) );
- if ( pWin )
+ FloatingWindow* pWin = dynamic_cast<FloatingWindow*>(pData->mpBorderWindow->GetWindow(WINDOW_CLIENT));
+ if (pWin)
{
- vcl::Region aClipRgn( aInRect );
- Rectangle aItemClipRect( pWin->ImplGetItemEdgeClipRect() );
- if( !aItemClipRect.IsEmpty() )
+ vcl::Region aClipRgn(aInRect);
+ Rectangle aItemClipRect(pWin->ImplGetItemEdgeClipRect());
+ if (!aItemClipRect.IsEmpty())
{
- aItemClipRect.SetPos( pData->mpBorderWindow->AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
- aClipRgn.Exclude( aItemClipRect );
- pDev->SetClipRegion( aClipRgn );
+ aItemClipRect.SetPos(pData->mpBorderWindow->AbsoluteScreenToOutputPixel(aItemClipRect.TopLeft()));
+ aClipRgn.Exclude(aItemClipRect);
+ pDev->SetClipRegion(aClipRgn);
}
}
}
// single line frame
- pDev->SetLineColor( aFrameColor );
+ pDev->SetLineColor(aFrameColor);
pDev->SetFillColor();
- pDev->DrawRect( aInRect );
+ pDev->DrawRect(aInRect);
++aInRect.Left();
--aInRect.Right();
++aInRect.Top();
--aInRect.Bottom();
// restore
- if ( pData->mnTitleType == BORDERWINDOW_TITLE_POPUP )
- pDev->SetClipRegion( oldClipRgn );
+ if (pData->mnTitleType == BORDERWINDOW_TITLE_POPUP)
+ pDev->SetClipRegion(oldClipRgn);
}
else
- aInRect = aDecoView.DrawFrame( aInRect, FRAME_DRAW_DOUBLEOUT | FRAME_DRAW_NODRAW);
+ aInRect = aDecoView.DrawFrame(aInRect, FRAME_DRAW_DOUBLEOUT | FRAME_DRAW_NODRAW);
// Draw Border
pDev->SetLineColor();
long nBorderSize = pData->mnBorderSize;
- if ( (nDrawFlags & BORDERWINDOW_DRAW_BORDER) && nBorderSize )
+ if ((nDrawFlags & BORDERWINDOW_DRAW_BORDER) && nBorderSize)
{
- pDev->SetFillColor( rStyleSettings.GetFaceColor() );
- pDev->DrawRect( Rectangle( Point( aInRect.Left(), aInRect.Top() ),
- Size( aInRect.GetWidth(), nBorderSize ) ) );
- pDev->DrawRect( Rectangle( Point( aInRect.Left(), aInRect.Top()+nBorderSize ),
- Size( nBorderSize, aInRect.GetHeight()-nBorderSize ) ) );
- pDev->DrawRect( Rectangle( Point( aInRect.Left(), aInRect.Bottom()-nBorderSize+1 ),
- Size( aInRect.GetWidth(), nBorderSize ) ) );
- pDev->DrawRect( Rectangle( Point( aInRect.Right()-nBorderSize+1, aInRect.Top()+nBorderSize ),
- Size( nBorderSize, aInRect.GetHeight()-nBorderSize ) ) );
+ pDev->SetFillColor(rStyleSettings.GetFaceColor());
+ pDev->DrawRect(Rectangle(Point(aInRect.Left(), aInRect.Top()),
+ Size(aInRect.GetWidth(), nBorderSize)));
+ pDev->DrawRect(Rectangle(Point(aInRect.Left(), aInRect.Top() + nBorderSize),
+ Size(nBorderSize, aInRect.GetHeight() - nBorderSize)));
+ pDev->DrawRect(Rectangle(Point(aInRect.Left(), aInRect.Bottom() - nBorderSize + 1),
+ Size(aInRect.GetWidth(), nBorderSize)));
+ pDev->DrawRect(Rectangle(Point(aInRect.Right()-nBorderSize + 1, aInRect.Top() + nBorderSize),
+ Size(nBorderSize, aInRect.GetHeight() - nBorderSize)));
}
// Draw Title
- if ( (nDrawFlags & BORDERWINDOW_DRAW_TITLE) && !pData->maTitleRect.IsEmpty() )
+ if ((nDrawFlags & BORDERWINDOW_DRAW_TITLE) && !pData->maTitleRect.IsEmpty())
{
aInRect = pData->maTitleRect;
// use no gradient anymore, just a static titlecolor
- if ( pData->mnTitleType != BORDERWINDOW_TITLE_POPUP )
- pDev->SetFillColor( aFrameColor );
+ if (pData->mnTitleType != BORDERWINDOW_TITLE_POPUP)
+ pDev->SetFillColor(aFrameColor);
else
- pDev->SetFillColor( aFaceColor );
+ pDev->SetFillColor(aFaceColor);
- pDev->SetTextColor( rStyleSettings.GetButtonTextColor() );
- Rectangle aTitleRect( pData->maTitleRect );
- if( pOffset )
- aTitleRect.Move( pOffset->X(), pOffset->Y() );
- pDev->DrawRect( aTitleRect );
+ pDev->SetTextColor(rStyleSettings.GetButtonTextColor());
+ Rectangle aTitleRect(pData->maTitleRect);
+ if(pOffset)
+ aTitleRect.Move(pOffset->X(), pOffset->Y());
+ pDev->DrawRect(aTitleRect);
- if ( pData->mnTitleType != BORDERWINDOW_TITLE_TEAROFF )
+ if (pData->mnTitleType != BORDERWINDOW_TITLE_TEAROFF)
{
aInRect.Left() += 2;
aInRect.Right() -= 2;
- if ( !pData->maPinRect.IsEmpty() )
- aInRect.Left() = pData->maPinRect.Right()+2;
-
- if ( !pData->maHelpRect.IsEmpty() )
- aInRect.Right() = pData->maHelpRect.Left()-2;
- else if ( !pData->maRollRect.IsEmpty() )
- aInRect.Right() = pData->maRollRect.Left()-2;
- else if ( !pData->maHideRect.IsEmpty() )
- aInRect.Right() = pData->maHideRect.Left()-2;
- else if ( !pData->maDockRect.IsEmpty() )
- aInRect.Right() = pData->maDockRect.Left()-2;
- else if ( !pData->maMenuRect.IsEmpty() )
- aInRect.Right() = pData->maMenuRect.Left()-2;
- else if ( !pData->maCloseRect.IsEmpty() )
- aInRect.Right() = pData->maCloseRect.Left()-2;
-
- if ( pOffset )
- aInRect.Move( pOffset->X(), pOffset->Y() );
+ if (!pData->maPinRect.IsEmpty())
+ aInRect.Left() = pData->maPinRect.Right() + 2;
+
+ if (!pData->maHelpRect.IsEmpty())
+ aInRect.Right() = pData->maHelpRect.Left() - 2;
+ else if (!pData->maRollRect.IsEmpty())
+ aInRect.Right() = pData->maRollRect.Left() - 2;
+ else if (!pData->maHideRect.IsEmpty())
+ aInRect.Right() = pData->maHideRect.Left() - 2;
+ else if (!pData->maDockRect.IsEmpty())
+ aInRect.Right() = pData->maDockRect.Left() - 2;
+ else if (!pData->maMenuRect.IsEmpty())
+ aInRect.Right() = pData->maMenuRect.Left() - 2;
+ else if (!pData->maCloseRect.IsEmpty())
+ aInRect.Right() = pData->maCloseRect.Left() - 2;
+
+ if (pOffset)
+ aInRect.Move(pOffset->X(), pOffset->Y());
sal_uInt16 nTextStyle = TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_ENDELLIPSIS | TEXT_DRAW_CLIP;
// must show tooltip ?
TextRectInfo aInfo;
- pDev->GetTextRect( aInRect, pBorderWindow->GetText(), nTextStyle, &aInfo );
+ pDev->GetTextRect(aInRect, pBorderWindow->GetText(), nTextStyle, &aInfo);
pData->mbTitleClipped = aInfo.IsEllipses();
- pDev->DrawText( aInRect, pBorderWindow->GetText(), nTextStyle );
+ pDev->DrawText(aInRect, pBorderWindow->GetText(), nTextStyle);
}
}
- if ( ((nDrawFlags & BORDERWINDOW_DRAW_CLOSE) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
- !pData->maCloseRect.IsEmpty() )
+ if (((nDrawFlags & BORDERWINDOW_DRAW_CLOSE) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE))
+ && !pData->maCloseRect.IsEmpty())
{
- Rectangle aSymbolRect( pData->maCloseRect );
- if ( pOffset )
- aSymbolRect.Move( pOffset->X(), pOffset->Y() );
- ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SymbolType::CLOSE, pData->mnCloseState );
+ Rectangle aSymbolRect(pData->maCloseRect);
+ if (pOffset)
+ aSymbolRect.Move(pOffset->X(), pOffset->Y());
+ ImplDrawBrdWinSymbolButton(pDev, aSymbolRect, SymbolType::CLOSE, pData->mnCloseState);
}
- if ( ((nDrawFlags & BORDERWINDOW_DRAW_DOCK) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
- !pData->maDockRect.IsEmpty() )
+ if (((nDrawFlags & BORDERWINDOW_DRAW_DOCK) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE))
+ && !pData->maDockRect.IsEmpty())
{
- Rectangle aSymbolRect( pData->maDockRect );
- if ( pOffset )
- aSymbolRect.Move( pOffset->X(), pOffset->Y() );
- ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SymbolType::DOCK, pData->mnDockState );
+ Rectangle aSymbolRect(pData->maDockRect);
+ if (pOffset)
+ aSymbolRect.Move(pOffset->X(), pOffset->Y());
+ ImplDrawBrdWinSymbolButton(pDev, aSymbolRect, SymbolType::DOCK, pData->mnDockState);
}
- if ( ((nDrawFlags & BORDERWINDOW_DRAW_MENU) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
- !pData->maMenuRect.IsEmpty() )
+ if (((nDrawFlags & BORDERWINDOW_DRAW_MENU) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE))
+ && !pData->maMenuRect.IsEmpty())
{
- Rectangle aSymbolRect( pData->maMenuRect );
- if ( pOffset )
- aSymbolRect.Move( pOffset->X(), pOffset->Y() );
- ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SymbolType::MENU, pData->mnMenuState );
+ Rectangle aSymbolRect(pData->maMenuRect);
+ if (pOffset)
+ aSymbolRect.Move(pOffset->X(), pOffset->Y());
+ ImplDrawBrdWinSymbolButton(pDev, aSymbolRect, SymbolType::MENU, pData->mnMenuState);
}
- if ( ((nDrawFlags & BORDERWINDOW_DRAW_HIDE) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
- !pData->maHideRect.IsEmpty() )
+ if (((nDrawFlags & BORDERWINDOW_DRAW_HIDE) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE))
+ && !pData->maHideRect.IsEmpty())
{
- Rectangle aSymbolRect( pData->maHideRect );
- if ( pOffset )
- aSymbolRect.Move( pOffset->X(), pOffset->Y() );
- ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SymbolType::HIDE, pData->mnHideState );
+ Rectangle aSymbolRect(pData->maHideRect);
+ if (pOffset)
+ aSymbolRect.Move(pOffset->X(), pOffset->Y());
+ ImplDrawBrdWinSymbolButton(pDev, aSymbolRect, SymbolType::HIDE, pData->mnHideState);
}
- if ( ((nDrawFlags & BORDERWINDOW_DRAW_ROLL) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
- !pData->maRollRect.IsEmpty() )
+ if (((nDrawFlags & BORDERWINDOW_DRAW_ROLL) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE))
+ && !pData->maRollRect.IsEmpty())
{
SymbolType eType;
- if ( pBorderWindow->mbRollUp )
+ if (pBorderWindow->mbRollUp)
eType = SymbolType::ROLLDOWN;
else
eType = SymbolType::ROLLUP;
- Rectangle aSymbolRect( pData->maRollRect );
- if ( pOffset )
- aSymbolRect.Move( pOffset->X(), pOffset->Y() );
- ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, eType, pData->mnRollState );
+ Rectangle aSymbolRect(pData->maRollRect);
+ if (pOffset)
+ aSymbolRect.Move(pOffset->X(), pOffset->Y());
+ ImplDrawBrdWinSymbolButton(pDev, aSymbolRect, eType, pData->mnRollState);
}
- if ( ((nDrawFlags & BORDERWINDOW_DRAW_HELP) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
- !pData->maHelpRect.IsEmpty() )
+ if (((nDrawFlags & BORDERWINDOW_DRAW_HELP) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE))
+ && !pData->maHelpRect.IsEmpty())
{
- Rectangle aSymbolRect( pData->maHelpRect );
- if ( pOffset )
- aSymbolRect.Move( pOffset->X(), pOffset->Y() );
- ImplDrawBrdWinSymbolButton( pDev, aSymbolRect, SymbolType::HELP, pData->mnHelpState );
+ Rectangle aSymbolRect(pData->maHelpRect);
+ if (pOffset)
+ aSymbolRect.Move(pOffset->X(), pOffset->Y());
+ ImplDrawBrdWinSymbolButton(pDev, aSymbolRect, SymbolType::HELP, pData->mnHelpState);
}
- if ( ((nDrawFlags & BORDERWINDOW_DRAW_PIN) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE)) &&
- !pData->maPinRect.IsEmpty() )
+ if (((nDrawFlags & BORDERWINDOW_DRAW_PIN) || (nDrawFlags & BORDERWINDOW_DRAW_TITLE))
+ && !pData->maPinRect.IsEmpty())
{
Image aImage;
- ImplGetPinImage( pData->mnPinState, pBorderWindow->mbPinned, aImage );
+ ImplGetPinImage(pData->mnPinState, pBorderWindow->mbPinned, aImage);
Size aImageSize = aImage.GetSizePixel();
long nRectHeight = pData->maPinRect.GetHeight();
- Point aPos( pData->maPinRect.TopLeft() );
- if ( pOffset )
- aPos.Move( pOffset->X(), pOffset->Y() );
- if ( nRectHeight < aImageSize.Height() )
+ Point aPos(pData->maPinRect.TopLeft());
+ if (pOffset)
+ aPos.Move(pOffset->X(), pOffset->Y());
+ if (nRectHeight < aImageSize.Height())
{
- pDev->DrawImage( aPos, Size( aImageSize.Width(), nRectHeight ), aImage );
+ pDev->DrawImage(aPos, Size( aImageSize.Width(), nRectHeight ), aImage);
}
else
{
- aPos.Y() += (nRectHeight-aImageSize.Height())/2;
- pDev->DrawImage( aPos, aImage );
+ aPos.Y() += (nRectHeight-aImageSize.Height()) / 2;
+ pDev->DrawImage(aPos, aImage);
}
}
}
@@ -1877,14 +1879,14 @@ void ImplBorderWindow::Tracking( const TrackingEvent& rTEvt )
mpBorderView->Tracking( rTEvt );
}
-void ImplBorderWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void ImplBorderWindow::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
{
- mpBorderView->DrawWindow( BORDERWINDOW_DRAW_ALL );
+ mpBorderView->DrawWindow(BORDERWINDOW_DRAW_ALL, &rRenderContext);
}
void ImplBorderWindow::Draw( const Rectangle&, OutputDevice* pOutDev, const Point& rPos )
{
- mpBorderView->DrawWindow( BORDERWINDOW_DRAW_ALL, pOutDev, &rPos );
+ mpBorderView->DrawWindow(BORDERWINDOW_DRAW_ALL, pOutDev, &rPos);
}
void ImplBorderWindow::Activate()
commit 976e6b764638f9a44ab692024bd49b39b7efbc0d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu May 7 15:18:41 2015 +0900
refactor PopupFloatWin to use RenderContext
Change-Id: Ib3f74c89c9a930deb0c153bf456f9c84095e237e
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 89be3db..0480b30 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -483,7 +483,7 @@ public:
virtual void dispose() SAL_OVERRIDE;
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() 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 MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
@@ -494,8 +494,8 @@ public:
Rectangle GetDragRect() const;
Point GetToolboxPosition() const;
Point GetTearOffPosition() const;
- void DrawGrip();
- void DrawBorder();
+ void DrawGrip(vcl::RenderContext& rRenderContext);
+ void DrawBorder(vcl::RenderContext& rRenderContext);
bool hasGrip() const { return mbHasGrip; }
};
@@ -596,9 +596,9 @@ Point ImplPopupFloatWin::GetTearOffPosition() const
return aPt;
}
-void ImplPopupFloatWin::DrawBorder()
+void ImplPopupFloatWin::DrawBorder(vcl::RenderContext& rRenderContext)
{
- SetFillColor();
+ rRenderContext.SetFillColor();
Point aPt;
Rectangle aRect( aPt, GetOutputSizePixel() );
@@ -610,113 +610,114 @@ void ImplPopupFloatWin::DrawBorder()
aItemClipRect.SetPos( AbsoluteScreenToOutputPixel( aItemClipRect.TopLeft() ) );
// draw the excluded border part with the background color of a toolbox
- SetClipRegion( vcl::Region( aItemClipRect ) );
- SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
- DrawRect( aRect );
+ rRenderContext.SetClipRegion( vcl::Region( aItemClipRect ) );
+ rRenderContext.SetLineColor( GetSettings().GetStyleSettings().GetFaceColor() );
+ rRenderContext.DrawRect( aRect );
aClipRgn.Exclude( aItemClipRect );
SetClipRegion( aClipRgn );
}
- SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
- DrawRect( aRect );
- SetClipRegion( oldClipRgn );
+ rRenderContext.SetLineColor( rRenderContext.GetSettings().GetStyleSettings().GetShadowColor() );
+ rRenderContext.DrawRect( aRect );
+ rRenderContext.SetClipRegion( oldClipRgn );
}
-void ImplPopupFloatWin::DrawGrip()
+void ImplPopupFloatWin::DrawGrip(vcl::RenderContext& rRenderContext)
{
- bool bLinecolor = IsLineColor();
- Color aLinecolor = GetLineColor();
- bool bFillcolor = IsFillColor();
- Color aFillcolor = GetFillColor();
+ bool bLinecolor = rRenderContext.IsLineColor();
+ Color aLinecolor = rRenderContext.GetLineColor();
+ bool bFillcolor = rRenderContext.IsFillColor();
+ Color aFillcolor = rRenderContext.GetFillColor();
// draw background
- Rectangle aRect( GetDragRect() );
- aRect.Top() += POPUP_DRAGBORDER;
- aRect.Bottom() -= POPUP_DRAGBORDER;
- aRect.Left()+=3;
- aRect.Right()-=3;
+ Rectangle aRect(GetDragRect());
+ aRect.Top() += POPUP_DRAGBORDER;
+ aRect.Bottom() -= POPUP_DRAGBORDER;
+ aRect.Left() += 3;
+ aRect.Right() -= 3;
- if( mbHighlight )
+ if (mbHighlight)
{
- Erase( aRect );
- DrawSelectionBackground( aRect, 2, false, true, false );
+ rRenderContext.Erase(aRect);
+ DrawSelectionBackground(aRect, 2, false, true, false);
}
else
{
- SetFillColor( GetSettings().GetStyleSettings().GetFaceColor() );
- SetLineColor();
- DrawRect( aRect );
+ rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetFaceColor());
+ rRenderContext.SetLineColor();
+ rRenderContext.DrawRect(aRect);
}
- if( !ToolBox::AlwaysLocked() ) // no grip if toolboxes are locked
+ if (!ToolBox::AlwaysLocked()) // no grip if toolboxes are locked
{
#ifdef TEAROFF_DASHED
// draw single dashed line
- LineInfo aLineInfo( LINE_DASH );
- aLineInfo.SetDistance( 4 );
- aLineInfo.SetDashLen( 12 );
- aLineInfo.SetDashCount( 1 );
+ LineInfo aLineInfo(LINE_DASH);
+ aLineInfo.SetDistance(4);
+ aLineInfo.SetDashLen(12);
+ aLineInfo.SetDashCount(1);
- aRect.Left()+=2;
- aRect.Right()-=2;
+ aRect.Left() += 2;
+ aRect.Right()-= 2;
- aRect.Top()+=2;
+ aRect.Top() += 2;
aRect.Bottom() = aRect.Top();
- SetLineColor( GetSettings().GetStyleSettings().GetDarkShadowColor() );
- DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
+ rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetDarkShadowColor());
+ rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight(), aLineInfo);
- if( !mbHighlight )
+ if (!mbHighlight)
{
++aRect.Top();
++aRect.Bottom();
- SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
- DrawLine( aRect.TopLeft(), aRect.TopRight(), aLineInfo );
+ rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetLightColor());
+ rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight(), aLineInfo);
}
#else
// draw several grip lines
- SetFillColor( GetSettings().GetStyleSettings().GetShadowColor() );
+ rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetShadowColor());
aRect.Top()++;
aRect.Bottom() = aRect.Top();
int width = POPUP_DRAGWIDTH;
- while( width >= aRect.getWidth() )
+ while(width >= aRect.getWidth())
+ {
width -= 4;
- if( width <= 0 )
+ }
+ if (width <= 0)
width = aRect.getWidth();
//aRect.nLeft = aRect.nLeft + (aRect.getWidth() - width) / 2;
aRect.Left() = (aRect.Left() + aRect.Right() - width) / 2;
aRect.Right() = aRect.Left() + width;
- int i=0;
- while( i< POPUP_DRAGGRIP )
+ int i = 0;
+ while (i < POPUP_DRAGGRIP)
{
- DrawRect( aRect );
- aRect.Top()+=2;
- aRect.Bottom()+=2;
- i+=2;
+ rRenderContext.DrawRect(aRect);
+ aRect.Top() += 2;
+ aRect.Bottom() += 2;
+ i += 2;
}
#endif
}
- if( bLinecolor )
- SetLineColor( aLinecolor );
+ if (bLinecolor)
+ rRenderContext.SetLineColor(aLinecolor);
else
- SetLineColor();
- if( bFillcolor )
- SetFillColor( aFillcolor );
+ rRenderContext.SetLineColor();
+ if (bFillcolor)
+ rRenderContext.SetFillColor(aFillcolor);
else
- SetFillColor();
+ rRenderContext.SetFillColor();
}
-void ImplPopupFloatWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void ImplPopupFloatWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
- Point aPt;
- Rectangle aRect( aPt, GetOutputSizePixel() );
- DrawWallpaper( aRect, Wallpaper( GetSettings().GetStyleSettings().GetFaceGradientColor() ) );
- DrawBorder();
- if( hasGrip() )
- DrawGrip();
+ Rectangle aRect(Point(), rRenderContext.GetOutputSizePixel());
+ rRenderContext.DrawWallpaper(aRect, Wallpaper(rRenderContext.GetSettings().GetStyleSettings().GetFaceGradientColor()));
+ DrawBorder(rRenderContext);
+ if (hasGrip())
+ DrawGrip(rRenderContext);
}
void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
@@ -735,12 +736,12 @@ void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
if( !mbHighlight && GetDragRect().IsInside( aMousePos ) )
{
mbHighlight = true;
- DrawGrip();
+ Invalidate();
}
- if( mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) )
+ if (mbHighlight && ( rMEvt.IsLeaveWindow() || !GetDragRect().IsInside( aMousePos ) ) )
{
mbHighlight = false;
- DrawGrip();
+ Invalidate();
}
}
}
commit a563bd6a3e2768a5248abb3ad889d0ed739df1ba
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu May 7 15:12:42 2015 +0900
refactor DockingAreaWindow to use RenderContext
Change-Id: Iacd4fb271dcf006c2eb81017d364f1c2d452b915
diff --git a/vcl/source/window/dockingarea.cxx b/vcl/source/window/dockingarea.cxx
index 24fc270..786c84b 100644
--- a/vcl/source/window/dockingarea.cxx
+++ b/vcl/source/window/dockingarea.cxx
@@ -159,55 +159,54 @@ WindowAlign DockingAreaWindow::GetAlign() const
return mpImplData->meAlign;
}
-void DockingAreaWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& )
+void DockingAreaWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
- EnableNativeWidget( true ); // only required because the toolkit currently switches this flag off
- if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
+ EnableNativeWidget(true); // only required because the toolkit currently switches this flag off
+ if (rRenderContext.IsNativeControlSupported(CTRL_TOOLBAR, PART_ENTIRE_CONTROL))
{
- ToolbarValue aControlValue;
- const StyleSettings rSetting = Application::GetSettings().GetStyleSettings();
+ ToolbarValue aControlValue;
+ const StyleSettings rSetting = rRenderContext.GetSettings().GetStyleSettings();
- if( GetAlign() == WINDOWALIGN_TOP && ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG )
+ if (GetAlign() == WINDOWALIGN_TOP && ImplGetSVData()->maNWFData.mbMenuBarDockingAreaCommonBG)
{
// give NWF a hint that this dockingarea is adjacent to the menubar
// useful for special gradient effects that should cover both windows
aControlValue.mbIsTopDockingArea = true;
}
- ControlState nState = ControlState::ENABLED;
+ ControlState nState = ControlState::ENABLED;
const bool isFooter = GetAlign() == WINDOWALIGN_BOTTOM && !rSetting.GetPersonaFooter().IsEmpty();
- if (( GetAlign() == WINDOWALIGN_TOP && !rSetting.GetPersonaHeader().IsEmpty() ) || isFooter )
- Erase();
- else if ( !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB )
+ if ((GetAlign() == WINDOWALIGN_TOP && !rSetting.GetPersonaHeader().IsEmpty() ) || isFooter)
+ rRenderContext.Erase();
+ else if (!ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB)
{
// draw a single toolbar background covering the whole docking area
- Point tmp;
- Rectangle aCtrlRegion( tmp, GetOutputSizePixel() );
+ Rectangle aCtrlRegion(Point(), GetOutputSizePixel());
- DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
- aCtrlRegion, nState, aControlValue, OUString() );
+ rRenderContext.DrawNativeControl(CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
+ aCtrlRegion, nState, aControlValue, OUString() );
- if( !ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames )
+ if (!ImplGetSVData()->maNWFData.mbDockingAreaAvoidTBFrames)
{
// each toolbar gets a thin border to better recognize its borders on the homogeneous docking area
sal_uInt16 nChildren = GetChildCount();
- for( sal_uInt16 n = 0; n < nChildren; n++ )
+ for (sal_uInt16 n = 0; n < nChildren; n++)
{
- vcl::Window* pChild = GetChild( n );
- if ( pChild->IsVisible() )
+ vcl::Window* pChild = GetChild(n);
+ if (pChild->IsVisible())
{
Point aPos = pChild->GetPosPixel();
Size aSize = pChild->GetSizePixel();
- Rectangle aRect( aPos, aSize );
+ Rectangle aRect(aPos, aSize);
- SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
- DrawLine( aRect.TopLeft(), aRect.TopRight() );
- DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
+ rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetLightColor());
+ rRenderContext.DrawLine(aRect.TopLeft(), aRect.TopRight());
+ rRenderContext.DrawLine(aRect.TopLeft(), aRect.BottomLeft());
- SetLineColor( GetSettings().GetStyleSettings().GetSeparatorColor() );
- DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
- DrawLine( aRect.TopRight(), aRect.BottomRight() );
+ rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetSeparatorColor());
+ rRenderContext.DrawLine(aRect.BottomLeft(), aRect.BottomRight());
+ rRenderContext.DrawLine(aRect.TopRight(), aRect.BottomRight());
}
}
}
@@ -215,40 +214,41 @@ void DockingAreaWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rec
else
{
// create map to find toolbar lines
- Size aOutSz = GetOutputSizePixel();
- std::map< int, int > ranges;
+ Size aOutSz = rRenderContext.GetOutputSizePixel();
+ std::map<int, int> ranges;
sal_uInt16 nChildren = GetChildCount();
- for( sal_uInt16 n = 0; n < nChildren; n++ )
+ for (sal_uInt16 n = 0; n < nChildren; n++)
{
- vcl::Window* pChild = GetChild( n );
+ vcl::Window* pChild = GetChild(n);
Point aPos = pChild->GetPosPixel();
Size aSize = pChild->GetSizePixel();
- if( IsHorizontal() )
- ranges[ aPos.Y() ] = aSize.Height();
+ if (IsHorizontal())
+ ranges[aPos.Y()] = aSize.Height();
else
- ranges[ aPos.X() ] = aSize.Width();
+ ranges[aPos.X()] = aSize.Width();
}
// draw multiple toolbar backgrounds, i.e., one for each toolbar line
- for( std::map<int,int>::const_iterator it = ranges.begin(); it != ranges.end(); ++it )
+ std::map<int, int>::const_iterator it;
+ for (it = ranges.begin(); it != ranges.end(); ++it)
{
Rectangle aTBRect;
- if( IsHorizontal() )
+ if (IsHorizontal())
{
- aTBRect.Left() = 0;
- aTBRect.Right() = aOutSz.Width() - 1;
- aTBRect.Top() = it->first;
- aTBRect.Bottom() = it->first + it->second - 1;
+ aTBRect.Left() = 0;
+ aTBRect.Right() = aOutSz.Width() - 1;
+ aTBRect.Top() = it->first;
+ aTBRect.Bottom() = it->first + it->second - 1;
}
else
{
- aTBRect.Left() = it->first;
- aTBRect.Right() = it->first + it->second - 1;
- aTBRect.Top() = 0;
- aTBRect.Bottom() = aOutSz.Height() - 1;
+ aTBRect.Left() = it->first;
+ aTBRect.Right() = it->first + it->second - 1;
+ aTBRect.Top() = 0;
+ aTBRect.Bottom() = aOutSz.Height() - 1;
}
- DrawNativeControl( CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
- aTBRect, nState, aControlValue, OUString() );
+ rRenderContext.DrawNativeControl(CTRL_TOOLBAR, IsHorizontal() ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT,
+ aTBRect, nState, aControlValue, OUString());
}
}
}
@@ -258,7 +258,7 @@ void DockingAreaWindow::Resize()
{
ImplInitBackground( this );
ImplInvalidateMenubar( this );
- if( IsNativeControlSupported( CTRL_TOOLBAR, PART_ENTIRE_CONTROL ) )
+ if (IsNativeControlSupported(CTRL_TOOLBAR, PART_ENTIRE_CONTROL))
Invalidate();
}
commit dca01def7885ad69cf66edd75cf8207a5adb64f9
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu May 7 14:18:37 2015 +0900
refactor ListBox/ComboBox to use RenderContext
Change-Id: I367d6e4f54375bd61e46f0c1437444306b127c68
diff --git a/vcl/inc/ilstbox.hxx b/vcl/inc/ilstbox.hxx
index 71d86f2..180b9f1 100644
--- a/vcl/inc/ilstbox.hxx
+++ b/vcl/inc/ilstbox.hxx
@@ -250,7 +250,7 @@ protected:
virtual void LoseFocus() SAL_OVERRIDE;
bool SelectEntries( sal_Int32 nSelect, LB_EVENT_TYPE eLET, bool bShift = false, bool bCtrl = false, bool bSelectPosChange = false );
- void ImplPaint(sal_Int32 nPos, bool bErase = false, bool bLayout = false);
+ void ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 nPos, bool bErase = false, bool bLayout = false);
void ImplDoPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bLayout = false);
void ImplCalcMetrics();
void ImplUpdateEntryMetrics( ImplEntryType& rEntry );
@@ -279,7 +279,7 @@ public:
sal_uInt16 GetDisplayLineCount() const;
void SetEntryFlags( sal_Int32 nPos, long nFlags );
- void DrawEntry( sal_Int32 nPos, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false, bool bLayout = false );
+ void DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32 nPos, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos = false, bool bLayout = false);
void SelectEntry( sal_Int32 nPos, bool bSelect );
void DeselectAll();
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 05b1e7d..7c12bbc 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -1249,10 +1249,10 @@ void ComboBox::EnableUserDraw( bool bUserDraw )
mpImplLB->GetMainWindow()->EnableUserDraw( bUserDraw );
}
-void ComboBox::DrawEntry( const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos )
+void ComboBox::DrawEntry(const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos)
{
- DBG_ASSERT( rEvt.GetDevice() == mpImplLB->GetMainWindow(), "DrawEntry?!" );
- mpImplLB->GetMainWindow()->DrawEntry( rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
+ DBG_ASSERT(rEvt.GetDevice() == mpImplLB->GetMainWindow(), "DrawEntry?!");
+ mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetDevice(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos);
}
void ComboBox::SetSeparatorPos( sal_Int32 n )
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index 4c93414..ca1027a 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -989,15 +989,15 @@ void ImplListBoxWindow::SelectEntry( sal_Int32 nPos, bool bSelect )
{
//SelectEntryPos( nDeselect, false );
GetEntryList()->SelectEntry( nDeselect, false );
- if ( IsUpdateMode() && IsReallyVisible() )
- ImplPaint( nDeselect, true );
+ if (IsUpdateMode() && IsReallyVisible())
+ Invalidate();
}
}
mpEntryList->SelectEntry( nPos, true );
mnCurrentPos = nPos;
if ( ( nPos != LISTBOX_ENTRY_NOTFOUND ) && IsUpdateMode() )
{
- ImplPaint( nPos );
+ Invalidate();
if ( !IsVisible( nPos ) )
{
ImplClearLayoutData();
@@ -1017,7 +1017,7 @@ void ImplListBoxWindow::SelectEntry( sal_Int32 nPos, bool bSelect )
else
{
mpEntryList->SelectEntry( nPos, false );
- ImplPaint( nPos, true );
+ Invalidate();
}
mbSelectionChanged = true;
}
@@ -1148,7 +1148,7 @@ bool ImplListBoxWindow::SelectEntries( sal_Int32 nSelect, LB_EVENT_TYPE eLET, bo
else if( eLET != LET_TRACKING )
{
ImplHideFocusRect();
- ImplPaint( nSelect, true );
+ Invalidate();
bFocusChanged = true;
}
}
@@ -1704,175 +1704,174 @@ void ImplListBoxWindow::SelectEntry( vcl::StringEntryIdentifier _entry )
}
}
-void ImplListBoxWindow::ImplPaint( sal_Int32 nPos, bool bErase, bool bLayout )
+void ImplListBoxWindow::ImplPaint(vcl::RenderContext& rRenderContext, sal_Int32 nPos, bool bErase, bool bLayout)
{
- const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nPos );
- if( ! pEntry )
+ if (!pEntry)
return;
- long nWidth = GetOutputSizePixel().Width();
- long nY = mpEntryList->GetAddedHeight( nPos, mnTop );
- Rectangle aRect( Point( 0, nY ), Size( nWidth, pEntry->mnHeight ) );
+ long nWidth = rRenderContext.GetOutputSizePixel().Width();
+ long nY = mpEntryList->GetAddedHeight(nPos, mnTop);
+ Rectangle aRect(Point(0, nY), Size(nWidth, pEntry->mnHeight));
- if( ! bLayout )
+ if (!bLayout)
{
- if( mpEntryList->IsEntryPosSelected( nPos ) )
+ if (mpEntryList->IsEntryPosSelected(nPos))
{
- SetTextColor( !IsEnabled() ? rStyleSettings.GetDisableColor() : rStyleSettings.GetHighlightTextColor() );
- SetFillColor( rStyleSettings.GetHighlightColor() );
- SetTextFillColor( rStyleSettings.GetHighlightColor() );
- DrawRect( aRect );
+ rRenderContext.SetTextColor(!IsEnabled() ? rStyleSettings.GetDisableColor() : rStyleSettings.GetHighlightTextColor());
+ rRenderContext.SetFillColor(rStyleSettings.GetHighlightColor());
+ rRenderContext.SetTextFillColor(rStyleSettings.GetHighlightColor());
+ rRenderContext.DrawRect(aRect);
}
else
{
- ImplInitSettings( false, true, false );
- if( !IsEnabled() )
- SetTextColor( rStyleSettings.GetDisableColor() );
- SetTextFillColor();
- if( bErase )
- Erase( aRect );
+ ImplInitSettings(false, true, false);
+ if (!IsEnabled())
+ rRenderContext.SetTextColor(rStyleSettings.GetDisableColor());
+ rRenderContext.SetTextFillColor();
+ if (bErase)
+ rRenderContext.Erase(aRect);
}
}
- if ( IsUserDrawEnabled() )
+ if (IsUserDrawEnabled())
{
mbInUserDraw = true;
mnUserDrawEntry = nPos;
aRect.Left() -= mnLeft;
- if ( nPos < GetEntryList()->GetMRUCount() )
- nPos = GetEntryList()->FindEntry( GetEntryList()->GetEntryText( nPos ) );
+ if (nPos < GetEntryList()->GetMRUCount())
+ nPos = GetEntryList()->FindEntry(GetEntryList()->GetEntryText(nPos));
nPos = nPos - GetEntryList()->GetMRUCount();
sal_Int32 nCurr = mnCurrentPos;
- if ( mnCurrentPos < GetEntryList()->GetMRUCount() )
- nCurr = GetEntryList()->FindEntry( GetEntryList()->GetEntryText( nCurr ) );
- nCurr = sal::static_int_cast<sal_Int32>( nCurr - GetEntryList()->GetMRUCount());
+ if (mnCurrentPos < GetEntryList()->GetMRUCount())
+ nCurr = GetEntryList()->FindEntry(GetEntryList()->GetEntryText(nCurr));
+ nCurr = sal::static_int_cast<sal_Int32>(nCurr - GetEntryList()->GetMRUCount());
- UserDrawEvent aUDEvt( this, aRect, nPos, nCurr );
- userDrawSignal( &aUDEvt );
+ UserDrawEvent aUDEvt(this, aRect, nPos, nCurr);
+ userDrawSignal(&aUDEvt);
mbInUserDraw = false;
}
else
{
- DrawEntry( nPos, true, true, false, bLayout );
+ DrawEntry(rRenderContext, nPos, true, true, false, bLayout);
}
}
-void ImplListBoxWindow::DrawEntry( sal_Int32 nPos, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos, bool bLayout )
+void ImplListBoxWindow::DrawEntry(vcl::RenderContext& rRenderContext, sal_Int32 nPos, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos, bool bLayout)
{
- const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( nPos );
- if( ! pEntry )
+ const ImplEntryType* pEntry = mpEntryList->GetEntryPtr(nPos);
+ if (!pEntry)
return;
// when changing this function don't forget to adjust ImplWin::DrawEntry()
- if ( mbInUserDraw )
+ if (mbInUserDraw)
nPos = mnUserDrawEntry; // real entry, not the matching entry from MRU
- long nY = mpEntryList->GetAddedHeight( nPos, mnTop );
+ long nY = mpEntryList->GetAddedHeight(nPos, mnTop);
Size aImgSz;
- if( bDrawImage && mpEntryList->HasImages() && !bLayout )
+ if (bDrawImage && mpEntryList->HasImages() && !bLayout)
{
- Image aImage = mpEntryList->GetEntryImage( nPos );
- if( !!aImage )
+ Image aImage = mpEntryList->GetEntryImage(nPos);
+ if (!!aImage)
{
aImgSz = aImage.GetSizePixel();
- Point aPtImg( mnBorder - mnLeft, nY + ( ( pEntry->mnHeight - aImgSz.Height() ) / 2 ) );
+ Point aPtImg(mnBorder - mnLeft, nY + ((pEntry->mnHeight - aImgSz.Height()) / 2));
// pb: #106948# explicit mirroring for calc
- if ( mbMirroring )
+ if (mbMirroring)
// right aligned
aPtImg.X() = mnMaxWidth + mnBorder - aImgSz.Width() - mnLeft;
- if ( !IsZoom() )
+ if (!IsZoom())
{
- DrawImage( aPtImg, aImage );
+ rRenderContext.DrawImage(aPtImg, aImage);
}
else
{
- aImgSz.Width() = CalcZoom( aImgSz.Width() );
- aImgSz.Height() = CalcZoom( aImgSz.Height() );
- DrawImage( aPtImg, aImgSz, aImage );
+ aImgSz.Width() = CalcZoom(aImgSz.Width());
+ aImgSz.Height() = CalcZoom(aImgSz.Height());
+ rRenderContext.DrawImage(aPtImg, aImgSz, aImage);
}
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
const sal_uInt16 nEdgeBlendingPercent(GetEdgeBlending() ? rStyleSettings.GetEdgeBlending() : 0);
- if(nEdgeBlendingPercent && aImgSz.Width() && aImgSz.Height())
+ if (nEdgeBlendingPercent && aImgSz.Width() && aImgSz.Height())
{
const Color& rTopLeft(rStyleSettings.GetEdgeBlendingTopLeftColor());
const Color& rBottomRight(rStyleSettings.GetEdgeBlendingBottomRightColor());
const sal_uInt8 nAlpha((nEdgeBlendingPercent * 255) / 100);
const BitmapEx aBlendFrame(createBlendFrame(aImgSz, nAlpha, rTopLeft, rBottomRight));
- if(!aBlendFrame.IsEmpty())
+ if (!aBlendFrame.IsEmpty())
{
- DrawBitmapEx(aPtImg, aBlendFrame);
+ rRenderContext.DrawBitmapEx(aPtImg, aBlendFrame);
}
}
}
}
- if( bDrawText )
+ if (bDrawText)
{
MetricVector* pVector = bLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : NULL;
OUString* pDisplayText = bLayout ? &mpControlData->mpLayoutData->m_aDisplayText : NULL;
- OUString aStr( mpEntryList->GetEntryText( nPos ) );
- if ( !aStr.isEmpty() )
+ OUString aStr(mpEntryList->GetEntryText(nPos));
+ if (!aStr.isEmpty())
{
- long nMaxWidth = std::max( static_cast< long >( mnMaxWidth ),
- GetOutputSizePixel().Width() - 2*mnBorder );
+ long nMaxWidth = std::max(static_cast< long >(mnMaxWidth), rRenderContext.GetOutputSizePixel().Width() - 2 * mnBorder);
// a multiline entry should only be as wide a the window
- if( (pEntry->mnFlags & LISTBOX_ENTRY_FLAG_MULTILINE) )
- nMaxWidth = GetOutputSizePixel().Width() - 2*mnBorder;
+ if ((pEntry->mnFlags & LISTBOX_ENTRY_FLAG_MULTILINE))
+ nMaxWidth = rRenderContext.GetOutputSizePixel().Width() - 2 * mnBorder;
- Rectangle aTextRect( Point( mnBorder - mnLeft, nY ),
- Size( nMaxWidth, pEntry->mnHeight ) );
+ Rectangle aTextRect(Point(mnBorder - mnLeft, nY),
+ Size(nMaxWidth, pEntry->mnHeight));
- if( !bDrawTextAtImagePos && ( mpEntryList->HasEntryImage(nPos) || IsUserDrawEnabled() ) )
+ if (!bDrawTextAtImagePos && (mpEntryList->HasEntryImage(nPos) || IsUserDrawEnabled()))
{
- long nImageWidth = std::max( mnMaxImgWidth, maUserItemSize.Width() );
+ long nImageWidth = std::max(mnMaxImgWidth, maUserItemSize.Width());
aTextRect.Left() += nImageWidth + IMG_TXT_DISTANCE;
}
- if( bLayout )
- mpControlData->mpLayoutData->m_aLineIndices.push_back( mpControlData->mpLayoutData->m_aDisplayText.getLength() );
+ if (bLayout)
+ mpControlData->mpLayoutData->m_aLineIndices.push_back(mpControlData->mpLayoutData->m_aDisplayText.getLength());
// pb: #106948# explicit mirroring for calc
- if ( mbMirroring )
+ if (mbMirroring)
{
// right aligned
- aTextRect.Left() = nMaxWidth + mnBorder - GetTextWidth( aStr ) - mnLeft;
- if ( aImgSz.Width() > 0 )
- aTextRect.Left() -= ( aImgSz.Width() + IMG_TXT_DISTANCE );
+ aTextRect.Left() = nMaxWidth + mnBorder - rRenderContext.GetTextWidth(aStr) - mnLeft;
+ if (aImgSz.Width() > 0)
+ aTextRect.Left() -= (aImgSz.Width() + IMG_TXT_DISTANCE);
}
sal_uInt16 nDrawStyle = ImplGetTextStyle();
- if( (pEntry->mnFlags & LISTBOX_ENTRY_FLAG_MULTILINE) )
+ if ((pEntry->mnFlags & LISTBOX_ENTRY_FLAG_MULTILINE))
nDrawStyle |= MULTILINE_ENTRY_DRAW_FLAGS;
- if( (pEntry->mnFlags & LISTBOX_ENTRY_FLAG_DRAW_DISABLED) )
+ if ((pEntry->mnFlags & LISTBOX_ENTRY_FLAG_DRAW_DISABLED))
nDrawStyle |= TEXT_DRAW_DISABLE;
- DrawText( aTextRect, aStr, nDrawStyle, pVector, pDisplayText );
+ rRenderContext.DrawText(aTextRect, aStr, nDrawStyle, pVector, pDisplayText);
}
}
- if( !bLayout )
+ if (!bLayout)
{
- if ( ( mnSeparatorPos != LISTBOX_ENTRY_NOTFOUND ) &&
- ( ( nPos == mnSeparatorPos ) || ( nPos == mnSeparatorPos+1 ) ) )
+ if ((mnSeparatorPos != LISTBOX_ENTRY_NOTFOUND) &&
+ ((nPos == mnSeparatorPos) || (nPos == mnSeparatorPos + 1)))
{
- Color aOldLineColor( GetLineColor() );
- SetLineColor( ( GetBackground().GetColor() != COL_LIGHTGRAY ) ? COL_LIGHTGRAY : COL_GRAY );
- Point aStartPos( 0, nY );
- if ( nPos == mnSeparatorPos )
- aStartPos.Y() += pEntry->mnHeight-1;
- Point aEndPos( aStartPos );
+ Color aOldLineColor(rRenderContext.GetLineColor());
+ rRenderContext.SetLineColor((GetBackground().GetColor() != COL_LIGHTGRAY) ? COL_LIGHTGRAY : COL_GRAY);
+ Point aStartPos(0, nY);
+ if (nPos == mnSeparatorPos)
+ aStartPos.Y() += pEntry->mnHeight - 1;
+ Point aEndPos(aStartPos);
aEndPos.X() = GetOutputSizePixel().Width();
- DrawLine( aStartPos, aEndPos );
- SetLineColor( aOldLineColor );
+ rRenderContext.DrawLine(aStartPos, aEndPos);
+ rRenderContext.SetLineColor(aOldLineColor);
}
}
}
@@ -1883,33 +1882,33 @@ void ImplListBoxWindow::FillLayoutData() const
const_cast<ImplListBoxWindow*>(this)->Invalidate(Rectangle(Point(0, 0), GetOutputSize()));
}
-void ImplListBoxWindow::ImplDoPaint(vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect, bool bLayout)
+void ImplListBoxWindow::ImplDoPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bLayout)
{
sal_Int32 nCount = mpEntryList->GetEntryCount();
bool bShowFocusRect = mbHasFocusRect;
- if ( mbHasFocusRect && ! bLayout )
+ if (mbHasFocusRect && !bLayout)
ImplHideFocusRect();
long nY = 0; // + mnBorder;
long nHeight = GetOutputSizePixel().Height();// - mnMaxHeight + mnBorder;
- for( sal_Int32 i = (sal_Int32)mnTop; i < nCount && nY < nHeight + mnMaxHeight; i++ )
+ for (sal_Int32 i = (sal_Int32)mnTop; i < nCount && nY < nHeight + mnMaxHeight; i++)
{
- const ImplEntryType* pEntry = mpEntryList->GetEntryPtr( i );
- if( nY + pEntry->mnHeight >= rRect.Top() &&
- nY <= rRect.Bottom() + mnMaxHeight )
+ const ImplEntryType* pEntry = mpEntryList->GetEntryPtr(i);
+ if (nY + pEntry->mnHeight >= rRect.Top() &&
+ nY <= rRect.Bottom() + mnMaxHeight)
{
- ImplPaint( i, false, bLayout );
+ ImplPaint(rRenderContext, i, false, bLayout);
}
nY += pEntry->mnHeight;
}
- long nHeightDiff = mpEntryList->GetAddedHeight( mnCurrentPos, mnTop, 0 );
- maFocusRect.SetPos( Point( 0, nHeightDiff ) );
- Size aSz( maFocusRect.GetWidth(), mpEntryList->GetEntryHeight( mnCurrentPos ) );
- maFocusRect.SetSize( aSz );
- if( HasFocus() && bShowFocusRect && !bLayout )
+ long nHeightDiff = mpEntryList->GetAddedHeight(mnCurrentPos, mnTop, 0);
+ maFocusRect.SetPos(Point(0, nHeightDiff));
+ Size aSz(maFocusRect.GetWidth(), mpEntryList->GetEntryHeight(mnCurrentPos));
+ maFocusRect.SetSize(aSz);
+ if (HasFocus() && bShowFocusRect && !bLayout)
ImplShowFocusRect();
}
@@ -2126,11 +2125,11 @@ sal_uInt16 ImplListBoxWindow::ImplGetTextStyle() const
{
sal_uInt16 nTextStyle = TEXT_DRAW_VCENTER;
- if ( mpEntryList->HasImages() )
+ if (mpEntryList->HasImages())
nTextStyle |= TEXT_DRAW_LEFT;
- else if ( mbCenter )
+ else if (mbCenter)
nTextStyle |= TEXT_DRAW_CENTER;
- else if ( mbRight )
+ else if (mbRight)
nTextStyle |= TEXT_DRAW_RIGHT;
else
nTextStyle |= TEXT_DRAW_LEFT;
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index 9090184..156561b 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -1377,12 +1377,12 @@ void ListBox::UserDraw( const UserDrawEvent& )
{
}
-void ListBox::DrawEntry( const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos )
+void ListBox::DrawEntry(const UserDrawEvent& rEvt, bool bDrawImage, bool bDrawText, bool bDrawTextAtImagePos)
{
- if ( rEvt.GetDevice() == mpImplLB->GetMainWindow() )
- mpImplLB->GetMainWindow()->DrawEntry( rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
- else if ( rEvt.GetDevice() == mpImplWin )
- mpImplWin->DrawEntry( bDrawImage, bDrawText, bDrawTextAtImagePos );
+ if (rEvt.GetDevice() == mpImplLB->GetMainWindow())
+ mpImplLB->GetMainWindow()->DrawEntry(*rEvt.GetDevice(), rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
+ else if (rEvt.GetDevice() == mpImplWin)
+ mpImplWin->DrawEntry(bDrawImage, bDrawText, bDrawTextAtImagePos);
}
void ListBox::SetUserItemSize( const Size& rSz )
commit 7a11ec1992bf877f42edce8d1d930c5b00bd3d48
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu May 7 12:17:25 2015 +0900
refactor ImageControl to use RenderContext
Change-Id: I1290757fa5d6b61b68bf6c985b657253dca83586
diff --git a/vcl/source/control/imgctrl.cxx b/vcl/source/control/imgctrl.cxx
index baaaa20..9050a9b 100644
--- a/vcl/source/control/imgctrl.cxx
+++ b/vcl/source/control/imgctrl.cxx
@@ -23,7 +23,7 @@
#include <com/sun/star/awt/ImageScaleMode.hpp>
-namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
+namespace ImageScaleMode = css::awt::ImageScaleMode;
ImageControl::ImageControl( vcl::Window* pParent, WinBits nStyle )
:FixedImage( pParent, nStyle )
@@ -67,7 +67,7 @@ namespace
}
}
-void ImageControl::ImplDraw( OutputDevice& rDev, sal_uLong nDrawFlags, const Point& rPos, const Size& rSize ) const
+void ImageControl::ImplDraw(OutputDevice& rDev, sal_uLong nDrawFlags, const Point& rPos, const Size& rSize) const
{
sal_uInt16 nStyle = 0;
if ( !(nDrawFlags & WINDOW_DRAW_NODISABLE) )
@@ -135,25 +135,25 @@ void ImageControl::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*
{
ImplDraw(rRenderContext, 0, Point(), GetOutputSizePixel());
- if( HasFocus() )
+ if (HasFocus())
{
- vcl::Window *pWin = GetWindow( WINDOW_BORDER );
+ vcl::Window* pBorderWindow = GetWindow(WINDOW_BORDER);
bool bFlat = (GetBorderStyle() == WindowBorderStyle::MONO);
- Rectangle aRect( Point(0,0), pWin->GetOutputSizePixel() );
- Color oldLineCol = pWin->GetLineColor();
- Color oldFillCol = pWin->GetFillColor();
- pWin->SetFillColor();
- pWin->SetLineColor( bFlat ? COL_WHITE : COL_BLACK );
- pWin->DrawRect( aRect );
+ Rectangle aRect(Point(0,0), pBorderWindow->GetOutputSizePixel());
+ Color oldLineCol = pBorderWindow->GetLineColor();
+ Color oldFillCol = pBorderWindow->GetFillColor();
+ pBorderWindow->SetFillColor();
+ pBorderWindow->SetLineColor(bFlat ? COL_WHITE : COL_BLACK);
+ pBorderWindow->DrawRect(aRect);
++aRect.Left();
--aRect.Right();
++aRect.Top();
--aRect.Bottom();
- pWin->SetLineColor( bFlat ? COL_BLACK : COL_WHITE );
- pWin->DrawRect( aRect );
- pWin->SetLineColor( oldLineCol );
- pWin->SetFillColor( oldFillCol );
+ pBorderWindow->SetLineColor(bFlat ? COL_BLACK : COL_WHITE);
+ pBorderWindow->DrawRect(aRect);
+ pBorderWindow->SetLineColor(oldLineCol);
+ pBorderWindow->SetFillColor(oldFillCol);
}
}
commit 04c037d8a8f1ca954181d75ab3a7cc648a5d1d63
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu May 7 12:12:34 2015 +0900
refactor ScrollBar to use RenderContext
Change-Id: I8707fa934d729d96e019ad5d0688299bf88954c4
diff --git a/include/vcl/scrbar.hxx b/include/vcl/scrbar.hxx
index 18efc60..946bcd9 100644
--- a/include/vcl/scrbar.hxx
+++ b/include/vcl/scrbar.hxx
@@ -76,13 +76,13 @@ private:
SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
SAL_DLLPRIVATE void ImplCalc( bool bUpdate = true );
- SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags, OutputDevice* pOutDev );
+ SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags);
using Window::ImplScroll;
SAL_DLLPRIVATE long ImplScroll( long nNewPos, bool bCallEndScroll );
SAL_DLLPRIVATE long ImplDoAction( bool bCallEndScroll );
SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, bool bCallAction = true );
SAL_DLLPRIVATE void ImplInvert();
- SAL_DLLPRIVATE bool ImplDrawNative( sal_uInt16 nDrawFlags );
+ SAL_DLLPRIVATE bool ImplDrawNative(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags);
SAL_DLLPRIVATE void ImplDragThumb( const Point& rMousePos );
SAL_DLLPRIVATE Size getCurrentCalcSize() const;
DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer* );
diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx
index 65960d7..b5baa3e 100644
--- a/vcl/source/control/scrbar.cxx
+++ b/vcl/source/control/scrbar.cxx
@@ -231,7 +231,7 @@ void ScrollBar::ImplUpdateRects( bool bUpdate )
nDraw |= SCRBAR_DRAW_PAGE2;
if ( aOldThumbRect != maThumbRect )
nDraw |= SCRBAR_DRAW_THUMB;
- ImplDraw( nDraw, this );
+ Invalidate();
}
}
@@ -448,26 +448,27 @@ void ScrollBar::Draw( OutputDevice* pDev, const Point& rPos, const Size& /* rSiz
maPage1Rect+=aPos;
maPage2Rect+=aPos;
- ImplDraw( SCRBAR_DRAW_ALL, pDev );
+ ImplDraw(*pDev, SCRBAR_DRAW_ALL);
pDev->Pop();
mbCalcSize = true;
}
-bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags )
+bool ScrollBar::ImplDrawNative(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags)
{
ScrollbarValue scrValue;
- bool bNativeOK = IsNativeControlSupported(CTRL_SCROLLBAR, PART_ENTIRE_CONTROL);
- if( !bNativeOK )
+ bool bNativeOK = rRenderContext.IsNativeControlSupported(CTRL_SCROLLBAR, PART_ENTIRE_CONTROL);
+ if (!bNativeOK)
return false;
bool bHorz = (GetStyle() & WB_HORZ) != 0;
// Draw the entire background if the control supports it
- if( IsNativeControlSupported(CTRL_SCROLLBAR, bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_SCROLLBAR, bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT))
{
- ControlState nState = ( IsEnabled() ? ControlState::ENABLED : ControlState::NONE ) | ( HasFocus() ? ControlState::FOCUSED : ControlState::NONE );
+ ControlState nState = (IsEnabled() ? ControlState::ENABLED : ControlState::NONE)
+ | (HasFocus() ? ControlState::FOCUSED : ControlState::NONE);
scrValue.mnMin = mnMinRange;
scrValue.mnMax = mnMaxRange;
@@ -484,91 +485,90 @@ bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags )
scrValue.mnPage1State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE1_DOWN) ? ControlState::PRESSED : ControlState::NONE);
scrValue.mnPage2State = nState | ((mnStateFlags & SCRBAR_STATE_PAGE2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
- if( IsMouseOver() )
+ if (IsMouseOver())
{
- Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
- if( pRect )
+ Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
+ if (pRect)
{
- if( pRect == &maThumbRect )
+ if (pRect == &maThumbRect)
scrValue.mnThumbState |= ControlState::ROLLOVER;
- else if( pRect == &maBtn1Rect )
+ else if (pRect == &maBtn1Rect)
scrValue.mnButton1State |= ControlState::ROLLOVER;
- else if( pRect == &maBtn2Rect )
+ else if (pRect == &maBtn2Rect)
scrValue.mnButton2State |= ControlState::ROLLOVER;
- else if( pRect == &maPage1Rect )
+ else if (pRect == &maPage1Rect)
scrValue.mnPage1State |= ControlState::ROLLOVER;
- else if( pRect == &maPage2Rect )
+ else if (pRect == &maPage2Rect)
scrValue.mnPage2State |= ControlState::ROLLOVER;
}
}
Rectangle aCtrlRegion;
- aCtrlRegion.Union( maBtn1Rect );
- aCtrlRegion.Union( maBtn2Rect );
- aCtrlRegion.Union( maPage1Rect );
- aCtrlRegion.Union( maPage2Rect );
- aCtrlRegion.Union( maThumbRect );
+ aCtrlRegion.Union(maBtn1Rect);
+ aCtrlRegion.Union(maBtn2Rect);
+ aCtrlRegion.Union(maPage1Rect);
+ aCtrlRegion.Union(maPage2Rect);
+ aCtrlRegion.Union(maThumbRect);
- Rectangle aRequestedRegion(Point(0,0), GetOutputSizePixel());
+ Rectangle aRequestedRegion(Point(0,0), rRenderContext.GetOutputSizePixel());
// if the actual native control region is smaller then the region that
// we requested the control to draw in, then draw a background rectangle
// to avoid drawing artifacts in the uncovered region
if (aCtrlRegion.GetWidth() < aRequestedRegion.GetWidth() ||
aCtrlRegion.GetHeight() < aRequestedRegion.GetHeight())
{
- Color aFaceColor = GetSettings().GetStyleSettings().GetFaceColor();
- SetFillColor(aFaceColor);
- SetLineColor(aFaceColor);
- DrawRect(aRequestedRegion);
+ Color aFaceColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor();
+ rRenderContext.SetFillColor(aFaceColor);
+ rRenderContext.SetLineColor(aFaceColor);
+ rRenderContext.DrawRect(aRequestedRegion);
}
- bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, (bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT),
- aCtrlRegion, nState, scrValue, OUString() );
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, (bHorz ? PART_DRAW_BACKGROUND_HORZ : PART_DRAW_BACKGROUND_VERT),
+ aCtrlRegion, nState, scrValue, OUString());
}
else
{
- if ( (nDrawFlags & SCRBAR_DRAW_PAGE1) || (nDrawFlags & SCRBAR_DRAW_PAGE2) )
+ if ((nDrawFlags & SCRBAR_DRAW_PAGE1) || (nDrawFlags & SCRBAR_DRAW_PAGE2))
{
- sal_uInt32 part1 = bHorz ? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER;
- sal_uInt32 part2 = bHorz ? PART_TRACK_HORZ_RIGHT : PART_TRACK_VERT_LOWER;
- Rectangle aCtrlRegion1( maPage1Rect );
- Rectangle aCtrlRegion2( maPage2Rect );
- ControlState nState1 = (IsEnabled() ? ControlState::ENABLED : ControlState::NONE) | (HasFocus() ? ControlState::FOCUSED : ControlState::NONE);
+ sal_uInt32 part1 = bHorz ? PART_TRACK_HORZ_LEFT : PART_TRACK_VERT_UPPER;
+ sal_uInt32 part2 = bHorz ? PART_TRACK_HORZ_RIGHT : PART_TRACK_VERT_LOWER;
+ Rectangle aCtrlRegion1(maPage1Rect);
+ Rectangle aCtrlRegion2(maPage2Rect);
+ ControlState nState1 = (IsEnabled() ? ControlState::ENABLED : ControlState::NONE)
+ | (HasFocus() ? ControlState::FOCUSED : ControlState::NONE);
ControlState nState2 = nState1;
nState1 |= ((mnStateFlags & SCRBAR_STATE_PAGE1_DOWN) ? ControlState::PRESSED : ControlState::NONE);
nState2 |= ((mnStateFlags & SCRBAR_STATE_PAGE2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
- if( IsMouseOver() )
+ if (IsMouseOver())
{
- Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
- if( pRect )
+ Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
+ if (pRect)
{
- if( pRect == &maPage1Rect )
+ if (pRect == &maPage1Rect)
nState1 |= ControlState::ROLLOVER;
- else if( pRect == &maPage2Rect )
+ else if (pRect == &maPage2Rect)
nState2 |= ControlState::ROLLOVER;
}
}
- if ( nDrawFlags & SCRBAR_DRAW_PAGE1 )
- bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1,
- scrValue, OUString() );
+ if (nDrawFlags & SCRBAR_DRAW_PAGE1)
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1, scrValue, OUString());
- if ( nDrawFlags & SCRBAR_DRAW_PAGE2 )
- bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2,
- scrValue, OUString() );
+ if (nDrawFlags & SCRBAR_DRAW_PAGE2)
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2, scrValue, OUString());
}
- if ( (nDrawFlags & SCRBAR_DRAW_BTN1) || (nDrawFlags & SCRBAR_DRAW_BTN2) )
+ if ((nDrawFlags & SCRBAR_DRAW_BTN1) || (nDrawFlags & SCRBAR_DRAW_BTN2))
{
- sal_uInt32 part1 = bHorz ? PART_BUTTON_LEFT : PART_BUTTON_UP;
- sal_uInt32 part2 = bHorz ? PART_BUTTON_RIGHT : PART_BUTTON_DOWN;
- Rectangle aCtrlRegion1( maBtn1Rect );
- Rectangle aCtrlRegion2( maBtn2Rect );
+ sal_uInt32 part1 = bHorz ? PART_BUTTON_LEFT : PART_BUTTON_UP;
+ sal_uInt32 part2 = bHorz ? PART_BUTTON_RIGHT : PART_BUTTON_DOWN;
+ Rectangle aCtrlRegion1(maBtn1Rect);
+ Rectangle aCtrlRegion2(maBtn2Rect);
ControlState nState1 = HasFocus() ? ControlState::FOCUSED : ControlState::NONE;
ControlState nState2 = nState1;
- if ( !Window::IsEnabled() || !IsEnabled() )
+ if (!Window::IsEnabled() || !IsEnabled())
nState1 = (nState2 &= ~ControlState::ENABLED);
else
nState1 = (nState2 |= ControlState::ENABLED);
@@ -576,171 +576,169 @@ bool ScrollBar::ImplDrawNative( sal_uInt16 nDrawFlags )
nState1 |= ((mnStateFlags & SCRBAR_STATE_BTN1_DOWN) ? ControlState::PRESSED : ControlState::NONE);
nState2 |= ((mnStateFlags & SCRBAR_STATE_BTN2_DOWN) ? ControlState::PRESSED : ControlState::NONE);
- if(mnStateFlags & SCRBAR_STATE_BTN1_DISABLE)
+ if (mnStateFlags & SCRBAR_STATE_BTN1_DISABLE)
nState1 &= ~ControlState::ENABLED;
- if(mnStateFlags & SCRBAR_STATE_BTN2_DISABLE)
+ if (mnStateFlags & SCRBAR_STATE_BTN2_DISABLE)
nState2 &= ~ControlState::ENABLED;
- if( IsMouseOver() )
+ if (IsMouseOver())
{
- Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
- if( pRect )
+ Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
+ if (pRect)
{
- if( pRect == &maBtn1Rect )
+ if (pRect == &maBtn1Rect)
nState1 |= ControlState::ROLLOVER;
- else if( pRect == &maBtn2Rect )
+ else if (pRect == &maBtn2Rect)
nState2 |= ControlState::ROLLOVER;
}
}
- if ( nDrawFlags & SCRBAR_DRAW_BTN1 )
- bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1,
- scrValue, OUString() );
+ if (nDrawFlags & SCRBAR_DRAW_BTN1)
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part1, aCtrlRegion1, nState1, scrValue, OUString());
- if ( nDrawFlags & SCRBAR_DRAW_BTN2 )
- bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2,
- scrValue, OUString() );
+ if (nDrawFlags & SCRBAR_DRAW_BTN2)
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, part2, aCtrlRegion2, nState2, scrValue, OUString());
}
- if ( (nDrawFlags & SCRBAR_DRAW_THUMB) && !maThumbRect.IsEmpty() )
+ if ((nDrawFlags & SCRBAR_DRAW_THUMB) && !maThumbRect.IsEmpty())
{
- ControlState nState = IsEnabled() ? ControlState::ENABLED : ControlState::NONE;
- Rectangle aCtrlRegion( maThumbRect );
+ ControlState nState = IsEnabled() ? ControlState::ENABLED : ControlState::NONE;
+ Rectangle aCtrlRegion(maThumbRect);
- if ( mnStateFlags & SCRBAR_STATE_THUMB_DOWN )
+ if (mnStateFlags & SCRBAR_STATE_THUMB_DOWN)
nState |= ControlState::PRESSED;
- if ( HasFocus() )
+ if (HasFocus())
nState |= ControlState::FOCUSED;
- if( IsMouseOver() )
+ if (IsMouseOver())
{
- Rectangle* pRect = ImplFindPartRect( GetPointerPosPixel() );
- if( pRect )
+ Rectangle* pRect = ImplFindPartRect(GetPointerPosPixel());
+ if (pRect)
{
- if( pRect == &maThumbRect )
+ if (pRect == &maThumbRect)
nState |= ControlState::ROLLOVER;
}
}
- bNativeOK = DrawNativeControl( CTRL_SCROLLBAR, (bHorz ? PART_THUMB_HORZ : PART_THUMB_VERT),
- aCtrlRegion, nState, scrValue, OUString() );
+ bNativeOK = rRenderContext.DrawNativeControl(CTRL_SCROLLBAR, (bHorz ? PART_THUMB_HORZ : PART_THUMB_VERT),
+ aCtrlRegion, nState, scrValue, OUString());
}
}
return bNativeOK;
}
-void ScrollBar::ImplDraw( sal_uInt16 nDrawFlags, OutputDevice* pOutDev )
+void ScrollBar::ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags)
{
- DecorationView aDecoView( pOutDev );
- Rectangle aTempRect;
- sal_uInt16 nStyle;
- const StyleSettings& rStyleSettings = pOutDev->GetSettings().GetStyleSettings();
- SymbolType eSymbolType;
- bool bEnabled = IsEnabled();
+ DecorationView aDecoView(&rRenderContext);
+ Rectangle aTempRect;
+ sal_uInt16 nStyle;
+ const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ SymbolType eSymbolType;
+ bool bEnabled = IsEnabled();
// Finish some open calculations (if any)
- if ( mbCalcSize )
- ImplCalc( false );
+ if (mbCalcSize)
+ ImplCalc(false);
vcl::Window *pWin = NULL;
- if( pOutDev->GetOutDevType() == OUTDEV_WINDOW )
- pWin = static_cast<vcl::Window*>(pOutDev);
+ if (rRenderContext.GetOutDevType() == OUTDEV_WINDOW)
+ pWin = static_cast<vcl::Window*>(&rRenderContext);
// Draw the entire control if the native theme engine needs it
- if ( nDrawFlags && pWin && pWin->IsNativeControlSupported(CTRL_SCROLLBAR, PART_DRAW_BACKGROUND_HORZ) )
+ if (nDrawFlags && pWin && rRenderContext.IsNativeControlSupported(CTRL_SCROLLBAR, PART_DRAW_BACKGROUND_HORZ))
{
- ImplDrawNative( SCRBAR_DRAW_BACKGROUND );
+ ImplDrawNative(rRenderContext, SCRBAR_DRAW_BACKGROUND);
return;
}
- if( (nDrawFlags & SCRBAR_DRAW_BTN1) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_BTN1 ) ) )
+ if ((nDrawFlags & SCRBAR_DRAW_BTN1) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_BTN1)))
{
nStyle = BUTTON_DRAW_NOLIGHTBORDER;
- if ( mnStateFlags & SCRBAR_STATE_BTN1_DOWN )
+ if (mnStateFlags & SCRBAR_STATE_BTN1_DOWN)
nStyle |= BUTTON_DRAW_PRESSED;
aTempRect = aDecoView.DrawButton( maBtn1Rect, nStyle );
ImplCalcSymbolRect( aTempRect );
nStyle = 0;
- if ( (mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) || !bEnabled )
+ if ((mnStateFlags & SCRBAR_STATE_BTN1_DISABLE) || !bEnabled)
nStyle |= SYMBOL_DRAW_DISABLE;
- if ( rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW )
+ if (rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW)
{
- if ( GetStyle() & WB_HORZ )
+ if (GetStyle() & WB_HORZ)
eSymbolType = SymbolType::ARROW_LEFT;
else
eSymbolType = SymbolType::ARROW_UP;
}
else
{
- if ( GetStyle() & WB_HORZ )
+ if (GetStyle() & WB_HORZ)
eSymbolType = SymbolType::SPIN_LEFT;
else
eSymbolType = SymbolType::SPIN_UP;
}
- aDecoView.DrawSymbol( aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle );
+ aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle);
}
- if ( (nDrawFlags & SCRBAR_DRAW_BTN2) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_BTN2 ) ) )
+ if ((nDrawFlags & SCRBAR_DRAW_BTN2) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_BTN2)))
{
nStyle = BUTTON_DRAW_NOLIGHTBORDER;
- if ( mnStateFlags & SCRBAR_STATE_BTN2_DOWN )
+ if (mnStateFlags & SCRBAR_STATE_BTN2_DOWN)
nStyle |= BUTTON_DRAW_PRESSED;
- aTempRect = aDecoView.DrawButton( maBtn2Rect, nStyle );
- ImplCalcSymbolRect( aTempRect );
+ aTempRect = aDecoView.DrawButton(maBtn2Rect, nStyle);
+ ImplCalcSymbolRect(aTempRect);
nStyle = 0;
- if ( (mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) || !bEnabled )
+ if ((mnStateFlags & SCRBAR_STATE_BTN2_DISABLE) || !bEnabled)
nStyle |= SYMBOL_DRAW_DISABLE;
- if ( rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW )
+ if (rStyleSettings.GetOptions() & STYLE_OPTION_SCROLLARROW)
{
- if ( GetStyle() & WB_HORZ )
+ if (GetStyle() & WB_HORZ)
eSymbolType = SymbolType::ARROW_RIGHT;
else
eSymbolType = SymbolType::ARROW_DOWN;
}
else
{
- if ( GetStyle() & WB_HORZ )
+ if (GetStyle() & WB_HORZ)
eSymbolType = SymbolType::SPIN_RIGHT;
else
eSymbolType = SymbolType::SPIN_DOWN;
}
- aDecoView.DrawSymbol( aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle );
+ aDecoView.DrawSymbol(aTempRect, eSymbolType, rStyleSettings.GetButtonTextColor(), nStyle);
}
- pOutDev->SetLineColor();
+ rRenderContext.SetLineColor();
- if ( (nDrawFlags & SCRBAR_DRAW_THUMB) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_THUMB ) ) )
+ if ((nDrawFlags & SCRBAR_DRAW_THUMB) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_THUMB)))
{
- if ( !maThumbRect.IsEmpty() )
+ if (!maThumbRect.IsEmpty())
{
- if ( bEnabled )
+ if (bEnabled)
{
nStyle = BUTTON_DRAW_NOLIGHTBORDER;
- aTempRect = aDecoView.DrawButton( maThumbRect, nStyle );
+ aTempRect = aDecoView.DrawButton(maThumbRect, nStyle);
}
else
{
- pOutDev->SetFillColor( rStyleSettings.GetCheckedColor() );
- pOutDev->DrawRect( maThumbRect );
+ rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
+ rRenderContext.DrawRect(maThumbRect);
}
}
}
- if ( (nDrawFlags & SCRBAR_DRAW_PAGE1) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_PAGE1 ) ) )
+ if ((nDrawFlags & SCRBAR_DRAW_PAGE1) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_PAGE1)))
{
- if ( mnStateFlags & SCRBAR_STATE_PAGE1_DOWN )
- pOutDev->SetFillColor( rStyleSettings.GetShadowColor() );
+ if (mnStateFlags & SCRBAR_STATE_PAGE1_DOWN)
+ rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
else
- pOutDev->SetFillColor( rStyleSettings.GetCheckedColor() );
- pOutDev->DrawRect( maPage1Rect );
+ rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
+ rRenderContext.DrawRect(maPage1Rect);
}
- if ( (nDrawFlags & SCRBAR_DRAW_PAGE2) && (!pWin || !ImplDrawNative( SCRBAR_DRAW_PAGE2 ) ) )
+ if ((nDrawFlags & SCRBAR_DRAW_PAGE2) && (!pWin || !ImplDrawNative(rRenderContext, SCRBAR_DRAW_PAGE2)))
{
- if ( mnStateFlags & SCRBAR_STATE_PAGE2_DOWN )
- pOutDev->SetFillColor( rStyleSettings.GetShadowColor() );
+ if (mnStateFlags & SCRBAR_STATE_PAGE2_DOWN)
+ rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
else
- pOutDev->SetFillColor( rStyleSettings.GetCheckedColor() );
- pOutDev->DrawRect( maPage2Rect );
+ rRenderContext.SetFillColor(rStyleSettings.GetCheckedColor());
+ rRenderContext.DrawRect(maPage2Rect);
}
}
@@ -858,7 +856,7 @@ void ScrollBar::ImplDoMouseAction( const Point& rMousePos, bool bCallAction )
}
if ( nOldStateFlags != mnStateFlags )
- ImplDraw( mnDragDraw, this );
+ Invalidate();
if ( bAction )
ImplDoAction( false );
}
@@ -947,8 +945,11 @@ void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt )
if( mpData )
{
mpData->mbHide = true; // disable focus blinking
- if( HasFocus() )
- ImplDraw( SCRBAR_DRAW_THUMB, this ); // paint without focus
+ if (HasFocus())
+ {
+ mnStateFlags |= SCRBAR_DRAW_THUMB; // paint without focus
+ Invalidate();
+ }
}
if ( mnVisibleSize < mnMaxRange-mnMinRange )
@@ -975,7 +976,7 @@ void ScrollBar::MouseButtonDown( const MouseEvent& rMEvt )
}
mnStateFlags |= SCRBAR_STATE_THUMB_DOWN;
- ImplDraw( mnDragDraw, this );
+ Invalidate();
}
}
else if(bPage && (!HitTestNativeControl( CTRL_SCROLLBAR, bHorizontal? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA,
@@ -1028,7 +1029,7 @@ void ScrollBar::Tracking( const TrackingEvent& rTEvt )
SCRBAR_STATE_PAGE1_DOWN | SCRBAR_STATE_PAGE2_DOWN |
SCRBAR_STATE_THUMB_DOWN);
if ( nOldStateFlags != mnStateFlags )
- ImplDraw( mnDragDraw, this );
+ Invalidate();
mnDragDraw = 0;
// Restore the old ThumbPosition when canceled
@@ -1122,7 +1123,7 @@ void ScrollBar::KeyInput( const KeyEvent& rKEvt )
void ScrollBar::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
{
- ImplDraw(SCRBAR_DRAW_ALL, &rRenderContext);
+ ImplDraw(rRenderContext, SCRBAR_DRAW_ALL);
}
void ScrollBar::Resize()
@@ -1176,7 +1177,7 @@ void ScrollBar::LoseFocus()
{
if( mpData )
mpData->maTimer.Stop();
- ImplDraw( SCRBAR_DRAW_THUMB, this );
+ Invalidate();
Control::LoseFocus();
}
commit 4c329456e1b70cfccfee905222d40f32ebcf562c
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu May 7 12:11:49 2015 +0900
refactor ProgressBar to use RenderContext
Change-Id: Idf33332a207736f70809820853dee5ce1e0a3cb1
diff --git a/include/vcl/status.hxx b/include/vcl/status.hxx
index 3520b0e..270ef4e 100644
--- a/include/vcl/status.hxx
+++ b/include/vcl/status.hxx
@@ -31,12 +31,10 @@ typedef ::std::vector< ImplStatusItem* > ImplStatusItemList;
// - Progress-Ausgabe -
-
-void VCL_DLLPUBLIC DrawProgress( vcl::Window* pWindow, const Point& rPos,
- long nOffset, long nPrgsWidth, long nPrgsHeight,
- sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
- const Rectangle& rFramePosSize
- );
+void VCL_DLLPUBLIC DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, const Point& rPos,
+ long nOffset, long nPrgsWidth, long nPrgsHeight,
+ sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
+ const Rectangle& rFramePosSize);
// - StatusBarItemBits -
diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx
index b480754..b9e8cb9 100644
--- a/vcl/source/control/prgsbar.cxx
+++ b/vcl/source/control/prgsbar.cxx
@@ -117,33 +117,37 @@ void ProgressBar::ImplInitSettings( bool bFont,
}
}
-void ProgressBar::ImplDrawProgress(vcl::RenderContext& /*rRenderContext*/, sal_uInt16 nOldPerc, sal_uInt16 nNewPerc)
+void ProgressBar::ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt16 nOldPerc, sal_uInt16 nNewPerc)
{
- if ( mbCalcNew )
+ if (mbCalcNew)
{
mbCalcNew = false;
- Size aSize = GetOutputSizePixel();
- mnPrgsHeight = aSize.Height()-(PROGRESSBAR_WIN_OFFSET*2);
- mnPrgsWidth = (mnPrgsHeight*2)/3;
+ Size aSize = rRenderContext.GetOutputSizePixel();
+ mnPrgsHeight = aSize.Height() - (PROGRESSBAR_WIN_OFFSET * 2);
+ mnPrgsWidth = (mnPrgsHeight * 2) / 3;
maPos.Y() = PROGRESSBAR_WIN_OFFSET;
- long nMaxWidth = (aSize.Width()-(PROGRESSBAR_WIN_OFFSET*2)+PROGRESSBAR_OFFSET);
+ long nMaxWidth = (aSize.Width() - (PROGRESSBAR_WIN_OFFSET * 2) + PROGRESSBAR_OFFSET);
sal_uInt16 nMaxCount = (sal_uInt16)(nMaxWidth / (mnPrgsWidth+PROGRESSBAR_OFFSET));
- if ( nMaxCount <= 1 )
+ if (nMaxCount <= 1)
+ {
nMaxCount = 1;
+ }
else
{
- while ( ((10000/(10000/nMaxCount))*(mnPrgsWidth+PROGRESSBAR_OFFSET)) > nMaxWidth )
+ while (((10000 / (10000 / nMaxCount)) * (mnPrgsWidth + PROGRESSBAR_OFFSET)) > nMaxWidth)
+ {
nMaxCount--;
+ }
}
- mnPercentCount = 10000/nMaxCount;
- nMaxWidth = ((10000/(10000/nMaxCount))*(mnPrgsWidth+PROGRESSBAR_OFFSET))-PROGRESSBAR_OFFSET;
- maPos.X() = (aSize.Width()-nMaxWidth)/2;
+ mnPercentCount = 10000 / nMaxCount;
+ nMaxWidth = ((10000 / (10000 / nMaxCount)) * (mnPrgsWidth + PROGRESSBAR_OFFSET)) - PROGRESSBAR_OFFSET;
+ maPos.X() = (aSize.Width() - nMaxWidth) / 2;
}
- ::DrawProgress( this, maPos, PROGRESSBAR_OFFSET, mnPrgsWidth, mnPrgsHeight,
- nOldPerc*100, nNewPerc*100, mnPercentCount,
- Rectangle( Point(), GetSizePixel() ) );
+ ::DrawProgress(this, rRenderContext, maPos, PROGRESSBAR_OFFSET, mnPrgsWidth, mnPrgsHeight,
+ nOldPerc * 100, nNewPerc * 100, mnPercentCount,
+ Rectangle(Point(), GetSizePixel()));
}
void ProgressBar::Paint(vcl::RenderContext& rRenderContext, const Rectangle& /*rRect*/)
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 7b7efaf..6145614 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -468,147 +468,143 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& /*rRenderContext*/, bool bOffSc
CallEventListeners( VCLEVENT_STATUSBAR_DRAWITEM, reinterpret_cast<void*>(pItem->mnId) );
}
-void DrawProgress( vcl::Window* pWindow, const Point& rPos,
- long nOffset, long nPrgsWidth, long nPrgsHeight,
- sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
- const Rectangle& rFramePosSize
- )
+void DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, const Point& rPos,
+ long nOffset, long nPrgsWidth, long nPrgsHeight,
+ sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
+ const Rectangle& rFramePosSize)
{
- if( pWindow->IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
+ if (rRenderContext.IsNativeControlSupported(CTRL_PROGRESS, PART_ENTIRE_CONTROL))
{
bool bNeedErase = ImplGetSVData()->maNWFData.mbProgressNeedsErase;
long nFullWidth = (nPrgsWidth + nOffset) * (10000 / nPercentCount);
long nPerc = (nPercent2 > 10000) ? 10000 : nPercent2;
- ImplControlValue aValue( nFullWidth * (long)nPerc / 10000 );
- Rectangle aDrawRect( rPos, Size( nFullWidth, nPrgsHeight ) );
- Rectangle aControlRegion( aDrawRect );
- if( bNeedErase )
+ ImplControlValue aValue(nFullWidth * long(nPerc) / 10000);
+ Rectangle aDrawRect(rPos, Size(nFullWidth, nPrgsHeight));
+ Rectangle aControlRegion(aDrawRect);
+
+ if(bNeedErase)
{
vcl::Window* pEraseWindow = pWindow;
- while( pEraseWindow->IsPaintTransparent() &&
- ! pEraseWindow->ImplGetWindowImpl()->mbFrame )
+ while (pEraseWindow->IsPaintTransparent() && !pEraseWindow->ImplGetWindowImpl()->mbFrame)
{
pEraseWindow = pEraseWindow->ImplGetWindowImpl()->mpParent;
}
- if( pEraseWindow == pWindow )
+
+ if (pEraseWindow == pWindow)
+ {
// restore background of pWindow
- pEraseWindow->Erase( rFramePosSize );
+ rRenderContext.Erase(rFramePosSize);
+ }
else
{
// restore transparent background
- Point aTL( pWindow->OutputToAbsoluteScreenPixel( rFramePosSize.TopLeft() ) );
- aTL = pEraseWindow->AbsoluteScreenToOutputPixel( aTL );
- Rectangle aRect( aTL, rFramePosSize.GetSize() );
- pEraseWindow->Invalidate( aRect, INVALIDATE_NOCHILDREN |
- INVALIDATE_NOCLIPCHILDREN |
- INVALIDATE_TRANSPARENT );
+ Point aTL(pWindow->OutputToAbsoluteScreenPixel(rFramePosSize.TopLeft()));
+ aTL = pEraseWindow->AbsoluteScreenToOutputPixel(aTL);
+ Rectangle aRect(aTL, rFramePosSize.GetSize());
+ pEraseWindow->Invalidate(aRect, INVALIDATE_NOCHILDREN |
+ INVALIDATE_NOCLIPCHILDREN |
+ INVALIDATE_TRANSPARENT);
pEraseWindow->Update();
}
- pWindow->Push( PushFlags::CLIPREGION );
- pWindow->IntersectClipRegion( rFramePosSize );
+ rRenderContext.Push(PushFlags::CLIPREGION);
+ rRenderContext.IntersectClipRegion(rFramePosSize);
}
- bool bNativeOK = pWindow->DrawNativeControl( CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
- ControlState::ENABLED, aValue, OUString() );
- if( bNeedErase )
- pWindow->Pop();
- if( bNativeOK )
- {
- pWindow->Flush();
+
+ bool bNativeOK = rRenderContext.DrawNativeControl(CTRL_PROGRESS, PART_ENTIRE_CONTROL, aControlRegion,
+ ControlState::ENABLED, aValue, OUString());
+ if (bNeedErase)
+ rRenderContext.Pop();
+ if (bNativeOK)
return;
- }
}
// precompute values
sal_uInt16 nPerc1 = nPercent1 / nPercentCount;
sal_uInt16 nPerc2 = nPercent2 / nPercentCount;
- if ( nPerc1 > nPerc2 )
+ if (nPerc1 > nPerc2)
{
// support progress that can also decrease
// compute rectangle
- long nDX = nPrgsWidth + nOffset;
- long nLeft = rPos.X()+((nPerc1-1)*nDX);
- Rectangle aRect( nLeft, rPos.Y(), nLeft+nPrgsWidth, rPos.Y()+nPrgsHeight );
+ long nDX = nPrgsWidth + nOffset;
+ long nLeft = rPos.X() + ((nPerc1 - 1) * nDX);
+ Rectangle aRect(nLeft, rPos.Y(), nLeft + nPrgsWidth, rPos.Y() + nPrgsHeight);
do
{
- pWindow->Erase( aRect );
+ rRenderContext.Erase(aRect);
aRect.Left() -= nDX;
aRect.Right() -= nDX;
nPerc1--;
}
- while ( nPerc1 > nPerc2 );
-
- pWindow->Flush();
+ while (nPerc1 > nPerc2);
}
- else if ( nPerc1 < nPerc2 )
+ else if (nPerc1 < nPerc2)
{
// draw Percent rectangle
// if Percent2 greater than 100%, adapt values
- if ( nPercent2 > 10000 )
+ if (nPercent2 > 10000)
{
nPerc2 = 10000 / nPercentCount;
- if ( nPerc1 >= nPerc2 )
- nPerc1 = nPerc2-1;
+ if (nPerc1 >= nPerc2)
+ nPerc1 = nPerc2 - 1;
}
// compute rectangle
- long nDX = nPrgsWidth + nOffset;
- long nLeft = rPos.X()+(nPerc1*nDX);
- Rectangle aRect( nLeft, rPos.Y(), nLeft+nPrgsWidth, rPos.Y()+nPrgsHeight );
+ long nDX = nPrgsWidth + nOffset;
+ long nLeft = rPos.X() + (nPerc1 * nDX);
+ Rectangle aRect(nLeft, rPos.Y(), nLeft + nPrgsWidth, rPos.Y() + nPrgsHeight);
do
{
- pWindow->DrawRect( aRect );
+ rRenderContext.DrawRect(aRect);
aRect.Left() += nDX;
aRect.Right() += nDX;
nPerc1++;
}
- while ( nPerc1 < nPerc2 );
+ while (nPerc1 < nPerc2);
// if greater than 100%, set rectangle to blink
- if ( nPercent2 > 10000 )
+ if (nPercent2 > 10000)
{
// define on/off status
- if ( ((nPercent2 / nPercentCount) & 0x01) == (nPercentCount & 0x01) )
+ if (((nPercent2 / nPercentCount) & 0x01) == (nPercentCount & 0x01))
{
aRect.Left() -= nDX;
aRect.Right() -= nDX;
- pWindow->Erase( aRect );
+ rRenderContext.Erase(aRect);
}
}
-
- pWindow->Flush();
}
}
void StatusBar::ImplDrawProgress(vcl::RenderContext& rRenderContext, bool bPaint,
sal_uInt16 nPercent1, sal_uInt16 nPercent2)
{
- bool bNative = IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL );
+ bool bNative = rRenderContext.IsNativeControlSupported(CTRL_PROGRESS, PART_ENTIRE_CONTROL);
// bPaint: draw text also, else only update progress
if (bPaint)
{
- DrawText( maPrgsTxtPos, maPrgsTxt );
- if( ! bNative )
+ rRenderContext.DrawText(maPrgsTxtPos, maPrgsTxt);
+ if (!bNative)
{
DecorationView aDecoView(&rRenderContext);
- aDecoView.DrawFrame( maPrgsFrameRect, FRAME_DRAW_IN );
+ aDecoView.DrawFrame(maPrgsFrameRect, FRAME_DRAW_IN);
}
}
- Point aPos( maPrgsFrameRect.Left()+STATUSBAR_PRGS_OFFSET,
- maPrgsFrameRect.Top()+STATUSBAR_PRGS_OFFSET );
+ Point aPos(maPrgsFrameRect.Left() + STATUSBAR_PRGS_OFFSET,
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list