diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-06 15:49:16 +0900 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-05-07 09:57:50 +0200 |
commit | 29b1e6718f6ebdb45d2a8c6a89a86bc0a6bbb3ae (patch) | |
tree | 2e405f964e47ee481926d8af5b2a70a81987119f /vcl | |
parent | c299413c6d51280804e1996330a960d02050507d (diff) |
refactor "TextEdit" & co. to use RenderContext
Change-Id: Ib26ecb9640d23714acec73304f26e2fd6af90ed4
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/edit/texteng.cxx | 5 | ||||
-rw-r--r-- | vcl/source/edit/textview.cxx | 86 | ||||
-rw-r--r-- | vcl/source/edit/vclmedit.cxx | 6 |
3 files changed, 45 insertions, 52 deletions
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index e5a3c84d2e2b..7311148bacf8 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -1499,10 +1499,7 @@ void TextEngine::UpdateViews( TextView* pCurView ) aNewPos.X() -= aOutSz.Width() - 1; aClipRect.SetPos( aNewPos ); - if ( pView == pCurView ) - pView->ImpPaint( aClipRect, !pView->GetWindow()->IsPaintTransparent() ); - else - pView->GetWindow()->Invalidate( aClipRect ); + pView->GetWindow()->Invalidate( aClipRect ); } } diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx index 2dd8da99768f..bd0ccc91589e 100644 --- a/vcl/source/edit/textview.cxx +++ b/vcl/source/edit/textview.cxx @@ -293,99 +293,97 @@ void TextView::DeleteSelected() ShowCursor(); } -void TextView::ImpPaint( OutputDevice* pOut, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange, TextSelection const* pSelection ) +void TextView::ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange, TextSelection const* pSelection) { - if ( !mpImpl->mbPaintSelection ) + if (!mpImpl->mbPaintSelection) + { pSelection = NULL; + } else { // set correct background color; // unfortunately we cannot detect if it has changed vcl::Font aFont = mpImpl->mpTextEngine->GetFont(); - Color aColor = pOut->GetBackground().GetColor(); - aColor.SetTransparency( 0 ); - if ( aColor != aFont.GetFillColor() ) + Color aColor = rRenderContext.GetBackground().GetColor(); + aColor.SetTransparency(0); + if (aColor != aFont.GetFillColor()) { - if( aFont.IsTransparent() ) - aColor = Color( COL_TRANSPARENT ); - aFont.SetFillColor( aColor ); + if (aFont.IsTransparent()) + aColor = Color(COL_TRANSPARENT); + aFont.SetFillColor(aColor); mpImpl->mpTextEngine->maFont = aFont; } } - mpImpl->mpTextEngine->ImpPaint( pOut, rStartPos, pPaintArea, pPaintRange, pSelection ); + mpImpl->mpTextEngine->ImpPaint(&rRenderContext, rStartPos, pPaintArea, pPaintRange, pSelection); } -void TextView::Paint( const Rectangle& rRect ) +void TextView::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) { - ImpPaint( rRect, false ); + ImpPaint(rRenderContext, rRect, false); } -void TextView::ImpPaint( const Rectangle& rRect, bool bUseVirtDev ) +void TextView::ImpPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bUseVirtDev) { if ( !mpImpl->mpTextEngine->GetUpdateMode() || mpImpl->mpTextEngine->IsInUndo() ) return; TextSelection *pDrawSelection = NULL; - if ( !mpImpl->mbHighlightSelection && mpImpl->maSelection.HasRange() ) + if (!mpImpl->mbHighlightSelection && mpImpl->maSelection.HasRange()) pDrawSelection = &mpImpl->maSelection; - if ( bUseVirtDev ) + if (bUseVirtDev) { VirtualDevice* pVDev = GetVirtualDevice(); const Color& rBackgroundColor = mpImpl->mpWindow->GetBackground().GetColor(); - if ( pVDev->GetFillColor() != rBackgroundColor ) + if (pVDev->GetFillColor() != rBackgroundColor) pVDev->SetFillColor( rBackgroundColor ); - if ( pVDev->GetBackground().GetColor() != rBackgroundColor ) + if (pVDev->GetBackground().GetColor() != rBackgroundColor) pVDev->SetBackground( rBackgroundColor ); bool bVDevValid = true; - Size aOutSz( pVDev->GetOutputSizePixel() ); - if ( ( aOutSz.Width() < rRect.GetWidth() ) || - ( aOutSz.Height() < rRect.GetHeight() ) ) + Size aOutSz(pVDev->GetOutputSizePixel()); + if ((aOutSz.Width() < rRect.GetWidth()) || + (aOutSz.Height() < rRect.GetHeight())) { - bVDevValid = pVDev->SetOutputSizePixel( rRect.GetSize() ); + bVDevValid = pVDev->SetOutputSizePixel(rRect.GetSize()); } else { // the VirtDev can get very large on Resize => // shrink now and then - if ( ( aOutSz.Height() > ( rRect.GetHeight() + 20 ) ) || - ( aOutSz.Width() > ( rRect.GetWidth() + 20 ) ) ) + if ((aOutSz.Height() > (rRect.GetHeight() + 20)) || + (aOutSz.Width() > (rRect.GetWidth() + 20))) { - bVDevValid = pVDev->SetOutputSizePixel( rRect.GetSize() ); + bVDevValid = pVDev->SetOutputSizePixel(rRect.GetSize()); } else { pVDev->Erase(); } } - if ( !bVDevValid ) + if (!bVDevValid) { - ImpPaint( rRect, false /* without VDev */ ); + ImpPaint(rRenderContext, rRect, false); return; } - Rectangle aTmpRect( Point( 0, 0 ), rRect.GetSize() ); + Rectangle aTmpRect(Point(0, 0), rRect.GetSize()); - Point aDocPos( mpImpl->maStartDocPos.X(), mpImpl->maStartDocPos.Y() + rRect.Top() ); - Point aStartPos = ImpGetOutputStartPos( aDocPos ); - ImpPaint( pVDev, aStartPos, &aTmpRect, NULL, pDrawSelection ); - mpImpl->mpWindow->DrawOutDev( rRect.TopLeft(), rRect.GetSize(), - Point(0,0), rRect.GetSize(), *pVDev ); -// ShowSelection(); - if ( mpImpl->mbHighlightSelection ) - ImpHighlight( mpImpl->maSelection ); + Point aDocPos(mpImpl->maStartDocPos.X(), mpImpl->maStartDocPos.Y() + rRect.Top()); + Point aStartPos = ImpGetOutputStartPos(aDocPos); + ImpPaint(*pVDev, aStartPos, &aTmpRect, NULL, pDrawSelection); + rRenderContext.DrawOutDev(rRect.TopLeft(), rRect.GetSize(), Point(0,0), rRect.GetSize(), *pVDev); + if (mpImpl->mbHighlightSelection) + ImpHighlight(mpImpl->maSelection); } else { - Point aStartPos = ImpGetOutputStartPos( mpImpl->maStartDocPos ); - ImpPaint( mpImpl->mpWindow, aStartPos, &rRect, NULL, pDrawSelection ); - -// ShowSelection(); - if ( mpImpl->mbHighlightSelection ) - ImpHighlight( mpImpl->maSelection ); + Point aStartPos = ImpGetOutputStartPos(mpImpl->maStartDocPos); + ImpPaint(rRenderContext, aStartPos, &rRect, NULL, pDrawSelection); + if (mpImpl->mbHighlightSelection) + ImpHighlight(mpImpl->maSelection); } } @@ -499,7 +497,7 @@ void TextView::ShowSelection( const TextSelection& rRange ) ImpShowHideSelection( true, &rRange ); } -void TextView::ImpShowHideSelection( bool bShow, const TextSelection* pRange ) +void TextView::ImpShowHideSelection(bool /*bShow*/, const TextSelection* pRange) { const TextSelection* pRangeOrSelection = pRange ? pRange : &mpImpl->maSelection; @@ -515,14 +513,12 @@ void TextView::ImpShowHideSelection( bool bShow, const TextSelection* pRange ) mpImpl->mpWindow->Invalidate(); else { - Rectangle aOutArea( Point( 0, 0 ), mpImpl->mpWindow->GetOutputSizePixel() ); - Point aStartPos( ImpGetOutputStartPos( mpImpl->maStartDocPos ) ); TextSelection aRange( *pRangeOrSelection ); aRange.Justify(); bool bVisCursor = mpImpl->mpCursor->IsVisible(); mpImpl->mpCursor->Hide(); - ImpPaint( mpImpl->mpWindow, aStartPos, &aOutArea, &aRange, bShow ? &mpImpl->maSelection : NULL ); - if ( bVisCursor ) + Invalidate(); + if (bVisCursor) mpImpl->mpCursor->Show(); } } diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx index c04606f3f00d..46c7c90c8e46 100644 --- a/vcl/source/edit/vclmedit.cxx +++ b/vcl/source/edit/vclmedit.cxx @@ -60,7 +60,7 @@ public: 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 Resize() SAL_OVERRIDE; virtual void GetFocus() SAL_OVERRIDE; @@ -807,9 +807,9 @@ void TextWindow::KeyInput( const KeyEvent& rKEvent ) Window::KeyInput( rKEvent ); } -void TextWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) +void TextWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) { - mpExtTextView->Paint( rRect ); + mpExtTextView->Paint(rRenderContext, rRect); } void TextWindow::Resize() |