| Summary: | Incorrect GC colors on Table's PaintItem event when row selected + no EraseItem | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | ArronM <arronm> | ||||
| Component: | SWT | Assignee: | Grant Gayed <grant_gayed> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | grant_gayed, Silenio_Quarti, skovatch | ||||
| Version: | 3.6 | Flags: | Silenio_Quarti:
review+
skovatch: review+ |
||||
| Target Milestone: | 3.6 RC2 | ||||||
| Hardware: | PC | ||||||
| OS: | Mac OS X | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
I haven't double checked, but I think I saw the same behavior on Tree widgets as well (In reply to comment #1) > I haven't double checked, but I think I saw the same behavior on Tree widgets > as well That wouldn't surprise me. The implementations are very similar. SSQ as part of Table revision 1.131 (no associated bug report) you added line "boolean hasFocus = hooksErase && hasFocus ();". Do you remember if there was a reason for the hooksErase part? hasFocus is only referenced in the block that immediately follows, and in a block further down where hooksErase is already known to be true, so I believe this fix is safe. Created attachment 168613 [details]
patch
Discussed with SSQ, he thinks having hooksErase there is wrong. Running the test with and without the patch so I can understand what's going on. Should have an answer shortly, but it looks good at first glance. Looks good. I'm building up my understanding of custom tree and table drawing, but I think this is the right change. fixed > 20100518 |
Build Identifier: SWT3647 When a table has a PaintItem listener but no EraseItem listener, the PaintItem's event.GC will not have the correct Foreground and Background color. Run the snippet below and select the first row of each table. When in focus, the table without the EraseItem will have wrong colors. Reproducible: Always Steps to Reproduce: Snippet: import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.*; public class testTableFG { public static void main(String[] args) { Display display = new Display(); Shell shellMain = new Shell(display, SWT.SHELL_TRIM); shellMain.setLayout(new FillLayout(SWT.VERTICAL)); Table table = new Table(shellMain, SWT.BORDER); new TableColumn(table, SWT.RIGHT); new TableItem(table, SWT.NONE).setText("setText"); table.getColumn(0).setWidth(300); table.addListener(SWT.PaintItem, new Listener() { public void handleEvent(Event event) { Rectangle bounds = ((TableItem) event.item).getBounds(event.index); event.gc.fillRectangle(bounds.x + 5, bounds.y, 10, bounds.height); event.gc.drawText("drawnText/No EraseItem", bounds.x + 20, bounds.y, true); } }); ///////////////////// Table table2 = new Table(shellMain, SWT.BORDER); new TableColumn(table2, SWT.RIGHT); new TableItem(table2, SWT.NONE).setText("setText"); table2.getColumn(0).setWidth(300); table2.addListener(SWT.PaintItem, new Listener() { public void handleEvent(Event event) { Rectangle bounds = ((TableItem) event.item).getBounds(event.index); event.gc.fillRectangle(bounds.x + 5, bounds.y, 10, bounds.height); event.gc.drawText("drawnText/EraseItem", bounds.x + 20, bounds.y, true); } }); table2.addListener(SWT.EraseItem, new Listener() { public void handleEvent(Event event) { } }); //////////////// shellMain.open(); while (!shellMain.isDisposed()) { try { if (!display.readAndDispatch()) display.sleep(); } catch (Throwable t) { t.printStackTrace(); } } display.dispose(); } }