Mercurial > projects > dwt-samples
comparison snippets/ctabfolder/Snippet82.d @ 119:9a1be6ff19a2
More snippets, thanks to Tom D.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 20 Jul 2008 15:26:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
118:7b1c122b4128 | 119:9a1be6ff19a2 |
---|---|
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 ctabfolder.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 dwt.DWT; | |
24 import dwt.custom.CTabFolder; | |
25 import dwt.custom.CTabFolder2Adapter; | |
26 import dwt.custom.CTabFolderEvent; | |
27 import dwt.custom.CTabItem; | |
28 import dwt.layout.FillLayout; | |
29 import dwt.widgets.Button; | |
30 import dwt.widgets.Display; | |
31 import dwt.widgets.Item; | |
32 import dwt.widgets.Shell; | |
33 import dwt.widgets.Text; | |
34 | |
35 import dwt.dwthelper.utils; | |
36 | |
37 import tango.util.Convert; | |
38 | |
39 void main(String[] args) { | |
40 Display display = new Display(); | |
41 Shell shell = new Shell(display); | |
42 shell.setLayout(new FillLayout()); | |
43 CTabFolder folder = new CTabFolder(shell, DWT.BORDER); | |
44 for (int i = 0; i < 4; i++) { | |
45 CTabItem item = new CTabItem(folder, DWT.CLOSE); | |
46 item.setText("Item " ~ to!(String)(i) ); | |
47 Text text = new Text(folder, DWT.MULTI); | |
48 text.setText("Content for Item "~ to!(String)(i)); | |
49 item.setControl(text); | |
50 } | |
51 | |
52 CTabItem specialItem = new CTabItem(folder, DWT.CLOSE); | |
53 specialItem.setText("Don't Close Me"); | |
54 Text text = new Text(folder, DWT.MULTI); | |
55 text.setText("This tab can never be closed"); | |
56 specialItem.setControl(text); | |
57 | |
58 folder.addCTabFolder2Listener(new class() CTabFolder2Adapter { | |
59 public void close(CTabFolderEvent event) { | |
60 if (event.item == specialItem) { | |
61 event.doit = false; | |
62 } | |
63 } | |
64 }); | |
65 | |
66 CTabItem noCloseItem = new CTabItem(folder, DWT.NONE); | |
67 noCloseItem.setText("No Close Button"); | |
68 Text text2 = new Text(folder, DWT.MULTI); | |
69 text2.setText("This tab does not have a close button"); | |
70 noCloseItem.setControl(text2); | |
71 | |
72 shell.pack(); | |
73 shell.open(); | |
74 while (!shell.isDisposed()) { | |
75 if (!display.readAndDispatch()) | |
76 display.sleep(); | |
77 } | |
78 display.dispose(); | |
79 } | |
80 |