changeset 175:548a657378b8

First Browser snippet added
author John Reimer <terminal.node@gmail.com>
date Sun, 02 Nov 2008 07:35:12 -0800
parents c58389a70da3
children 219f3c1087d1
files snippets/browser/Snippet136.d snippets/dsss.conf
diffstat 2 files changed, 71 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/snippets/browser/Snippet136.d	Sun Nov 02 07:35:12 2008 -0800
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Ported to the D Programming Language
+ *     John Reimer <terminal.node@gmail.com>
+ *******************************************************************************/
+module Snippet136;
+
+/*
+ * Browser example snippet: render HTML from memory
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ * 
+ * @since 3.0
+ */
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+
+import dwt.browser.Browser;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.layout.FillLayout;
+
+import dwt.dwthelper.utils;
+
+import tango.io.Console;
+
+version(linux) {
+    version(build)
+    {
+    pragma(link, "stdc++");
+    pragma(link, "xpcomglue");
+    }
+}
+
+void main() {
+		String html = "<HTML><HEAD><TITLE>HTML Test</TITLE></HEAD><BODY>";
+		for (int i = 0; i < 100; i++) html ~= "<P>This is line </P>";
+		html ~= "</BODY></HTML>";
+
+		Display display = new Display();
+		Shell shell = new Shell(display);
+		shell.setLayout(new FillLayout());
+		Browser browser;
+		try {
+			browser = new Browser(shell, DWT.NONE);
+		} catch (DWTError e) {
+			Cout("Could not instatiate Browser.").newline;
+			return;
+		}
+		browser.setText(html);
+		shell.open();
+		while (!shell.isDisposed()) {
+			if (!display.readAndDispatch())
+				display.sleep();
+		}
+		display.dispose();
+}
+
+
--- a/snippets/dsss.conf	Sun Oct 26 14:53:47 2008 +0100
+++ b/snippets/dsss.conf	Sun Nov 02 07:35:12 2008 -0800
@@ -136,7 +136,9 @@
 version(Windows){
     [ole/Snippet81.d]
 }
-
+version(linux) {
+    [browser/Snippet136.d]
+}
 version(Derelict){
     [opengl]
     type=subdir