summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2012-09-04 20:12:45 +0100
committerNoel Power <noel.power@suse.com>2012-09-11 16:04:10 +0100
commit613f8a3137e0af2e97214b4b1c2da8c87b3f8889 (patch)
treeab77014d527534998bb0ca29a0752a6f5f965322 /toolkit
parent744d6e22bb087854b0535c660dcc5b4b85de2874 (diff)
attempt own scroll
Change-Id: I4abc00bf4fcebb098b63cc2c3638e0d573381ca5
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/inc/toolkit/awt/scrollabledialog.hxx21
-rw-r--r--toolkit/inc/toolkit/helper/property.hxx2
-rw-r--r--toolkit/source/awt/scrollabledialog.cxx154
-rw-r--r--toolkit/source/awt/vclxtoolkit.cxx5
-rw-r--r--toolkit/source/controls/dialogcontrol.cxx2
-rw-r--r--toolkit/source/helper/property.cxx2
6 files changed, 154 insertions, 32 deletions
diff --git a/toolkit/inc/toolkit/awt/scrollabledialog.hxx b/toolkit/inc/toolkit/awt/scrollabledialog.hxx
index 19cd1e150f9c..968771b56e6c 100644
--- a/toolkit/inc/toolkit/awt/scrollabledialog.hxx
+++ b/toolkit/inc/toolkit/awt/scrollabledialog.hxx
@@ -36,16 +36,35 @@ namespace toolkit
{
class ScrollableDialog : public Dialog
{
- Window maContents;
ScrollBar maHScrollBar;
ScrollBar maVScrollBar;
+ Size maScrollArea;
bool mbHasHoriBar;
bool mbHasVertBar;
Point mnScrollPos;
+ long mnScrWidth;
+
+ public:
+ enum ScrollBarVisibility { None, Vert, Hori, Both };
+ private:
+ 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();
+ ScrollBarVisibility getScrollVisibility() { return maScrollVis; }
+ void setScrollVisibility( ScrollBarVisibility rState );
+ virtual void Paint( const Rectangle& rRect );
+ virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
DECL_LINK( ScrollBarHdl, ScrollBar* );
DECL_LINK( ContainerScrolled, void* );
// Window
diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx
index a44db628a346..4a1c07bb102f 100644
--- a/toolkit/inc/toolkit/helper/property.hxx
+++ b/toolkit/inc/toolkit/helper/property.hxx
@@ -211,6 +211,8 @@ namespace rtl {
#define BASEPROPERTY_ROW_HEADER_WIDTH 158
#define BASEPROPERTY_COLUMN_HEADER_HEIGHT 159
#define BASEPROPERTY_USE_GRID_LINES 160
+#define BASEPROPERTY_HORISCROLL 161
+#define BASEPROPERTY_VERTSCROLL 162
// These properties are not bound, they are always extracted from the BASEPROPERTY_FONTDESCRIPTOR property
diff --git a/toolkit/source/awt/scrollabledialog.cxx b/toolkit/source/awt/scrollabledialog.cxx
index 1c64ab61846e..2732e6077ac5 100644
--- a/toolkit/source/awt/scrollabledialog.cxx
+++ b/toolkit/source/awt/scrollabledialog.cxx
@@ -3,14 +3,44 @@
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 )
+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 )
{
Link aLink( LINK( this, ScrollableDialog, ScrollBarHdl ) );
maVScrollBar.SetScrollHdl( aLink );
maHScrollBar.SetScrollHdl( aLink );
- maContents.Show();
- maVScrollBar.Show();
- maHScrollBar.Show();
+
+ Size aOutSz = GetOutputSizePixel();
+ ScrollBarVisibility aVis = None;
+
+ if ( nStyle & ( WB_HSCROLL | WB_VSCROLL ) )
+ {
+ if ( nStyle & WB_HSCROLL )
+ aVis = Hori;
+ if ( nStyle & WB_VSCROLL )
+ {
+ if ( aVis == Hori )
+ aVis = Both;
+ else
+ aVis = Vert;
+ }
+ }
+ setScrollVisibility( aVis );
+ mnScrWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
+}
+
+void ScrollableDialog::setScrollVisibility( ScrollBarVisibility rVisState )
+{
+ maScrollVis = rVisState;
+ if ( maScrollVis == Hori || maScrollVis == Both )
+ mbHasHoriBar = true;
+ if ( maScrollVis == Vert || maScrollVis == Both )
+ mbHasVertBar = true;
+ if ( mbHasVertBar )
+ maVScrollBar.Show();
+ if ( mbHasHoriBar )
+ maHScrollBar.Show();
+ if ( mbHasHoriBar || mbHasVertBar )
+ SetStyle( GetStyle() | WB_CLIPCHILDREN | SCROLL_UPDATE );
}
ScrollableDialog::~ScrollableDialog()
@@ -19,42 +49,109 @@ ScrollableDialog::~ScrollableDialog()
Window* ScrollableDialog::getContentWindow()
{
- return &maContents;
+ return this;
+}
+
+void ScrollableDialog::lcl_Scroll( long nX, long nY )
+{
+ long nXScroll = mnScrollPos.Y() - nX;
+ long nYScroll = mnScrollPos.X() - nY;
+
+ mnScrollPos = Point( nX, nY );
+
+ Rectangle aScrollableArea( 0, 0, maScrollArea.Width(), maScrollArea.Height() );
+ Window::Scroll(nXScroll, nYScroll, aScrollableArea );
+ // Manually scroll all children ( except the scrollbars )
+ for ( int index = 0; index < GetChildCount(); ++index )
+ {
+ Window* pChild = GetChild( index );
+ if ( pChild && pChild != &maVScrollBar && pChild != &maHScrollBar )
+ {
+ Point aPos = pChild->GetPosPixel();
+ aPos += Point( nXScroll, nYScroll );
+ pChild->SetPosPixel( aPos );
+ }
+ }
}
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 )
+ Scroll(0, nPos );
+ else if( pSB == &maHScrollBar )
+ lcl_Scroll(nPos, 0 );
+#if 0
+ sal_uInt16 nPos = (sal_uInt16) pSB->GetThumbPos();
+ Rectangle aScrollableArea( 0, 0, maScrollArea.Width(), maScrollArea.Height() );
+ Point aScroll;
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 );
+ Size aTmpScroll( nPos, nPos );
+ long nScroll = mnScrollPos.Y() - aTmpScroll.Width();
+ // I'm guessing I need to call scroll for ( stuff ) to happen
+ Scroll(0, nScroll, aScrollableArea );
mnScrollPos.Y() = nPos;
+ aScroll.Y() = nScroll;
}
else if( pSB == &maHScrollBar )
{
printf("horizontal scroll %d\n", nPos );
- long nScroll = mnScrollPos.X() - nPos;
- maContents.Scroll( nScroll, 0, aScrollableArea);
+ Size aTmpScroll( nPos, nPos );
+ long nScroll = mnScrollPos.X() - aTmpScroll.Width();
+ Scroll( nScroll, 0, aScrollableArea);
mnScrollPos.X() = nPos;
+ aScroll.X() = nScroll;
+ }
+
+ // Manually scroll all children ( except the scrollbars )
+ for ( int index = 0; index < GetChildCount(); ++index )
+ {
+ Window* pChild = GetChild( index );
+ if ( pChild && pChild != &maVScrollBar && pChild != &maHScrollBar )
+ {
+ Point aPos = pChild->GetPosPixel();
+ aPos += Point( aScroll.X(), aScroll.Y() );
+ pChild->SetPosPixel( aPos );
+ }
}
+#endif
return 1;
}
+void ScrollableDialog::SetScrollWidth( long nWidth )
+{
+ maScrollArea.Width() = nWidth;
+}
+
+void ScrollableDialog::SetScrollHeight( long nHeight )
+{
+ maScrollArea.Height() = nHeight;
+}
+
+void ScrollableDialog::Paint( const Rectangle& rRect )
+{
+ printf("ScrollableDialog::Paint( %d, %d, %d, %d width %d height %d\n", rRect.Top(), rRect.Left(), rRect.Right(), rRect.Bottom(),GetSizePixel().Width(), GetSizePixel().Height() );
+ Dialog::Paint( rRect );
+}
+
+void ScrollableDialog::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
+{
+ printf("ScrollableDialog::Draw( ( %d, %d ) h %d, w %d \n", rPos.X(), rPos.Y(), rSize.Height(), rSize.Width() );
+ Dialog::Draw( pDev, rPos, rSize, nFlags );
+}
+
void ScrollableDialog::Resize()
{
+ Size aOutSz = GetOutputSizePixel();
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 )
+ for ( int index = 0, count = GetChildCount(); index < count; ++index )
{
- Window* pChild = maContents.GetChild( index );
+ Window* pChild = GetChild( index );
if ( pChild )
{
Point aPos = pChild->GetPosPixel();
@@ -68,34 +165,33 @@ void ScrollableDialog::Resize()
}
}
- Size aOutSz = GetOutputSizePixel();
- long nScrWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
-
+#if 0
// assume for the moment that we have both hori & vert scroll bars
Size aContentsSize( aOutSz );
if ( mbHasVertBar )
{
- aContentsSize.Width() -= nScrWidth;
+ aContentsSize.Width() -= mnScrWidth;
nMaxX += nScrWidth;
}
if ( mbHasHoriBar )
{
- aContentsSize.Height() -= nScrWidth;
- nMaxY += nScrWidth;
+ aContentsSize.Height() -= mnScrWidth;
+ nMaxY += mnScrWidth;
}
maContents.SetSizePixel( aContentsSize );
+#endif
- Point aVPos( aOutSz.Width() - nScrWidth, 0 );
- Point aHPos( 0, aOutSz.Height() - nScrWidth );
+ Point aVPos( aOutSz.Width() - mnScrWidth, 0 );
+ Point aHPos( 0, aOutSz.Height() - mnScrWidth );
- maVScrollBar.SetPosSizePixel( aVPos, Size( nScrWidth, aContentsSize.Height() ) );
- maHScrollBar.SetPosSizePixel( aHPos, Size( aContentsSize.Width(), nScrWidth ) );
- maHScrollBar.SetRangeMax( nMaxX );
+ maVScrollBar.SetPosSizePixel( aVPos, Size( mnScrWidth, GetSizePixel().Height() - mnScrWidth ) );
+ maHScrollBar.SetPosSizePixel( aHPos, Size( GetSizePixel().Width() - mnScrWidth, mnScrWidth ) );
+ maHScrollBar.SetRangeMax( maScrollArea.Width() );
maHScrollBar.SetVisibleSize( GetSizePixel().Width() );
- maHScrollBar.SetPageSize( GetSizePixel().Width() );
- maVScrollBar.SetRangeMax( nMaxY );
+ maHScrollBar.SetPageSize( maScrollArea.Width() );
+ maVScrollBar.SetRangeMax( maScrollArea.Height() );
maVScrollBar.SetVisibleSize( GetSizePixel().Height() );
- maVScrollBar.SetPageSize( GetSizePixel().Height() );
+ maVScrollBar.SetPageSize( maScrollArea.Height() );
}
} // toolkit
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx
index c2bb0a1352ef..55ca00c4acf9 100644
--- a/toolkit/source/awt/vclxtoolkit.cxx
+++ b/toolkit/source/awt/vclxtoolkit.cxx
@@ -787,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 toolkit::ScrollableDialog( pParent, nWinBits | WB_AUTOHSCROLL | WB_AUTOVSCROLL );
+ pNewWindow = new toolkit::ScrollableDialog( 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,6 +1062,7 @@ 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 );
@@ -1070,7 +1071,7 @@ css::uno::Reference< css::awt::XWindowPeer > VCLXToolkit::ImplCreateWindow(
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/controls/dialogcontrol.cxx b/toolkit/source/controls/dialogcontrol.cxx
index 51c05108b041..630f64aa232f 100644
--- a/toolkit/source/controls/dialogcontrol.cxx
+++ b/toolkit/source/controls/dialogcontrol.cxx
@@ -173,6 +173,8 @@ UnoControlDialogModel::UnoControlDialogModel( const Reference< XMultiServiceFact
ImplRegisterProperty( BASEPROPERTY_DIALOGSOURCEURL );
ImplRegisterProperty( BASEPROPERTY_GRAPHIC );
ImplRegisterProperty( BASEPROPERTY_IMAGEURL );
+ ImplRegisterProperty( BASEPROPERTY_HSCROLL );
+ ImplRegisterProperty( BASEPROPERTY_VSCROLL );
Any aBool;
aBool <<= (sal_Bool) sal_True;
diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx
index a3d4b373e71c..5e13d2a94bed 100644
--- a/toolkit/source/helper/property.cxx
+++ b/toolkit/source/helper/property.cxx
@@ -185,6 +185,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount )
DECL_PROP_2 ( "HelpURL", HELPURL, ::rtl::OUString, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "HideInactiveSelection", HIDEINACTIVESELECTION, bool, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "HighContrastMode", HIGHCONTRASTMODE, bool, BOUND, MAYBEDEFAULT ),
+ DECL_PROP_2 ( "HoriScroll", HORISCROLL, bool, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "HScroll", HSCROLL, bool, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "HardLineBreaks", HARDLINEBREAKS, bool, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "ImageAlign", IMAGEALIGN, sal_Int16, BOUND, MAYBEDEFAULT),
@@ -256,6 +257,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount )
DECL_PROP_2 ( "ValueMin", VALUEMIN_DOUBLE, double, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "ValueStep", VALUESTEP_DOUBLE, double, BOUND, MAYBEDEFAULT ),
DECL_PROP_3 ( "VerticalAlign", VERTICALALIGN, VerticalAlignment, BOUND, MAYBEDEFAULT, MAYBEVOID ),
+ DECL_PROP_2 ( "VertScroll", VERTSCROLL, bool, BOUND, MAYBEDEFAULT ),
DECL_DEP_PROP_3 ( "VisibleSize", VISIBLESIZE, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ),
DECL_PROP_2 ( "Activated", ACTIVATED, sal_Bool, BOUND, MAYBEDEFAULT ),
DECL_PROP_2 ( "Complete", COMPLETE, sal_Bool, BOUND, MAYBEDEFAULT ),