You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2008/05/27 00:21:57 UTC

svn commit: r660326 [8/17] - in /harmony/enhanced/microemulator: ./ microemu-android/ microemu-android/src/ microemu-android/src/org/ microemu-android/src/org/microemu/ microemu-android/src/org/microemu/android/ microemu-android/src/org/microemu/androi...

Added: harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/RGBImageFilter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/RGBImageFilter.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/RGBImageFilter.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/RGBImageFilter.java Mon May 26 15:20:19 2008
@@ -0,0 +1,75 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+ 
+package org.microemu.device.j2se;
+
+
+import org.microemu.device.DeviceFactory;
+import org.microemu.device.impl.Color;
+
+
+
+public class RGBImageFilter extends java.awt.image.RGBImageFilter
+{
+
+  private double Rr, Rg, Rb;
+  private Color backgroundColor;
+  private Color foregroundColor;
+  
+
+  public RGBImageFilter()
+	{
+    canFilterIndexColorModel = true;
+    backgroundColor = 
+        ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getBackgroundColor();    
+    foregroundColor = 
+        ((J2SEDeviceDisplay) DeviceFactory.getDevice().getDeviceDisplay()).getForegroundColor();    
+    Rr = foregroundColor.getRed() - backgroundColor.getRed();
+    Rg = foregroundColor.getGreen() - backgroundColor.getGreen();
+    Rb = foregroundColor.getBlue() - backgroundColor.getBlue();
+  }
+
+
+  public int filterRGB (int x, int y, int rgb)
+	{
+    int a = (rgb & 0xFF000000);
+    int r = (rgb & 0x00FF0000) >>> 16;
+    int g = (rgb & 0x0000FF00) >>> 8;
+    int b = (rgb & 0x000000FF);
+
+    if (Rr > 0) {
+      r = (int) (r * Rr) / 255 + backgroundColor.getRed();
+    } else {
+      r = (int) (r * -Rr) / 255 + foregroundColor.getRed();
+    }
+    if (Rr > 0) {
+      g = (int) (g * Rg) / 255 + backgroundColor.getGreen();
+    } else {
+      g = (int) (g * -Rg) / 255 + foregroundColor.getGreen();
+    }
+    if (Rr > 0) {
+      b = (int) (b * Rb) / 255 + backgroundColor.getBlue();
+    } else {
+      b = (int) (b * -Rb) / 255 + foregroundColor.getBlue();
+    }
+
+    return a | (r << 16) | (g << 8) | b;
+  }
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/RGBImageFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SECanvasUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SECanvasUI.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SECanvasUI.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SECanvasUI.java Mon May 26 15:20:19 2008
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.device.j2se.ui;
+
+import javax.microedition.lcdui.Canvas;
+
+import org.microemu.device.impl.ui.DisplayableImplUI;
+import org.microemu.device.ui.CanvasUI;
+
+public class J2SECanvasUI extends DisplayableImplUI implements CanvasUI {
+
+	public J2SECanvasUI(Canvas canvas) {
+	}
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SECanvasUI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SEListUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SEListUI.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SEListUI.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SEListUI.java Mon May 26 15:20:19 2008
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.device.j2se.ui;
+
+import javax.microedition.lcdui.Command;
+import javax.microedition.lcdui.Image;
+import javax.microedition.lcdui.List;
+
+import org.microemu.device.impl.ui.DisplayableImplUI;
+import org.microemu.device.ui.ListUI;
+
+public class J2SEListUI extends DisplayableImplUI implements ListUI {
+
+	public J2SEListUI(List list) {
+	}
+
+	public int append(String stringPart, Image imagePart) {
+		// TODO not yet used
+		return -1;
+	}
+
+	public void setSelectCommand(Command command) {
+		// TODO not yet used
+	}
+
+	public int getSelectedIndex() {
+		// TODO not yet used
+		return 0;
+	}
+
+	public String getString(int elementNum) {
+		// TODO not yet used
+		return null;
+	}
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SEListUI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SETextBoxUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SETextBoxUI.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SETextBoxUI.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SETextBoxUI.java Mon May 26 15:20:19 2008
@@ -0,0 +1,49 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.device.j2se.ui;
+
+import javax.microedition.lcdui.TextBox;
+
+import org.microemu.device.impl.ui.DisplayableImplUI;
+import org.microemu.device.ui.TextBoxUI;
+
+public class J2SETextBoxUI extends DisplayableImplUI implements TextBoxUI {
+
+	private String text;
+
+	public J2SETextBoxUI(TextBox textBox) {
+	}
+
+	public int getCaretPosition() {
+		// TODO not yet used
+		return -1;
+	}
+
+	public String getString() {
+		// TODO not yet used
+		return text;
+	}
+
+	public void setString(String text) {
+		// TODO not yet used
+		this.text = text;
+	}
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swing/src/main/java/org/microemu/device/j2se/ui/J2SETextBoxUI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/pom.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/pom.xml?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/pom.xml (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/pom.xml Mon May 26 15:20:19 2008
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns="http://maven.apache.org/POM/4.0.0">
+    <!-- @version $Revision: 1626 $ ($Author: vlads $) $Date: 2008-03-04 21:47:36 -0500 (Tue, 04 Mar 2008) $ -->
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.microemu</groupId>
+        <artifactId>microemu</artifactId>
+        <version>2.0.3-SNAPSHOT</version><!--me-version-->
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>microemu-javase-swt</artifactId>
+    <name>microemu-javase-swt</name>
+
+    <description>javase-swt</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.microemu</groupId>
+            <artifactId>microemu-javase</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!-- Used for ready for applet Preprocessor  -->
+        <dependency>
+            <groupId>org.microemu</groupId>
+            <artifactId>microemu-injected</artifactId>
+            <version>${project.version}</version>
+            <classifier>inject</classifier>
+            <optional>true</optional>
+        </dependency>
+
+        <!--
+            GET SWT for your platform from http://www.eclipse.org/swt/
+            Make ENV variable
+        -->
+        <dependency>
+            <groupId>swt</groupId>
+            <artifactId>swt</artifactId>
+            <version>3.2.1</version>
+            <scope>system</scope>
+            <systemPath>${SWT_HOME}/swt.jar</systemPath>
+        </dependency>
+
+    </dependencies>
+
+</project>
\ No newline at end of file

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/Swt.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/Swt.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/Swt.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/Swt.java Mon May 26 15:20:19 2008
@@ -0,0 +1,379 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.app;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+import org.microemu.DisplayComponent;
+import org.microemu.EmulatorContext;
+import org.microemu.MIDletBridge;
+import org.microemu.app.ui.Message;
+import org.microemu.app.ui.ResponseInterfaceListener;
+import org.microemu.app.ui.StatusBarListener;
+import org.microemu.app.ui.swt.SwtDeviceComponent;
+import org.microemu.app.ui.swt.SwtDialog;
+import org.microemu.app.ui.swt.SwtErrorMessageDialogPanel;
+import org.microemu.app.ui.swt.SwtInputDialog;
+import org.microemu.app.ui.swt.SwtMessageDialog;
+import org.microemu.app.ui.swt.SwtSelectDeviceDialog;
+import org.microemu.app.util.DeviceEntry;
+import org.microemu.app.util.IOUtils;
+import org.microemu.device.Device;
+import org.microemu.device.DeviceDisplay;
+import org.microemu.device.DeviceFactory;
+import org.microemu.device.FontManager;
+import org.microemu.device.InputMethod;
+import org.microemu.device.impl.DeviceImpl;
+import org.microemu.device.impl.Rectangle;
+import org.microemu.device.swt.SwtDevice;
+import org.microemu.device.swt.SwtDeviceDisplay;
+import org.microemu.device.swt.SwtFontManager;
+import org.microemu.device.swt.SwtInputMethod;
+
+public class Swt extends Common {
+	public static Shell shell;
+
+	protected static SwtDeviceComponent devicePanel;
+
+	protected MenuItem menuOpenJADFile;
+
+	protected MenuItem menuOpenJADURL;
+
+	private SwtSelectDeviceDialog selectDeviceDialog;
+
+	private FileDialog fileDialog = null;
+
+	private MenuItem menuSelectDevice;
+
+	private DeviceEntry deviceEntry;
+
+	private Label statusBar;
+
+	private KeyListener keyListener = new KeyListener() {
+		public void keyTyped(KeyEvent e) {
+		}
+
+		public void keyPressed(KeyEvent e) {
+			// devicePanel.keyPressed(e);
+		}
+
+		public void keyReleased(KeyEvent e) {
+			// devicePanel.keyReleased(e);
+		}
+	};
+
+	protected Listener menuOpenJADFileListener = new Listener() {
+		public void handleEvent(Event ev) {
+			if (fileDialog == null) {
+				fileDialog = new FileDialog(shell, SWT.OPEN);
+				fileDialog.setText("Open JAD File...");
+				fileDialog.setFilterNames(new String[] { "JAD files" });
+				fileDialog.setFilterExtensions(new String[] { "*.jad" });
+				fileDialog.setFilterPath(Config.getRecentDirectory("recentJadDirectory"));
+			}
+
+			fileDialog.open();
+
+			if (fileDialog.getFileName().length() > 0) {
+				File selectedFile;
+				if (fileDialog.getFilterPath() == null) {
+					selectedFile = new File(fileDialog.getFileName());
+				} else {
+					selectedFile = new File(fileDialog.getFilterPath(), fileDialog.getFileName());
+					Config.setRecentDirectory("recentJadDirectory", fileDialog.getFilterPath());
+				}
+				String url = IOUtils.getCanonicalFileURL(selectedFile);
+				Common.openJadUrlSafe(url);
+			}
+		}
+	};
+
+	protected Listener menuOpenJADURLListener = new Listener() {
+		public void handleEvent(Event ev) {
+			// TODO change to JadUrlPanel
+			SwtInputDialog inputDialog = new SwtInputDialog(shell, "Open...", "Enter JAD URL:");
+			if (inputDialog.open() == SwtDialog.OK) {
+				try {
+					openJadUrl(inputDialog.getValue());
+				} catch (IOException ex) {
+					System.err.println("Cannot load " + inputDialog.getValue());
+				}
+			}
+		}
+	};
+
+	protected Listener menuExitListener = new Listener() {
+		public void handleEvent(Event e) {
+			Config.setWindow("main", new Rectangle(shell.getLocation().x, shell.getLocation().y, shell.getSize().x,
+					shell.getSize().y), true);
+
+			System.exit(0);
+		}
+	};
+
+	private Listener menuSelectDeviceListener = new Listener() {
+		public void handleEvent(Event e) {
+			if (selectDeviceDialog.open() == SwtDialog.OK) {
+				if (selectDeviceDialog.getSelectedDeviceEntry().equals(getDevice())) {
+					return;
+				}
+				if (MIDletBridge.getCurrentMIDlet() != getLauncher()) {
+					if (!SwtMessageDialog
+							.openQuestion(shell, "Question?",
+									"Changing device needs MIDlet to be restarted. All MIDlet data will be lost. Are you sure?")) {
+						return;
+					}
+				}
+				setDevice(selectDeviceDialog.getSelectedDeviceEntry());
+
+				if (MIDletBridge.getCurrentMIDlet() != getLauncher()) {
+					try {
+						initMIDlet(true);
+					} catch (Exception ex) {
+						System.err.println(ex);
+					}
+				} else {
+					startLauncher(MIDletBridge.getMIDletContext());
+				}
+			}
+		}
+	};
+
+	private StatusBarListener statusBarListener = new StatusBarListener() {
+		public void statusBarChanged(final String text) {
+			shell.getDisplay().asyncExec(new Runnable() {
+				public void run() {
+					statusBar.setText(text);
+				}
+			});
+		}
+	};
+
+	private ResponseInterfaceListener responseInterfaceListener = new ResponseInterfaceListener() {
+		public void stateChanged(final boolean state) {
+			shell.getDisplay().asyncExec(new Runnable() {
+				public void run() {
+					menuOpenJADFile.setEnabled(state);
+					menuOpenJADURL.setEnabled(state);
+					menuSelectDevice.setEnabled(state);
+				}
+			});
+		}
+	};
+
+	/*
+	 * WindowAdapter windowListener = new WindowAdapter() { public void
+	 * windowClosing(WindowEvent ev) { menuExitListener.actionPerformed(null); }
+	 * 
+	 * 
+	 * public void windowIconified(WindowEvent ev) {
+	 * MIDletBridge.getMIDletAccess(common.getLauncher().getCurrentMIDlet()).pauseApp(); }
+	 * 
+	 * public void windowDeiconified(WindowEvent ev) { try {
+	 * MIDletBridge.getMIDletAccess(common.getLauncher().getCurrentMIDlet()).startApp(); }
+	 * catch (MIDletStateChangeException ex) { System.err.println(ex); } } };
+	 */
+
+	protected Swt(Shell shell) {
+		this(shell, null);
+	}
+
+	protected Swt(Shell shell, DeviceEntry defaultDevice) {
+		super(new EmulatorContext() {
+			private InputMethod inputMethod = new SwtInputMethod();
+
+			private DeviceDisplay deviceDisplay = new SwtDeviceDisplay(this);
+
+			private FontManager fontManager = new SwtFontManager();
+
+			public DisplayComponent getDisplayComponent() {
+				return devicePanel.getDisplayComponent();
+			}
+
+			public InputMethod getDeviceInputMethod() {
+				return inputMethod;
+			}
+
+			public DeviceDisplay getDeviceDisplay() {
+				return deviceDisplay;
+			}
+
+			public FontManager getDeviceFontManager() {
+				return fontManager;
+			}
+
+			public InputStream getResourceAsStream(String name) {
+				return MIDletBridge.getCurrentMIDlet().getClass().getResourceAsStream(name);
+			}
+		});
+
+		initInterface(shell);
+
+		// addWindowListener(windowListener);
+
+		Config.loadConfig(null, emulatorContext);
+		loadImplementationsFromConfig();
+
+		Rectangle window = Config.getWindow("main", new Rectangle(0, 0, 160, 120));
+		shell.setLocation(window.x, window.y);
+
+		shell.addKeyListener(keyListener);
+
+		selectDeviceDialog = new SwtSelectDeviceDialog(shell, emulatorContext);
+
+		setStatusBarListener(statusBarListener);
+		setResponseInterfaceListener(responseInterfaceListener);
+
+		Message.addListener(new SwtErrorMessageDialogPanel(shell));
+	}
+
+	protected void initInterface(Shell shell) {
+		GridLayout layout = new GridLayout(1, false);
+		shell.setLayout(layout);
+		shell.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+		Menu bar = new Menu(shell, SWT.BAR);
+		shell.setMenuBar(bar);
+
+		MenuItem menuFile = new MenuItem(bar, SWT.CASCADE);
+		menuFile.setText("File");
+
+		Menu fileSubmenu = new Menu(shell, SWT.DROP_DOWN);
+		menuFile.setMenu(fileSubmenu);
+
+		menuOpenJADFile = new MenuItem(fileSubmenu, SWT.PUSH);
+		menuOpenJADFile.setText("Open JAD File...");
+		menuOpenJADFile.addListener(SWT.Selection, menuOpenJADFileListener);
+
+		menuOpenJADURL = new MenuItem(fileSubmenu, 0);
+		menuOpenJADURL.setText("Open JAD URL...");
+		menuOpenJADURL.addListener(SWT.Selection, menuOpenJADURLListener);
+
+		new MenuItem(fileSubmenu, SWT.SEPARATOR);
+
+		MenuItem menuExit = new MenuItem(fileSubmenu, SWT.PUSH);
+		menuExit.setText("Exit");
+		menuExit.addListener(SWT.Selection, menuExitListener);
+
+		MenuItem menuOptions = new MenuItem(bar, SWT.CASCADE);
+		menuOptions.setText("Options");
+
+		Menu optionsSubmenu = new Menu(shell, SWT.DROP_DOWN);
+		menuOptions.setMenu(optionsSubmenu);
+
+		menuSelectDevice = new MenuItem(optionsSubmenu, SWT.PUSH);
+		menuSelectDevice.setText("Select device...");
+		menuSelectDevice.addListener(SWT.Selection, menuSelectDeviceListener);
+
+		shell.setText("MicroEmulator");
+
+		devicePanel = new SwtDeviceComponent(shell);
+		devicePanel.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+		statusBar = new Label(shell, SWT.HORIZONTAL);
+		statusBar.setText("Status");
+		statusBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+	}
+
+	public void setDevice(DeviceEntry entry) {
+		if (DeviceFactory.getDevice() != null) {
+			// ((SwtDevice) DeviceFactory.getDevice()).dispose();
+		}
+
+		try {
+			ClassLoader classLoader = getClass().getClassLoader();
+			if (entry.getFileName() != null) {
+				URL[] urls = new URL[1];
+				urls[0] = new File(Config.getConfigPath(), entry.getFileName()).toURI().toURL();
+				classLoader = Common.createExtensionsClassLoader(urls);
+			}
+
+			// TODO font manager have to be moved from emulatorContext into
+			// device
+			emulatorContext.getDeviceFontManager().init();
+
+			Device device = DeviceImpl.create(emulatorContext, classLoader, entry.getDescriptorLocation(),
+					SwtDevice.class);
+			this.deviceEntry = entry;
+			setDevice(device);
+			updateDevice();
+		} catch (MalformedURLException ex) {
+			System.err.println(ex);
+		} catch (IOException ex) {
+			System.err.println(ex);
+		}
+	}
+
+	protected void updateDevice() {
+		shell.setSize(shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
+	}
+
+	public static void main(String args[]) {
+		Display display = new Display();
+		shell = new Shell(display, SWT.CLOSE | SWT.TITLE | SWT.MIN);
+
+		List params = new ArrayList();
+		for (int i = 0; i < args.length; i++) {
+			params.add(args[i]);
+		}
+
+		Swt app = new Swt(shell);
+		app.initParams(params, app.selectDeviceDialog.getSelectedDeviceEntry(), SwtDevice.class);
+		app.updateDevice();
+
+		shell.pack();
+		shell.open();
+
+		String midletString;
+		try {
+			midletString = (String) params.iterator().next();
+		} catch (NoSuchElementException ex) {
+			midletString = null;
+		}
+		app.initMIDlet(false);
+
+		while (!shell.isDisposed()) {
+			if (!display.readAndDispatch())
+				display.sleep();
+		}
+		display.dispose();
+	}
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/Swt.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/ImageFilter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/ImageFilter.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/ImageFilter.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/ImageFilter.java Mon May 26 15:20:19 2008
@@ -0,0 +1,30 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+ 
+package org.microemu.app.ui.swt;
+
+import org.eclipse.swt.graphics.RGB;
+
+
+public interface ImageFilter 
+{
+
+	RGB filterRGB (int x, int y, RGB rgb);
+	
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/ImageFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/OptionPane.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/OptionPane.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/OptionPane.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/OptionPane.java Mon May 26 15:20:19 2008
@@ -0,0 +1,135 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.app.ui.swt;
+
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Label;
+import java.awt.Panel;
+import java.awt.TextField;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+
+public class OptionPane 
+{
+	
+	public static final int ERROR_MESSAGE = 1;
+	public static final int INFORMATION_MESSAGE = 2;
+	
+	
+	private static WindowAdapter windowListener = new WindowAdapter()
+	{
+		public void windowClosing(WindowEvent ev) 
+		{
+			((Dialog) ev.getSource()).hide();
+		}
+	};
+	
+
+	public static String showInputDialog(Component parentComponent, String message)
+	{
+		final StringBuffer result = new StringBuffer();
+		final Dialog dialog = new Dialog(getFrame(parentComponent), "Input");
+		final TextField tfInput = new TextField(40);
+
+		dialog.setModal(true);
+		dialog.setLayout(new BorderLayout());
+		dialog.add(new Label(message), BorderLayout.WEST);
+		dialog.add(tfInput, BorderLayout.CENTER);
+		Panel panel = new Panel();
+		Button btOk = new Button("OK");
+		panel.add(btOk);
+		Button btCancel = new Button("Cancel");
+		panel.add(btCancel);
+		dialog.add(panel, BorderLayout.SOUTH); 
+		dialog.pack();
+		dialog.addWindowListener(windowListener);
+		
+		btOk.addActionListener(new ActionListener() 
+		{
+			public void actionPerformed(ActionEvent ev) 
+			{
+				result.append(tfInput.getText());
+				dialog.hide();
+			}
+		});
+		
+		btCancel.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent ev) 
+			{
+				dialog.hide();
+			}
+		}); 
+
+		dialog.show();
+				
+		if (result.length() > 0) {		
+			return result.toString();
+		}
+		
+		return null;
+	}
+	
+	
+	public static void showMessageDialog(Component parentComponent, String message, String title, int messageType)
+	{	
+		final Dialog dialog = new Dialog(getFrame(parentComponent), title);
+
+		dialog.setModal(true);
+		dialog.setLayout(new BorderLayout());
+		dialog.add(new Label(message), BorderLayout.CENTER);
+		Panel panel = new Panel();
+		Button btOk = new Button("OK");
+		panel.add(btOk);
+		dialog.add(panel, BorderLayout.SOUTH); 
+		dialog.pack();
+		dialog.addWindowListener(windowListener);
+		
+		btOk.addActionListener(new ActionListener() 
+		{
+			public void actionPerformed(ActionEvent ev) 
+			{
+				dialog.hide();
+			}
+		});		
+
+		dialog.show();
+	}
+	
+	
+	private static Frame getFrame(Component parentComponent) 
+	{
+		Component tmp = parentComponent;
+		while (true) {
+			if (tmp instanceof Frame) {
+				return (Frame) tmp;
+			}
+			tmp = tmp.getParent();
+		}
+	}
+	
+	
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/OptionPane.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDeviceComponent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDeviceComponent.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDeviceComponent.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDeviceComponent.java Mon May 26 15:20:19 2008
@@ -0,0 +1,672 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.app.ui.swt;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.microedition.lcdui.Command;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.microemu.DisplayAccess;
+import org.microemu.DisplayComponent;
+import org.microemu.MIDletAccess;
+import org.microemu.MIDletBridge;
+import org.microemu.device.Device;
+import org.microemu.device.DeviceFactory;
+import org.microemu.device.impl.Rectangle;
+import org.microemu.device.impl.SoftButton;
+import org.microemu.device.swt.SwtButton;
+import org.microemu.device.swt.SwtDeviceDisplay;
+import org.microemu.device.swt.SwtImmutableImage;
+import org.microemu.device.swt.SwtInputMethod;
+
+public class SwtDeviceComponent extends Canvas {
+	private static SwtDeviceComponent instance;
+
+	private static HashMap colors = new HashMap();
+
+	private SwtDisplayComponent dc;
+
+	private Image fBuffer = null;
+
+	private SwtButton prevOverButton;
+
+	private SwtButton overButton;
+
+	private SwtButton pressedButton;
+
+	private SoftButton initialPressedSoftButton;
+
+	private boolean mousePressed;
+
+	KeyListener keyListener = new KeyListener() {
+		public void keyPressed(KeyEvent ev) {
+			if (MIDletBridge.getCurrentMIDlet() == null) {
+				return;
+			}
+
+			Device device = DeviceFactory.getDevice();
+
+			for (Iterator it = device.getButtons().iterator(); it.hasNext();) {
+				SwtButton button = (SwtButton) it.next();
+				if (ev.keyCode == button.getKeyboardKey()) {
+					ev.keyCode = button.getKeyCode();
+					break;
+				}
+			}
+
+			((SwtInputMethod) device.getInputMethod()).keyPressed(ev);
+
+			pressedButton = ((SwtInputMethod) device.getInputMethod()).getButton(ev);
+			if (pressedButton != null) {
+				org.microemu.device.impl.Shape shape = pressedButton.getShape();
+				if (shape != null) {
+					Rectangle r = shape.getBounds();
+					redraw(r.x, r.y, r.width, r.height, true);
+				}
+			} else {
+				redraw();
+			}
+		}
+
+		public void keyReleased(KeyEvent ev) {
+			if (MIDletBridge.getCurrentMIDlet() == null) {
+				return;
+			}
+
+			Device device = DeviceFactory.getDevice();
+
+			for (Iterator it = device.getButtons().iterator(); it.hasNext();) {
+				SwtButton button = (SwtButton) it.next();
+				if (ev.keyCode == button.getKeyboardKey()) {
+					ev.keyCode = button.getKeyCode();
+					break;
+				}
+			}
+
+			((SwtInputMethod) device.getInputMethod()).keyReleased(ev);
+
+			prevOverButton = pressedButton;
+			pressedButton = null;
+			if (prevOverButton != null) {
+				org.microemu.device.impl.Shape shape = prevOverButton.getShape();
+				if (shape != null) {
+					Rectangle r = shape.getBounds();
+					redraw(r.x, r.y, r.width, r.height, true);
+				}
+			} else {
+				redraw();
+			}
+		}
+	};
+
+	MouseAdapter mouseListener = new MouseAdapter() {
+		public void mouseDown(MouseEvent e) {
+			if (MIDletBridge.getCurrentMIDlet() == null) {
+				return;
+			}
+
+			Device device = DeviceFactory.getDevice();
+			org.microemu.device.impl.Rectangle rect = ((SwtDeviceDisplay) device.getDeviceDisplay())
+					.getDisplayRectangle();
+			SwtInputMethod inputMethod = (SwtInputMethod) device.getInputMethod();
+			// if the displayable is in full screen mode, we should not
+			// invoke any associated commands, but send the raw key codes
+			// instead
+			boolean fullScreenMode = device.getDeviceDisplay().isFullScreenMode();
+
+			if (rect.x <= e.x && (rect.x + rect.width) > e.x && rect.y <= e.y && (rect.y + rect.height) > e.y) {
+				if (device.hasPointerEvents()) {
+					if (!fullScreenMode) {
+						Iterator it = device.getSoftButtons().iterator();
+						while (it.hasNext()) {
+							SoftButton button = (SoftButton) it.next();
+							if (button.isVisible()) {
+								org.microemu.device.impl.Rectangle pb = button.getPaintable();
+								if (pb != null && pb.contains(e.x - rect.x, e.y - rect.y)) {
+									initialPressedSoftButton = button;
+									button.setPressed(true);
+									dc.repaintRequest(pb.x, pb.y, pb.width, pb.height);
+									break;
+								}
+							}
+						}
+					}
+					if (fullScreenMode) {
+						inputMethod.pointerPressed(e.x - rect.x, e.y - rect.y);
+					} else {
+						org.microemu.device.impl.Rectangle pb = ((SwtDeviceDisplay) device.getDeviceDisplay())
+								.getDisplayPaintable();
+						inputMethod.pointerPressed(e.x - rect.x - pb.x, e.y - rect.y - pb.y);
+					}
+				}
+			} else {
+				pressedButton = getButton(e.x, e.y);
+				if (pressedButton != null) {
+					if (pressedButton instanceof SoftButton && !fullScreenMode) {
+						Command cmd = ((SoftButton) pressedButton).getCommand();
+						if (cmd != null) {
+							MIDletAccess ma = MIDletBridge.getMIDletAccess();
+							if (ma == null) {
+								return;
+							}
+							DisplayAccess da = ma.getDisplayAccess();
+							if (da == null) {
+								return;
+							}
+							da.commandAction(cmd, da.getCurrent());
+						}
+					} else {
+						Event event = new Event();
+						event.widget = e.widget;
+						KeyEvent ev = new KeyEvent(event);
+						ev.keyCode = pressedButton.getKeyCode();
+						inputMethod.mousePressed(ev);
+					}
+					// optimize for some video cards.
+					Rectangle r = pressedButton.getShape().getBounds();
+					redraw(r.x, r.y, r.width, r.height, true);
+				}
+			}
+
+			mousePressed = true;
+		}
+
+		public void mouseUp(MouseEvent e) {
+			if (MIDletBridge.getCurrentMIDlet() == null) {
+				return;
+			}
+
+			Device device = DeviceFactory.getDevice();
+			org.microemu.device.impl.Rectangle rect = ((SwtDeviceDisplay) device.getDeviceDisplay())
+					.getDisplayRectangle();
+			SwtInputMethod inputMethod = (SwtInputMethod) device.getInputMethod();
+			boolean fullScreenMode = device.getDeviceDisplay().isFullScreenMode();
+			if (rect.x <= e.x && (rect.x + rect.width) > e.x && rect.y <= e.y && (rect.y + rect.height) > e.y) {
+				if (device.hasPointerEvents()) {
+					if (!fullScreenMode) {
+						if (initialPressedSoftButton != null && initialPressedSoftButton.isPressed()) {
+							initialPressedSoftButton.setPressed(false);
+							org.microemu.device.impl.Rectangle pb = initialPressedSoftButton.getPaintable();
+							if (pb != null) {
+								dc.repaintRequest(pb.x, pb.y, pb.width, pb.height);
+								if (pb.contains(e.x - rect.x, e.y - rect.y)) {
+									Command cmd = initialPressedSoftButton.getCommand();
+									if (cmd != null) {
+										MIDletAccess ma = MIDletBridge.getMIDletAccess();
+										if (ma == null) {
+											return;
+										}
+										DisplayAccess da = ma.getDisplayAccess();
+										if (da == null) {
+											return;
+										}
+										da.commandAction(cmd, da.getCurrent());
+									}
+								}
+							}
+						}
+						initialPressedSoftButton = null;
+					}
+					if (fullScreenMode) {
+						inputMethod.pointerReleased(e.x - rect.x, e.y - rect.y);
+					} else {
+						org.microemu.device.impl.Rectangle pb = ((SwtDeviceDisplay) device.getDeviceDisplay())
+								.getDisplayPaintable();
+						inputMethod.pointerReleased(e.x - rect.x - pb.x, e.y - rect.y - pb.y);
+					}
+				}
+			} else {
+				SwtButton prevOverButton = getButton(e.x, e.y);
+				if (prevOverButton != null) {
+					inputMethod.mouseReleased(prevOverButton.getKeyCode());
+				}
+				pressedButton = null;
+				// optimize for some video cards.
+				if (prevOverButton != null) {
+					Rectangle r = prevOverButton.getShape().getBounds();
+					redraw(r.x, r.y, r.width, r.height, true);
+				} else {
+					redraw();
+				}
+			}
+
+			mousePressed = false;
+		}
+	};
+
+	MouseMoveListener mouseMoveListener = new MouseMoveListener() {
+		public void mouseMove(MouseEvent e) {
+			prevOverButton = overButton;
+			overButton = getButton(e.x, e.y);
+			if (overButton != prevOverButton) {
+				// optimize for some video cards.
+				if (prevOverButton != null) {
+					Rectangle r = prevOverButton.getShape().getBounds();
+					redraw(r.x, r.y, r.width, r.height, true);
+				}
+				if (overButton != null) {
+					Rectangle r = overButton.getShape().getBounds();
+					redraw(r.x, r.y, r.width, r.height, true);
+				}
+			}
+
+			if (mousePressed) {
+				Device device = DeviceFactory.getDevice();
+				org.microemu.device.impl.Rectangle rect = ((SwtDeviceDisplay) device.getDeviceDisplay())
+						.getDisplayRectangle();
+				SwtInputMethod inputMethod = (SwtInputMethod) device.getInputMethod();
+				boolean fullScreenMode = device.getDeviceDisplay().isFullScreenMode();
+				if (rect.x <= e.x && (rect.x + rect.width) > e.x && rect.y <= e.y && (rect.y + rect.height) > e.y) {
+					if (device.hasPointerMotionEvents()) {
+						if (!fullScreenMode) {
+							if (initialPressedSoftButton != null) {
+								org.microemu.device.impl.Rectangle pb = initialPressedSoftButton.getPaintable();
+								if (pb != null) {
+									if (pb.contains(e.x - rect.x, e.y - rect.y)) {
+										if (!initialPressedSoftButton.isPressed()) {
+											initialPressedSoftButton.setPressed(true);
+											dc.repaintRequest(pb.x, pb.y, pb.width, pb.height);
+										}
+									} else {
+										if (initialPressedSoftButton.isPressed()) {
+											initialPressedSoftButton.setPressed(false);
+											dc.repaintRequest(pb.x, pb.y, pb.width, pb.height);
+										}
+									}
+								}
+							}
+						}
+						if (fullScreenMode) {
+							inputMethod.pointerDragged(e.x - rect.x, e.y - rect.y);
+						} else {
+							org.microemu.device.impl.Rectangle pb = ((SwtDeviceDisplay) device.getDeviceDisplay())
+									.getDisplayPaintable();
+							inputMethod.pointerDragged(e.x - rect.x - pb.x, e.y - rect.y - pb.y);
+						}
+					}
+				}
+			}
+		}
+	};
+
+	public SwtDeviceComponent(Composite parent) {
+		super(parent, SWT.NO_BACKGROUND);
+		instance = this;
+		mousePressed = false;
+
+		dc = new SwtDisplayComponent(this);
+
+		this.initialPressedSoftButton = null;
+
+		addKeyListener(keyListener);
+		addMouseListener(mouseListener);
+		addMouseMoveListener(mouseMoveListener);
+		addPaintListener(new PaintListener() {
+			public void paintControl(PaintEvent e) {
+				SwtDeviceComponent.this.paintControl(e);
+			}
+		});
+	}
+
+	public DisplayComponent getDisplayComponent() {
+		return dc;
+	}
+
+	public Point computeSize(int wHint, int hHint, boolean changed) {
+		javax.microedition.lcdui.Image tmp = DeviceFactory.getDevice().getNormalImage();
+
+		return new Point(tmp.getWidth(), tmp.getHeight());
+	}
+
+	public void paintControl(PaintEvent pe) {
+		Point size = getSize();
+
+		if (size.x <= 0 || size.y <= 0)
+			return;
+
+		if (fBuffer != null) {
+			org.eclipse.swt.graphics.Rectangle r = fBuffer.getBounds();
+			if (r.width != size.x || r.height != size.y) {
+				fBuffer.dispose();
+				fBuffer = null;
+			}
+		}
+		if (fBuffer == null) {
+			fBuffer = new Image(getDisplay(), size.x, size.y);
+		}
+
+		SwtGraphics gc = new SwtGraphics(new GC(fBuffer));
+		try {
+			Device device = DeviceFactory.getDevice();
+
+			gc.drawImage(((SwtImmutableImage) device.getNormalImage()).getImage(), 0, 0);
+
+			org.microemu.device.impl.Rectangle displayRectangle = ((SwtDeviceDisplay) device.getDeviceDisplay())
+					.getDisplayRectangle();
+			gc.translate(displayRectangle.x, displayRectangle.y);
+			dc.paint(gc);
+			gc.translate(-displayRectangle.x, -displayRectangle.y);
+
+			if (prevOverButton != null) {
+				org.microemu.device.impl.Shape shape = prevOverButton.getShape();
+				if (shape != null) {
+					drawImageInShape(gc, ((SwtImmutableImage) device.getNormalImage()).getImage(), shape);
+				}
+				prevOverButton = null;
+			}
+			if (overButton != null) {
+				org.microemu.device.impl.Shape shape = overButton.getShape();
+				if (shape != null) {
+					drawImageInShape(gc, ((SwtImmutableImage) device.getOverImage()).getImage(), shape);
+				}
+			}
+			if (pressedButton != null) {
+				org.microemu.device.impl.Shape shape = pressedButton.getShape();
+				if (shape != null) {
+					drawImageInShape(gc, ((SwtImmutableImage) device.getPressedImage()).getImage(), shape);
+				}
+			}
+
+			org.microemu.device.impl.Rectangle rect;
+			if (prevOverButton != null) {
+				rect = prevOverButton.getShape().getBounds();
+				if (rect != null) {
+					gc.drawImage(((SwtImmutableImage) DeviceFactory.getDevice().getNormalImage()).getImage(), rect.x,
+							rect.y, rect.width, rect.height, rect.x, rect.y, rect.width, rect.height);
+				}
+				prevOverButton = null;
+			}
+			if (overButton != null) {
+				rect = overButton.getShape().getBounds();
+				if (rect != null) {
+					gc.drawImage(((SwtImmutableImage) DeviceFactory.getDevice().getOverImage()).getImage(), rect.x,
+							rect.y, rect.width, rect.height, rect.x, rect.y, rect.width, rect.height);
+				}
+			}
+			if (pressedButton != null) {
+				rect = pressedButton.getShape().getBounds();
+				if (rect != null) {
+					gc.drawImage(((SwtImmutableImage) DeviceFactory.getDevice().getPressedImage()).getImage(), rect.x,
+							rect.y, rect.width, rect.height, rect.x, rect.y, rect.width, rect.height);
+				}
+			}
+		} finally {
+			gc.dispose();
+		}
+
+		pe.gc.drawImage(fBuffer, 0, 0);
+	}
+
+	private void drawImageInShape(SwtGraphics g, Image image, org.microemu.device.impl.Shape shape) {
+		org.eclipse.swt.graphics.Rectangle clipSave = g.getClipping();
+		if (shape instanceof org.microemu.device.impl.Polygon) {
+			// TODO not implemented yet
+			// g.setCliping(region);
+		}
+		org.microemu.device.impl.Rectangle r = shape.getBounds();
+		g.drawImage(image, r.x, r.y, r.width, r.height, r.x, r.y, r.width, r.height);
+		g.setClipping(clipSave);
+	}
+
+	private SwtButton getButton(int x, int y) {
+		for (Enumeration e = DeviceFactory.getDevice().getButtons().elements(); e.hasMoreElements();) {
+			SwtButton button = (SwtButton) e.nextElement();
+			if (button.getShape() != null) {
+				try {
+					org.microemu.device.impl.Shape tmp = (org.microemu.device.impl.Shape) button.getShape().clone();
+					if (tmp.contains(x, y)) {
+						return button;
+					}
+				} catch (CloneNotSupportedException ex) {
+					ex.printStackTrace();
+				}
+			}
+		}
+		return null;
+	}
+
+	private class CreateImageRunnable implements Runnable {
+		private ImageData data;
+
+		private Image image;
+
+		CreateImageRunnable(ImageData data) {
+			this.data = data;
+		}
+
+		Image getImage() {
+			return image;
+		}
+
+		public void run() {
+			image = new Image(instance.getParent().getDisplay(), data);
+		}
+	}
+
+	public static Image createImage(int width, int height) {
+		return new Image(instance.getDisplay(), width, height);
+	}
+
+	public static Image createImage(Image image) {
+		return new Image(instance.getDisplay(), image, SWT.IMAGE_COPY);
+	}
+
+	public static Image createImage(ImageData data) {
+		CreateImageRunnable createImageRunnable = instance.new CreateImageRunnable(data);
+		instance.getDisplay().syncExec(createImageRunnable);
+
+		return createImageRunnable.getImage();
+	}
+
+	public static Image createImage(InputStream is) {
+		ImageData data = new ImageData(is);
+
+		CreateImageRunnable createImageRunnable = instance.new CreateImageRunnable(data);
+		instance.getDisplay().syncExec(createImageRunnable);
+
+		return createImageRunnable.getImage();
+	}
+
+	public static Image createImage(InputStream is, ImageFilter filter) throws IOException {
+		try {
+			ImageData data = new ImageData(is);
+
+			RGB[] rgbs = data.getRGBs();
+			if (rgbs != null) {
+				for (int i = 0; i < rgbs.length; i++) {
+					rgbs[i] = filter.filterRGB(0, 0, rgbs[i]);
+				}
+			} else {
+				RGB rgb;
+				int pixel;
+				for (int y = 0; y < data.height; y++) {
+					for (int x = 0; x < data.width; x++) {
+						pixel = data.getPixel(x, y);
+						rgb = new RGB((pixel >> 16) & 255, (pixel >> 8) & 255, pixel & 255);
+						rgb = filter.filterRGB(x, y, rgb);
+						data.setPixel(x, y, (rgb.red << 16) + (rgb.green << 8) + rgb.blue);
+					}
+				}
+			}
+
+			CreateImageRunnable createImageRunnable = instance.new CreateImageRunnable(data);
+			instance.getDisplay().syncExec(createImageRunnable);
+
+			return createImageRunnable.getImage();
+		} catch (SWTException ex) {
+			throw new IOException(ex.toString());
+		}
+	}
+
+	private class CreateColorRunnable implements Runnable {
+		private RGB rgb;
+
+		private Color color;
+
+		CreateColorRunnable(RGB rgb) {
+			this.rgb = rgb;
+		}
+
+		Color getColor() {
+			return color;
+		}
+
+		public void run() {
+			color = new Color(instance.getParent().getDisplay(), rgb);
+		}
+	}
+
+	public static Color getColor(RGB rgb) {
+		Color result = (Color) colors.get(rgb);
+
+		if (result == null) {
+			CreateColorRunnable createColorRunnable = instance.new CreateColorRunnable(rgb);
+			instance.getDisplay().syncExec(createColorRunnable);
+			result = createColorRunnable.getColor();
+			colors.put(rgb, result);
+		}
+
+		return result;
+	}
+
+	private class GetFontMetricsRunnable implements Runnable {
+		private Font font;
+
+		private FontMetrics fontMetrics;
+
+		GetFontMetricsRunnable(Font font) {
+			this.font = font;
+		}
+
+		FontMetrics getFontMetrics() {
+			return fontMetrics;
+		}
+
+		public void run() {
+			SwtGraphics gc = new SwtGraphics(instance.getParent().getDisplay());
+			gc.setFont(font);
+			fontMetrics = gc.getFontMetrics();
+			gc.dispose();
+		}
+	}
+
+	private class GetFontRunnable implements Runnable {
+		private String name;
+
+		private int size;
+
+		private int style;
+
+		private boolean antialiasing;
+
+		private Font font;
+
+		GetFontRunnable(String name, int size, int style, boolean antialiasing) {
+			this.name = name;
+			this.size = size;
+			this.style = style;
+		}
+
+		Font getFont() {
+			return font;
+		}
+
+		public void run() {
+			SwtGraphics gc = new SwtGraphics(instance.getParent().getDisplay());
+			gc.setAntialias(antialiasing);
+			gc.setFont(new Font(instance.getParent().getDisplay(), name, size, style));
+			font = gc.getFont();
+			gc.dispose();
+		}
+	}
+
+	private class StringWidthRunnable implements Runnable {
+		private Font font;
+
+		private String str;
+
+		private int stringWidth;
+
+		StringWidthRunnable(Font font, String str) {
+			this.font = font;
+			this.str = str;
+		}
+
+		int stringWidth() {
+			return stringWidth;
+		}
+
+		public void run() {
+			SwtGraphics gc = new SwtGraphics(instance.getParent().getDisplay());
+			gc.setFont(font);
+			stringWidth = gc.stringWidth(str);
+			gc.dispose();
+		}
+	}
+
+	public static Font getFont(String name, int size, int style, boolean antialiasing) {
+		GetFontRunnable getFontRunnable = instance.new GetFontRunnable(name, size, style, antialiasing);
+
+		instance.getDisplay().syncExec(getFontRunnable);
+
+		return getFontRunnable.getFont();
+	}
+
+	public static FontMetrics getFontMetrics(Font font) {
+		GetFontMetricsRunnable getFontMetricsRunnable = instance.new GetFontMetricsRunnable(font);
+
+		instance.getDisplay().syncExec(getFontMetricsRunnable);
+
+		return getFontMetricsRunnable.getFontMetrics();
+	}
+
+	public static int stringWidth(Font font, String str) {
+		StringWidthRunnable stringWidthRunnable = instance.new StringWidthRunnable(font, str);
+
+		instance.getDisplay().syncExec(stringWidthRunnable);
+
+		return stringWidthRunnable.stringWidth();
+	}
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDeviceComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDialog.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDialog.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDialog.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDialog.java Mon May 26 15:20:19 2008
@@ -0,0 +1,315 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.app.ui.swt;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.ShellAdapter;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.ShellListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+
+public abstract class SwtDialog
+{
+	public static final int OK = 0;
+	public static final int CANCEL = 1;
+
+	private Shell parentShell;
+	private Shell shell;
+	
+	protected Control dialogArea;
+	protected Control buttonBar;
+	
+	protected Button btOk;
+	protected Button btCancel;
+
+	private boolean resizeHasOccurred = false;
+	private Listener resizeListener;
+	private Control contents;
+	private int shellStyle = SWT.SHELL_TRIM;
+	private boolean block = false;
+	private int returnCode = OK;
+
+
+	public SwtDialog(Shell parentShell)
+	{
+		this.parentShell = parentShell;
+		this.block = true;
+		this.shellStyle = SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL;
+	}
+	
+	
+	public void create() 
+	{
+		shell = createShell();
+		contents = createContents(shell);
+
+		//initialize the bounds of the shell to that appropriate for the contents
+		initializeBounds();
+	}
+
+
+	protected final Shell createShell() 
+	{
+		Shell newShell = new Shell(parentShell, shellStyle);
+
+		resizeListener = new Listener() {
+			public void handleEvent(Event e) {
+				resizeHasOccurred = true;
+			}
+		};
+	
+		newShell.addListener(SWT.Resize,resizeListener);
+		newShell.setData(this);
+
+		newShell.addShellListener(getShellListener());
+
+		configureShell(newShell);
+		
+		return newShell;
+	}
+	
+	
+	protected void configureShell(Shell newShell) 
+	{
+		GridLayout layout = new GridLayout();
+		layout.marginHeight = 0;
+		layout.marginWidth = 0;
+		newShell.setLayout(layout);
+	}
+
+
+	protected Control createContents(Composite parent) 
+	{
+		Composite composite = new Composite(parent, 0);
+		GridLayout layout = new GridLayout();
+		layout.marginHeight = 0;
+		layout.marginWidth = 0;
+		layout.verticalSpacing = 0;
+		composite.setLayout(layout);
+		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+		composite.setFont(parent.getFont());
+
+		dialogArea = createDialogArea(composite);
+		buttonBar = createButtonBar(composite);
+
+		return composite;
+	}
+
+
+	protected Control createDialogArea(Composite parent) 
+	{
+		Composite composite = new Composite(parent, SWT.NONE);
+		
+		composite.setLayout(new GridLayout());
+		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+		composite.setFont(parent.getFont());
+
+		return composite;
+	}
+	
+
+	protected Control createButtonBar(Composite parent) 
+	{
+		Composite composite = new Composite(parent, SWT.NONE);
+		
+		composite.setLayout(new GridLayout(2, false));
+		composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
+		composite.setFont(parent.getFont());
+
+		btOk = new Button(composite, SWT.PUSH);
+		btOk.setText("OK");		
+		btOk.addSelectionListener(new SelectionAdapter() 
+		{
+			public void widgetSelected(SelectionEvent event) 
+			{
+				buttonPressed(OK);
+			}
+		});
+		
+		btCancel = new Button(composite, SWT.PUSH);
+		btCancel.setText("Cancel");		
+		btCancel.addSelectionListener(new SelectionAdapter() 
+		{
+			public void widgetSelected(SelectionEvent event) 
+			{
+				buttonPressed(CANCEL);
+			}
+		});
+
+		return composite;
+	}
+	
+
+	protected void initializeBounds() 
+	{
+		if (resizeListener != null) {
+			shell.removeListener(SWT.Resize,resizeListener);
+		}
+	
+		if (resizeHasOccurred) { // Check if shell size has been set already.
+			return;
+		}
+
+		Point size = getInitialSize();
+		Point location = getInitialLocation(size);
+
+		shell.setBounds(location.x, location.y, size.x, size.y);
+	}
+	
+	
+	protected Point getInitialSize() 
+	{
+		return shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+	}
+
+
+	protected Point getInitialLocation(Point initialSize) 
+	{
+		Composite parentShell = shell.getParent();
+		Rectangle containerBounds = (parentShell != null) ? parentShell.getBounds() : shell.getDisplay().getClientArea();
+		int x = Math.max(0, containerBounds.x + (containerBounds.width - initialSize.x) / 2);
+		int y = Math.max(0, containerBounds.y + (containerBounds.height - initialSize.y) / 3);
+		return new Point(x, y);
+	}
+	
+	
+	protected void buttonPressed(int buttonId) 
+	{
+		if (buttonId == OK) {
+			okPressed();
+		} else if (buttonId == CANCEL) {
+			cancelPressed();
+		}
+	}
+
+
+	protected void okPressed() 
+	{
+		setReturnCode(OK);
+		close();
+	}
+	
+	
+	protected void cancelPressed() {
+		setReturnCode(CANCEL);
+		close();
+	}
+	
+	
+	protected int getReturnCode() 
+	{
+		return returnCode;
+	}
+	
+	
+	protected void setReturnCode(int code) 
+	{
+		returnCode = code;
+	}
+	
+	
+	protected ShellListener getShellListener() 
+	{
+		return new ShellAdapter() 
+		{
+			public void shellClosed(ShellEvent event) 
+			{
+				event.doit= false;	// don't close now
+				setReturnCode(CANCEL);
+				close();
+			}
+		};
+	}
+
+
+	public boolean close() 
+	{
+		if (shell != null || !shell.isDisposed()) {
+			shell.dispose();
+			shell = null;
+			contents = null;
+		}
+
+		buttonBar = null;
+		dialogArea = null;
+
+		return true;
+	}
+
+
+	public Shell getShell() 
+	{
+		return shell;
+	}
+
+
+	public int open() 
+	{
+
+		if (shell == null) {
+			create();
+		}
+
+		shell.open();
+
+		if (block) { 
+			runEventLoop(shell);
+		}	
+
+		return returnCode;
+	}
+
+
+	private void runEventLoop(Shell shell) 
+	{
+		Display display;
+		if(shell == null) {
+			 display = Display.getCurrent();
+		}	else {
+			display = shell.getDisplay();
+		}
+		
+		while (shell != null && ! shell.isDisposed()) {
+			try {
+				if (!display.readAndDispatch()) {
+					display.sleep();
+				}
+			} catch (Throwable ex) {
+				System.err.println(ex);
+			}
+		}
+		display.update();
+	}
+
+}
+

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDialog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDisplayComponent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDisplayComponent.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDisplayComponent.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDisplayComponent.java Mon May 26 15:20:19 2008
@@ -0,0 +1,145 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+ 
+package org.microemu.app.ui.swt;
+
+import javax.microedition.lcdui.Displayable;
+
+import org.eclipse.swt.widgets.Canvas;
+import org.microemu.DisplayAccess;
+import org.microemu.DisplayComponent;
+import org.microemu.MIDletAccess;
+import org.microemu.MIDletBridge;
+import org.microemu.app.ui.DisplayRepaintListener;
+import org.microemu.device.Device;
+import org.microemu.device.DeviceFactory;
+import org.microemu.device.MutableImage;
+import org.microemu.device.swt.SwtDeviceDisplay;
+import org.microemu.device.swt.SwtDisplayGraphics;
+import org.microemu.device.swt.SwtMutableImage;
+
+
+//TODO extends Canvas like in swing version
+public class SwtDisplayComponent implements DisplayComponent
+{
+	private Canvas deviceCanvas;
+	private SwtMutableImage displayImage = null;
+	private DisplayRepaintListener displayRepaintListener;
+	
+	private Runnable redrawRunnable = new Runnable()
+	{
+		public void run() 
+		{
+			if (!deviceCanvas.isDisposed()) {
+				deviceCanvas.redraw();
+			}
+		}
+	};
+
+
+	SwtDisplayComponent(Canvas deviceCanvas)
+	{
+		this.deviceCanvas = deviceCanvas;
+	}
+	
+	
+	public void addDisplayRepaintListener(DisplayRepaintListener l)
+	{
+		displayRepaintListener = l;
+	}
+
+
+	public void removeDisplayRepaintListener(DisplayRepaintListener l)
+	{
+		if (displayRepaintListener == l) {
+			displayRepaintListener = null;
+		}
+	}
+	
+	
+	public MutableImage getDisplayImage()
+	{
+		return displayImage;
+	}
+
+
+	public void paint(SwtGraphics gc) 
+	{
+		synchronized (this) {
+			if (displayImage != null) {
+				gc.drawImage(displayImage.img, 0, 0);
+			}
+		}
+	}
+
+  
+	public void repaintRequest(int x, int y, int width, int height) 
+	{
+		if (!deviceCanvas.isDisposed()) {			
+			MIDletAccess ma = MIDletBridge.getMIDletAccess();
+			if (ma == null) {
+				return;
+			}
+			DisplayAccess da = ma.getDisplayAccess();
+			if (da == null) {
+				return;
+			}
+			Displayable current = da.getCurrent();
+			if (current == null) {
+				return;
+			}
+
+			Device device = DeviceFactory.getDevice();
+
+			SwtMutableImage image = new SwtMutableImage(
+					device.getDeviceDisplay().getFullWidth(), device.getDeviceDisplay().getFullHeight());
+						
+			SwtGraphics gc = ((SwtDisplayGraphics) image.getGraphics()).g;
+			try {
+				SwtDeviceDisplay deviceDisplay = (SwtDeviceDisplay) device.getDeviceDisplay();
+				deviceDisplay.paintDisplayable(gc, x, y, width, height);
+				if (!deviceDisplay.isFullScreenMode()) {
+					deviceDisplay.paintControls(gc);
+				}
+			} finally {
+				gc.dispose();
+			}
+
+			synchronized (this) {
+				if (displayImage != null) {
+					displayImage.img.dispose();
+				}
+				displayImage = image;
+			}
+			
+			fireDisplayRepaint(displayImage);	
+	
+			deviceCanvas.getDisplay().asyncExec(redrawRunnable);
+		}
+	}
+	
+	
+	private void fireDisplayRepaint(MutableImage image)
+	{
+		if (displayRepaintListener != null) {
+			displayRepaintListener.repaintInvoked(image);
+		}
+	}
+  
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtDisplayComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtErrorMessageDialogPanel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtErrorMessageDialogPanel.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtErrorMessageDialogPanel.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtErrorMessageDialogPanel.java Mon May 26 15:20:19 2008
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.app.ui.swt;
+
+import org.eclipse.swt.widgets.Shell;
+import org.microemu.app.ui.Message;
+import org.microemu.app.ui.MessageListener;
+
+public class SwtErrorMessageDialogPanel implements MessageListener {
+	
+	private Shell shell;
+
+	public SwtErrorMessageDialogPanel(Shell shell) {
+		this.shell = shell;
+	}
+
+	public void showMessage(int level, String title, String text, Throwable throwable) {
+		// TODO Add option to show throwable
+		int messageType;
+		switch (level) {
+		case Message.ERROR:
+			messageType = SwtMessageDialog.ERROR;
+			break;
+		case Message.WARN:
+			messageType = SwtMessageDialog.WARNING;
+			break;
+		default:
+			messageType = SwtMessageDialog.INFORMATION;
+		}
+		SwtMessageDialog.openMessageDialog(shell, title, text, messageType);
+	}
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtErrorMessageDialogPanel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtGraphics.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtGraphics.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtGraphics.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtGraphics.java Mon May 26 15:20:19 2008
@@ -0,0 +1,240 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.app.ui.swt;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+
+public class SwtGraphics 
+{
+	private Display display;
+	private GC gc;
+	private int transX = 0;
+	private int transY = 0;
+	private HashMap colors;
+	
+
+	public SwtGraphics(Display display) 
+	{
+		this.display = display;
+		this.gc = new GC(display);
+	}
+
+
+	public SwtGraphics(GC gc)
+	{
+		this.gc = gc;
+	}
+
+
+	public void dispose()
+	{
+		gc.dispose();
+		
+		if (colors != null) {
+			for (Iterator it = colors.values().iterator(); it.hasNext(); ) {
+				((Color) it.next()).dispose();
+			}
+		}
+	}
+
+
+	public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight,
+			int destX, int destY, int destWidth, int destHeight) 
+	{
+		gc.drawImage(image, srcX, srcY, srcWidth, srcHeight, destX + transX, destY + transY, destWidth, destHeight);
+	}
+
+
+	public void drawImage(Image image, int x, int y) 
+	{
+		gc.drawImage(image, x + transX, y + transY);
+	}
+	
+	
+	public void translate(int x, int y)
+	{
+		transX += x;
+		transY += y;
+	}
+	
+	
+	public Color getColor(RGB rgb)
+	{
+		if (colors == null) {
+			colors = new HashMap();
+		}
+		
+		Color result = (Color) colors.get(rgb);
+		if (result == null) {
+			result = new Color(display, rgb);
+			colors.put(rgb, result);
+		}
+		
+		return result;
+	}
+
+
+	public FontMetrics getFontMetrics() 
+	{
+		return gc.getFontMetrics();
+	}
+
+
+	public void setFont(Font font) 
+	{
+		gc.setFont(font);
+	}
+
+
+	public Color getBackground() 
+	{
+		return gc.getBackground();
+	}
+
+
+	public Color getForeground() 
+	{
+		return gc.getForeground();
+	}
+
+
+	public void setBackground(Color color) 
+	{
+		gc.setBackground(color);
+	}
+
+
+	public void setForeground(Color color) 
+	{
+		gc.setForeground(color);
+	}
+
+
+	public Rectangle getClipping() 
+	{
+		return gc.getClipping();
+	}
+
+
+	public void setClipping(int x, int y, int width, int height) 
+	{
+		gc.setClipping(x + transX, y + transY, width, height);
+	}
+
+
+	public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle) 
+	{
+		gc.drawArc(x + transX, y + transY, width, height, startAngle, endAngle);
+	}
+
+
+	public void drawLine(int x1, int y1, int x2, int y2) 
+	{
+		gc.drawLine(x1 + transX, y1 + transY, x2 + transX, y2 + transY);
+	}
+
+
+	public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) 
+	{
+		gc.drawRoundRectangle(x + transX, y + transY, width, height, arcWidth, arcHeight);
+	}
+
+
+	public void drawString(String string, int x, int y, boolean isTransparent) 
+	{
+		gc.drawString(string, x + transX, y + transY, isTransparent);
+	}
+
+
+	public void fillArc(int x, int y, int width, int height, int startAngle, int endAngle) 
+	{
+		gc.fillArc(x + transX, y + transY, width, height, startAngle, endAngle);
+	}
+
+
+	public void fillPolygon(int[] pointArray) 
+	{
+		gc.fillPolygon(pointArray);
+	}
+
+
+	public void fillRectangle(int x, int y, int width, int height) 
+	{
+		gc.fillRectangle(x + transX, y + transY, width, height);
+	}
+
+
+	public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) 
+	{
+		gc.fillRoundRectangle(x + transX, y + transY, width, height, arcWidth, arcHeight);
+	}
+
+
+	public int stringWidth(String string) 
+	{
+		return gc.stringExtent(string).x;
+	}
+
+
+	public Font getFont() 
+	{
+		return gc.getFont();
+	}
+
+
+	public void setClipping(Rectangle rect) 
+	{
+		Rectangle tmp = new Rectangle(rect.x + transX, rect.y + transY, rect.width, rect.height);
+		gc.setClipping(tmp);
+	}
+	
+	
+	public boolean getAntialias()
+	{
+		if (gc.getAntialias() == SWT.ON) {
+			return  true;
+		} else {
+			return false;
+		}
+	}
+	
+	
+	public void setAntialias(boolean antialias)
+	{
+		if (antialias) {
+			gc.setAntialias(SWT.ON);
+		} else {
+			gc.setAntialias(SWT.OFF);
+		}
+	}
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtGraphics.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtInputDialog.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtInputDialog.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtInputDialog.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtInputDialog.java Mon May 26 15:20:19 2008
@@ -0,0 +1,92 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.microemu.app.ui.swt;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+
+public class SwtInputDialog extends SwtDialog 
+{
+	private String title;
+	private String message;
+	private String value;
+	
+
+	public SwtInputDialog(Shell parentShell, String title, String message)
+	{
+		super(parentShell);
+		
+		this.title = title;
+		this.message = message;
+	}
+
+
+	public String getValue() 
+	{
+		return value;
+	}
+
+
+	protected void configureShell(Shell shell) 
+	{
+		super.configureShell(shell);
+		
+		if (title != null) {
+			shell.setText(title);
+		}
+	}
+
+
+	protected Control createDialogArea(Composite composite) 
+	{
+		GridLayout gridLayout = new GridLayout();
+		gridLayout.numColumns = 1;
+		composite.setLayout(gridLayout);
+
+		Label lbMessage = new Label(composite, SWT.NONE);
+		lbMessage.setText(message);
+		lbMessage.setLayoutData(new GridData(GridData.FILL_BOTH));
+		
+		final Text txInput = new Text(composite, SWT.SINGLE | SWT.BORDER);
+		GridData gridData = 
+				new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+		gridData.widthHint = txInput.getLineHeight() * 15;
+		txInput.setLayoutData(gridData);
+		txInput.addModifyListener(new ModifyListener() 
+		{
+			public void modifyText(ModifyEvent e) 
+			{
+				value = txInput.getText();
+			}
+		});
+		
+		return composite;
+	}
+	
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtInputDialog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtMessageDialog.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtMessageDialog.java?rev=660326&view=auto
==============================================================================
--- harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtMessageDialog.java (added)
+++ harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtMessageDialog.java Mon May 26 15:20:19 2008
@@ -0,0 +1,138 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+ 
+package org.microemu.app.ui.swt;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+
+public class SwtMessageDialog extends SwtDialog 
+{
+	public final static int ERROR = 1;
+	public final static int WARNING = 2;
+	public final static int INFORMATION = 3;
+	public final static int QUESTION = 4;
+	
+	private String title;
+	private String message;
+	private String[] buttonLabels;
+	private int defaultIndex;
+
+
+	public SwtMessageDialog(Shell parentShell, String title, String message, int imageType, String[] buttonLabels, int defaultIndex) 
+	{
+		super(parentShell);
+		
+		this.title = title;
+		this.message = message;
+		this.buttonLabels = buttonLabels;
+		this.defaultIndex = defaultIndex;
+	}
+
+
+	public static void openMessageDialog(Shell parent, String title, String message, int messageType) 
+	{
+		SwtMessageDialog dialog = 
+				new SwtMessageDialog(parent, title, message, messageType, new String[] {"OK"}, 0);
+		dialog.open();	
+	}
+	
+	
+	public static boolean openQuestion(Shell parent, String title, String message) 
+	{
+		SwtMessageDialog dialog = 
+				new SwtMessageDialog(parent, title, message, QUESTION, new String[] {"Yes", "No"}, 0);
+		return dialog.open() == 0;
+	}
+	
+
+
+	protected void configureShell(Shell shell) 
+	{
+		super.configureShell(shell);
+		
+		if (title != null) {
+			shell.setText(title);
+		}
+	}
+	
+	
+	protected Control createDialogArea(Composite composite) 
+	{
+		GridLayout gridLayout = new GridLayout();
+		gridLayout.numColumns = 1;
+		composite.setLayout(gridLayout);
+
+		Label lbMessage = new Label(composite, SWT.NONE);
+		lbMessage.setText(message);
+		lbMessage.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+		return composite;
+	}
+
+
+	protected Control createButtonBar(Composite parent) 
+	{
+		Composite composite = new Composite(parent, SWT.NONE);
+		
+		composite.setLayout(new GridLayout(buttonLabels.length, false));
+		composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
+		composite.setFont(parent.getFont());
+
+		for (int i = 0; i < buttonLabels.length; i++) {
+			Button button = new Button(composite, SWT.PUSH);
+			button.setText(buttonLabels[i]);
+			button.setData(new Integer(i));
+			button.addSelectionListener(new SelectionAdapter() 
+			{
+				public void widgetSelected(SelectionEvent event) 
+				{
+					buttonPressed(((Integer) event.widget.getData()).intValue());
+				}
+			});
+			
+			if (i == defaultIndex) {
+				Shell shell = parent.getShell();
+				if (shell != null) {
+					shell.setDefaultButton(button);
+				}
+			}
+		}
+
+		return composite;
+	}
+
+
+	protected void buttonPressed(int buttonId) 
+	{
+		setReturnCode(buttonId);
+		close();
+	}
+	
+
+}

Propchange: harmony/enhanced/microemulator/microemu-javase-swt/src/main/java/org/microemu/app/ui/swt/SwtMessageDialog.java
------------------------------------------------------------------------------
    svn:eol-style = native