Community
Participate
Working Groups
computeTrim does not work for Text on Windows. Test case pasted below. When the shell comes up, you should see 345 in the Text, but you only see 34. (the 5 is scrolled to the right). If you uncomment these 2 lines: //Point pt2 = text.computeSize (pt.x, pt.y); //text.setSize (pt2.x, pt2.y); and comment these 2 lines: Rectangle rect = text.computeTrim (0, 0, pt.x, pt.y); text.setSize (rect.width, rect.height); then you will see that computeSize works fine - it's just the computeTrim that is bogus. [ import com.ibm.swt.*; import com.ibm.swt.graphics.*; import com.ibm.swt.widgets.*; public class PR1G8W5RN { public static void main (String[] args) { String string = "345"; Display display = new Display(); Shell shell = new Shell(display); shell.setSize(300, 150); Text text = new Text (shell, SWT.SINGLE | SWT.BORDER); text.setText (string); GC gc = new GC (text); Point pt = gc.textExtent (string); gc.dispose (); Rectangle rect = text.computeTrim (0, 0, pt.x, pt.y); text.setSize (rect.width, rect.height); //Point pt2 = text.computeSize (pt.x, pt.y); //text.setSize (pt2.x, pt2.y); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } } ] NOTES: CM (3/10/01 6:06:25 PM) It's even worse on Motif - you can barely see the top half of the 3. Changing PR title to ALL instead of just WINNT. We should fix this. McQ (26/06/2001 11:09:50 AM) - CM to look at all of these.
PRODUCT VERSION: SWT 0.059 on Windows
On Windows, the problem is that the default computeTrim does not take into account the edit rectangle, which is usually a subset of the text client area in OS terms. A workaround is probably to use EM_GETMARGINS in a way similar to Text.computeSize. EM_GETRECT is good on the paper but returns undesired values when the width is < than a char, on W2K.
Chrix, do you have a fix for this?
Fixed > 20040726