diff options
-rw-r--r-- | toolkit/Library_tk.mk | 2 | ||||
-rw-r--r-- | toolkit/inc/toolkit/awt/scrollabledialog.hxx | 60 | ||||
-rw-r--r-- | toolkit/source/awt/scrollabledialog.cxx | 102 | ||||
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 13 |
4 files changed, 175 insertions, 2 deletions
diff --git a/toolkit/Library_tk.mk b/toolkit/Library_tk.mk index b242b84adf73..6ce272fef93e 100644 --- a/toolkit/Library_tk.mk +++ b/toolkit/Library_tk.mk @@ -52,12 +52,14 @@ $(eval $(call gb_Library_use_libraries,tk,\ tl \ utl \ vcl \ + svt \ $(gb_STDLIBS) \ )) $(eval $(call gb_Library_add_exception_objects,tk,\ toolkit/source/awt/asynccallback \ toolkit/source/awt/stylesettings \ + toolkit/source/awt/scrollabledialog \ toolkit/source/awt/vclxaccessiblecomponent \ toolkit/source/awt/vclxbitmap \ toolkit/source/awt/vclxcontainer \ diff --git a/toolkit/inc/toolkit/awt/scrollabledialog.hxx b/toolkit/inc/toolkit/awt/scrollabledialog.hxx new file mode 100644 index 000000000000..19cd1e150f9c --- /dev/null +++ b/toolkit/inc/toolkit/awt/scrollabledialog.hxx @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef TOOLKIT_AWT_SCROLLABLEDIALOG_HXX +#define TOOLKIT_AWT_SCROLLABLEDIALOG_HXX + +#include <vcl/dialog.hxx> +#include <vcl/scrbar.hxx> + +//........................................................................ +namespace toolkit +{ + class ScrollableDialog : public Dialog + { + Window maContents; + ScrollBar maHScrollBar; + ScrollBar maVScrollBar; + bool mbHasHoriBar; + bool mbHasVertBar; + Point mnScrollPos; + public: + ScrollableDialog( Window* pParent, WinBits nStyle = WB_STDDIALOG ); + virtual ~ScrollableDialog(); + Window* getContentWindow(); + DECL_LINK( ScrollBarHdl, ScrollBar* ); + DECL_LINK( ContainerScrolled, void* ); + // Window + virtual void Resize(); + }; +//........................................................................ +} // namespacetoolkit +//........................................................................ + +#endif // TOOLKIT_AWT_SCROLLABLEDIALOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/scrollabledialog.cxx b/toolkit/source/awt/scrollabledialog.cxx new file mode 100644 index 000000000000..1c64ab61846e --- /dev/null +++ b/toolkit/source/awt/scrollabledialog.cxx @@ -0,0 +1,102 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#include <toolkit/awt/scrollabledialog.hxx> +namespace toolkit +{ + +ScrollableDialog::ScrollableDialog( Window* pParent, WinBits nStyle ) : Dialog( pParent, nStyle ), maContents( this, nStyle ), maHScrollBar( this, WB_HSCROLL | WB_DRAG), maVScrollBar( this, WB_VSCROLL | WB_DRAG ), mbHasHoriBar( true ), mbHasVertBar( true ) +{ + Link aLink( LINK( this, ScrollableDialog, ScrollBarHdl ) ); + maVScrollBar.SetScrollHdl( aLink ); + maHScrollBar.SetScrollHdl( aLink ); + maContents.Show(); + maVScrollBar.Show(); + maHScrollBar.Show(); +} + +ScrollableDialog::~ScrollableDialog() +{ +} + +Window* ScrollableDialog::getContentWindow() +{ + return &maContents; +} + +IMPL_LINK( ScrollableDialog, ScrollBarHdl, ScrollBar*, pSB ) +{ + sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos(); + Rectangle aScrollableArea( 0, 0, maContents.GetSizePixel().Width(), maContents.GetSizePixel().Height() ); + + if( pSB == &maVScrollBar ) + { + printf("vertical scroll %d\n", nPos ); + printf("vertical scroll %d\n", nPos ); + long nScroll = mnScrollPos.Y() - nPos; + maContents.Scroll(0, nScroll, aScrollableArea ); + mnScrollPos.Y() = nPos; + } + else if( pSB == &maHScrollBar ) + { + printf("horizontal scroll %d\n", nPos ); + long nScroll = mnScrollPos.X() - nPos; + maContents.Scroll( nScroll, 0, aScrollableArea); + mnScrollPos.X() = nPos; + } + return 1; +} + +void ScrollableDialog::Resize() +{ + printf("ScrollableDialog::Resize() - size is width %d height %d\n", GetSizePixel().Width(), GetSizePixel().Height() ); + maContents.SetSizePixel( GetSizePixel() ); + // find the output area for the window + long nMaxX = GetSizePixel().Width(); + long nMaxY = GetSizePixel().Height(); + for ( int index = 0, count = maContents.GetChildCount(); index < count; ++index ) + { + Window* pChild = maContents.GetChild( index ); + if ( pChild ) + { + Point aPos = pChild->GetPosPixel(); + Size aSize = pChild->GetSizePixel(); + long nX = aPos.X() + aSize.Width(); + long nY = aPos.Y() + aSize.Height(); + if ( nX > nMaxX ) + nMaxX = nX; + if ( nY > nMaxY ) + nMaxY = nY; + } + } + + Size aOutSz = GetOutputSizePixel(); + long nScrWidth = GetSettings().GetStyleSettings().GetScrollBarSize(); + + // assume for the moment that we have both hori & vert scroll bars + Size aContentsSize( aOutSz ); + if ( mbHasVertBar ) + { + aContentsSize.Width() -= nScrWidth; + nMaxX += nScrWidth; + } + if ( mbHasHoriBar ) + { + aContentsSize.Height() -= nScrWidth; + nMaxY += nScrWidth; + } + maContents.SetSizePixel( aContentsSize ); + + Point aVPos( aOutSz.Width() - nScrWidth, 0 ); + Point aHPos( 0, aOutSz.Height() - nScrWidth ); + + maVScrollBar.SetPosSizePixel( aVPos, Size( nScrWidth, aContentsSize.Height() ) ); + maHScrollBar.SetPosSizePixel( aHPos, Size( aContentsSize.Width(), nScrWidth ) ); + maHScrollBar.SetRangeMax( nMaxX ); + maHScrollBar.SetVisibleSize( GetSizePixel().Width() ); + maHScrollBar.SetPageSize( GetSizePixel().Width() ); + maVScrollBar.SetRangeMax( nMaxY ); + maVScrollBar.SetVisibleSize( GetSizePixel().Height() ); + maVScrollBar.SetPageSize( GetSizePixel().Height() ); +} + +} // toolkit +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index b3b6828eedf2..c2bb0a1352ef 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -129,9 +129,10 @@ using org::libreoffice::touch::ByteBufferWrapper; #include <vcl/wrkwin.hxx> #include <vcl/throbber.hxx> #include "toolkit/awt/vclxspinbutton.hxx" - +#include "toolkit/awt/scrollabledialog.hxx" #include <tools/debug.hxx> #include <comphelper/processfactory.hxx> +#include <toolkit/awt/scrollabledialog.hxx> namespace css = ::com::sun::star; @@ -786,7 +787,7 @@ Window* VCLXToolkit::ImplCreateWindow( VCLXWindow** ppNewComp, // Modal/Modeless nur durch Show/Execute if ( (pParent == NULL ) && ( rDescriptor.ParentIndex == -1 ) ) pParent = DIALOG_NO_PARENT; - pNewWindow = new Dialog( pParent, nWinBits ); + pNewWindow = new toolkit::ScrollableDialog( pParent, nWinBits | WB_AUTOHSCROLL | WB_AUTOVSCROLL ); // #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. @@ -1061,6 +1062,14 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow( if ( pParentComponent ) pParent = pParentComponent->GetWindow(); } + // #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(); + } WinBits nWinBits = ImplGetWinBits( rDescriptor.WindowAttributes, ImplGetComponentType( rDescriptor.WindowServiceName ) ); |