Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 75284 - Inconsistant getBounds() or fillRectangle() behaviour between linux and windows
Summary: Inconsistant getBounds() or fillRectangle() behaviour between linux and windows
Status: RESOLVED DUPLICATE of bug 42416
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux-GTK
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-29 10:21 EDT by Stephen Rowles CLA
Modified: 2004-09-30 13:05 EDT (History)
1 user (show)

See Also:


Attachments
windows correctly highlighting the grey cell (40.45 KB, image/jpeg)
2004-09-29 10:22 EDT, Stephen Rowles CLA
no flags Details
linux-gtk incorrectly highlighting the grey-cell (33.92 KB, image/jpeg)
2004-09-29 10:22 EDT, Stephen Rowles CLA
no flags Details
Incorrect alignment of cell in a table (as opposed to TableViewer) (1.52 KB, image/jpeg)
2004-09-29 10:24 EDT, Stephen Rowles CLA
no flags Details
Source code for modified SampleView.java (3.28 KB, text/plain)
2004-09-29 10:25 EDT, Stephen Rowles CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Rowles CLA 2004-09-29 10:21:14 EDT
I use a TableViewer to create a table containing several rows of data.
As part of this I wish to "grey out" some selected cells in the table.

To do this I use a new GC placed on the table, and get the location of the cell
to draw a rectangle on by calling the getBounds(index) on the table item in the
table.

On windows this produces the correct behaviour, and the grey cell is perfectly
aligned with the required cell. On linux-gtk, the bound box appears to be out by
the size of the column heading titles. Additionally if you use a 
table, rather than a TableViewer() the cells almost line up but they appear
to be out by a few pixels on linux (see tablebug_linux.jpg attached file). It
would appear that the getBounds(index) call is not returning the correct
bounding rectangle in either case.

Below is the code needed to draw a simple table, it should highlight the cell
containing the words "item 1 col 1" as seen in the windows screen shot, but
on linux it draws the box in completely the wrong place.

Windows eclipse: 3.0.0 - 200406192000
Linux   eclipse: 3.0.1 - 200409161125

To re-create do the following:

1) Create a simple plugin, using the plugin with view wizard
2) replace the SampleView code with the code attached to the bug

Relevant painting section of the code is below:

  private void paintGreyCells() {
    // For each row...
    for (int i = 0; i < viewer.getTable().getItemCount(); i++) {
      // Get the table item, and check text to see if we grey it out
      TableItem tableItem = viewer.getTable().getItem(i);
      if (tableItem.getText(1).equals("item 1 col 1")) {
        tableItemGC.fillRectangle(tableItem.getBounds(1));
      }
    }
  }
Comment 1 Stephen Rowles CLA 2004-09-29 10:22:10 EDT
Created attachment 14883 [details]
windows correctly highlighting the grey cell
Comment 2 Stephen Rowles CLA 2004-09-29 10:22:43 EDT
Created attachment 14884 [details]
linux-gtk incorrectly highlighting the grey-cell
Comment 3 Stephen Rowles CLA 2004-09-29 10:24:14 EDT
Created attachment 14886 [details]
Incorrect alignment of cell in a table (as opposed to TableViewer)
Comment 4 Stephen Rowles CLA 2004-09-29 10:25:19 EDT
Created attachment 14890 [details]
Source code for modified SampleView.java
Comment 5 Grant Gayed CLA 2004-09-30 13:05:03 EDT
Note that there's new api on TableItem in 3.0 for setting an individual cell's
foreground, background and font.  This might be an easier approach.


*** This bug has been marked as a duplicate of 42416 ***