view 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
line wrap: on
line source

/*******************************************************************************
 * 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();
}