From 9090dc1f3b27195f5defd35586ac79357992be21 Mon Sep 17 00:00:00 2001
From: Noel Grandin <noelgrandin@gmail.com>
Date: Mon, 18 Jan 2021 18:27:19 +0200
Subject: split OutputDevice from Window

as part of a longer-term goal of doing our
widget rendering only inside a top-level render-
context.

I moved all of the OutputDevice-related code that existed in vcl::Window
into a new subclass of OutputDevice called WindowOutputDevice.

Notes for further work

(*) not sure why we are getting an 1x1 surface in
    SvpSalGraphics::releaseCairoContext, but to fix it I clamp
    the size there

(*) might have to dump VCLXDevice, and move it's code down into VCLXWindow and VCLXVirtualDevice

(*) can we remove use of VCLXDevice in other places, in favour of just talking to the VCL code?

Change-Id: I105946377f5322677d6f7d0c1c23847178a720b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113204
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
---
 vcl/source/treelist/headbar.cxx     | 30 +++++++++++++++---------------
 vcl/source/treelist/svimpbox.cxx    | 24 ++++++++++++------------
 vcl/source/treelist/svlbitm.cxx     |  8 ++++----
 vcl/source/treelist/svtabbx.cxx     |  2 +-
 vcl/source/treelist/treelistbox.cxx |  6 +++---
 5 files changed, 35 insertions(+), 35 deletions(-)

(limited to 'vcl/source/treelist')

diff --git a/vcl/source/treelist/headbar.cxx b/vcl/source/treelist/headbar.cxx
index 882015e02a84..91cb86cc73ca 100644
--- a/vcl/source/treelist/headbar.cxx
+++ b/vcl/source/treelist/headbar.cxx
@@ -130,16 +130,16 @@ void HeaderBar::ImplInitSettings(bool bFont, bool bForeground, bool bBackground)
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
 
     if (bFont)
-        ApplyControlFont(*this, rStyleSettings.GetToolFont());
+        ApplyControlFont(*GetOutDev(), rStyleSettings.GetToolFont());
 
     if (bForeground || bFont)
     {
-        ApplyControlForeground(*this, rStyleSettings.GetButtonTextColor());
+        ApplyControlForeground(*GetOutDev(), rStyleSettings.GetButtonTextColor());
         SetTextFillColor();
     }
 
     if (bBackground)
-        ApplyControlBackground(*this, rStyleSettings.GetFaceColor());
+        ApplyControlBackground(*GetOutDev(), rStyleSettings.GetFaceColor());
 }
 
 tools::Long HeaderBar::ImplGetItemPos( sal_uInt16 nPos ) const
@@ -239,30 +239,30 @@ void HeaderBar::ImplInvertDrag( sal_uInt16 nStartPos, sal_uInt16 nEndPos )
         aEndPos.setX( aRect2.Left()+6 );
     }
 
