Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 178008 - Offsets when rendering text in a tree/table item
Summary: Offsets when rendering text in a tree/table item
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 134504 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-03-19 04:40 EDT by Martin Aeschlimann CLA
Modified: 2007-05-07 06:33 EDT (History)
6 users (show)

See Also:


Attachments
SWT snippet (2.69 KB, text/plain)
2007-04-12 10:52 EDT, Martin Aeschlimann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2007-03-19 04:40:49 EDT
20070319

When I use owner draw on a TreeItem or TableItem and want to draw text at the same location as where the native painter would draw the text, I need to know a x and y offset relative to the items bound.
I believe the offsets depend on the OS and on the font used.
Comment 1 Steve Northover CLA 2007-04-04 15:01:15 EDT
I would like to fix this but it requires new API.  Please apply pressure to make it happen.
Comment 2 Martin Aeschlimann CLA 2007-04-05 05:19:45 EDT
ok, I will
Comment 3 Martin Aeschlimann CLA 2007-04-05 09:04:42 EDT
*** Bug 134504 has been marked as a duplicate of this bug. ***
Comment 4 Martin Aeschlimann CLA 2007-04-12 10:52:15 EDT
Created attachment 63610 [details]
SWT snippet

SWT snippet that shows how we use owner draw.
It also shows the usage of hard coded constants:
	int x= bounds.x + 2;
	int y= bounds.y + 2;
I'm not sure if the 'y' can be computed by using the bound height and font height.
Comments from the SWT team about the snippet are highly welcome.
Comment 5 Martin Aeschlimann CLA 2007-04-12 10:54:22 EDT
Steve, can you maybe add a patch to show a preview of the required new API? We can then post this bug to the PMC mailing list for approval.
Comment 6 Steve Northover CLA 2007-04-14 17:40:08 EDT
Fooling around with offsets won't work.  Some platforms leave space for images even though there is no image there.

The API I have in mind is TableItem.getTextBounds(int) and TreeItem.getTextBounds(int).  I am just hacking up test code and implementations on all platforms to make sure it works.
Comment 7 Steve Northover CLA 2007-04-19 18:51:32 EDT
Martin, please post this bug on the PMC list.
Comment 8 Martin Aeschlimann CLA 2007-04-20 03:12:26 EDT
PMC request sent
Comment 9 Mike Wilson CLA 2007-04-23 14:25:17 EDT
+1
Comment 10 Silenio Quarti CLA 2007-04-23 15:14:13 EDT
Fixed > 20070423.

See TableItem.getTextBounds(int) and TreeItem.getTextBounds(int).  
Comment 11 Markus Keller CLA 2007-04-24 10:12:40 EDT
All versions except win32 are currently missing Javadocs.
Comment 12 Silenio Quarti CLA 2007-04-24 10:19:53 EDT
All SWT javadocs will be copied from windows to the other platforms close to the end of 3.3.