summaryrefslogtreecommitdiff
path: root/toolkit/source/awt/scrollabledialog.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/source/awt/scrollabledialog.cxx')
-rw-r--r--toolkit/source/awt/scrollabledialog.cxx90
1 files changed, 54 insertions, 36 deletions
diff --git a/toolkit/source/awt/scrollabledialog.cxx b/toolkit/source/awt/scrollabledialog.cxx
index 202a561cfaf1..fbea906b16a0 100644
--- a/toolkit/source/awt/scrollabledialog.cxx
+++ b/toolkit/source/awt/scrollabledialog.cxx
@@ -1,15 +1,18 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#include <toolkit/awt/scrollabledialog.hxx>
+#include <vcl/group.hxx>
+
namespace toolkit
{
-ScrollableDialog::ScrollableDialog( Window* pParent, WinBits nStyle ) : Dialog( pParent, nStyle | ~( WB_HSCROLL | WB_VSCROLL ) ), maHScrollBar( this, WB_HSCROLL | WB_DRAG), maVScrollBar( this, WB_VSCROLL | WB_DRAG ), mbHasHoriBar( false ), mbHasVertBar( false ), maScrollVis( None )
+template< class T>
+ScrollableDialog<T>::ScrollableDialog( Window* pParent, WinBits nStyle ) : T( pParent, nStyle | ~( WB_HSCROLL | WB_VSCROLL ) ), maHScrollBar( this, WB_HSCROLL | WB_DRAG), maVScrollBar( this, WB_VSCROLL | WB_DRAG ), mbHasHoriBar( false ), mbHasVertBar( false ), maScrollVis( None )
{
Link aLink( LINK( this, ScrollableDialog, ScrollBarHdl ) );
maVScrollBar.SetScrollHdl( aLink );
maHScrollBar.SetScrollHdl( aLink );
- Size aOutSz = GetOutputSizePixel();
+ Size aOutSz = T::GetOutputSizePixel();
ScrollBarVisibility aVis = None;
if ( nStyle & ( WB_HSCROLL | WB_VSCROLL ) )
@@ -25,46 +28,51 @@ ScrollableDialog::ScrollableDialog( Window* pParent, WinBits nStyle ) : Dialog(
}
}
setScrollVisibility( aVis );
- mnScrWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
+ mnScrWidth = T::GetSettings().GetStyleSettings().GetScrollBarSize();
}
-void ScrollableDialog::setScrollVisibility( ScrollBarVisibility rVisState )
+template< class T>
+void ScrollableDialog<T>::setScrollVisibility( ScrollBarVisibility rVisState )
{
maScrollVis = rVisState;
if ( maScrollVis == Hori || maScrollVis == Both )
+ {
mbHasHoriBar = true;
+ maHScrollBar.Show();
+ }
if ( maScrollVis == Vert || maScrollVis == Both )
+ {
mbHasVertBar = true;
- if ( mbHasVertBar )
maVScrollBar.Show();
- if ( mbHasHoriBar )
- maHScrollBar.Show();
+ }
if ( mbHasHoriBar || mbHasVertBar )
- SetStyle( GetStyle() | WB_CLIPCHILDREN | SCROLL_UPDATE );
+ SetStyle( T::GetStyle() | WB_CLIPCHILDREN | SCROLL_UPDATE );
}
-ScrollableDialog::~ScrollableDialog()
+template< class T>
+ScrollableDialog<T>::~ScrollableDialog()
{
}
-Window* ScrollableDialog::getContentWindow()
+template< class T>
+Window* ScrollableDialog<T>::getContentWindow()
{
return this;
}
-void ScrollableDialog::lcl_Scroll( long nX, long nY )
+template< class T>
+void ScrollableDialog<T>::lcl_Scroll( long nX, long nY )
{
long nXScroll = mnScrollPos.X() - nX;
long nYScroll = mnScrollPos.Y() - nY;
- printf( "ScrollableDialog::lcl_Scroll %d, %d resulting in delta nXScroll %d, nYScroll %d for ( %d ) children\n", nX, nY, nXScroll, nYScroll, GetChildCount() -2 );
mnScrollPos = Point( nX, nY );
Rectangle aScrollableArea( 0, 0, maScrollArea.Width(), maScrollArea.Height() );
- Window::Scroll(nXScroll, nYScroll, aScrollableArea );
+ T::Scroll(nXScroll, nYScroll, aScrollableArea );
// Manually scroll all children ( except the scrollbars )
- for ( int index = 0; index < GetChildCount(); ++index )
+ for ( int index = 0; index < T::GetChildCount(); ++index )
{
- Window* pChild = GetChild( index );
+ Window* pChild = T::GetChild( index );
if ( pChild && pChild != &maVScrollBar && pChild != &maHScrollBar )
{
Point aPos = pChild->GetPosPixel();
@@ -74,7 +82,17 @@ void ScrollableDialog::lcl_Scroll( long nX, long nY )
}
}
-IMPL_LINK( ScrollableDialog, ScrollBarHdl, ScrollBar*, pSB )
+//Can't use IMPL_LINK with the template
+//IMPL_LINK( ScrollableDialog, ScrollBarHdl, ScrollBar*, pSB )
+
+template< class T>
+long ScrollableDialog<T>::LinkStubScrollBarHdl( void* pThis, void* pCaller)
+{
+ return ((ScrollableDialog<T>*)pThis )->ScrollBarHdl( (ScrollBar*)pCaller );
+}
+
+template< class T>
+long ScrollableDialog<T>::ScrollBarHdl( ScrollBar* pSB )
{
sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos();
if( pSB == &maVScrollBar )
@@ -84,64 +102,64 @@ IMPL_LINK( ScrollableDialog, ScrollBarHdl, ScrollBar*, pSB )
return 1;
}
-void ScrollableDialog::SetScrollTop( long nTop )
+template< class T>
+void ScrollableDialog<T>::SetScrollTop( long nTop )
{
- printf("ScrollableDialog::SetScrollTop(%d)\n", nTop );
Point aOld = mnScrollPos;
lcl_Scroll( mnScrollPos.X() , mnScrollPos.Y() - nTop );
- printf("about to set thumb\n");
maHScrollBar.SetThumbPos( 0 );
// new pos is 0,0
mnScrollPos = aOld;
}
-void ScrollableDialog::SetScrollLeft( long nLeft )
+template< class T>
+void ScrollableDialog<T>::SetScrollLeft( long nLeft )
{
- printf("ScrollableDialog::SetScrollLeft(%d)\n", nLeft );
Point aOld = mnScrollPos;
lcl_Scroll( mnScrollPos.X() - nLeft , mnScrollPos.Y() );
- printf("about to set thumb\n");
maVScrollBar.SetThumbPos( 0 );
// new pos is 0,0
mnScrollPos = aOld;
}
-void ScrollableDialog::SetScrollWidth( long nWidth )
+template< class T>
+void ScrollableDialog<T>::SetScrollWidth( long nWidth )
{
- printf("ScrollableDialog::SetScrollWidth(%d)\n", nWidth );
maScrollArea.Width() = nWidth;
ResetScrollBars();
}
-void ScrollableDialog::SetScrollHeight( long nHeight )
+template< class T>
+void ScrollableDialog<T>::SetScrollHeight( long nHeight )
{
- printf("ScrollableDialog::SetScrollHeight(%d)\n", nHeight );
maScrollArea.Height() = nHeight;
ResetScrollBars();
}
-void ScrollableDialog::Resize()
+template< class T>
+void ScrollableDialog<T>::Resize()
{
ResetScrollBars();
}
-void ScrollableDialog::ResetScrollBars()
+template< class T>
+void ScrollableDialog<T>::ResetScrollBars()
{
- Size aOutSz = GetOutputSizePixel();
- printf("ScrollableDialog::ResetScrollbars() - size is width %d height %d\n", GetSizePixel().Width(), GetSizePixel().Height() );
+ Size aOutSz = T::GetOutputSizePixel();
Point aVPos( aOutSz.Width() - mnScrWidth, 0 );
Point aHPos( 0, aOutSz.Height() - mnScrWidth );
- maVScrollBar.SetPosSizePixel( aVPos, Size( mnScrWidth, GetSizePixel().Height() - mnScrWidth ) );
- maHScrollBar.SetPosSizePixel( aHPos, Size( GetSizePixel().Width() - mnScrWidth, mnScrWidth ) );
+ maVScrollBar.SetPosSizePixel( aVPos, Size( mnScrWidth, T::GetSizePixel().Height() - mnScrWidth ) );
+ maHScrollBar.SetPosSizePixel( aHPos, Size( T::GetSizePixel().Width() - mnScrWidth, mnScrWidth ) );
maHScrollBar.SetRangeMax( maScrollArea.Width() + mnScrWidth );
- maHScrollBar.SetVisibleSize( GetSizePixel().Width() );
-// maHScrollBar.SetPageSize( maScrollArea.Height() );
+ maHScrollBar.SetVisibleSize( T::GetSizePixel().Width() );
maVScrollBar.SetRangeMax( maScrollArea.Height() + mnScrWidth );
- maVScrollBar.SetVisibleSize( GetSizePixel().Height() );
-// maVScrollBar.SetPageSize( maScrollArea.Width() );
+ maVScrollBar.SetVisibleSize( T::GetSizePixel().Height() );
}
+template class ScrollableDialog< Dialog >;
+template class ScrollableDialog< GroupBox >;
+
} // toolkit
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */