refactor "TextEdit" & co. to use RenderContext
Change-Id: Ib26ecb9640d23714acec73304f26e2fd6af90ed4
This commit is contained in:
parent
c299413c6d
commit
29b1e6718f
@ -915,12 +915,12 @@ void EditorWindow::SetupAndShowCodeCompleteWnd( const std::vector< OUString >& a
|
|||||||
pEditView->GetWindow()->GrabFocus();
|
pEditView->GetWindow()->GrabFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWindow::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect )
|
void EditorWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
|
||||||
{
|
{
|
||||||
if ( !pEditEngine ) // We need it now at latest
|
if (!pEditEngine) // We need it now at latest
|
||||||
CreateEditEngine();
|
CreateEditEngine();
|
||||||
|
|
||||||
pEditView->Paint( rRect );
|
pEditView->Paint(rRenderContext, rRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWindow::LoseFocus()
|
void EditorWindow::LoseFocus()
|
||||||
|
@ -25,10 +25,11 @@
|
|||||||
#include <vcl/dllapi.h>
|
#include <vcl/dllapi.h>
|
||||||
#include <vcl/dndhelp.hxx>
|
#include <vcl/dndhelp.hxx>
|
||||||
#include <vcl/textdata.hxx>
|
#include <vcl/textdata.hxx>
|
||||||
|
#include <vcl/window.hxx>
|
||||||
|
|
||||||
class TextEngine;
|
class TextEngine;
|
||||||
class OutputDevice;
|
class OutputDevice;
|
||||||
namespace vcl { class Window; }
|
|
||||||
class KeyEvent;
|
class KeyEvent;
|
||||||
class MouseEvent;
|
class MouseEvent;
|
||||||
class CommandEvent;
|
class CommandEvent;
|
||||||
@ -37,11 +38,7 @@ class SelectionEngine;
|
|||||||
class VirtualDevice;
|
class VirtualDevice;
|
||||||
struct TextDDInfo;
|
struct TextDDInfo;
|
||||||
|
|
||||||
namespace com {
|
namespace com { namespace sun { namespace star { namespace datatransfer { namespace clipboard {
|
||||||
namespace sun {
|
|
||||||
namespace star {
|
|
||||||
namespace datatransfer {
|
|
||||||
namespace clipboard {
|
|
||||||
class XClipboard;
|
class XClipboard;
|
||||||
}}}}}
|
}}}}}
|
||||||
|
|
||||||
@ -72,8 +69,8 @@ protected:
|
|||||||
void ImpSetSelection( const TextSelection& rNewSel, bool bUI );
|
void ImpSetSelection( const TextSelection& rNewSel, bool bUI );
|
||||||
bool IsInSelection( const TextPaM& rPaM );
|
bool IsInSelection( const TextPaM& rPaM );
|
||||||
|
|
||||||
void ImpPaint( OutputDevice* pOut, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0 );
|
void ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0);
|
||||||
void ImpPaint( const Rectangle& rRect, bool bUseVirtDev );
|
void ImpPaint(vcl::RenderContext& rRenderContext, const Rectangle& rRect, bool bUseVirtDev);
|
||||||
void ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bEndKey );
|
void ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bEndKey );
|
||||||
void ImpHighlight( const TextSelection& rSel );
|
void ImpHighlight( const TextSelection& rSel );
|
||||||
void ImpSetSelection( const TextSelection& rSelection );
|
void ImpSetSelection( const TextSelection& rSelection );
|
||||||
@ -127,8 +124,8 @@ public:
|
|||||||
|
|
||||||
void InsertText( const OUString& rNew, bool bSelect = false );
|
void InsertText( const OUString& rNew, bool bSelect = false );
|
||||||
|
|
||||||
bool KeyInput( const KeyEvent& rKeyEvent );
|
bool KeyInput( const KeyEvent& rKeyEvent );
|
||||||
void Paint( const Rectangle& rRect );
|
void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
|
||||||
void MouseButtonUp( const MouseEvent& rMouseEvent );
|
void MouseButtonUp( const MouseEvent& rMouseEvent );
|
||||||
void MouseButtonDown( const MouseEvent& rMouseEvent );
|
void MouseButtonDown( const MouseEvent& rMouseEvent );
|
||||||
void MouseMove( const MouseEvent& rMouseEvent );
|
void MouseMove( const MouseEvent& rMouseEvent );
|
||||||
|
@ -478,9 +478,9 @@ void TextViewOutWin::KeyInput( const KeyEvent& rKEvt )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextViewOutWin::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect )
|
void TextViewOutWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect)
|
||||||
{
|
{
|
||||||
pTextView->Paint( rRect );
|
pTextView->Paint(rRenderContext, rRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwSrcEditWindow::CreateTextEngine()
|
void SwSrcEditWindow::CreateTextEngine()
|
||||||
|
@ -1499,10 +1499,7 @@ void TextEngine::UpdateViews( TextView* pCurView )
|
|||||||
aNewPos.X() -= aOutSz.Width() - 1;
|
aNewPos.X() -= aOutSz.Width() - 1;
|
||||||
aClipRect.SetPos( aNewPos );
|
aClipRect.SetPos( aNewPos );
|
||||||
|
|
||||||
if ( pView == pCurView )
|
pView->GetWindow()->Invalidate( aClipRect );
|
||||||
pView->ImpPaint( aClipRect, !pView->GetWindow()->IsPaintTransparent() );
|
|
||||||
else
|
|
||||||
pView->GetWindow()->Invalidate( aClipRect );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,99 +293,97 @@ void TextView::DeleteSelected()
|
|||||||
ShowCursor();
|
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;
|
pSelection = NULL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// set correct background color;
|
// set correct background color;
|
||||||
// unfortunately we cannot detect if it has changed
|
// unfortunately we cannot detect if it has changed
|
||||||
vcl::Font aFont = mpImpl->mpTextEngine->GetFont();
|
vcl::Font aFont = mpImpl->mpTextEngine->GetFont();
|
||||||
Color aColor = pOut->GetBackground().GetColor();
|
Color aColor = rRenderContext.GetBackground().GetColor();
|
||||||
aColor.SetTransparency( 0 );
|
aColor.SetTransparency(0);
|
||||||
if ( aColor != aFont.GetFillColor() )
|
if (aColor != aFont.GetFillColor())
|
||||||
{
|
{
|
||||||
if( aFont.IsTransparent() )
|
if (aFont.IsTransparent())
|
||||||
aColor = Color( COL_TRANSPARENT );
|
aColor = Color(COL_TRANSPARENT);
|
||||||
aFont.SetFillColor( aColor );
|
aFont.SetFillColor(aColor);
|
||||||
mpImpl->mpTextEngine->maFont = aFont;
|
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() )
|
if ( !mpImpl->mpTextEngine->GetUpdateMode() || mpImpl->mpTextEngine->IsInUndo() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TextSelection *pDrawSelection = NULL;
|
TextSelection *pDrawSelection = NULL;
|
||||||
if ( !mpImpl->mbHighlightSelection && mpImpl->maSelection.HasRange() )
|
if (!mpImpl->mbHighlightSelection && mpImpl->maSelection.HasRange())
|
||||||
pDrawSelection = &mpImpl->maSelection;
|
pDrawSelection = &mpImpl->maSelection;
|
||||||
|
|
||||||
if ( bUseVirtDev )
|
if (bUseVirtDev)
|
||||||
{
|
{
|
||||||
VirtualDevice* pVDev = GetVirtualDevice();
|
VirtualDevice* pVDev = GetVirtualDevice();
|
||||||
|
|
||||||
const Color& rBackgroundColor = mpImpl->mpWindow->GetBackground().GetColor();
|
const Color& rBackgroundColor = mpImpl->mpWindow->GetBackground().GetColor();
|
||||||
if ( pVDev->GetFillColor() != rBackgroundColor )
|
if (pVDev->GetFillColor() != rBackgroundColor)
|
||||||
pVDev->SetFillColor( rBackgroundColor );
|
pVDev->SetFillColor( rBackgroundColor );
|
||||||
if ( pVDev->GetBackground().GetColor() != rBackgroundColor )
|
if (pVDev->GetBackground().GetColor() != rBackgroundColor)
|
||||||
pVDev->SetBackground( rBackgroundColor );
|
pVDev->SetBackground( rBackgroundColor );
|
||||||
|
|
||||||
bool bVDevValid = true;
|
bool bVDevValid = true;
|
||||||
Size aOutSz( pVDev->GetOutputSizePixel() );
|
Size aOutSz(pVDev->GetOutputSizePixel());
|
||||||
if ( ( aOutSz.Width() < rRect.GetWidth() ) ||
|
if ((aOutSz.Width() < rRect.GetWidth()) ||
|
||||||
( aOutSz.Height() < rRect.GetHeight() ) )
|
(aOutSz.Height() < rRect.GetHeight()))
|
||||||
{
|
{
|
||||||
bVDevValid = pVDev->SetOutputSizePixel( rRect.GetSize() );
|
bVDevValid = pVDev->SetOutputSizePixel(rRect.GetSize());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// the VirtDev can get very large on Resize =>
|
// the VirtDev can get very large on Resize =>
|
||||||
// shrink now and then
|
// shrink now and then
|
||||||
if ( ( aOutSz.Height() > ( rRect.GetHeight() + 20 ) ) ||
|
if ((aOutSz.Height() > (rRect.GetHeight() + 20)) ||
|
||||||
( aOutSz.Width() > ( rRect.GetWidth() + 20 ) ) )
|
(aOutSz.Width() > (rRect.GetWidth() + 20)))
|
||||||
{
|
{
|
||||||
bVDevValid = pVDev->SetOutputSizePixel( rRect.GetSize() );
|
bVDevValid = pVDev->SetOutputSizePixel(rRect.GetSize());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pVDev->Erase();
|
pVDev->Erase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !bVDevValid )
|
if (!bVDevValid)
|
||||||
{
|
{
|
||||||
ImpPaint( rRect, false /* without VDev */ );
|
ImpPaint(rRenderContext, rRect, false);
|
||||||
return;
|
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 aDocPos(mpImpl->maStartDocPos.X(), mpImpl->maStartDocPos.Y() + rRect.Top());
|
||||||
Point aStartPos = ImpGetOutputStartPos( aDocPos );
|
Point aStartPos = ImpGetOutputStartPos(aDocPos);
|
||||||
ImpPaint( pVDev, aStartPos, &aTmpRect, NULL, pDrawSelection );
|
ImpPaint(*pVDev, aStartPos, &aTmpRect, NULL, pDrawSelection);
|
||||||
mpImpl->mpWindow->DrawOutDev( rRect.TopLeft(), rRect.GetSize(),
|
rRenderContext.DrawOutDev(rRect.TopLeft(), rRect.GetSize(), Point(0,0), rRect.GetSize(), *pVDev);
|
||||||
Point(0,0), rRect.GetSize(), *pVDev );
|
if (mpImpl->mbHighlightSelection)
|
||||||
// ShowSelection();
|
ImpHighlight(mpImpl->maSelection);
|
||||||
if ( mpImpl->mbHighlightSelection )
|
|
||||||
ImpHighlight( mpImpl->maSelection );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Point aStartPos = ImpGetOutputStartPos( mpImpl->maStartDocPos );
|
Point aStartPos = ImpGetOutputStartPos(mpImpl->maStartDocPos);
|
||||||
ImpPaint( mpImpl->mpWindow, aStartPos, &rRect, NULL, pDrawSelection );
|
ImpPaint(rRenderContext, aStartPos, &rRect, NULL, pDrawSelection);
|
||||||
|
if (mpImpl->mbHighlightSelection)
|
||||||
// ShowSelection();
|
ImpHighlight(mpImpl->maSelection);
|
||||||
if ( mpImpl->mbHighlightSelection )
|
|
||||||
ImpHighlight( mpImpl->maSelection );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +497,7 @@ void TextView::ShowSelection( const TextSelection& rRange )
|
|||||||
ImpShowHideSelection( true, &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;
|
const TextSelection* pRangeOrSelection = pRange ? pRange : &mpImpl->maSelection;
|
||||||
|
|
||||||
@ -515,14 +513,12 @@ void TextView::ImpShowHideSelection( bool bShow, const TextSelection* pRange )
|
|||||||
mpImpl->mpWindow->Invalidate();
|
mpImpl->mpWindow->Invalidate();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Rectangle aOutArea( Point( 0, 0 ), mpImpl->mpWindow->GetOutputSizePixel() );
|
|
||||||
Point aStartPos( ImpGetOutputStartPos( mpImpl->maStartDocPos ) );
|
|
||||||
TextSelection aRange( *pRangeOrSelection );
|
TextSelection aRange( *pRangeOrSelection );
|
||||||
aRange.Justify();
|
aRange.Justify();
|
||||||
bool bVisCursor = mpImpl->mpCursor->IsVisible();
|
bool bVisCursor = mpImpl->mpCursor->IsVisible();
|
||||||
mpImpl->mpCursor->Hide();
|
mpImpl->mpCursor->Hide();
|
||||||
ImpPaint( mpImpl->mpWindow, aStartPos, &aOutArea, &aRange, bShow ? &mpImpl->maSelection : NULL );
|
Invalidate();
|
||||||
if ( bVisCursor )
|
if (bVisCursor)
|
||||||
mpImpl->mpCursor->Show();
|
mpImpl->mpCursor->Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
|
|
||||||
virtual void Command( const CommandEvent& rCEvt ) 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 Resize() SAL_OVERRIDE;
|
virtual void Resize() SAL_OVERRIDE;
|
||||||
|
|
||||||
virtual void GetFocus() SAL_OVERRIDE;
|
virtual void GetFocus() SAL_OVERRIDE;
|
||||||
@ -807,9 +807,9 @@ void TextWindow::KeyInput( const KeyEvent& rKEvent )
|
|||||||
Window::KeyInput( 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()
|
void TextWindow::Resize()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user