forms/source/richtext/richtextimplcontrol.cxx |   24 ++++++++++++++----------
 forms/source/richtext/richtextimplcontrol.hxx |    9 +++++----
 2 files changed, 19 insertions(+), 14 deletions(-)

New commits:
commit cdf5b6a2a6f0ba2838323ce4398948c3d3a56f8e
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Aug 7 15:49:25 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Aug 8 09:54:31 2022 +0200

    tdf#117388 use native scrollbar under gtk in richedit control
    
    you get one of these by starting with a normal text box form control
    and changing its "text type" property to multi-line with formatting
    
    Change-Id: If922b6b9fdc49b78fa379dbb3e5974a73f6095ae
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137933
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/forms/source/richtext/richtextimplcontrol.cxx 
b/forms/source/richtext/richtextimplcontrol.cxx
index c51a3a8772af..fc9251074e64 100644
--- a/forms/source/richtext/richtextimplcontrol.cxx
+++ b/forms/source/richtext/richtextimplcontrol.cxx
@@ -306,25 +306,23 @@ namespace frm
             m_pVScroll->SetThumbPos( m_pView->GetVisArea().Top() );
     }
 
-
     IMPL_LINK_NOARG( RichTextControlImpl, OnInvalidateAllAttributes, 
LinkParamNone*, void )
     {
         updateAllAttributes();
     }
 
-
-    IMPL_LINK( RichTextControlImpl, OnHScroll, ScrollBar*, _pScrollbar, void )
+    IMPL_LINK( RichTextControlImpl, OnHScroll, weld::Scrollbar&, rScrollbar, 
void )
     {
-        m_pView->Scroll( -_pScrollbar->GetDelta(), 0, 
ScrollRangeCheck::PaperWidthTextSize );
+        auto nDiff = m_pView->GetVisArea().Left() - 
rScrollbar.adjustment_get_value();
+        m_pView->Scroll(nDiff, 0, ScrollRangeCheck::PaperWidthTextSize);
     }
 
-
-    IMPL_LINK( RichTextControlImpl, OnVScroll, ScrollBar*, _pScrollbar, void )
+    IMPL_LINK(RichTextControlImpl, OnVScroll, weld::Scrollbar&, rScrollbar, 
void)
     {
-        m_pView->Scroll( 0, -_pScrollbar->GetDelta(), 
ScrollRangeCheck::PaperWidthTextSize );
+        auto nDiff = m_pView->GetVisArea().Top() - 
rScrollbar.adjustment_get_value();
+        m_pView->Scroll(0, nDiff, ScrollRangeCheck::PaperWidthTextSize);
     }
 
-
     void RichTextControlImpl::ensureScrollbars()
     {
         bool bNeedVScroll = 0 != ( m_pAntiImpl->GetStyle() & WB_VSCROLL );
@@ -341,7 +339,7 @@ namespace frm
         }
         else
         {
-            m_pVScroll = VclPtr<ScrollBar>::Create( m_pAntiImpl, WB_VSCROLL | 
WB_DRAG | WB_REPEAT );
+            m_pVScroll = VclPtr<ScrollAdaptor>::Create( m_pAntiImpl, false );
             m_pVScroll->SetScrollHdl ( LINK( this, RichTextControlImpl, 
OnVScroll ) );
             m_pVScroll->Show();
         }
@@ -352,7 +350,7 @@ namespace frm
         }
         else
         {
-            m_pHScroll = VclPtr<ScrollBar>::Create( m_pAntiImpl, WB_HSCROLL | 
WB_DRAG | WB_REPEAT );
+            m_pHScroll = VclPtr<ScrollAdaptor>::Create( m_pAntiImpl, true );
             m_pHScroll->SetScrollHdl ( LINK( this, RichTextControlImpl, 
OnHScroll ) );
             m_pHScroll->Show();
         }
@@ -417,9 +415,15 @@ namespace frm
         m_pViewport->SetPosSizePixel( Point( nOffset, nOffset ), 
aViewportSizePixel );
         // position the scrollbars
         if ( m_pVScroll )
+        {
+            m_pVScroll->SetThickness(nScrollBarWidth);
             m_pVScroll->SetPosSizePixel( Point( 
aViewportPlaygroundPixel.Width(), 0 ), Size( nScrollBarWidth, 
aViewportPlaygroundPixel.Height() ) );
+        }
         if ( m_pHScroll )
+        {
+            m_pHScroll->SetThickness(nScrollBarHeight);
             m_pHScroll->SetPosSizePixel( Point( 0, 
aViewportPlaygroundPixel.Height() ), Size( aViewportPlaygroundPixel.Width(), 
nScrollBarHeight ) );
+        }
         if ( m_pScrollCorner )
             m_pScrollCorner->SetPosSizePixel( Point( 
aViewportPlaygroundPixel.Width(), aViewportPlaygroundPixel.Height() ), Size( 
nScrollBarWidth, nScrollBarHeight ) );
 
diff --git a/forms/source/richtext/richtextimplcontrol.hxx 
b/forms/source/richtext/richtextimplcontrol.hxx
index d4fef2f66806..f1cbb81ffe22 100644
--- a/forms/source/richtext/richtextimplcontrol.hxx
+++ b/forms/source/richtext/richtextimplcontrol.hxx
@@ -21,6 +21,7 @@
 #include "rtattributehandler.hxx"
 #include "richtextviewport.hxx"
 #include "richtextengine.hxx"
+#include <svtools/scrolladaptor.hxx>
 #include <vcl/scrbar.hxx>
 #include <editeng/editdata.hxx>
 
@@ -53,8 +54,8 @@ namespace frm
 
         VclPtr<Control>                m_pAntiImpl;
         VclPtr<RichTextViewPort>       m_pViewport;
-        VclPtr<ScrollBar>              m_pHScroll;
-        VclPtr<ScrollBar>              m_pVScroll;
+        VclPtr<ScrollAdaptor>          m_pHScroll;
+        VclPtr<ScrollAdaptor>          m_pVScroll;
         VclPtr<ScrollBarBox>           m_pScrollCorner;
         RichTextEngine*         m_pEngine;
         std::unique_ptr<EditView> m_pView;
@@ -173,8 +174,8 @@ namespace frm
 
     private:
         DECL_LINK( OnInvalidateAllAttributes, LinkParamNone*, void );
-        DECL_LINK( OnHScroll, ScrollBar*, void );
-        DECL_LINK( OnVScroll, ScrollBar*, void );
+        DECL_LINK( OnHScroll, weld::Scrollbar&, void );
+        DECL_LINK( OnVScroll, weld::Scrollbar&, void );
     };
 
 

Reply via email to