Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 266204 Details for
Bug 510172
[Cocoa] MeasureItem-event sent 3 times, sometimes with wrong event.details
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Sample to reproduce
Snippet220.java (text/plain), 2.31 KB, created by
Thomas Singer
on 2017-01-10 05:21:30 EST
(
hide
)
Description:
Sample to reproduce
Filename:
MIME Type:
Creator:
Thomas Singer
Created:
2017-01-10 05:21:30 EST
Size:
2.31 KB
patch
obsolete
>import org.eclipse.swt.*; >import org.eclipse.swt.graphics.*; >import org.eclipse.swt.widgets.*; > >/** > * @author Thomas Singer > */ >public class Snippet220 { > > public static void main(String [] args) { > Display display = new Display(); > Shell shell = new Shell(display); > shell.setBounds(10, 10, 350, 200); > Image xImage = new Image (display, 16, 16); > GC gc = new GC(xImage); > gc.setForeground(display.getSystemColor(SWT.COLOR_RED)); > gc.drawLine(1, 1, 14, 14); > gc.drawLine(1, 14, 14, 1); > gc.drawOval(2, 2, 11, 11); > gc.dispose(); > final int IMAGE_MARGIN = 2; > final Tree tree = new Tree(shell, SWT.BORDER); > tree.setBounds(10, 10, 300, 150); > TreeItem item = new TreeItem(tree, SWT.NONE); > item.setText("root item"); > for (int i = 0; i < 4; i++) { > TreeItem newItem = new TreeItem(item, SWT.NONE); > newItem.setText("descendent " + i); > if (i % 2 == 0) newItem.setData(xImage); > item.setExpanded(true); > item = newItem; > } > > /* > * NOTE: MeasureItem and PaintItem are called repeatedly. Therefore it is > * critical for performance that these methods be as efficient as possible. > */ > final Listener listener = new Listener() { > private boolean selected; > > @Override > public void handleEvent(Event event) { > TreeItem item1 = (TreeItem)event.item; > Image trailingImage = (Image)item1.getData(); > if (event.type == SWT.MeasureItem) { > selected = (event.detail & SWT.SELECTED) != 0; > System.out.println("measure " + item1.getText() + " = " + selected); > if (trailingImage != null) { > event.width += trailingImage.getBounds().width + IMAGE_MARGIN; > } > } > else if (event.type == SWT.PaintItem) { > if (trailingImage != null) { > int x = event.x; > System.out.println("paint " + item1.getText() + " = " + ((event.detail & SWT.SELECTED) != 0)); > if (selected) { > x += event.width + IMAGE_MARGIN; > } > int itemHeight = tree.getItemHeight(); > int imageHeight = trailingImage.getBounds().height; > int y = event.y + (itemHeight - imageHeight) / 2; > event.gc.drawImage(trailingImage, x, y); > } > } > } > }; > tree.addListener(SWT.MeasureItem, listener); > tree.addListener(SWT.PaintItem, listener); > > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) display.sleep(); > } > xImage.dispose(); > display.dispose(); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 510172
: 266204