tdf#117388 use native scrollbar under gtk in basic editor

Change-Id: Id8f2b4fdc40116bb28053dc6fbbf6fa86e6808fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137862
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2022-08-05 11:37:48 +01:00
parent f5109c38e2
commit 5ae01ffa70
13 changed files with 60 additions and 62 deletions

View File

@@ -1164,7 +1164,7 @@ void ModulWindow::GetState( SfxItemSet &rSet )
}
}
void ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
void ModulWindow::DoScroll( Scrollable* pCurScrollBar )
{
if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() )
{

View File

@@ -32,6 +32,7 @@
#include <vcl/weld.hxx>
#include <svtools/colorcfg.hxx>
#include <svtools/scrolladaptor.hxx>
#include <o3tl/enumarray.hxx>
#include <rtl/ustrbuf.hxx>
@@ -253,12 +254,12 @@ private:
VclPtr<BreakPointWindow> aBrkWindow;
VclPtr<LineNumberWindow> aLineNumberWindow;
VclPtr<EditorWindow> aEdtWindow;
VclPtr<ScrollBar> aEWVScrollBar;
VclPtr<ScrollAdaptor> aEWVScrollBar;
virtual void DataChanged(DataChangedEvent const & rDCEvt) override;
virtual void Resize() override;
DECL_LINK( ScrollHdl, ScrollBar*, void );
DECL_LINK(ScrollHdl, weld::Scrollbar&, void);
public:
explicit ComplexEditorWindow( ModulWindow* pParent );
@@ -267,7 +268,7 @@ public:
BreakPointWindow& GetBrkWindow() { return *aBrkWindow; }
LineNumberWindow& GetLineNumberWindow() { return *aLineNumberWindow; }
EditorWindow& GetEdtWindow() { return *aEdtWindow; }
ScrollBar& GetEWVScrollBar() { return *aEWVScrollBar; }
ScrollAdaptor& GetEWVScrollBar() { return *aEWVScrollBar; }
void SetLineNumberDisplay(bool b);
};
@@ -294,7 +295,7 @@ protected:
virtual void GetFocus() override;
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
virtual void DoInit() override;
virtual void DoScroll( ScrollBar* pCurScrollBar ) override;
virtual void DoScroll(Scrollable* pCurScrollBar) override;
public:
ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, const OUString& aLibName, const OUString& aName, OUString aModule );
@@ -360,7 +361,7 @@ public:
EditorWindow& GetEditorWindow() { return m_aXEditorWindow->GetEdtWindow(); }
BreakPointWindow& GetBreakPointWindow() { return m_aXEditorWindow->GetBrkWindow(); }
LineNumberWindow& GetLineNumberWindow() { return m_aXEditorWindow->GetLineNumberWindow(); }
ScrollBar& GetEditVScrollBar() { return m_aXEditorWindow->GetEWVScrollBar(); }
ScrollAdaptor& GetEditVScrollBar() { return m_aXEditorWindow->GetEWVScrollBar(); }
ExtTextEngine* GetEditEngine() { return GetEditorWindow().GetEditEngine(); }
TextView* GetEditView() { return GetEditorWindow().GetEditView(); }
BreakPointList& GetBreakPoints() { return GetBreakPointWindow().GetBreakPoints(); }

View File

