Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 4376 Details for
Bug 35790
GC#stringExtent() lies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Test program.
(text/plain), 2.44 KB, created by
adrian
on 2003-03-27 19:07:10 EST
(
hide
)
Description:
Test program.
Filename:
MIME Type:
Creator:
adrian
Created:
2003-03-27 19:07:10 EST
Size:
2.44 KB
patch
obsolete
>// Mismatch between actual painting with gc.drawString() and the gc.stringExtent() >// info, for e.g., chars '\u0001' - \u0006'. The extent returned is larger than the >// actual extent painted. >// >// This makes it impossible e.g., to match a mouse-click's x offset in the window >// to the correct index inside the displayed text string. >// >// These characters seem to be filtered out somehow by StyledText's rendering >// (they have a width of 0 pixels on the display)?! What is the full set of these >// characters? > >import org.eclipse.swt.*; >import org.eclipse.swt.graphics.*; >import org.eclipse.swt.widgets.*; > >public class Main { > >public static void main (String[] args) { > Display display = new Display(); > Shell shell = new Shell(display); > shell.open(); > GC gc = new GC(shell); > > Font font = new Font(display, "Courier", 10, SWT.NORMAL); > gc.setFont(font); > > String r = "*23456789012345678901234567890....+....01234567890"; > String x1 = "0....+....01234567890"; > String x2 = "....01234567890"; > String x3 = "890"; > > int extr = gc.stringExtent(r).x; > int ext1 = gc.stringExtent(x1).x; > int ext2 = gc.stringExtent(x2).x; > int ext3 = gc.stringExtent(x3).x; > > gc.drawString(r, 0, 0); > for (int i = 0; i < 50; i++) { > int x = gc.stringExtent(r.substring(0,i)).x; > gc.drawLine(x, 15, x, 25); > gc.drawString(String.valueOf(r.charAt(i)), x, 30); > } > > gc.drawString(x1, 0, 60); > for (int i = 0; i < 50; i++) { > int x = gc.stringExtent(x1.substring(0,i)).x; > gc.drawLine(x, 75, x, 85); > gc.drawString(String.valueOf(x1.charAt(i)), x, 90); > } > > gc.drawString(x2, 0, 120); > for (int i = 0; i < 50; i++) { > int x = gc.stringExtent(x2.substring(0,i)).x; > gc.drawLine(x, 135, x, 145); > gc.drawString(String.valueOf(x2.charAt(i)), x, 150); > } > > gc.drawString(x3, 0, 180); > for (int i = 0; i < 50; i++) { > int x = gc.stringExtent(x3.substring(0,i)).x; > gc.drawLine(x, 195, x, 205); > gc.drawString(String.valueOf(x3.charAt(i)), x, 210); > } > > gc.drawString("*** stringExtent()s: " + extr + ' ' + ext1 + ' ' + ext2 + ' ' + ext3, > 0, 240); > > gc.dispose (); > while (!shell.isDisposed ()) { > if (!display.readAndDispatch ()) display.sleep (); > } > display.dispose (); >} >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 35790
: 4376 |
4380
|
4381
|
4390