annotate dwtsnippets/text/Snippet258.d @ 22:40dae5136e84

Porting comment
author Frank Benoit <benoit@tionex.de>
date Sun, 02 Mar 2008 18:46:18 +0100
parents 0f63eae37f35
children 3b18f03b2f41
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
1 /*******************************************************************************
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2007 IBM Corporation and others.
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
7 *
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
8 * Contributors:
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
22
40dae5136e84 Porting comment
Frank Benoit <benoit@tionex.de>
parents: 19
diff changeset
10 * Port to the D programming language:
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
11 * Jesse Phillips <Jesse.K.Phillips+D> gmail.com
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
12 *******************************************************************************/
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
13
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
14 module dwtsnippets.text.Snippet258;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
15
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
16 /*
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
17 * Create a search text control
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
18 *
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
19 * For a list of all SWT example snippets see
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
20 * http://www.eclipse.org/swt/snippets/
12
47a66440dddd made the resources for Snippet258 included at compile time
Frank Benoit <benoit@tionex.de>
parents: 11
diff changeset
21 *
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
22 * @since 3.3
12
47a66440dddd made the resources for Snippet258 included at compile time
Frank Benoit <benoit@tionex.de>
parents: 11
diff changeset
23 */
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
24 import dwt.DWT;
19
0f63eae37f35 Added bunch of snippets. Rearranged imports on the text snippet258.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 17
diff changeset
25 import dwt.dwthelper.ByteArrayInputStream;
0f63eae37f35 Added bunch of snippets. Rearranged imports on the text snippet258.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 17
diff changeset
26 import dwt.events.SelectionAdapter;
0f63eae37f35 Added bunch of snippets. Rearranged imports on the text snippet258.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 17
diff changeset
27 import dwt.events.SelectionEvent;
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
28 import dwt.graphics.Image;
19
0f63eae37f35 Added bunch of snippets. Rearranged imports on the text snippet258.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 17
diff changeset
29 import dwt.graphics.ImageData;
0f63eae37f35 Added bunch of snippets. Rearranged imports on the text snippet258.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 17
diff changeset
30 import dwt.layout.GridLayout;
0f63eae37f35 Added bunch of snippets. Rearranged imports on the text snippet258.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 17
diff changeset
31 import dwt.layout.GridData;
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
32 import dwt.widgets.Display;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
33 import dwt.widgets.Shell;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
34 import dwt.widgets.Text;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
35 import dwt.widgets.ToolBar;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
36 import dwt.widgets.ToolItem;
19
0f63eae37f35 Added bunch of snippets. Rearranged imports on the text snippet258.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 17
diff changeset
37
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
38 import tango.io.Stdout;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
39
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
40 void main() {
17
7b7a54b047e1 Added unfinished but usable ClipboardExample and Snippet293. Updated other snippets to use the auto keyword. Made the opengl example windows only until it is added to the linux version.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 12
diff changeset
41 auto display = new Display();
7b7a54b047e1 Added unfinished but usable ClipboardExample and Snippet293. Updated other snippets to use the auto keyword. Made the opengl example windows only until it is added to the linux version.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 12
diff changeset
42 auto shell = new Shell(display);
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
43 shell.setLayout(new GridLayout(2, false));
12
47a66440dddd made the resources for Snippet258 included at compile time
Frank Benoit <benoit@tionex.de>
parents: 11
diff changeset
44
17
7b7a54b047e1 Added unfinished but usable ClipboardExample and Snippet293. Updated other snippets to use the auto keyword. Made the opengl example windows only until it is added to the linux version.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 12
diff changeset
45 auto text = new Text(shell, DWT.SEARCH | DWT.CANCEL);
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
46 Image image = null;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
47 if ((text.getStyle() & DWT.CANCEL) == 0) {
12
47a66440dddd made the resources for Snippet258 included at compile time
Frank Benoit <benoit@tionex.de>
parents: 11
diff changeset
48 image = new Image (display, new ImageData(new ByteArrayInputStream( cast(byte[]) import("cancel.gif" ))));
17
7b7a54b047e1 Added unfinished but usable ClipboardExample and Snippet293. Updated other snippets to use the auto keyword. Made the opengl example windows only until it is added to the linux version.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 12
diff changeset
49 auto toolBar = new ToolBar (shell, DWT.FLAT);
7b7a54b047e1 Added unfinished but usable ClipboardExample and Snippet293. Updated other snippets to use the auto keyword. Made the opengl example windows only until it is added to the linux version.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents: 12
diff changeset
50 auto item = new ToolItem (toolBar, DWT.PUSH);
11
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
51 item.setImage (image);
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
52 item.addSelectionListener(new class SelectionAdapter {
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
53 public void widgetSelected(SelectionEvent e) {
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
54 text.setText("");
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
55 Stdout("Search cancelled").newline;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
56 }
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
57 });
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
58 }
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
59 text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
60 text.setText("Search text");
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
61 text.addSelectionListener(new class SelectionAdapter {
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
62 public void widgetDefaultSelected(SelectionEvent e) {
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
63 if (e.detail == DWT.CANCEL) {
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
64 Stdout("Search cancelled").newline;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
65 } else {
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
66 Stdout("Searching for: ")(text.getText())("...").newline;
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
67 }
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
68 }
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
69 });
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
70
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
71 shell.pack();
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
72 shell.open();
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
73 while (!shell.isDisposed()) {
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
74 if (!display.readAndDispatch()) display.sleep();
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
75 }
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
76 if (image != null) image.dispose();
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
77 display.dispose();
b61e7baf0574 Reworked the DrawingBoard for better organization. And also removed the linker fixes in the source files and moved it to dsss.conf by adding buildflags+=-L-lDD-tango-util.
Jesse Phillips <Jesse.K.Phillips+D@gmail.com>
parents:
diff changeset
78 }