Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 56593 - TableItem.setFont() causes cels to be rendered with ellipsis even when they aren't necessary
Summary: TableItem.setFont() causes cels to be rendered with ellipsis even when they a...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Veronika Irvine CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 68164 (view as bug list)
Depends on:
Blocks: 54057
  Show dependency tree
 
Reported: 2004-03-29 11:23 EST by Kim Horne CLA
Modified: 2005-02-23 15:59 EST (History)
1 user (show)

See Also:


Attachments
Doesn't happen for me (82.65 KB, image/bmp)
2004-03-30 09:55 EST, Steve Northover CLA
no flags Details
What I get (22.10 KB, image/jpeg)
2004-03-30 10:01 EST, Kim Horne CLA
no flags Details
Table.setFont() vs TabileItem.setFont() (20.74 KB, image/jpeg)
2004-03-30 14:33 EST, Kim Horne CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kim Horne CLA 2004-03-29 11:23:08 EST
M8

See the following example and note that the second table (with the fonts set)
has ellipis even when there is plenty of space.

/**
 * @since 3.0
 */
public class TableItemTest {

    public static void main(String [] argv) {
		final Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());
		
		Table t = new Table(shell, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
		TableItem i = new TableItem(t, SWT.NONE);
		i.setText("Good table item 1");
		i = new TableItem(t, SWT.NONE);
		i.setText("Good table item 2");
		i = new TableItem(t, SWT.NONE);
		i.setText("Good table item 3");		
		
		Font f = new Font(shell.getDisplay(), "Courier New", 8, SWT.NORMAL);
		t = new Table(shell, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
		i = new TableItem(t, SWT.NONE);
		i.setText("Bad table item 1");
		i.setFont(f);
		i = new TableItem(t, SWT.NONE);
		i.setText("Bad table item 2");
		i.setFont(f);
		i = new TableItem(t, SWT.NONE);
		i.setText("Bad table item 3");
		i.setFont(f);
		
		shell.pack();
		
		shell.open();
		shell.redraw();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();

    }
}
Comment 1 Steve Northover CLA 2004-03-30 09:55:45 EST
Created attachment 9007 [details]
Doesn't happen for me
Comment 2 Kim Horne CLA 2004-03-30 10:01:22 EST
Created attachment 9008 [details]
What I get

There is what I get, both before and after resizing the window.
Comment 3 Steve Northover CLA 2004-03-30 13:38:17 EST
Do you have any ideas?  What theme are you using?
Comment 4 Kim Horne CLA 2004-03-30 14:03:28 EST
I'm running the XP Silver theme with slightly modified font sizes - my window
title font is set a bit larger.  I've tried reverting to the default theme and I
still see the same results.

Michael suggested it might be an issue with my video card(s)/drivers(s).  
Comment 5 Kim Horne CLA 2004-03-30 14:25:24 EST
If you modify the code to set the font on the "good table" items to
Display.getSystemFont() they render correctly.  

Also, if you set the 'bad font" font on the "bad table" (not the items) then the
ellipsis do not appear.
Comment 6 Kim Horne CLA 2004-03-30 14:32:12 EST
I also found something else... not sure if it's a symptom of the same problem or
not.  If you set the font on a cel item to be something very large (20pt, for
instance) then the cel items draw over one another and are not sufficiently
large to contain the text.  However, if you set it on the table itself then the
cels are sized properly (both vertically and horizontally).
Comment 7 Kim Horne CLA 2004-03-30 14:33:07 EST
Created attachment 9029 [details]
Table.setFont() vs TabileItem.setFont()
Comment 8 Steve Northover CLA 2004-03-30 15:23:54 EST
The problem is that the Windows table does not really support different fonts 
in table items very well.  What it provides is the ability to draw an item 
using a different font.  Needless to say, it doesn't know to use the font that 
you are going to draw with to do the measuring necessary to show scroll bars.  
We could possible hack Table.setScrollWidth() to measure the right font.

Strangely, it does't seem to fail on my machine no matter what font I choose.  
Could something else be going on?
Comment 9 Kim Horne CLA 2004-03-30 15:36:35 EST
What version of XP are you running?  I'm running XP Professional 2002 SP 1... 

I've managed to find a workaround for my particular case.  Whenever I'm going to
set a font on the item I check to see how wide the item string is when rendered
in that font.  If it's larger than my last known largest value I set that font
on the table as well as the item.  It's ugly but it'll work until this gets sorted.
Comment 10 Kim Horne CLA 2004-06-22 10:35:02 EDT
*** Bug 68164 has been marked as a duplicate of this bug. ***
Comment 11 Veronika Irvine CLA 2005-02-23 15:05:15 EST
The Table widget was changed so that it measures each string rather than using 
LVSCW_AUTOSIZE.  This was done for performance.  As a side effect, I think it 
may have fixed this bug.  I can not make the problem happen for me.  Kim, does 
the problem still happen for you?
Comment 12 Kim Horne CLA 2005-02-23 15:09:34 EST
I havn't noticed it in some time, now that you mention it.
Comment 13 Veronika Irvine CLA 2005-02-23 15:59:23 EST
Closing as Fixed.  Resolved some time late 2004 as a side effect of another 
bug fix.  Please reopen if you see this again.