-    SetRasterOp( RasterOp::Invert );
-    DrawRect( aStartRect );
-    DrawLine( aStartPos, aEndPos );
+    GetOutDev()->SetRasterOp( RasterOp::Invert );
+    GetOutDev()->DrawRect( aStartRect );
+    GetOutDev()->DrawLine( aStartPos, aEndPos );
     if ( nEndPos > nStartPos )
     {
-        DrawLine( Point( aEndPos.X()+1, aEndPos.Y()-3 ),
+        GetOutDev()->DrawLine( Point( aEndPos.X()+1, aEndPos.Y()-3 ),
                   Point( aEndPos.X()+1, aEndPos.Y()+3 ) );
-        DrawLine( Point( aEndPos.X()+2, aEndPos.Y()-2 ),
+        GetOutDev()->DrawLine( Point( aEndPos.X()+2, aEndPos.Y()-2 ),
                   Point( aEndPos.X()+2, aEndPos.Y()+2 ) );
-        DrawLine( Point( aEndPos.X()+3, aEndPos.Y()-1 ),
+        GetOutDev()->DrawLine( Point( aEndPos.X()+3, aEndPos.Y()-1 ),
                   Point( aEndPos.X()+3, aEndPos.Y()+1 ) );
-        DrawPixel( Point( aEndPos.X()+4, aEndPos.Y() ) );
+        GetOutDev()->DrawPixel( Point( aEndPos.X()+4, aEndPos.Y() ) );
     }
     else
     {
-        DrawLine( Point( aEndPos.X()-1, aEndPos.Y()-3 ),
+        GetOutDev()->DrawLine( Point( aEndPos.X()-1, aEndPos.Y()-3 ),
                   Point( aEndPos.X()-1, aEndPos.Y()+3 ) );
-        DrawLine( Point( aEndPos.X()-2, aEndPos.Y()-2 ),
+        GetOutDev()->DrawLine( Point( aEndPos.X()-2, aEndPos.Y()-2 ),
                   Point( aEndPos.X()-2, aEndPos.Y()+2 ) );
-        DrawLine( Point( aEndPos.X()-3, aEndPos.Y()-1 ),
+        GetOutDev()->DrawLine( Point( aEndPos.X()-3, aEndPos.Y()-1 ),
                   Point( aEndPos.X()-3, aEndPos.Y()+1 ) );
-        DrawPixel( Point( aEndPos.X()-4, aEndPos.Y() ) );
+        GetOutDev()->DrawPixel( Point( aEndPos.X()-4, aEndPos.Y() ) );
     }
-    SetRasterOp( RasterOp::OverPaint );
+    GetOutDev()->SetRasterOp( RasterOp::OverPaint );
 }
 
 void HeaderBar::ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHigh,
diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx
index 7397305e0aba..60b8a5962e42 100644
--- a/vcl/source/treelist/svimpbox.cxx
+++ b/vcl/source/treelist/svimpbox.cxx
@@ -259,7 +259,7 @@ void SvImpLBox::Clear()
     m_pView->Control::SetMapMode( aMapMode );
     m_aHorSBar->SetRange( aRange );
     m_aHorSBar->SetSizePixel(Size(m_aOutputSize.Width(),m_nHorSBarHeight));
-    m_pView->SetClipRegion();
+    m_pView->GetOutDev()->SetClipRegion();
     if( GetUpdateMode() )
         m_pView->Invalidate( GetVisibleArea() );
     m_nFlags |= LBoxFlags::Filling;
@@ -563,11 +563,11 @@ void SvImpLBox::RecalcFocusRect()
         m_pView->HideFocus();
         tools::Long nY = GetEntryLine( m_pCursor );
         tools::Rectangle aRect = m_pView->GetFocusRect( m_pCursor, nY );
-        vcl::Region aOldClip( m_pView->GetClipRegion());
+        vcl::Region aOldClip( m_pView->GetOutDev()->GetClipRegion());
         vcl::Region aClipRegion( GetClipRegionRect() );
-        m_pView->SetClipRegion( aClipRegion );
+        m_pView->GetOutDev()->SetClipRegion( aClipRegion );
         m_pView->ShowFocus( aRect );
-        m_pView->SetClipRegion( aOldClip );
+        m_pView->GetOutDev()->SetClipRegion( aOldClip );
     }
 }
 
@@ -646,21 +646,21 @@ void SvImpLBox::ShowCursor( bool bShow )
 {
     if( !bShow || !m_pCursor || !m_pView->HasFocus() )
     {
-        vcl::Region aOldClip( m_pView->GetClipRegion());
+        vcl::Region aOldClip( m_pView->GetOutDev()->GetClipRegion());
         vcl::Region aClipRegion( GetClipRegionRect() );
-        m_pView->SetClipRegion( aClipRegion );
+        m_pView->GetOutDev()->SetClipRegion( aClipRegion );
         m_pView->HideFocus();
-        m_pView->SetClipRegion( aOldClip );
+        m_pView->GetOutDev()->SetClipRegion( aOldClip );
     }
     else
     {
         tools::Long nY = GetEntryLine( m_pCursor );
         tools::Rectangle aRect = m_pView->GetFocusRect( m_pCursor, nY );
-        vcl::Region aOldClip( m_pView->GetClipRegion());
+        vcl::Region aOldClip( m_pView->GetOutDev()->GetClipRegion());
         vcl::Region aClipRegion( GetClipRegionRect() );
-        m_pView->SetClipRegion( aClipRegion );
+        m_pView->GetOutDev()->SetClipRegion( aClipRegion );
         m_pView->ShowFocus( aRect );
-        m_pView->SetClipRegion( aOldClip );
+        m_pView->GetOutDev()->SetClipRegion( aOldClip );
     }
 }
 
@@ -2803,7 +2803,7 @@ void SvImpLBox::PaintDDCursor(SvTreeListEntry* pEntry, bool bShow)
         pViewData->SetDragTarget(bShow);
 #ifdef MACOSX
         // in MacOS we need to draw directly (as we are synchronous) or no invalidation happens
-        m_pView->PaintEntry1(*pEntry, GetEntryLine(pEntry), *m_pView);
+        m_pView->PaintEntry1(*pEntry, GetEntryLine(pEntry), *m_pView->GetOutDev());
 #else
         InvalidateEntry(pEntry);
 #endif
@@ -2842,7 +2842,7 @@ tools::Rectangle SvImpLBox::GetVisibleArea() const
 
 void SvImpLBox::Invalidate()
 {
-    m_pView->SetClipRegion();
+    m_pView->GetOutDev()->SetClipRegion();
 }
 
 void SvImpLBox::SetCurEntry( SvTreeListEntry* pEntry )
diff --git a/vcl/source/treelist/svlbitm.cxx b/vcl/source/treelist/svlbitm.cxx
index aaf9124765aa..0736ee65109c 100644
--- a/vcl/source/treelist/svlbitm.cxx
+++ b/vcl/source/treelist/svlbitm.cxx
@@ -292,7 +292,7 @@ void SvLBoxString::InitViewData(
 
     if (mbEmphasized)
     {
-        pView->Push();
+        pView->GetOutDev()->Push();
         vcl::Font aFont( pView->GetFont());
         aFont.SetWeight(WEIGHT_BOLD);
         pView->Control::SetFont( aFont );
@@ -300,7 +300,7 @@ void SvLBoxString::InitViewData(
 
     if (mbCustom)
     {
-        Size aSize = pView->MeasureCustomEntry(*pView, *pEntry);
+        Size aSize = pView->MeasureCustomEntry(*pView->GetOutDev(), *pEntry);
         pViewData->mnWidth = aSize.Width();
         pViewData->mnHeight = aSize.Height();
     }
@@ -311,7 +311,7 @@ void SvLBoxString::InitViewData(
     }
 
     if (mbEmphasized)
-        pView->Pop();
+        pView->GetOutDev()->Pop();
 }
 
 int SvLBoxString::CalcWidth(const SvTreeListBox* pView) const
@@ -443,7 +443,7 @@ void SvLBoxButton::InitViewData(SvTreeListBox* pView,SvTreeListEntry* pEntry, Sv
 
     ControlType eCtrlType = (pData->IsRadio())? ControlType::Radiobutton : ControlType::Checkbox;
     if ( pView )
-        ImplAdjustBoxSize(aSize, eCtrlType, *pView);
+        ImplAdjustBoxSize(aSize, eCtrlType, *pView->GetOutDev());
     pViewData->mnWidth = aSize.Width();
     pViewData->mnHeight = aSize.Height();
 }
diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx
index e653edf73b04..5ebe086708ac 100644
--- a/vcl/source/treelist/svtabbx.cxx
+++ b/vcl/source/treelist/svtabbx.cxx
@@ -1053,7 +1053,7 @@ void SvHeaderTabListBox::GrabTableFocus()
 
 bool SvHeaderTabListBox::GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex, int nLen, std::vector< tools::Rectangle >& rVector )
 {
-    return Control::GetGlyphBoundRects( rOrigin, rStr, nIndex, nLen, rVector );
+    return GetOutDev()->GetGlyphBoundRects( rOrigin, rStr, nIndex, nLen, rVector );
 }
 
 tools::Rectangle SvHeaderTabListBox::GetWindowExtentsRelative(const vcl::Window *pRelativeWindow) const
diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx
index 1fc5feaf21fc..f2357b890fe2 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -1275,7 +1275,7 @@ void SvTreeListBox::InitTreeView()
     AdjustEntryHeightAndRecalc();
 
     SetSpaceBetweenEntries( 0 );
-    SetLineColor();
+    GetOutDev()->SetLineColor();
     InitSettings();
     ImplInitStyle();
     SetTabs();
@@ -3432,7 +3432,7 @@ void SvTreeListBox::StateChanged( StateChangedType eType )
 
 void SvTreeListBox::ApplySettings(vcl::RenderContext& rRenderContext)
 {
-    SetPointFont(rRenderContext, GetPointFont(*this));
+    SetPointFont(rRenderContext, GetPointFont(*GetOutDev()));
 
     const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
     rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
@@ -3448,7 +3448,7 @@ void SvTreeListBox::InitSettings()
 {
     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     vcl::Font aFont = rStyleSettings.GetFieldFont();
-    SetPointFont(*this, aFont);
+    SetPointFont(*GetOutDev(), aFont);
     AdjustEntryHeightAndRecalc();
 
     SetTextColor(rStyleSettings.GetFieldTextColor());
-- 
cgit