summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-09-06 18:36:00 +0100
committerNoel Power <noel.power@suse.com>2012-09-11 16:04:11 +0100
commit27a19817c6271b76013aa6bda5c3353c8a9dd35b (patch)
tree75c939b2695447a0915706a508a979f73865f1d2 /toolkit
parent5dc19680cd27d4eaea5f2f7fdc48969f704e696a (diff)
some more tweaking to import scrollbar data for mso Frame & Userform
also removed printf(s) Change-Id: If83565dcd97b276e1f6a8488a9f1d23066c2a9ff
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/inc/toolkit/awt/scrollabledialog.hxx4
-rw-r--r--toolkit/source/awt/scrollabledialog.cxx90
-rw-r--r--toolkit/source/awt/vclxtoolkit.cxx17
-rw-r--r--toolkit/source/awt/vclxwindows.cxx49
-rw-r--r--toolkit/source/controls/dialogcontrol.cxx7
5 files changed, 114 insertions, 53 deletions
diff --git a/toolkit/inc/toolkit/awt/scrollabledialog.hxx b/toolkit/inc/toolkit/awt/scrollabledialog.hxx
index 41ae32f72c9f..01ba525dbdcf 100644
--- a/toolkit/inc/toolkit/awt/scrollabledialog.hxx
+++ b/toolkit/inc/toolkit/awt/scrollabledialog.hxx
@@ -34,7 +34,8 @@
//........................................................................
namespace toolkit
{
- class ScrollableDialog : public Dialog
+ template < class T >
+ class ScrollableDialog : public T
{
ScrollBar maHScrollBar;
ScrollBar maVScrollBar;
@@ -64,7 +65,6 @@ namespace toolkit
ScrollBarVisibility getScrollVisibility() { return maScrollVis; }
void setScrollVisibility( ScrollBarVisibility rState );
DECL_LINK( ScrollBarHdl, ScrollBar* );
- DECL_LINK( ContainerScrolled, void* );
virtual void ResetScrollBars();
// Window
virtual void Resize();
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: */
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index 55ca00c4acf9..1f17f38cdea8 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -724,7 +724,10 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp,
break;
case WINDOW_GROUPBOX:
{
- pNewWindow = new GroupBox( pParent, nWinBits );
+ if ( bFrameControl )
+ pNewWindow = new toolkit::ScrollableDialog< GroupBox >( pParent, nWinBits );
+ else
+ pNewWindow = new GroupBox( pParent, nWinBits );
if ( bFrameControl )
{
GroupBox* pGroupBox = static_cast< GroupBox* >( pNewWindow );
@@ -787,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( pParent, nWinBits );
+ pNewWindow = new toolkit::ScrollableDialog<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.
@@ -1062,16 +1065,6 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow(
if ( pParentComponent )
pParent = pParentComponent->GetWindow();
}
-#if 0
- // #FIXME inglorious HACK we possibly need to interface at XContainerWindowPeer ?
- // to allow access to the 'real' parent that we pass to children
- toolkit::ScrollableDialog* pSrcDialog = dynamic_cast< toolkit::ScrollableDialog* > ( pParent );
- if ( pSrcDialog )
- {
- printf( "found a parent that is a scrollable dialog\n");
- pParent = pSrcDialog->getContentWindow();
- }
-#endif
WinBits nWinBits = ImplGetWinBits( rDescriptor.WindowAttributes,
ImplGetComponentType( rDescriptor.WindowServiceName ) );
nWinBits |= nForceWinBits;
diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx
index a70d5acd7337..09085007b0b9 100644
--- a/toolkit/source/awt/vclxwindows.cxx
+++ b/toolkit/source/awt/vclxwindows.cxx
@@ -68,6 +68,7 @@
#include <boost/bind.hpp>
#include <boost/function.hpp>
+#include <vcl/group.hxx>
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::makeAny;
@@ -2451,7 +2452,6 @@ throw(::com::sun::star::uno::RuntimeException)
sal_Bool bVoid = Value.getValueType().getTypeClass() == ::com::sun::star::uno::TypeClass_VOID;
sal_uInt16 nPropType = GetPropertyId( PropertyName );
- printf("XDialog setProperty... %s\n", rtl::OUStringToOString( PropertyName, RTL_TEXTENCODING_UTF8 ).getStr() );
switch ( nPropType )
{
case BASEPROPERTY_SCROLLHEIGHT:
@@ -2464,14 +2464,14 @@ throw(::com::sun::star::uno::RuntimeException)
Size aSize( nVal, nVal );
Window* pWindow = GetWindow();
MapMode aMode( MAP_APPFONT );
- if ( pWindow )
+ 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 );
- toolkit::ScrollableDialog* pScrollable = static_cast< toolkit::ScrollableDialog* >( pWindow );
switch ( nPropType )
{
case BASEPROPERTY_SCROLLHEIGHT:
@@ -6694,7 +6694,50 @@ 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 );
}
diff --git a/toolkit/source/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index d8efe4fed850..99c9d469f64b 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -1136,6 +1136,13 @@ UnoFrameModel::UnoFrameModel( const Reference< XMultiServiceFactory >& i_factor
ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES );
+ ImplRegisterProperty( BASEPROPERTY_HSCROLL );
+ ImplRegisterProperty( BASEPROPERTY_VSCROLL );
+ ImplRegisterProperty( BASEPROPERTY_SCROLLWIDTH );
+ ImplRegisterProperty( BASEPROPERTY_SCROLLHEIGHT );
+ ImplRegisterProperty( BASEPROPERTY_SCROLLTOP );
+ ImplRegisterProperty( BASEPROPERTY_SCROLLLEFT );
+
uno::Reference< XNameContainer > xNameCont = new SimpleNamedThingContainer< XControlModel >();
ImplRegisterProperty( BASEPROPERTY_USERFORMCONTAINEES, uno::makeAny( xNameCont ) );