diff options
author | Felipe Heidrich <fheidric> | 2007-09-13 16:33:44 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2007-09-13 16:33:44 +0000 |
commit | 4a3bc808f901fc912cb07ed81b640170056cb41c (patch) | |
tree | a94e384e72f1af7160e2262f0f17724fb92c6d19 /bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java | |
parent | d786dbacf836ad2de3f0df80c16f6245c829bc74 (diff) | |
download | eclipse.platform.swt-4a3bc808f901fc912cb07ed81b640170056cb41c.tar.gz eclipse.platform.swt-4a3bc808f901fc912cb07ed81b640170056cb41c.tar.xz eclipse.platform.swt-4a3bc808f901fc912cb07ed81b640170056cb41c.zip |
Bug 149576 [DnD] StyledText auto-scroll does not work if first line is empty
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java index 4af30cb234..9761630761 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextDropTargetEffect.java @@ -158,37 +158,27 @@ public class StyledTextDropTargetEffect extends DropTargetEffect { pt.y >= scrollY && pt.y <= (scrollY + SCROLL_TOLERANCE))) { if (System.currentTimeMillis() >= scrollBeginTime) { Rectangle area = text.getClientArea(); - Rectangle bounds = text.getTextBounds(0, 0); - int charWidth = bounds.width; + GC gc = new GC(text); + FontMetrics fm = gc.getFontMetrics(); + gc.dispose(); + int charWidth = fm.getAverageCharWidth(); int scrollAmount = 10*charWidth; if (pt.x < area.x + 3*charWidth) { int leftPixel = text.getHorizontalPixel(); text.setHorizontalPixel(leftPixel - scrollAmount); - if (text.getHorizontalPixel() != leftPixel) { - text.redraw(); - } } if (pt.x > area.width - 3*charWidth) { int leftPixel = text.getHorizontalPixel(); text.setHorizontalPixel(leftPixel + scrollAmount); - if (text.getHorizontalPixel() != leftPixel) { - text.redraw(); - } } - int lineHeight = bounds.height; + int lineHeight = text.getLineHeight(); if (pt.y < area.y + lineHeight) { int topPixel = text.getTopPixel(); text.setTopPixel(topPixel - lineHeight); - if (text.getTopPixel() != topPixel) { - text.redraw(); - } } if (pt.y > area.height - lineHeight) { int topPixel = text.getTopPixel(); text.setTopPixel(topPixel + lineHeight); - if (text.getTopPixel() != topPixel) { - text.redraw(); - } } scrollBeginTime = 0; scrollX = scrollY = -1; |