@@ -1940,7 +1940,7 @@ ComplexEditorWindow::ComplexEditorWindow( ModulWindow* pParent ) :
aBrkWindow(VclPtr<BreakPointWindow>::Create(this, pParent)),
aLineNumberWindow(VclPtr<LineNumberWindow>::Create(this, pParent)),
aEdtWindow(VclPtr<EditorWindow>::Create(this, pParent)),
aEWVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG) )
aEWVScrollBar( VclPtr<ScrollAdaptor>::Create(this, false) )
{
aEdtWindow->Show();
aBrkWindow->Show();
@@ -1995,17 +1995,16 @@ void ComplexEditorWindow::Resize()
aEWVScrollBar->SetPosSizePixel( Point( aOutSz.Width() - DWBORDER - nSBWidth, DWBORDER ), Size( nSBWidth, aSz.Height() ) );
}
IMPL_LINK(ComplexEditorWindow, ScrollHdl, ScrollBar *, pCurScrollBar, void )
IMPL_LINK_NOARG(ComplexEditorWindow, ScrollHdl, weld::Scrollbar&, void)
{
if (aEdtWindow->GetEditView())
{
DBG_ASSERT( pCurScrollBar == aEWVScrollBar.get(), "Who is scrolling?" );
tools::Long nDiff = aEdtWindow->GetEditView()->GetStartDocPos().Y() - pCurScrollBar->GetThumbPos();
tools::Long nDiff = aEdtWindow->GetEditView()->GetStartDocPos().Y() - aEWVScrollBar->GetThumbPos();
aEdtWindow->GetEditView()->Scroll( 0, nDiff );
aBrkWindow->DoScroll( nDiff );
aLineNumberWindow->DoScroll( nDiff );
aEdtWindow->GetEditView()->ShowCursor(false);
pCurScrollBar->SetThumbPos( aEdtWindow->GetEditView()->GetStartDocPos().Y() );
aEWVScrollBar->SetThumbPos( aEdtWindow->GetEditView()->GetStartDocPos().Y() );
}
}

View File

@@ -237,7 +237,7 @@ void DialogWindow::DoInit()
m_pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
}
void DialogWindow::DoScroll( ScrollBar* )
void DialogWindow::DoScroll( Scrollable* )
{
m_pEditor->DoScroll();
}

View File

@@ -159,8 +159,8 @@ unsigned Shell::nShellCount = 0;
Shell::Shell( SfxViewFrame* pFrame_, SfxViewShell* /* pOldShell */ ) :
SfxViewShell( pFrame_, SfxViewShellFlags::NO_NEWWINDOW ),
m_aCurDocument( ScriptDocument::getApplicationScriptDocument() ),
aHScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_HSCROLL | WB_DRAG )) ),
aVScrollBar( VclPtr<ScrollBar>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_VSCROLL | WB_DRAG )) ),
aHScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame()->GetWindow(), true) ),
aVScrollBar( VclPtr<ScrollAdaptor>::Create(&GetViewFrame()->GetWindow(), false) ),
aScrollBarBox( VclPtr<ScrollBarBox>::Create(&GetViewFrame()->GetWindow(), WinBits( WB_SIZEABLE )) ),
pLayout(nullptr),
aObjectCatalog(VclPtr<ObjectCatalog>::Create(&GetViewFrame()->GetWindow())),

View File

@@ -72,49 +72,51 @@ BaseWindow::~BaseWindow()
void BaseWindow::dispose()
{
if ( pShellVScrollBar )
pShellVScrollBar->SetScrollHdl( Link<ScrollBar*,void>() );
if ( pShellHScrollBar )
pShellHScrollBar->SetScrollHdl( Link<ScrollBar*,void>() );
if (pShellVScrollBar && !pShellVScrollBar>isDisposed())
pShellVScrollBar->SetScrollHdl( Link<weld::Scrollbar&,void>() );
if (pShellHScrollBar && !pShellHScrollBar->isDisposed())
pShellHScrollBar->SetScrollHdl( Link<weld::Scrollbar&,void>() );
pShellVScrollBar.clear();
pShellHScrollBar.clear();
vcl::Window::dispose();
}
void BaseWindow::Init()
{
if ( pShellVScrollBar )
pShellVScrollBar->SetScrollHdl( LINK( this, BaseWindow, ScrollHdl ) );
pShellVScrollBar->SetScrollHdl( LINK( this, BaseWindow, VertScrollHdl ) );
if ( pShellHScrollBar )
pShellHScrollBar->SetScrollHdl( LINK( this, BaseWindow, ScrollHdl ) );
pShellHScrollBar->SetScrollHdl( LINK( this, BaseWindow, HorzScrollHdl ) );
DoInit(); // virtual...
}
void BaseWindow::DoInit()
{ }
{
}
void BaseWindow::GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll )
void BaseWindow::GrabScrollBars(ScrollAdaptor* pHScroll, ScrollAdaptor* pVScroll)
{
pShellHScrollBar = pHScroll;
pShellVScrollBar = pVScroll;
// Init(); // does not make sense, leads to flickering and errors...
}
IMPL_LINK( BaseWindow, ScrollHdl, ScrollBar *, pCurScrollBar, void )
IMPL_LINK_NOARG(BaseWindow, VertScrollHdl, weld::Scrollbar&, void)
{
DoScroll( pCurScrollBar );
DoScroll(pShellVScrollBar);
}
IMPL_LINK_NOARG(BaseWindow, HorzScrollHdl, weld::Scrollbar&, void)
{
DoScroll(pShellHScrollBar);
}
void BaseWindow::ExecuteCommand (SfxRequest&)
{ }
{
}
void BaseWindow::ExecuteGlobal (SfxRequest&)
{ }
{
}
bool BaseWindow::EventNotify( NotifyEvent& rNEvt )
{
@@ -145,12 +147,10 @@ bool BaseWindow::EventNotify( NotifyEvent& rNEvt )
return bDone || Window::EventNotify( rNEvt );
}
void BaseWindow::DoScroll( ScrollBar* )
void BaseWindow::DoScroll( Scrollable* )
{
}
void BaseWindow::StoreData()
{
}
@@ -160,7 +160,6 @@ bool BaseWindow::AllowUndo()
return true;
}
void BaseWindow::UpdateData()
{
}

