Mercurial > projects > dwt2
annotate org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet136.d @ 112:9f4c18c268b2
Update to compile and execute with dmd 2.052.
author | kntroh |
---|---|
date | Wed, 16 Mar 2011 21:53:53 +0900 |
parents | 4e5843b771cc |
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 * Ported to the D Programming Language | |
11 * John Reimer <terminal.node@gmail.com> | |
12 *******************************************************************************/ | |
13 module Snippet136; | |
14 | |
15 /* | |
16 * Browser example snippet: render HTML from memory | |
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; | |
29
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
24 import org.eclipse.swt.SWTError; |
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
25 import org.eclipse.swt.SWTException; |
28 | 26 |
27 import org.eclipse.swt.browser.Browser; | |
28 import org.eclipse.swt.widgets.Display; | |
29 import org.eclipse.swt.widgets.Shell; | |
30 import org.eclipse.swt.layout.FillLayout; | |
31 | |
32 import java.lang.all; | |
33 | |
112 | 34 version(Tango){ |
35 import tango.io.Console; | |
36 } else { // Phobos | |
37 import std.stdio; | |
38 } | |
28 | 39 |
40 version(linux) { | |
41 version(build) | |
42 { | |
43 pragma(link, "stdc++"); | |
44 pragma(link, "xpcomglue"); | |
45 } | |
46 } | |
47 | |
48 void main() { | |
49 String html = "<HTML><HEAD><TITLE>HTML Test</TITLE></HEAD><BODY>"; | |
50 for (int i = 0; i < 100; i++) html ~= "<P>This is line </P>"; | |
51 html ~= "</BODY></HTML>"; | |
52 | |
53 Display display = new Display(); | |
54 Shell shell = new Shell(display); | |
55 shell.setLayout(new FillLayout()); | |
56 Browser browser; | |
57 try { | |
58 browser = new Browser(shell, SWT.NONE); | |
29
4e5843b771cc
First snippets buildable on windows
Frank Benoit <benoit@tionex.de>
parents:
28
diff
changeset
|
59 } catch (SWTError e) { |
112 | 60 version(Tango){ |
61 Cout("Could not instatiate Browser.").newline; | |
62 } else { // Phobos | |
63 writeln("Could not instatiate Browser."); | |
64 } | |
28 | 65 return; |
66 } | |
67 browser.setText(html); | |
68 shell.open(); | |
69 while (!shell.isDisposed()) { | |
70 if (!display.readAndDispatch()) | |
71 display.sleep(); | |
72 } | |
73 display.dispose(); | |
74 } | |
75 | |
76 |