2002/05/28 18:30:30
[org.ibex.core.git] / src / org / xwt / plat / AWT.java
index 5a0b120..43168fd 100644 (file)
@@ -25,6 +25,7 @@ public class AWT extends Platform {
     protected int _stringWidth(String font, String text) { return getFont(font).metrics.stringWidth(text); }
     protected int _getMaxAscent(String font) { return getFont(font).metrics.getMaxAscent(); }
     protected int _getMaxDescent(String font) { return getFont(font).metrics.getMaxDescent(); }
+    protected boolean _supressDirtyOnResize() { return true; }
 
     protected String _getClipBoard() {
         Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
@@ -48,6 +49,37 @@ public class AWT extends Platform {
         return 0;
     }
 
+    static class Open extends FileDialog implements WindowListener, ComponentListener {
+        Semaphore s;
+        public Open(String suggestedFileName, Semaphore s, boolean write) {
+            super(new Frame(), suggestedFileName, write ? FileDialog.SAVE : FileDialog.LOAD);
+            this.s = s;
+        }
+        public void windowActivated(WindowEvent e) { }
+        public void windowClosed(WindowEvent e) { s.release(); }
+        public void windowClosing(WindowEvent e) { }
+        public void windowDeactivated(WindowEvent e) { }
+        public void windowDeiconified(WindowEvent e) { }
+        public void windowIconified(WindowEvent e) { }
+        public void windowOpened(WindowEvent e) { }
+        public void componentHidden(ComponentEvent e) { s.release(); }
+        public void componentMoved(ComponentEvent e) { }
+        public void componentResized(ComponentEvent e) { }
+        public void componentShown(ComponentEvent e) { }
+    };
+
+    protected String _fileDialog(String suggestedFileName, boolean write) {
+        Semaphore s = new Semaphore();
+        Open fd = new Open(suggestedFileName, s, write);
+        fd.addWindowListener(fd);
+        fd.addComponentListener(fd);
+        fd.show();
+        s.block();
+        return fd.getDirectory() + File.separatorChar + fd.getFile();
+    }
+
+    protected void _saveFile(String suggestedFileName, ByteStream data) throws IOException { }
+
     // Inner Classes /////////////////////////////////////////////////////////////////////////////////////
 
     protected static class AWTPicture implements Picture {
@@ -171,6 +203,9 @@ public class AWT extends Platform {
                     componentResized(window.getWidth() - insets.left - insets.right, window.getHeight() - insets.top - insets.bottom);
 
                 Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
+
+                // this is safe because AWT's low-level drawing functions are threadsafe
+                blitDirtyScreenRegions();
             }
         }
 
@@ -180,6 +215,9 @@ public class AWT extends Platform {
             public void paint(Graphics gr) {
                 Rectangle r = gr.getClipBounds();
                 Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
+
+                // this is safe because AWT's low-level drawing functions are threadsafe
+                blitDirtyScreenRegions();
             }
         }