View File

@@ -237,7 +237,6 @@ DlgEditor::DlgEditor (
SetDialog(xDialogModel);
}
DlgEditor::~DlgEditor()
{
aMarkIdle.Stop();
@@ -245,7 +244,6 @@ DlgEditor::~DlgEditor()
::comphelper::disposeComponent( m_xControlContainer );
}
Reference< awt::XControlContainer > const & DlgEditor::GetWindowControlContainer()
{
if (!m_xControlContainer.is())
@@ -253,8 +251,7 @@ Reference< awt::XControlContainer > const & DlgEditor::GetWindowControlContainer
return m_xControlContainer;
}
void DlgEditor::SetScrollBars( ScrollBar* pHS, ScrollBar* pVS )
void DlgEditor::SetScrollBars(ScrollAdaptor* pHS, ScrollAdaptor* pVS)
{
pHScroll = pHS;
pVScroll = pVS;
@@ -262,7 +259,6 @@ void DlgEditor::SetScrollBars( ScrollBar* pHS, ScrollBar* pVS )
InitScrollBars();
}
void DlgEditor::InitScrollBars()
{
DBG_ASSERT( pHScroll, "DlgEditor::InitScrollBars: no horizontal scroll bar!" );

View File

@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <vcl/scrbar.hxx>
#include <svtools/scrolladaptor.hxx>
#include <svx/svdview.hxx>
#include <dlgedfunc.hxx>
#include <dlged.hxx>
@@ -45,8 +45,8 @@ void DlgEdFunc::ForceScroll( const Point& rPos )
tools::Rectangle aOutRect( aDefPoint, rWindow.GetOutputSizePixel() );
aOutRect = rWindow.PixelToLogic( aOutRect );
ScrollBar* pHScroll = rParent.GetHScroll();
ScrollBar* pVScroll = rParent.GetVScroll();
ScrollAdaptor* pHScroll = rParent.GetHScroll();
ScrollAdaptor* pVScroll = rParent.GetVScroll();
tools::Long nDeltaX = pHScroll->GetLineSize();
tools::Long nDeltaY = pVScroll->GetLineSize();
@@ -294,7 +294,7 @@ bool DlgEdFunc::KeyInput( const KeyEvent& rKEvt )
else
{
// scroll page
ScrollBar* pScrollBar = ( nX != 0 ) ? rParent.GetHScroll() : rParent.GetVScroll();
ScrollAdaptor* pScrollBar = ( nX != 0 ) ? rParent.GetHScroll() : rParent.GetVScroll();
if ( pScrollBar )
{
tools::Long nRangeMin = pScrollBar->GetRangeMin();

View File

@@ -21,8 +21,8 @@
#include <dlged.hxx>
#include <dlgedpage.hxx>
#include <svtools/scrolladaptor.hxx>
#include <vcl/canvastools.hxx>
#include <vcl/scrbar.hxx>
#include <dlgedobj.hxx>

View File

@@ -67,7 +67,7 @@ protected:
static void NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> );
virtual void DoInit() override;
virtual void DoScroll( ScrollBar* pCurScrollBar ) override;
virtual void DoScroll( Scrollable* pCurScrollBar ) override;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
void InitSettings();

View File

@@ -26,6 +26,7 @@
#include <sfx2/viewsh.hxx>
#include <svx/ifaceids.hxx>
#include <svl/srchitem.hxx>
#include <svtools/scrolladaptor.hxx>
#include <vcl/scrbar.hxx>
#include <map>
#include <memory>
@@ -68,8 +69,8 @@ private:
OUString m_aCurLibName;
std::shared_ptr<LocalizationMgr> m_pCurLocalizationMgr;
VclPtr<ScrollBar> aHScrollBar;
VclPtr<ScrollBar> aVScrollBar;
VclPtr<ScrollAdaptor> aHScrollBar;
VclPtr<ScrollAdaptor> aVScrollBar;
VclPtr<ScrollBarBox> aScrollBarBox;
VclPtr<TabBar> pTabBar; // basctl::TabBar
bool bCreatingWindow;

View File

@@ -21,6 +21,7 @@
#include "scriptdocument.hxx"
#include "sbxitem.hxx"
#include <svtools/scrolladaptor.hxx>
#include <svtools/tabbar.hxx>
#include <basic/sbdef.hxx>
#include <vcl/dockwin.hxx>
@@ -155,10 +156,11 @@ class EntryDescriptor;
class BaseWindow : public vcl::Window
{
private:
VclPtr<ScrollBar> pShellHScrollBar;
VclPtr<ScrollBar> pShellVScrollBar;
VclPtr<ScrollAdaptor> pShellHScrollBar;
VclPtr<ScrollAdaptor> pShellVScrollBar;
DECL_LINK( ScrollHdl, ScrollBar*, void );
DECL_LINK( VertScrollHdl, weld::Scrollbar&, void );
DECL_LINK( HorzScrollHdl, weld::Scrollbar&, void );
int nStatus;
ScriptDocument m_aDocument;
@@ -169,7 +171,7 @@ private:
friend class DialogWindow;
protected:
virtual void DoScroll( ScrollBar* pCurScrollBar );
virtual void DoScroll(Scrollable* pCurScrollBar);
public:
BaseWindow( vcl::Window* pParent, ScriptDocument aDocument, OUString aLibName, OUString aName );
@@ -180,10 +182,10 @@ public:
virtual void DoInit();
virtual void Activating () = 0;
virtual void Deactivating () = 0;
void GrabScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
void GrabScrollBars(ScrollAdaptor* pHScroll, ScrollAdaptor* pVScroll);
ScrollBar* GetHScrollBar() const { return pShellHScrollBar; }
ScrollBar* GetVScrollBar() const { return pShellVScrollBar; }
ScrollAdaptor* GetHScrollBar() const { return pShellHScrollBar; }
ScrollAdaptor* GetVScrollBar() const { return pShellVScrollBar; }
virtual void ExecuteCommand (SfxRequest&);
virtual void ExecuteGlobal (SfxRequest&);

View File

@@ -36,7 +36,7 @@
#include <memory>
class ScrollBar;
class ScrollAdaptor;
class Printer;
class KeyEvent;
class MouseEvent;
@@ -107,8 +107,8 @@ private:
static void Print( Printer* pPrinter, const OUString& rTitle );
private:
VclPtr<ScrollBar> pHScroll;
VclPtr<ScrollBar> pVScroll;
VclPtr<ScrollAdaptor> pHScroll;
VclPtr<ScrollAdaptor> pVScroll;
std::unique_ptr<DlgEdModel> pDlgEdModel; // never nullptr
DlgEdPage* pDlgEdPage; // never nullptr
std::unique_ptr<DlgEdView> pDlgEdView; // never nullptr
@@ -149,10 +149,10 @@ public:
css::uno::Reference< css::awt::XControlContainer > const &
GetWindowControlContainer();
void SetScrollBars( ScrollBar* pHScroll, ScrollBar* pVScroll );
void SetScrollBars(ScrollAdaptor* pHScroll, ScrollAdaptor* pVScroll);
void InitScrollBars();
ScrollBar* GetHScroll() const { return pHScroll; }
ScrollBar* GetVScroll() const { return pVScroll; }
ScrollAdaptor* GetHScroll() const { return pHScroll; }
ScrollAdaptor* GetVScroll() const { return pVScroll; }
void DoScroll();
void UpdateScrollBars();