diff options
author | Noel Power <noel.power@suse.com> | 2012-09-06 19:25:12 +0100 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2012-09-11 16:04:11 +0100 |
commit | b241005c51a6705425937218e6893b4be2165128 (patch) | |
tree | 0b276704f86e49402beb48c6f7ca47db02c7bd0d /toolkit | |
parent | 27a19817c6271b76013aa6bda5c3353c8a9dd35b (diff) |
make interface for scrollablity properties to allow more code sharing
Change-Id: I0e03360808e73426848820d807f741c13c76abf8
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/inc/toolkit/awt/scrollabledialog.hxx | 37 | ||||
-rw-r--r-- | toolkit/inc/toolkit/awt/vclxcontainer.hxx | 3 | ||||
-rw-r--r-- | toolkit/source/awt/scrollabledialog.cxx | 40 | ||||
-rw-r--r-- | toolkit/source/awt/vclxcontainer.cxx | 58 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 4 | ||||
-rw-r--r-- | toolkit/source/awt/vclxwindows.cxx | 84 |
6 files changed, 106 insertions, 120 deletions
diff --git a/toolkit/inc/toolkit/awt/scrollabledialog.hxx b/toolkit/inc/toolkit/awt/scrollabledialog.hxx index 01ba525dbdcf..19b0ab0c799b 100644 --- a/toolkit/inc/toolkit/awt/scrollabledialog.hxx +++ b/toolkit/inc/toolkit/awt/scrollabledialog.hxx @@ -34,8 +34,21 @@ //........................................................................ namespace toolkit { + class ScrollableInterface + { + public: + virtual void SetScrollWidth( long nWidth ) = 0; + virtual long GetScrollWidth() = 0; + virtual void SetScrollHeight( long nHeight ) = 0; + virtual long GetScrollHeight() = 0; + virtual void SetScrollLeft( long nLeft ) = 0; + virtual long GetScrollLeft() = 0; + virtual void SetScrollTop( long Top ) = 0; + virtual long GetScrollTop() = 0; + }; + template < class T > - class ScrollableDialog : public T + class ScrollableWrapper : public T, public ScrollableInterface { ScrollBar maHScrollBar; ScrollBar maVScrollBar; @@ -51,17 +64,17 @@ namespace toolkit ScrollBarVisibility maScrollVis; void lcl_Scroll( long nX, long nY ); public: - ScrollableDialog( Window* pParent, WinBits nStyle = WB_STDDIALOG ); - virtual ~ScrollableDialog(); - void SetScrollWidth( long nWidth ); - long GetScrollWidth() { return maScrollArea.Width(); } - void SetScrollHeight( long nHeight ); - long GetScrollHeight() { return maScrollArea.Height(); } - void SetScrollLeft( long nLeft ); - long GetScrollLeft() { return mnScrollPos.X(); } - void SetScrollTop( long Top ); - long GetScrollTop() { return mnScrollPos.Y() ; } - Window* getContentWindow(); + ScrollableWrapper( Window* pParent, WinBits nStyle = WB_STDDIALOG ); + virtual ~ScrollableWrapper(); + virtual void SetScrollWidth( long nWidth ); + virtual long GetScrollWidth() { return maScrollArea.Width(); } + virtual void SetScrollHeight( long nHeight ); + virtual long GetScrollHeight() { return maScrollArea.Height(); } + virtual void SetScrollLeft( long nLeft ); + virtual long GetScrollLeft() { return mnScrollPos.X(); } + virtual void SetScrollTop( long Top ); + virtual long GetScrollTop() { return mnScrollPos.Y() ; } + ScrollBarVisibility getScrollVisibility() { return maScrollVis; } void setScrollVisibility( ScrollBarVisibility rState ); DECL_LINK( ScrollBarHdl, ScrollBar* ); diff --git a/toolkit/inc/toolkit/awt/vclxcontainer.hxx b/toolkit/inc/toolkit/awt/vclxcontainer.hxx index 8a94682d178a..eda253106282 100644 --- a/toolkit/inc/toolkit/awt/vclxcontainer.hxx +++ b/toolkit/inc/toolkit/awt/vclxcontainer.hxx @@ -61,6 +61,9 @@ public: void SAL_CALL setTabOrder( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& WindowOrder, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Tabs, sal_Bool GroupControl ) throw(::com::sun::star::uno::RuntimeException); void SAL_CALL setGroup( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > >& Windows ) throw(::com::sun::star::uno::RuntimeException); + // ::com::sun::star::awt::XVclWindowPeer + void SAL_CALL setProperty( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Any& Value ) throw(::com::sun::star::uno::RuntimeException); + static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds ); virtual void GetPropertyIds( std::list< sal_uInt16 > &aIds ) { return ImplGetPropertyIds( aIds ); } }; diff --git a/toolkit/source/awt/scrollabledialog.cxx b/toolkit/source/awt/scrollabledialog.cxx index fbea906b16a0..74cabce2430d 100644 --- a/toolkit/source/awt/scrollabledialog.cxx +++ b/toolkit/source/awt/scrollabledialog.cxx @@ -6,9 +6,9 @@ namespace toolkit { 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 ) +ScrollableWrapper<T>::ScrollableWrapper( 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 ) ); + Link aLink( LINK( this, ScrollableWrapper, ScrollBarHdl ) ); maVScrollBar.SetScrollHdl( aLink ); maHScrollBar.SetScrollHdl( aLink ); @@ -32,7 +32,7 @@ ScrollableDialog<T>::ScrollableDialog( Window* pParent, WinBits nStyle ) : T( pP } template< class T> -void ScrollableDialog<T>::setScrollVisibility( ScrollBarVisibility rVisState ) +void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState ) { maScrollVis = rVisState; if ( maScrollVis == Hori || maScrollVis == Both ) @@ -50,18 +50,12 @@ void ScrollableDialog<T>::setScrollVisibility( ScrollBarVisibility rVisState ) } template< class T> -ScrollableDialog<T>::~ScrollableDialog() +ScrollableWrapper<T>::~ScrollableWrapper() { } template< class T> -Window* ScrollableDialog<T>::getContentWindow() -{ - return this; -} - -template< class T> -void ScrollableDialog<T>::lcl_Scroll( long nX, long nY ) +void ScrollableWrapper<T>::lcl_Scroll( long nX, long nY ) { long nXScroll = mnScrollPos.X() - nX; long nYScroll = mnScrollPos.Y() - nY; @@ -83,16 +77,16 @@ void ScrollableDialog<T>::lcl_Scroll( long nX, long nY ) } //Can't use IMPL_LINK with the template -//IMPL_LINK( ScrollableDialog, ScrollBarHdl, ScrollBar*, pSB ) +//IMPL_LINK( ScrollableWrapper, ScrollBarHdl, ScrollBar*, pSB ) template< class T> -long ScrollableDialog<T>::LinkStubScrollBarHdl( void* pThis, void* pCaller) +long ScrollableWrapper<T>::LinkStubScrollBarHdl( void* pThis, void* pCaller) { - return ((ScrollableDialog<T>*)pThis )->ScrollBarHdl( (ScrollBar*)pCaller ); + return ((ScrollableWrapper<T>*)pThis )->ScrollBarHdl( (ScrollBar*)pCaller ); } template< class T> -long ScrollableDialog<T>::ScrollBarHdl( ScrollBar* pSB ) +long ScrollableWrapper<T>::ScrollBarHdl( ScrollBar* pSB ) { sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos(); if( pSB == &maVScrollBar ) @@ -103,7 +97,7 @@ long ScrollableDialog<T>::ScrollBarHdl( ScrollBar* pSB ) } template< class T> -void ScrollableDialog<T>::SetScrollTop( long nTop ) +void ScrollableWrapper<T>::SetScrollTop( long nTop ) { Point aOld = mnScrollPos; lcl_Scroll( mnScrollPos.X() , mnScrollPos.Y() - nTop ); @@ -112,7 +106,7 @@ void ScrollableDialog<T>::SetScrollTop( long nTop ) mnScrollPos = aOld; } template< class T> -void ScrollableDialog<T>::SetScrollLeft( long nLeft ) +void ScrollableWrapper<T>::SetScrollLeft( long nLeft ) { Point aOld = mnScrollPos; lcl_Scroll( mnScrollPos.X() - nLeft , mnScrollPos.Y() ); @@ -121,27 +115,27 @@ void ScrollableDialog<T>::SetScrollLeft( long nLeft ) mnScrollPos = aOld; } template< class T> -void ScrollableDialog<T>::SetScrollWidth( long nWidth ) +void ScrollableWrapper<T>::SetScrollWidth( long nWidth ) { maScrollArea.Width() = nWidth; ResetScrollBars(); } template< class T> -void ScrollableDialog<T>::SetScrollHeight( long nHeight ) +void ScrollableWrapper<T>::SetScrollHeight( long nHeight ) { maScrollArea.Height() = nHeight; ResetScrollBars(); } template< class T> -void ScrollableDialog<T>::Resize() +void ScrollableWrapper<T>::Resize() { ResetScrollBars(); } template< class T> -void ScrollableDialog<T>::ResetScrollBars() +void ScrollableWrapper<T>::ResetScrollBars() { Size aOutSz = T::GetOutputSizePixel(); @@ -158,8 +152,8 @@ void ScrollableDialog<T>::ResetScrollBars() maVScrollBar.SetVisibleSize( T::GetSizePixel().Height() ); } -template class ScrollableDialog< Dialog >; -template class ScrollableDialog< GroupBox >; +template class ScrollableWrapper< Dialog >; +template class ScrollableWrapper< GroupBox >; } // toolkit /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxcontainer.cxx b/toolkit/source/awt/vclxcontainer.cxx index fd52b3d71d74..a15fef2e31da 100644 --- a/toolkit/source/awt/vclxcontainer.cxx +++ b/toolkit/source/awt/vclxcontainer.cxx @@ -36,6 +36,8 @@ #include <vcl/svapp.hxx> #include <vcl/window.hxx> #include <tools/debug.hxx> +#include "toolkit/awt/scrollabledialog.hxx" +#include <toolkit/helper/property.hxx> // ---------------------------------------------------- // class VCLXContainer @@ -232,4 +234,60 @@ void VCLXContainer::setGroup( const ::com::sun::star::uno::Sequence< ::com::sun: } } +void SAL_CALL VCLXContainer::setProperty( + const ::rtl::OUString& PropertyName, + const ::com::sun::star::uno::Any& Value ) +throw(::com::sun::star::uno::RuntimeException) +{ + SolarMutexGuard aGuard; + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) + { + case BASEPROPERTY_SCROLLHEIGHT: + case BASEPROPERTY_SCROLLWIDTH: + case BASEPROPERTY_SCROLLTOP: + case BASEPROPERTY_SCROLLLEFT: + { + sal_Int32 nVal =0; + Value >>= nVal; + Size aSize( nVal, nVal ); + Window* pWindow = GetWindow(); + MapMode aMode( MAP_APPFONT ); + toolkit::ScrollableInterface* pScrollable = dynamic_cast< toolkit::ScrollableInterface* >( pWindow ); + if ( pWindow && pScrollable ) + { + OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); + if ( !pDev ) + pDev = pWindow->GetParent(); + + aSize = pDev->LogicToPixel( aSize, aMode ); + switch ( nPropType ) + { + case BASEPROPERTY_SCROLLHEIGHT: + pScrollable->SetScrollHeight( aSize.Height() ); + break; + case BASEPROPERTY_SCROLLWIDTH: + pScrollable->SetScrollWidth( aSize.Width() ); + break; + case BASEPROPERTY_SCROLLTOP: + pScrollable->SetScrollTop( aSize.Height() ); + break; + case BASEPROPERTY_SCROLLLEFT: + pScrollable->SetScrollLeft( aSize.Width() ); + break; + default: + break; + } + break; + } + break; + } + + default: + { + VCLXWindow::setProperty( PropertyName, Value ); + } + } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 1f17f38cdea8..64bffaa38756 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -725,7 +725,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, case WINDOW_GROUPBOX: { if ( bFrameControl ) - pNewWindow = new toolkit::ScrollableDialog< GroupBox >( pParent, nWinBits ); + pNewWindow = new toolkit::ScrollableWrapper< GroupBox >( pParent, nWinBits ); else pNewWindow = new GroupBox( pParent, nWinBits ); if ( bFrameControl ) @@ -790,7 +790,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, // Modal/Modeless nur durch Show/Execute if ( (pParent == NULL ) && ( rDescriptor.ParentIndex == -1 ) ) pParent = DIALOG_NO_PARENT; - pNewWindow = new toolkit::ScrollableDialog<Dialog>( pParent, nWinBits ); + pNewWindow = new toolkit::ScrollableWrapper<Dialog>( pParent, nWinBits ); // #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() ) // which creates a component object. diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 09085007b0b9..0fd3cf0c80dc 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -2454,44 +2454,6 @@ throw(::com::sun::star::uno::RuntimeException) sal_uInt16 nPropType = GetPropertyId( PropertyName ); switch ( nPropType ) { - case BASEPROPERTY_SCROLLHEIGHT: - case BASEPROPERTY_SCROLLWIDTH: - case BASEPROPERTY_SCROLLTOP: - case BASEPROPERTY_SCROLLLEFT: - { - sal_Int32 nVal =0; - Value >>= nVal; - Size aSize( nVal, nVal ); - Window* pWindow = GetWindow(); - MapMode aMode( MAP_APPFONT ); - toolkit::ScrollableDialog<Dialog>* pScrollable = dynamic_cast< toolkit::ScrollableDialog<Dialog>* >( pWindow ); - if ( pWindow && pScrollable ) - { - OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); - if ( !pDev ) - pDev = pWindow->GetParent(); - - aSize = pDev->LogicToPixel( aSize, aMode ); - switch ( nPropType ) - { - case BASEPROPERTY_SCROLLHEIGHT: - pScrollable->SetScrollHeight( aSize.Height() ); - break; - case BASEPROPERTY_SCROLLWIDTH: - pScrollable->SetScrollWidth( aSize.Width() ); - break; - case BASEPROPERTY_SCROLLTOP: - pScrollable->SetScrollTop( aSize.Height() ); - break; - case BASEPROPERTY_SCROLLLEFT: - pScrollable->SetScrollLeft( aSize.Width() ); - break; - default: - break; - } - } - break; - } case BASEPROPERTY_GRAPHIC: { Reference< XGraphic > xGraphic; @@ -2517,7 +2479,7 @@ throw(::com::sun::star::uno::RuntimeException) default: { - VCLXWindow::setProperty( PropertyName, Value ); + VCLXContainer::setProperty( PropertyName, Value ); } } } @@ -6694,50 +6656,6 @@ throw(::com::sun::star::uno::RuntimeException) sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; (void)bVoid; #endif - // #TODO needs to be in common container base class, - // we need a common Scrollable interface then too - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_SCROLLHEIGHT: - case BASEPROPERTY_SCROLLWIDTH: - case BASEPROPERTY_SCROLLTOP: - case BASEPROPERTY_SCROLLLEFT: - { - sal_Int32 nVal =0; - Value >>= nVal; - Size aSize( nVal, nVal ); - Window* pWindow = GetWindow(); - MapMode aMode( MAP_APPFONT ); - toolkit::ScrollableDialog<GroupBox>* pScrollable = dynamic_cast< toolkit::ScrollableDialog<GroupBox>* >( pWindow ); - if ( pWindow && pScrollable ) - { - OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() ); - if ( !pDev ) - pDev = pWindow->GetParent(); - - aSize = pDev->LogicToPixel( aSize, aMode ); - switch ( nPropType ) - { - case BASEPROPERTY_SCROLLHEIGHT: - pScrollable->SetScrollHeight( aSize.Height() ); - break; - case BASEPROPERTY_SCROLLWIDTH: - pScrollable->SetScrollWidth( aSize.Width() ); - break; - case BASEPROPERTY_SCROLLTOP: - pScrollable->SetScrollTop( aSize.Height() ); - break; - case BASEPROPERTY_SCROLLLEFT: - pScrollable->SetScrollLeft( aSize.Width() ); - break; - default: - break; - } - } - break; - } - } VCLXContainer::setProperty( PropertyName, Value ); } |