diff options
author | Felipe Heidrich <fheidric> | 2005-10-19 20:01:05 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2005-10-19 20:01:05 +0000 |
commit | a1213b47c76ba7da3173cb596addde480b39ff3b (patch) | |
tree | 423b5c0c04941caef88d94e08866eca31120f7b1 | |
parent | 8254e52b409335cbc7d795d717fff180641a0706 (diff) | |
download | eclipse.platform.swt-a1213b47c76ba7da3173cb596addde480b39ff3b.tar.gz eclipse.platform.swt-a1213b47c76ba7da3173cb596addde480b39ff3b.tar.xz eclipse.platform.swt-a1213b47c76ba7da3173cb596addde480b39ff3b.zip |
*** empty log message ***
2 files changed, 20 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/textlayout/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/textlayout/org/eclipse/swt/graphics/TextLayout.java index f5cf5e7011..e14d10b4b3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/emulated/textlayout/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/textlayout/org/eclipse/swt/graphics/TextLayout.java @@ -938,6 +938,16 @@ public int getOffset (int x, int y, int[] trailing) { StyleItem run = lineRuns[i]; if (run.lineBreak && !run.softBreak) return run.start; if (width + run.width > x) { + if (run.style != null && run.style.metrics != null) { + int xRun = x - width; + GlyphMetrics metrics = run.style.metrics; + if (metrics.width > 0) { + if (trailing != null) { + trailing[0] = (xRun % metrics.width < metrics.width / 2) ? 0 : 1; + } + return run.start + xRun / metrics.width; + } + } if (run.tab) { if (trailing != null) { trailing[0] = x < (width + run.width / 2) ? 0 : 1; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/TextLayout.java index 1db9fb0ebd..bae6c57230 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/TextLayout.java @@ -980,6 +980,16 @@ public int getOffset (int x, int y, int[] trailing) { StyleItem run = lineRuns[i]; if (run.lineBreak && !run.softBreak) return run.start; if (width + run.width > x) { + if (run.style != null && run.style.metrics != null) { + int xRun = x - width; + GlyphMetrics metrics = run.style.metrics; + if (metrics.width > 0) { + if (trailing != null) { + trailing[0] = (xRun % metrics.width < metrics.width / 2) ? 0 : 1; + } + return run.start + xRun / metrics.width; + } + } if (run.tab) { if (trailing != null) { trailing[0] = x < (width + run.width / 2) ? 0 : 1; |