summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2020-11-11 03:06:46 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-11-12 01:56:42 +0100
commita874f1e6d4b3195885f440e2aaf2c848db435985 (patch)
tree6bc1368568e8d1bf41ef6cfe2ae6c144faba34ad
parentf74deaaeeed314a761443dd3d4a1cf04bca31c16 (diff)
Create tabpage scrollbars only on demand
Otherwise glade-ui code gets confused to find controls it never generated. Change-Id: Iaf9a6e6aa5080f7a49bb754fe967e6a85e80cfae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105572 Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--include/vcl/tabpage.hxx3
-rw-r--r--vcl/source/window/tabpage.cxx76
2 files changed, 35 insertions, 44 deletions
diff --git a/include/vcl/tabpage.hxx b/include/vcl/tabpage.hxx
index 10fe3d588ee3..e69c45585b74 100644
--- a/include/vcl/tabpage.hxx
+++ b/include/vcl/tabpage.hxx
@@ -48,8 +48,6 @@ private:
bool mbHasVertBar;
Point mnScrollPos;
long mnScrWidth;
- enum ScrollBarVisibility { None, Vert, Hori, Both };
- ScrollBarVisibility maScrollVis;
public:
explicit TabPage( vcl::Window* pParent, WinBits nStyle = 0 );
@@ -78,7 +76,6 @@ public:
void SetScrollHeight( long nHeight );
void SetScrollLeft( long nLeft );
void SetScrollTop( long Top );
- void setScrollVisibility( ScrollBarVisibility rState );
void ResetScrollBars();
};
diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx
index f411c94aa4e2..ce98bee73e64 100644
--- a/vcl/source/window/tabpage.cxx
+++ b/vcl/source/window/tabpage.cxx
@@ -32,35 +32,41 @@ void TabPage::ImplInit( vcl::Window* pParent, WinBits nStyle )
Window::ImplInit( pParent, nStyle, nullptr );
- ImplInitSettings();
-
- m_pVScroll.set(VclPtr<ScrollBar>::Create(this, ((nStyle & WB_VSCROLL) ? WB_HIDE : 0) | WB_VSCROLL | WB_DRAG));
- m_pHScroll.set(VclPtr<ScrollBar>::Create(this, ((nStyle & WB_HSCROLL) ? WB_HIDE : 0) | WB_HSCROLL | WB_DRAG));
- m_aScrollBarBox.set(
- VclPtr<ScrollBarBox>::Create(this,
- ((nStyle & (WB_VSCROLL|WB_HSCROLL)) ? WB_HIDE : 0)));
mbHasHoriBar = false;
mbHasVertBar = false;
- ScrollBarVisibility aVis = None;
+
+ Link<ScrollBar*,void> aLink( LINK( this, TabPage, ScrollBarHdl ) );
if ( nStyle & ( WB_AUTOHSCROLL | WB_AUTOVSCROLL ) )
{
if ( nStyle & WB_AUTOHSCROLL )
- aVis = Hori;
+ {
+ mbHasHoriBar = true;
+ m_pHScroll.set(VclPtr<ScrollBar>::Create(this, (WB_HSCROLL | WB_DRAG)));
+ m_pHScroll->Show();
+ m_pHScroll->SetScrollHdl(aLink);
+ }
if ( nStyle & WB_AUTOVSCROLL )
{
- if ( aVis == Hori )
- aVis = Both;
- else
- aVis = Vert;
+ mbHasVertBar = true;
+ m_pVScroll.set(VclPtr<ScrollBar>::Create(this, (WB_VSCROLL | WB_DRAG)));
+ m_pVScroll->Show();
+ m_pVScroll->SetScrollHdl(aLink);
}
}
- setScrollVisibility( aVis );
+
+ if ( mbHasHoriBar || mbHasVertBar )
+ {
+ m_aScrollBarBox.set(
+ VclPtr<ScrollBarBox>::Create(this,
+ ((nStyle & (WB_VSCROLL|WB_HSCROLL)) ? WB_HIDE : 0)));
+ m_aScrollBarBox->Show();
+ SetStyle( GetStyle() | WB_CLIPCHILDREN );
+ }
+
mnScrWidth = Application::GetSettings().GetStyleSettings().GetScrollBarSize();
- Link<ScrollBar*,void> aLink( LINK( this, TabPage, ScrollBarHdl ) );
- m_pVScroll->SetScrollHdl(aLink);
- m_pHScroll->SetScrollHdl(aLink);
+ ImplInitSettings();
// if the tabpage is drawn (ie filled) by a native widget, make sure all controls will have transparent background
// otherwise they will paint with a wrong background
@@ -235,23 +241,6 @@ void TabPage::SetPosPixel(const Point& rAllocPos)
}
}
-void TabPage::setScrollVisibility( ScrollBarVisibility rVisState )
-{
- maScrollVis = rVisState;
- if ( maScrollVis == Hori || maScrollVis == Both )
- {
- mbHasHoriBar = true;
- m_pHScroll->Show();
- }
- if ( maScrollVis == Vert || maScrollVis == Both )
- {
- mbHasVertBar = true;
- m_pVScroll->Show();
- }
- if ( mbHasHoriBar || mbHasVertBar )
- SetStyle( GetStyle() | WB_CLIPCHILDREN );
-}
-
void TabPage::lcl_Scroll( long nX, long nY )
{
long nXScroll = mnScrollPos.X() - nX;
@@ -323,14 +312,19 @@ void TabPage::ResetScrollBars()
Point aVPos( aOutSz.Width() - mnScrWidth, 0 );
Point aHPos( 0, aOutSz.Height() - mnScrWidth );
- m_pVScroll->SetPosSizePixel( aVPos, Size( mnScrWidth, GetSizePixel().Height() - mnScrWidth ) );
- m_pHScroll->SetPosSizePixel( aHPos, Size( GetSizePixel().Width() - mnScrWidth, mnScrWidth ) );
-
- m_pHScroll->SetRangeMax( maScrollArea.Width() + mnScrWidth );
- m_pHScroll->SetVisibleSize( GetSizePixel().Width() );
+ if( m_pVScroll )
+ {
+ m_pVScroll->SetPosSizePixel( aVPos, Size( mnScrWidth, GetSizePixel().Height() - mnScrWidth ) );
+ m_pVScroll->SetRangeMax( maScrollArea.Height() + mnScrWidth );
+ m_pVScroll->SetVisibleSize( GetSizePixel().Height() );
+ }
- m_pVScroll->SetRangeMax( maScrollArea.Height() + mnScrWidth );
- m_pVScroll->SetVisibleSize( GetSizePixel().Height() );
+ if( m_pHScroll )
+ {
+ m_pHScroll->SetPosSizePixel( aHPos, Size( GetSizePixel().Width() - mnScrWidth, mnScrWidth ) );
+ m_pHScroll->SetRangeMax( maScrollArea.Width() + mnScrWidth );
+ m_pHScroll->SetVisibleSize( GetSizePixel().Width() );
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */