Kaydet (Commit) f9fd6390 authored tarafından Noel Grandin's avatar Noel Grandin

ScrollableWrapper -> ScrollableDialog

no point in having a template and a virtual base class when it's only
used for one type

Change-Id: Idb1a1a551064cc10896eff33652038eb5be0297e
Reviewed-on: https://gerrit.libreoffice.org/32041Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 2a79ec7f
...@@ -358,7 +358,6 @@ merge sw::mark::IBookmark with sw::mark::Bookmark ...@@ -358,7 +358,6 @@ merge sw::mark::IBookmark with sw::mark::Bookmark
merge sw::mark::ICheckboxFieldmark with sw::mark::CheckboxFieldmark merge sw::mark::ICheckboxFieldmark with sw::mark::CheckboxFieldmark
merge sw::sidebarwindows::SwSidebarWin with sw::annotation::SwAnnotationWin merge sw::sidebarwindows::SwSidebarWin with sw::annotation::SwAnnotationWin
merge sw::util::WrtRedlineAuthor with WW8_WrtRedlineAuthor merge sw::util::WrtRedlineAuthor with WW8_WrtRedlineAuthor
merge toolkit::ScrollableInterface with toolkit::ScrollableWrapper
merge unographic::GraphicTransformer with unographic::Graphic merge unographic::GraphicTransformer with unographic::Graphic
merge vcl::DeletionNotifier with SalFrame merge vcl::DeletionNotifier with SalFrame
merge vcl::ExtOutDevData with vcl::PDFExtOutDevData merge vcl::ExtOutDevData with vcl::PDFExtOutDevData
......
...@@ -26,19 +26,12 @@ ...@@ -26,19 +26,12 @@
namespace toolkit namespace toolkit
{ {
class ScrollableInterface class ScrollableDialog : public Dialog
{ {
public: public:
virtual ~ScrollableInterface() {} enum ScrollBarVisibility { None, Vert, Hori, Both };
virtual void SetScrollWidth( long nWidth ) = 0;
virtual void SetScrollHeight( long nHeight ) = 0;
virtual void SetScrollLeft( long nLeft ) = 0;
virtual void SetScrollTop( long Top ) = 0;
};
template < class T > private:
class ScrollableWrapper : public T, public ScrollableInterface
{
VclPtr<ScrollBar> maHScrollBar; VclPtr<ScrollBar> maHScrollBar;
VclPtr<ScrollBar> maVScrollBar; VclPtr<ScrollBar> maVScrollBar;
Size maScrollArea; Size maScrollArea;
...@@ -46,26 +39,24 @@ namespace toolkit ...@@ -46,26 +39,24 @@ namespace toolkit
bool mbHasVertBar; bool mbHasVertBar;
Point mnScrollPos; Point mnScrollPos;
long mnScrWidth; long mnScrWidth;
public:
enum ScrollBarVisibility { None, Vert, Hori, Both };
private:
ScrollBarVisibility maScrollVis; ScrollBarVisibility maScrollVis;
void lcl_Scroll( long nX, long nY ); void lcl_Scroll( long nX, long nY );
DECL_LINK( ScrollBarHdl, ScrollBar*, void );
public: public:
ScrollableWrapper( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, Dialog::InitFlag eFlag = Dialog::InitFlag::Default ); ScrollableDialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, Dialog::InitFlag eFlag = Dialog::InitFlag::Default );
virtual ~ScrollableWrapper() override; virtual ~ScrollableDialog() override;
virtual void dispose() override; virtual void dispose() override;
virtual void SetScrollWidth( long nWidth ) override;
virtual void SetScrollHeight( long nHeight ) override;
virtual void SetScrollLeft( long nLeft ) override;
virtual void SetScrollTop( long Top ) override;
void setScrollVisibility( ScrollBarVisibility rState );
DECL_LINK( ScrollBarHdl, ScrollBar*, void );
void ResetScrollBars();
// Window // Window
virtual void Resize() override; virtual void Resize() override;
void SetScrollWidth( long nWidth );
void SetScrollHeight( long nHeight );
void SetScrollLeft( long nLeft );
void SetScrollTop( long Top );
void setScrollVisibility( ScrollBarVisibility rState );
void ResetScrollBars();
}; };
} // namespacetoolkit } // namespacetoolkit
......
...@@ -30,16 +30,15 @@ namespace toolkit ...@@ -30,16 +30,15 @@ namespace toolkit
// as css::awt::WindowAttribute::NODECORATION and they are used // as css::awt::WindowAttribute::NODECORATION and they are used
// in the same bitmap :-( WB_VSCROLL & WB_HSCROLL apparently are only for // in the same bitmap :-( WB_VSCROLL & WB_HSCROLL apparently are only for
// child classes ( whole thing is a mess if you ask me ) // child classes ( whole thing is a mess if you ask me )
template< class T> ScrollableDialog::ScrollableDialog( vcl::Window* pParent, WinBits nStyle, Dialog::InitFlag eFlag )
ScrollableWrapper<T>::ScrollableWrapper( vcl::Window* pParent, WinBits nStyle, Dialog::InitFlag eFlag ) : Dialog( pParent, nStyle & ~( WB_AUTOHSCROLL | WB_AUTOVSCROLL ), eFlag ),
: T( pParent, nStyle & ~( WB_AUTOHSCROLL | WB_AUTOVSCROLL ), eFlag ),
maHScrollBar( VclPtr<ScrollBar>::Create(this, WB_HSCROLL | WB_DRAG) ), maHScrollBar( VclPtr<ScrollBar>::Create(this, WB_HSCROLL | WB_DRAG) ),
maVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG) ), maVScrollBar( VclPtr<ScrollBar>::Create(this, WB_VSCROLL | WB_DRAG) ),
mbHasHoriBar( false ), mbHasHoriBar( false ),
mbHasVertBar( false ), mbHasVertBar( false ),
maScrollVis( None ) maScrollVis( None )
{ {
Link<ScrollBar*,void> aLink( LINK( this, ScrollableWrapper, ScrollBarHdl ) ); Link<ScrollBar*,void> aLink( LINK( this, ScrollableDialog, ScrollBarHdl ) );
maVScrollBar->SetScrollHdl( aLink ); maVScrollBar->SetScrollHdl( aLink );
maHScrollBar->SetScrollHdl( aLink ); maHScrollBar->SetScrollHdl( aLink );
...@@ -58,11 +57,10 @@ ScrollableWrapper<T>::ScrollableWrapper( vcl::Window* pParent, WinBits nStyle, D ...@@ -58,11 +57,10 @@ ScrollableWrapper<T>::ScrollableWrapper( vcl::Window* pParent, WinBits nStyle, D
} }
} }
setScrollVisibility( aVis ); setScrollVisibility( aVis );
mnScrWidth = T::GetSettings().GetStyleSettings().GetScrollBarSize(); mnScrWidth = Dialog::GetSettings().GetStyleSettings().GetScrollBarSize();
} }
template< class T> void ScrollableDialog::setScrollVisibility( ScrollBarVisibility rVisState )
void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState )
{ {
maScrollVis = rVisState; maScrollVis = rVisState;
if ( maScrollVis == Hori || maScrollVis == Both ) if ( maScrollVis == Hori || maScrollVis == Both )
...@@ -76,36 +74,33 @@ void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState ) ...@@ -76,36 +74,33 @@ void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState )
maVScrollBar->Show(); maVScrollBar->Show();
} }
if ( mbHasHoriBar || mbHasVertBar ) if ( mbHasHoriBar || mbHasVertBar )
this->SetStyle( T::GetStyle() | WB_CLIPCHILDREN | WB_AUTOSIZE ); this->SetStyle( Dialog::GetStyle() | WB_CLIPCHILDREN | WB_AUTOSIZE );
} }
template< class T> ScrollableDialog::~ScrollableDialog()
ScrollableWrapper<T>::~ScrollableWrapper()
{ {
T::disposeOnce(); disposeOnce();
} }
template< class T> void ScrollableDialog::dispose()
void ScrollableWrapper<T>::dispose()
{ {
maHScrollBar.disposeAndClear(); maHScrollBar.disposeAndClear();
maVScrollBar.disposeAndClear(); maVScrollBar.disposeAndClear();
T::dispose(); Dialog::dispose();
} }
template< class T> void ScrollableDialog::lcl_Scroll( long nX, long nY )
void ScrollableWrapper<T>::lcl_Scroll( long nX, long nY )
{ {
long nXScroll = mnScrollPos.X() - nX; long nXScroll = mnScrollPos.X() - nX;
long nYScroll = mnScrollPos.Y() - nY; long nYScroll = mnScrollPos.Y() - nY;
mnScrollPos = Point( nX, nY ); mnScrollPos = Point( nX, nY );
Rectangle aScrollableArea( 0, 0, maScrollArea.Width(), maScrollArea.Height() ); Rectangle aScrollableArea( 0, 0, maScrollArea.Width(), maScrollArea.Height() );
T::Scroll(nXScroll, nYScroll, aScrollableArea ); Scroll(nXScroll, nYScroll, aScrollableArea );
// Manually scroll all children ( except the scrollbars ) // Manually scroll all children ( except the scrollbars )
for ( int index = 0; index < T::GetChildCount(); ++index ) for ( int index = 0; index < GetChildCount(); ++index )
{ {
vcl::Window* pChild = T::GetChild( index ); vcl::Window* pChild = GetChild( index );
if ( pChild && pChild != maVScrollBar.get() && pChild != maHScrollBar.get() ) if ( pChild && pChild != maVScrollBar.get() && pChild != maHScrollBar.get() )
{ {
Point aPos = pChild->GetPosPixel(); Point aPos = pChild->GetPosPixel();
...@@ -115,17 +110,7 @@ void ScrollableWrapper<T>::lcl_Scroll( long nX, long nY ) ...@@ -115,17 +110,7 @@ void ScrollableWrapper<T>::lcl_Scroll( long nX, long nY )
} }
} }
//Can't use IMPL_LINK with the template IMPL_LINK( ScrollableDialog, ScrollBarHdl, ScrollBar*, pSB, void )
//IMPL_LINK( ScrollableWrapper, ScrollBarHdl, ScrollBar*, pSB, void )
template< class T>
void ScrollableWrapper<T>::LinkStubScrollBarHdl( void* pThis, ScrollBar* pCaller)
{
static_cast<ScrollableWrapper<T>*>(pThis)->ScrollBarHdl( pCaller );
}
template< class T>
void ScrollableWrapper<T>::ScrollBarHdl( ScrollBar* pSB )
{ {
sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos(); sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos();
if( pSB == maVScrollBar.get() ) if( pSB == maVScrollBar.get() )
...@@ -134,8 +119,7 @@ void ScrollableWrapper<T>::ScrollBarHdl( ScrollBar* pSB ) ...@@ -134,8 +119,7 @@ void ScrollableWrapper<T>::ScrollBarHdl( ScrollBar* pSB )
lcl_Scroll(nPos, mnScrollPos.Y() ); lcl_Scroll(nPos, mnScrollPos.Y() );
} }
template< class T> void ScrollableDialog::SetScrollTop( long nTop )
void ScrollableWrapper<T>::SetScrollTop( long nTop )
{ {
Point aOld = mnScrollPos; Point aOld = mnScrollPos;
lcl_Scroll( mnScrollPos.X() , mnScrollPos.Y() - nTop ); lcl_Scroll( mnScrollPos.X() , mnScrollPos.Y() - nTop );
...@@ -143,8 +127,7 @@ void ScrollableWrapper<T>::SetScrollTop( long nTop ) ...@@ -143,8 +127,7 @@ void ScrollableWrapper<T>::SetScrollTop( long nTop )
// new pos is 0,0 // new pos is 0,0
mnScrollPos = aOld; mnScrollPos = aOld;
} }
template< class T> void ScrollableDialog::SetScrollLeft( long nLeft )
void ScrollableWrapper<T>::SetScrollLeft( long nLeft )
{ {
Point aOld = mnScrollPos; Point aOld = mnScrollPos;
lcl_Scroll( mnScrollPos.X() - nLeft , mnScrollPos.Y() ); lcl_Scroll( mnScrollPos.X() - nLeft , mnScrollPos.Y() );
...@@ -152,45 +135,40 @@ void ScrollableWrapper<T>::SetScrollLeft( long nLeft ) ...@@ -152,45 +135,40 @@ void ScrollableWrapper<T>::SetScrollLeft( long nLeft )
// new pos is 0,0 // new pos is 0,0
mnScrollPos = aOld; mnScrollPos = aOld;
} }
template< class T>
void ScrollableWrapper<T>::SetScrollWidth( long nWidth ) void ScrollableDialog::SetScrollWidth( long nWidth )
{ {
maScrollArea.Width() = nWidth; maScrollArea.Width() = nWidth;
ResetScrollBars(); ResetScrollBars();
} }
template< class T> void ScrollableDialog::SetScrollHeight( long nHeight )
void ScrollableWrapper<T>::SetScrollHeight( long nHeight )
{ {
maScrollArea.Height() = nHeight; maScrollArea.Height() = nHeight;
ResetScrollBars(); ResetScrollBars();
} }
template< class T> void ScrollableDialog::Resize()
void ScrollableWrapper<T>::Resize()
{ {
ResetScrollBars(); ResetScrollBars();
} }
template< class T> void ScrollableDialog::ResetScrollBars()
void ScrollableWrapper<T>::ResetScrollBars()
{ {
Size aOutSz = T::GetOutputSizePixel(); Size aOutSz = GetOutputSizePixel();
Point aVPos( aOutSz.Width() - mnScrWidth, 0 ); Point aVPos( aOutSz.Width() - mnScrWidth, 0 );
Point aHPos( 0, aOutSz.Height() - mnScrWidth ); Point aHPos( 0, aOutSz.Height() - mnScrWidth );
maVScrollBar->SetPosSizePixel( aVPos, Size( mnScrWidth, T::GetSizePixel().Height() - mnScrWidth ) ); maVScrollBar->SetPosSizePixel( aVPos, Size( mnScrWidth, GetSizePixel().Height() - mnScrWidth ) );
maHScrollBar->SetPosSizePixel( aHPos, Size( T::GetSizePixel().Width() - mnScrWidth, mnScrWidth ) ); maHScrollBar->SetPosSizePixel( aHPos, Size( GetSizePixel().Width() - mnScrWidth, mnScrWidth ) );
maHScrollBar->SetRangeMax( maScrollArea.Width() + mnScrWidth ); maHScrollBar->SetRangeMax( maScrollArea.Width() + mnScrWidth );
maHScrollBar->SetVisibleSize( T::GetSizePixel().Width() ); maHScrollBar->SetVisibleSize( GetSizePixel().Width() );
maVScrollBar->SetRangeMax( maScrollArea.Height() + mnScrWidth ); maVScrollBar->SetRangeMax( maScrollArea.Height() + mnScrWidth );
maVScrollBar->SetVisibleSize( T::GetSizePixel().Height() ); maVScrollBar->SetVisibleSize( GetSizePixel().Height() );
} }
template class ScrollableWrapper< Dialog >;
} // toolkit } // toolkit
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -245,7 +245,7 @@ throw(css::uno::RuntimeException, std::exception) ...@@ -245,7 +245,7 @@ throw(css::uno::RuntimeException, std::exception)
Size aSize( nVal, nVal ); Size aSize( nVal, nVal );
VclPtr<vcl::Window> pWindow = GetWindow(); VclPtr<vcl::Window> pWindow = GetWindow();
MapMode aMode( MapUnit::MapAppFont ); MapMode aMode( MapUnit::MapAppFont );
toolkit::ScrollableInterface* pScrollable = dynamic_cast< toolkit::ScrollableInterface* >( pWindow.get() ); toolkit::ScrollableDialog* pScrollable = dynamic_cast< toolkit::ScrollableDialog* >( pWindow.get() );
if ( pWindow && pScrollable ) if ( pWindow && pScrollable )
{ {
OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
......
...@@ -984,9 +984,9 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, ...@@ -984,9 +984,9 @@ vcl::Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
{ {
// Modal/Modeless nur durch Show/Execute // Modal/Modeless nur durch Show/Execute
if ( (pParent == nullptr ) && ( rDescriptor.ParentIndex == -1 ) ) if ( (pParent == nullptr ) && ( rDescriptor.ParentIndex == -1 ) )
pNewWindow = VclPtr<toolkit::ScrollableWrapper<Dialog>>::Create( nullptr, nWinBits, Dialog::InitFlag::NoParent ); pNewWindow = VclPtr<toolkit::ScrollableDialog>::Create( nullptr, nWinBits, Dialog::InitFlag::NoParent );
else else
pNewWindow = VclPtr<toolkit::ScrollableWrapper<Dialog>>::Create( pParent, nWinBits ); pNewWindow = VclPtr<toolkit::ScrollableDialog>::Create( pParent, nWinBits );
// #i70217# Don't always create a new component object. It's possible that VCL has called // #i70217# Don't always create a new component object. It's possible that VCL has called
// GetComponentInterface( sal_True ) in the Dialog ctor itself (see Window::IsTopWindow() ) // GetComponentInterface( sal_True ) in the Dialog ctor itself (see Window::IsTopWindow() )
// which creates a component object. // which creates a component object.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment