Kaydet (Commit) b241005c authored tarafından Noel Power's avatar Noel Power

make interface for scrollablity properties to allow more code sharing

Change-Id: I0e03360808e73426848820d807f741c13c76abf8
üst 27a19817
...@@ -34,8 +34,21 @@ ...@@ -34,8 +34,21 @@
//........................................................................ //........................................................................
namespace toolkit 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 > template < class T >
class ScrollableDialog : public T class ScrollableWrapper : public T, public ScrollableInterface
{ {
ScrollBar maHScrollBar; ScrollBar maHScrollBar;
ScrollBar maVScrollBar; ScrollBar maVScrollBar;
...@@ -51,17 +64,17 @@ namespace toolkit ...@@ -51,17 +64,17 @@ namespace toolkit
ScrollBarVisibility maScrollVis; ScrollBarVisibility maScrollVis;
void lcl_Scroll( long nX, long nY ); void lcl_Scroll( long nX, long nY );
public: public:
ScrollableDialog( Window* pParent, WinBits nStyle = WB_STDDIALOG ); ScrollableWrapper( Window* pParent, WinBits nStyle = WB_STDDIALOG );
virtual ~ScrollableDialog(); virtual ~ScrollableWrapper();
void SetScrollWidth( long nWidth ); virtual void SetScrollWidth( long nWidth );
long GetScrollWidth() { return maScrollArea.Width(); } virtual long GetScrollWidth() { return maScrollArea.Width(); }
void SetScrollHeight( long nHeight ); virtual void SetScrollHeight( long nHeight );
long GetScrollHeight() { return maScrollArea.Height(); } virtual long GetScrollHeight() { return maScrollArea.Height(); }
void SetScrollLeft( long nLeft ); virtual void SetScrollLeft( long nLeft );
long GetScrollLeft() { return mnScrollPos.X(); } virtual long GetScrollLeft() { return mnScrollPos.X(); }
void SetScrollTop( long Top ); virtual void SetScrollTop( long Top );
long GetScrollTop() { return mnScrollPos.Y() ; } virtual long GetScrollTop() { return mnScrollPos.Y() ; }
Window* getContentWindow();
ScrollBarVisibility getScrollVisibility() { return maScrollVis; } ScrollBarVisibility getScrollVisibility() { return maScrollVis; }
void setScrollVisibility( ScrollBarVisibility rState ); void setScrollVisibility( ScrollBarVisibility rState );
DECL_LINK( ScrollBarHdl, ScrollBar* ); DECL_LINK( ScrollBarHdl, ScrollBar* );
......
...@@ -61,6 +61,9 @@ public: ...@@ -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 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); 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 ); static void ImplGetPropertyIds( std::list< sal_uInt16 > &aIds );
virtual void GetPropertyIds( std::list< sal_uInt16 > &aIds ) { return ImplGetPropertyIds( aIds ); } virtual void GetPropertyIds( std::list< sal_uInt16 > &aIds ) { return ImplGetPropertyIds( aIds ); }
}; };
......
...@@ -6,9 +6,9 @@ namespace toolkit ...@@ -6,9 +6,9 @@ namespace toolkit
{ {
template< class T> 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 ); maVScrollBar.SetScrollHdl( aLink );
maHScrollBar.SetScrollHdl( aLink ); maHScrollBar.SetScrollHdl( aLink );
...@@ -32,7 +32,7 @@ ScrollableDialog<T>::ScrollableDialog( Window* pParent, WinBits nStyle ) : T( pP ...@@ -32,7 +32,7 @@ ScrollableDialog<T>::ScrollableDialog( Window* pParent, WinBits nStyle ) : T( pP
} }
template< class T> template< class T>
void ScrollableDialog<T>::setScrollVisibility( ScrollBarVisibility rVisState ) void ScrollableWrapper<T>::setScrollVisibility( ScrollBarVisibility rVisState )
{ {
maScrollVis = rVisState; maScrollVis = rVisState;
if ( maScrollVis == Hori || maScrollVis == Both ) if ( maScrollVis == Hori || maScrollVis == Both )
...@@ -50,18 +50,12 @@ void ScrollableDialog<T>::setScrollVisibility( ScrollBarVisibility rVisState ) ...@@ -50,18 +50,12 @@ void ScrollableDialog<T>::setScrollVisibility( ScrollBarVisibility rVisState )
} }
template< class T> template< class T>
ScrollableDialog<T>::~ScrollableDialog() ScrollableWrapper<T>::~ScrollableWrapper()
{ {
} }
template< class T> template< class T>
Window* ScrollableDialog<T>::getContentWindow() void ScrollableWrapper<T>::lcl_Scroll( long nX, long nY )
{
return this;
}
template< class T>
void ScrollableDialog<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;
...@@ -83,16 +77,16 @@ void ScrollableDialog<T>::lcl_Scroll( long nX, long nY ) ...@@ -83,16 +77,16 @@ void ScrollableDialog<T>::lcl_Scroll( long nX, long nY )
} }
//Can't use IMPL_LINK with the template //Can't use IMPL_LINK with the template
//IMPL_LINK( ScrollableDialog, ScrollBarHdl, ScrollBar*, pSB ) //IMPL_LINK( ScrollableWrapper, ScrollBarHdl, ScrollBar*, pSB )
template< class T> 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> template< class T>
long ScrollableDialog<T>::ScrollBarHdl( ScrollBar* pSB ) long ScrollableWrapper<T>::ScrollBarHdl( ScrollBar* pSB )
{ {
sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos(); sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos();
if( pSB == &maVScrollBar ) if( pSB == &maVScrollBar )
...@@ -103,7 +97,7 @@ long ScrollableDialog<T>::ScrollBarHdl( ScrollBar* pSB ) ...@@ -103,7 +97,7 @@ long ScrollableDialog<T>::ScrollBarHdl( ScrollBar* pSB )
} }
template< class T> template< class T>
void ScrollableDialog<T>::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 );
...@@ -112,7 +106,7 @@ void ScrollableDialog<T>::SetScrollTop( long nTop ) ...@@ -112,7 +106,7 @@ void ScrollableDialog<T>::SetScrollTop( long nTop )
mnScrollPos = aOld; mnScrollPos = aOld;
} }
template< class T> template< class T>
void ScrollableDialog<T>::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() );
...@@ -121,27 +115,27 @@ void ScrollableDialog<T>::SetScrollLeft( long nLeft ) ...@@ -121,27 +115,27 @@ void ScrollableDialog<T>::SetScrollLeft( long nLeft )
mnScrollPos = aOld; mnScrollPos = aOld;
} }
template< class T> template< class T>
void ScrollableDialog<T>::SetScrollWidth( long nWidth ) void ScrollableWrapper<T>::SetScrollWidth( long nWidth )
{ {
maScrollArea.Width() = nWidth; maScrollArea.Width() = nWidth;
ResetScrollBars(); ResetScrollBars();
} }
template< class T> template< class T>
void ScrollableDialog<T>::SetScrollHeight( long nHeight ) void ScrollableWrapper<T>::SetScrollHeight( long nHeight )
{ {
maScrollArea.Height() = nHeight; maScrollArea.Height() = nHeight;
ResetScrollBars(); ResetScrollBars();
} }
template< class T> template< class T>
void ScrollableDialog<T>::Resize() void ScrollableWrapper<T>::Resize()
{ {
ResetScrollBars(); ResetScrollBars();
} }
template< class T> template< class T>
void ScrollableDialog<T>::ResetScrollBars() void ScrollableWrapper<T>::ResetScrollBars()
{ {
Size aOutSz = T::GetOutputSizePixel(); Size aOutSz = T::GetOutputSizePixel();
...@@ -158,8 +152,8 @@ void ScrollableDialog<T>::ResetScrollBars() ...@@ -158,8 +152,8 @@ void ScrollableDialog<T>::ResetScrollBars()
maVScrollBar.SetVisibleSize( T::GetSizePixel().Height() ); maVScrollBar.SetVisibleSize( T::GetSizePixel().Height() );
} }
template class ScrollableDialog< Dialog >; template class ScrollableWrapper< Dialog >;
template class ScrollableDialog< GroupBox >; template class ScrollableWrapper< GroupBox >;
} // toolkit } // toolkit
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include "toolkit/awt/scrollabledialog.hxx"
#include <toolkit/helper/property.hxx>
// ---------------------------------------------------- // ----------------------------------------------------
// class VCLXContainer // class VCLXContainer
...@@ -232,4 +234,60 @@ void VCLXContainer::setGroup( const ::com::sun::star::uno::Sequence< ::com::sun: ...@@ -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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -725,7 +725,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, ...@@ -725,7 +725,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
case WINDOW_GROUPBOX: case WINDOW_GROUPBOX:
{ {
if ( bFrameControl ) if ( bFrameControl )
pNewWindow = new toolkit::ScrollableDialog< GroupBox >( pParent, nWinBits ); pNewWindow = new toolkit::ScrollableWrapper< GroupBox >( pParent, nWinBits );
else else
pNewWindow = new GroupBox( pParent, nWinBits ); pNewWindow = new GroupBox( pParent, nWinBits );
if ( bFrameControl ) if ( bFrameControl )
...@@ -790,7 +790,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, ...@@ -790,7 +790,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
// Modal/Modeless nur durch Show/Execute // Modal/Modeless nur durch Show/Execute
if ( (pParent == NULL ) && ( rDescriptor.ParentIndex == -1 ) ) if ( (pParent == NULL ) && ( rDescriptor.ParentIndex == -1 ) )
pParent = DIALOG_NO_PARENT; 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 // #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.
......
...@@ -2454,44 +2454,6 @@ throw(::com::sun::star::uno::RuntimeException) ...@@ -2454,44 +2454,6 @@ throw(::com::sun::star::uno::RuntimeException)
sal_uInt16 nPropType = GetPropertyId( PropertyName ); sal_uInt16 nPropType = GetPropertyId( PropertyName );
switch ( nPropType ) 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: case BASEPROPERTY_GRAPHIC:
{ {
Reference< XGraphic > xGraphic; Reference< XGraphic > xGraphic;
...@@ -2517,7 +2479,7 @@ throw(::com::sun::star::uno::RuntimeException) ...@@ -2517,7 +2479,7 @@ throw(::com::sun::star::uno::RuntimeException)
default: default:
{ {
VCLXWindow::setProperty( PropertyName, Value ); VCLXContainer::setProperty( PropertyName, Value );
} }
} }
} }
...@@ -6694,50 +6656,6 @@ throw(::com::sun::star::uno::RuntimeException) ...@@ -6694,50 +6656,6 @@ throw(::com::sun::star::uno::RuntimeException)
sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID; sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
(void)bVoid; (void)bVoid;
#endif #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 ); VCLXContainer::setProperty( PropertyName, Value );
} }
......
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