Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318012

Summary: ExpandBar titles do not truncate with ellipsis
Product: [Eclipse Project] Platform Reporter: Matthew Wilson <mj.wilson.uk>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: eclipse.felipe
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description Matthew Wilson CLA 2010-06-25 12:24:02 EDT
Build Identifier: swt-3.6-win32-win32-x86

When horizontal space is limited, the titles of the items do not truncate with an ellipsis.  This means that the text overlaps the chevron, making it look slightly ugly.

A fix would probably include including DT_END_ELLIPSIS in the bits in ExpandItem.drawItem() when calling DrawThemeText/DrawText and trimming off CHEVRON_SIZE pixels from the rectangle too.

A prototype change I've made works fine on my machine.  The resulting code would be:

	if (text.length () > 0) {
		rect.left += ExpandItem.TEXT_INSET;
		TCHAR buffer = new TCHAR (parent.getCodePage (), text, false);
		rect.right -= ExpandItem.CHEVRON_SIZE;
		if (hTheme != 0) {
			OS.DrawThemeText (hTheme, hDC, OS.EBP_NORMALGROUPHEAD, 0, buffer.chars, buffer.length(), OS.DT_VCENTER | OS.DT_SINGLELINE | OS.DT_ENDELLIPSIS, 0, rect);
		} else {
			int oldBkMode = OS.SetBkMode (hDC, OS.TRANSPARENT);
			OS.DrawText (hDC, buffer, buffer.length (), rect, OS.DT_VCENTER | OS.DT_SINGLELINE | OS.DT_ENDELLIPSIS);
			OS.SetBkMode (hDC, oldBkMode);
		}
		rect.right += ExpandItem.CHEVRON_SIZE;
	}

Reproducible: Always

Steps to Reproduce:
1. Use ExpandBar in a program -- for example, a SWT snippet.
2. Compress the size of the window to less than the minimum space required
3. Witness that the text overlaps the chevron and there is no ellipsis.
Comment 1 Felipe Heidrich CLA 2010-08-13 12:40:21 EDT
Not sure I understand your problem.
There is bug there: when width is too small you can see that the chevron draws on top of the text (you can clearly see the text to the right of the chevron).

In the description you ask for us to not add ellipsis (which we do not). But in the code you are doing the opposite, and in order for it work properly you need to adjust the right edge of the rect so DrawText knows where to draw the ellipsis.

What is the fix you ask:
1) to clip the text (so it doesn't show behind of the chevron)
2) (1) + with ellipsis in the text
Comment 2 Matthew Wilson CLA 2010-08-16 04:37:17 EDT
Apologies if my original summary and description were unclear.  I was trying to describe the *current* behaviour.

I would like your option #2.

Further to this, the *current* behaviour will draw the chevron on top of the image (if present) when the width is very small -- I think this is bad also.  It would be better if it omitted the chevron if the width is too small for image + chevron.  If you like, I can update my 'patch' to include that logic.

So, in summary, the changes required are:

1. Clip the text's rectangle so that it does not overlap the chevron.
2. Use the option to draw text with an ellipsis.
3. Don't draw the chevron when there is insufficient width for both the image and chevron.

Thanks.
Comment 3 Felipe Heidrich CLA 2010-08-16 11:12:33 EDT
Not showing the chevron sounds wrong to me (as it is the only way you user has to see the whole title), maybe not showing the image is better. I don't think this a big deal, the item should not be that small anyway.
Comment 4 Matthew Wilson CLA 2010-08-17 05:18:16 EDT
Hiding the image instead is fine.  I'm not sure whether the height of the expand item's header should change in that case.
Comment 5 Eclipse Genie CLA 2018-12-07 14:57:49 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 6 Lars Vogel CLA 2019-09-02 15:03:33 EDT
This bug has been marked as stalebug a while ago without any further interaction.

If this report is still relevant for the current release, please reopen and remove the stalebug whiteboard flag.
Comment 7 Lars Vogel CLA 2019-09-02 15:04:13 EDT
This bug was marked as stalebug a while ago. Marking as worksforme.

If this report is still relevant for the current release, please reopen and remove the stalebug whiteboard tag.