Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorXi Yan2018-07-20 15:04:00 +0000
committerXi Yan2018-07-20 15:57:15 +0000
commit91bfeb013d3174ab0ad66822ff3e1a5b2f20123b (patch)
treecffc24c51e501c2c421f6479a1f47fcd7be210de /tests
parent10b642102b02924147b91fef615c43374b1d92e8 (diff)
downloadeclipse.platform.swt-91bfeb013d3174ab0ad66822ff3e1a5b2f20123b.tar.gz
eclipse.platform.swt-91bfeb013d3174ab0ad66822ff3e1a5b2f20123b.tar.xz
eclipse.platform.swt-91bfeb013d3174ab0ad66822ff3e1a5b2f20123b.zip
Bug 536934 - [GTK3] Tree does not allow painting the full item
Changes made to custom drawn trees which updates event.x from Cairo context causes paint to "jump" when scrolling horizontally and not scrolling to the end of the text on GTK3.16 and above. Checks for GTK versions >3.9 and <3.14.8 when making updating event.x from Cairo context. See bug 535124, and bug 465309. Tested on GTK3.22 with snippet attached to this patch, sample project in bug 535124, and the open type dialog, package explorer in a child Eclipse. Change-Id: Iaf464c6fee1d5ef288346abbd0ab5a60f20f1a95 Signed-off-by: Xi Yan <xixiyan@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug536934_TreeFullItem.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug536934_TreeFullItem.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug536934_TreeFullItem.java
new file mode 100644
index 0000000000..afcb837942
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug536934_TreeFullItem.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Thomas Singer
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class Bug536934_TreeFullItem {
+
+ 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.BORDER);
+
+ final TreeItem item1 = new TreeItem(tree, SWT.None);
+ new TreeItem(item1, SWT.NONE);
+ final TreeItem item2 = new TreeItem(tree, SWT.None);
+ new TreeItem(item2, SWT.NONE);
+
+ final Listener listener = new Listener() {
+ private final String text = "item fkds fjsd fd dsf d fd sfkl dsl fsld fl sfl sd f dflk sd flds fds END";
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.type == SWT.MeasureItem) {
+ final Point size = event.gc.textExtent(text);
+ event.width = size.x;
+ event.height = size.y;
+ }
+ else if (event.type == SWT.EraseItem) {
+ if ((event.detail & SWT.SELECTED) > 0) {
+ event.gc.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
+ event.gc.setForeground(display.getSystemColor(SWT.COLOR_YELLOW));
+ }
+ else {
+ event.gc.setBackground(display.getSystemColor(SWT.COLOR_MAGENTA));
+ event.gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
+ }
+ event.gc.fillRectangle(event.x, event.y, event.width, event.height);
+ event.detail &= ~SWT.SELECTED;
+ }
+ else if (event.type == SWT.PaintItem) {
+ event.gc.drawText(text, event.x, event.y, true);
+ }
+ }
+ };
+ tree.addListener(SWT.MeasureItem, listener);
+ tree.addListener(SWT.EraseItem, listener);
+ tree.addListener(SWT.PaintItem, listener);
+
+ shell.setSize(300, 300);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+
+ display.dispose();
+ }
+} \ No newline at end of file

Back to the top