Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d5cd06155b12b493120cb694368206b1b1d36f07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*******************************************************************************
 * Copyright (c) 2018 Red Hat and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Red Hat - initial API and implementation
 *******************************************************************************/
package org.eclipse.swt.tests.gtk.snippets;


import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class Bug443185_ToolbarTestFillLayout {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setSize(200, 400);
		shell.setLayout(new GridLayout());
		
	    // Create the tabs
	    CTabFolder tabFolder = new CTabFolder(shell, SWT.TOP|SWT.BORDER);
	    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true) );
	    tabFolder.setMaximizeVisible(true);
	    tabFolder.setMinimizeVisible(true);
	    
	    CTabItem item=new CTabItem(tabFolder, SWT.BORDER);
	    item.setText("Tab (1)");
	    item.setShowClose(true);
	    Label content=new Label(tabFolder,SWT.NONE);
	    content.setText("bla");
	    item.setControl(content);
	    
	    Composite composite = new Composite(tabFolder, SWT.NONE);
	    composite.setLayout(new FillLayout(SWT.HORIZONTAL));
	    
	    
	    ToolBar toolBar=new ToolBar(composite, SWT.FLAT|SWT.RIGHT|SWT.WRAP);
	    for(int i=0;i<15;i++){
		    ToolItem toolItem=new ToolItem(toolBar, SWT.PUSH);
		    toolItem.setText("test_"+i);
		    if(i%5==0){
		    	new ToolItem(toolBar, SWT.SEPARATOR);
		    }
	    }
	    tabFolder.setTopRight(composite,SWT.RIGHT | SWT.WRAP);
	    
	    
	    //SWT Loop
		shell.open();
		while (!shell.isDisposed()) {
		  if (!display.readAndDispatch())
		   {
		    display.sleep();
		   }
		}
		display.dispose(); 
	}

}

Back to the top