Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 179279 - Tree with PaintItem listener only shows horizontal scrollbar if MeasureItem is hooked
Summary: Tree with PaintItem listener only shows horizontal scrollbar if MeasureItem i...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 177339
  Show dependency tree
 
Reported: 2007-03-26 07:00 EDT by Markus Keller CLA
Modified: 2007-06-05 16:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2007-03-26 07:00:26 EDT
I20070323-1616

A Tree with a PaintItem listener only shows a horizontal scrollbar if MeasureItem is also hooked:

public class SnippetNoHScrollbar {

public static void main(String[] args) {
	final Display display = new Display();
	final Shell shell = new Shell(display);
	shell.setLayout (new FillLayout());
	
	final Tree tree= new Tree(shell, SWT.MULTI);
	for (int i= 0; i < 21; i++) {
		TreeItem item= new TreeItem(tree, SWT.NONE);
		item.setText("Item with long name" + i);
		
		for (int j= 0; j < 11; j++) {
			TreeItem subItem= new TreeItem(item, SWT.NONE);
			subItem.setText("SubItem " + j);
		}
	}
	final Color red= display.getSystemColor(SWT.COLOR_RED);
	tree.addListener(SWT.PaintItem, new Listener() {
		public void handleEvent(Event e) {
			e.gc.setForeground(red);
			e.gc.drawRectangle(e.x + 1, e.y + 1, e.width - 3, e.height - 3);
		}
	});
//	tree.addListener(SWT.MeasureItem, new Listener() {
//		public void handleEvent(Event e) {
//			// uncomment to make horizontal scrollbar appear ...
//		}
//	});
	
	shell.setSize(50, 300);
	shell.open();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
}
Comment 1 Steve Northover CLA 2007-05-12 08:40:55 EDT
This is a duplicate that has been fixed for a week or so (can't find the number).  If not fixed, please reopen.