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;
|
|
24 import org.eclipse.swt.DWTError;
|
|
25 import org.eclipse.swt.DWTException;
|
|
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
|
|
34 import tango.io.Console;
|
|
35
|
|
36 version(linux) {
|
|
37 version(build)
|
|
38 {
|
|
39 pragma(link, "stdc++");
|
|
40 pragma(link, "xpcomglue");
|
|
41 }
|
|
42 }
|
|
43
|
|
44 void main() {
|
|
45 String html = "<HTML><HEAD><TITLE>HTML Test</TITLE></HEAD><BODY>";
|
|
46 for (int i = 0; i < 100; i++) html ~= "<P>This is line </P>";
|
|
47 html ~= "</BODY></HTML>";
|
|
48
|
|
49 Display display = new Display();
|
|
50 Shell shell = new Shell(display);
|
|
51 shell.setLayout(new FillLayout());
|
|
52 Browser browser;
|
|
53 try {
|
|
54 browser = new Browser(shell, SWT.NONE);
|
|
55 } catch (DWTError e) {
|
|
56 Cout("Could not instatiate Browser.").newline;
|
|
57 return;
|
|
58 }
|
|
59 browser.setText(html);
|
|
60 shell.open();
|
|
61 while (!shell.isDisposed()) {
|
|
62 if (!display.readAndDispatch())
|
|
63 display.sleep();
|
|
64 }
|
|
65 display.dispose();
|
|
66 }
|
|
67
|
|
68
|