From 73ee56991535559e50652ecc6391cdfa11c08af2 Mon Sep 17 00:00:00 2001 From: Markus Keller Date: Thu, 8 Nov 2012 20:10:13 +0100 Subject: Bug 39934: [ScrolledComposite] ScrolledComposite page increment should default to size of client area --- .../common/org/eclipse/swt/custom/ScrolledCompositeLayout.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'bundles/org.eclipse.swt/Eclipse SWT Custom Widgets') diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledCompositeLayout.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledCompositeLayout.java index 0af014860e..c99710d11f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledCompositeLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledCompositeLayout.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -78,9 +78,12 @@ protected void layout(Composite composite, boolean flushCache) { contentRect.height = Math.max(sc.minHeight, hostRect.height); } + GC gc = new GC (sc); if (hBar != null) { hBar.setMaximum (contentRect.width); hBar.setThumb (Math.min (contentRect.width, hostRect.width)); + hBar.setIncrement (gc.getFontMetrics ().getAverageCharWidth ()); + hBar.setPageIncrement (hostRect.width); int hPage = contentRect.width - hostRect.width; int hSelection = hBar.getSelection (); if (hSelection >= hPage) { @@ -95,6 +98,8 @@ protected void layout(Composite composite, boolean flushCache) { if (vBar != null) { vBar.setMaximum (contentRect.height); vBar.setThumb (Math.min (contentRect.height, hostRect.height)); + vBar.setIncrement (gc.getFontMetrics ().getHeight ()); + vBar.setPageIncrement (hostRect.height); int vPage = contentRect.height - hostRect.height; int vSelection = vBar.getSelection (); if (vSelection >= vPage) { @@ -105,6 +110,7 @@ protected void layout(Composite composite, boolean flushCache) { contentRect.y = -vSelection; } } + gc.dispose (); sc.content.setBounds (contentRect); inLayout = false; -- cgit