public WebBrowser(Composite parent) {
initResources();
final Display display = parent.getDisplay();
FormLayout layout = new FormLayout();
parent.setLayout(layout);
ToolBar toolbar = new ToolBar(parent, SWT.NONE);
final ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
itemBack.setText(getResourceString("Back"));
final ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
itemForward.setText(getResourceString("Forward"));
final ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
itemStop.setText(getResourceString("Stop"));
final ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
itemRefresh.setText(getResourceString("Refresh"));
final ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
itemGo.setText(getResourceString("Go"));
location = new Text(parent, SWT.BORDER);
final Canvas canvas = new Canvas(parent, SWT.NO_BACKGROUND);
final Rectangle rect = images[0].getBounds();
canvas.addListener(SWT.Paint, new Listener() {
public void handleEvent(Event e) {
Point pt = canvas.getSize();
e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0,
pt.x, pt.y);
}
});
canvas.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event e) {
browser.setUrl(getResourceString("Startup"));
}
});
display.asyncExec(new Runnable() {
public void run() {
if (canvas.isDisposed())
return;
if (busy) {
index++;
if (index == images.length)
index = 0;
canvas.redraw();
}
display.timerExec(150, this);
}
});
final Label status = new Label(parent, SWT.NONE);
final ProgressBar progressBar = new ProgressBar(parent, SWT.NONE);
FormData data = new FormData();
data.top = new FormAttachment(0, 5);
toolbar.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(canvas, 5, SWT.DEFAULT);
data.bottom = new FormAttachment(status, -5, SWT.DEFAULT);