comparison snippets/browser/Snippet136.d @ 175:548a657378b8

First Browser snippet added
author John Reimer <terminal.node@gmail.com>
date Sun, 02 Nov 2008 07:35:12 -0800
parents
children
comparison
equal deleted inserted replaced
174:c58389a70da3 175:548a657378b8
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 dwt.DWT;
24 import dwt.DWTError;
25 import dwt.DWTException;
26
27 import dwt.browser.Browser;
28 import dwt.widgets.Display;
29 import dwt.widgets.Shell;
30 import dwt.layout.FillLayout;
31
32 import dwt.dwthelper.utils;
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, DWT.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