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 277856 Details for
Bug 531048
[GTK3] Large problems drawing ownerdraw tables
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Bug snippet reproducing the issue in Tree
Bug531048_VirtualTreeCheese.java (text/x-java), 4.33 KB, created by
Eric Williams
on 2019-03-13 15:51:00 EDT
(
hide
)
Description:
Bug snippet reproducing the issue in Tree
Filename:
MIME Type:
Creator:
Eric Williams
Created:
2019-03-13 15:51:00 EDT
Size:
4.33 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2019 Red Hat and others. All rights reserved. > * The contents of this file are made available under the terms > * of the GNU Lesser General Public License (LGPL) Version 2.1 that > * accompanies this distribution (lgpl-v21.txt). The LGPL is also > * available at http://www.gnu.org/licenses/lgpl.html. If the version > * of the LGPL at http://www.gnu.org is different to the version of > * the LGPL accompanying this distribution and there is any conflict > * between the two license versions, the terms of the LGPL accompanying > * this distribution shall govern. > * > * Contributors: > * Red Hat - initial API and implementation > *******************************************************************************/ >package org.eclipse.swt.tests.gtk.snippets; > >import org.eclipse.swt.SWT; >import org.eclipse.swt.events.SelectionAdapter; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.graphics.Point; >import org.eclipse.swt.graphics.Rectangle; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Listener; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Tree; >import org.eclipse.swt.widgets.TreeColumn; >import org.eclipse.swt.widgets.TreeItem; > >/** > * @author Thomas Singer > */ >public class Bug531048_VirtualTreeCheese { > > // Constants ============================================================== > > static final int COUNT1 = 10000; > static final int COUNT2 = 100; > > private static boolean packPending = true; > > // Static ================================================================= > > public static void main(String[] args) { > final Display display = new Display(); > final Shell shell = new Shell(display); > shell.setLayout(new FillLayout(SWT.VERTICAL)); > > final Button button = new Button(shell, SWT.NONE); > final Tree table = new Tree(shell, SWT.VIRTUAL | SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL); > button.setText("Change content"); > button.addSelectionListener(new SelectionAdapter() { > @Override > public void widgetSelected(SelectionEvent e) { > table.setItemCount(table.getItemCount() == COUNT1 ? COUNT2 : COUNT1); > } > }); > > table.setHeaderVisible(true); > final Listener listener = event -> { > final TreeItem item = (TreeItem)event.item; > if (event.type == SWT.EraseItem) { > if (event.index < 2) { > event.detail &= ~SWT.FOREGROUND; > } > } > else if (event.type == SWT.PaintItem) { > final String text1 = (String)item.getData(); > if (event.index == 0) { > event.gc.drawText(text1, event.x, event.y, true); > } > else if (event.index == 1) { > final Point size = event.gc.textExtent(text1); > final Rectangle bounds = item.getBounds(event.index); > event.gc.drawText(text1, bounds.x + bounds.width - size.x, bounds.y + bounds.height - size.y, true); > } > } > else if (event.type == SWT.MeasureItem) { > final String text2 = (String)item.getData(); > final Point point = event.gc.textExtent(text2); > event.height = point.y * 2; > event.width = Math.max(event.width, point.x); > } > else if (event.type == SWT.SetData) { > final int index = table.indexOf(item); > final String data = "Item " + index; > item.setText(2, data); > item.setData(data); > > if (packPending) { > packPending = false; > display.asyncExec(() -> { > table.setRedraw(false); > for (TreeColumn column : table.getColumns()) { > column.pack(); > } > table.setRedraw(true); > }); > } > } > }; > table.addListener(SWT.EraseItem, listener); > table.addListener(SWT.SetData, listener); > table.addListener(SWT.MeasureItem, listener); > table.addListener(SWT.PaintItem, listener); > > createColumn(SWT.LEFT, "OD Left", table); > createColumn(SWT.RIGHT, "OD Right", table); > createColumn(SWT.LEFT, "Primitive", table); > > table.setItemCount(COUNT1); > TreeItem topItem = table.getItem(0); > table.setTopItem(topItem); > > shell.setSize(400, 500); > shell.open(); > > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) { > display.sleep(); > } > } > display.dispose(); > } > > private static void createColumn(int style, String text, Tree table) { > final TreeColumn tableColumn = new TreeColumn(table, style); > tableColumn.setText(text); > tableColumn.setMoveable(true); > } >}
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 531048
:
272645
|
272647
|
272648
|
272649
|
272650
|
272838
| 277856