1 /******************************************************************************* 2 * Copyright (c) 2018 Red Hat and others. All rights reserved. 3 * The contents of this file are made available under the terms 4 * of the GNU Lesser General Public License (LGPL) Version 2.1 that 5 * accompanies this distribution (lgpl-v21.txt). The LGPL is also 6 * available at http://www.gnu.org/licenses/lgpl.html. If the version 7 * of the LGPL at http://www.gnu.org is different to the version of 8 * the LGPL accompanying this distribution and there is any conflict 9 * between the two license versions, the terms of the LGPL accompanying 10 * this distribution shall govern. 11 * 12 * Contributors: 13 * Red Hat - initial API and implementation 14 *******************************************************************************/ 15 package org.eclipse.swt.tests.gtk.snippets; 16 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.layout.GridData; 19 import org.eclipse.swt.layout.GridLayout; 20 import org.eclipse.swt.widgets.Combo; 21 import org.eclipse.swt.widgets.Display; 22 import org.eclipse.swt.widgets.Label; 23 import org.eclipse.swt.widgets.Shell; 24 25 /* 26 * Title: Bug 500703 - [GTK3.20+] Combo with SWT.READ_ONLY is garbled upon re-size 27 * How to run: launch snippet, select long box, start to shrink window 28 * Bug description: Text is drawn over itself numerous times, causing garbled text 29 * Expected results: Text should shrink and not be drawn over other widgets 30 * GTK Version(s): 3.20+ 31 */ 32 public class Bug500703_ComboGarbledResize { 33 main(String[] args)34 public static void main(String[] args) { 35 Display display = new Display(); 36 Shell shell = new Shell(display); 37 shell.setLayout(new GridLayout(2, false)); 38 39 Label label = new Label(shell, SWT.NONE); 40 label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,false, 1, 1)); 41 label.setText("Testing Label"); 42 43 Combo text = new Combo(shell, SWT.READ_ONLY); 44 text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 45 text.add("This is a very long long long long long box"); 46 text.add("short"); 47 48 // Uncomment to test different selections 49 // text.select(0); 50 // text.select(1); 51 52 shell.pack(); 53 // Uncomment for setBounds testing 54 // shell.setSize(400, 200); 55 shell.open(); 56 while (!shell.isDisposed()) { 57 if (!display.readAndDispatch()) 58 display.sleep(); 59 } 60 display.dispose(); 61 } 62 }