Mercurial > projects > dwt2
annotate org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet82.d @ 125:c43718956f21 default tip
Updated the snippets status.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Thu, 11 Aug 2011 19:55:14 +0200 |
parents | 536e43f63c81 |
children |
rev | line source |
---|---|
28 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2004 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * D Port: | |
11 * Thomas Demmer <t_demmer AT web DOT de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.swt.snippets.Snippet82; | |
14 | |
15 /* | |
16 * CTabFolder example snippet: prevent an item from closing | |
17 * | |
18 * For a list of all SWT example snippets see | |
19 * http://www.eclipse.org/swt/snippets/ | |
20 * | |
21 * @since 3.0 | |
22 */ | |
23 import org.eclipse.swt.SWT; | |
24 import org.eclipse.swt.custom.CTabFolder; | |
25 import org.eclipse.swt.custom.CTabFolder2Adapter; | |
26 import org.eclipse.swt.custom.CTabFolderEvent; | |
27 import org.eclipse.swt.custom.CTabItem; | |
28 import org.eclipse.swt.layout.FillLayout; | |
29 import org.eclipse.swt.widgets.Button; | |
30 import org.eclipse.swt.widgets.Display; | |
31 import org.eclipse.swt.widgets.Item; | |
32 import org.eclipse.swt.widgets.Shell; | |
33 import org.eclipse.swt.widgets.Text; | |
34 | |
35 import java.lang.all; | |
36 | |
112 | 37 version(Tango){ |
38 import tango.util.Convert; | |
39 } else { // Phobos | |
40 import std.conv; | |
41 } | |
28 | 42 |
120
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
112
diff
changeset
|
43 void main() { |
28 | 44 Display display = new Display(); |
45 Shell shell = new Shell(display); | |
46 shell.setLayout(new FillLayout()); | |
47 CTabFolder folder = new CTabFolder(shell, SWT.BORDER); | |
48 for (int i = 0; i < 4; i++) { | |
49 CTabItem item = new CTabItem(folder, SWT.CLOSE); | |
50 item.setText("Item " ~ to!(String)(i) ); | |
51 Text text = new Text(folder, SWT.MULTI); | |
52 text.setText("Content for Item "~ to!(String)(i)); | |
53 item.setControl(text); | |
54 } | |
55 | |
56 CTabItem specialItem = new CTabItem(folder, SWT.CLOSE); | |
57 specialItem.setText("Don't Close Me"); | |
58 Text text = new Text(folder, SWT.MULTI); | |
59 text.setText("This tab can never be closed"); | |
60 specialItem.setControl(text); | |
61 | |
120
536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
Denis Shelomovskij <verylonglogin.reg@gmail.com>
parents:
112
diff
changeset
|
62 folder.addCTabFolder2Listener(new class CTabFolder2Adapter { |
28 | 63 public void close(CTabFolderEvent event) { |
64 if (event.item == specialItem) { | |
65 event.doit = false; | |
66 } | |
67 } | |
68 }); | |
69 | |
70 CTabItem noCloseItem = new CTabItem(folder, SWT.NONE); | |
71 noCloseItem.setText("No Close Button"); | |
72 Text text2 = new Text(folder, SWT.MULTI); | |
73 text2.setText("This tab does not have a close button"); | |
74 noCloseItem.setControl(text2); | |
75 | |
76 shell.pack(); | |
77 shell.open(); | |
78 while (!shell.isDisposed()) { | |
79 if (!display.readAndDispatch()) | |
80 display.sleep(); | |
81 } | |
82 display.dispose(); | |
83 } | |
84 |