make i2 visible outside AWT.java
[org.ibex.core.git] / src / org / ibex / plat / AWT.java
index d937588..9ca0366 100644 (file)
@@ -120,8 +120,8 @@ public class AWT extends JVM {
 
     protected org.ibex.graphics.Font.Glyph _createGlyph(org.ibex.graphics.Font f, char c) { return new AWTGlyph(f, c); }
     protected static class AWTGlyph extends org.ibex.graphics.Font.Glyph {
 
     protected org.ibex.graphics.Font.Glyph _createGlyph(org.ibex.graphics.Font f, char c) { return new AWTGlyph(f, c); }
     protected static class AWTGlyph extends org.ibex.graphics.Font.Glyph {
-        private Image i = null;
-        private Image i2 = null;
+        Image i = null;
+        Image i2 = null;
         private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
 
         // this doesn't work on Win32 because the JVM is broken
         private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
 
         // this doesn't work on Win32 because the JVM is broken
@@ -297,12 +297,13 @@ public class AWT extends JVM {
         public void setMinimumSize(int minx, int miny, boolean resizable) { if (frame != null) frame.setResizable(resizable); }
         public void toBack() { if (window != null) window.toBack(); }
         public void toFront() { if (window != null) window.toFront(); }
         public void setMinimumSize(int minx, int miny, boolean resizable) { if (frame != null) frame.setResizable(resizable); }
         public void toBack() { if (window != null) window.toBack(); }
         public void toFront() { if (window != null) window.toFront(); }
-        public void setLocation() { window.setLocation(root.x, root.y); }
+        public void setLocation() { /*window.setLocation(root.x, root.y); FIXME */ }
         public void setTitleBarText(String s) { if (frame != null) frame.setTitle(s); }
         public void setIcon(Picture i) { if (frame != null) frame.setIconImage(((AWTPicture)i).i); }
         public void _setSize(int width, int height) {
             g = null;
         public void setTitleBarText(String s) { if (frame != null) frame.setTitle(s); }
         public void setIcon(Picture i) { if (frame != null) frame.setIconImage(((AWTPicture)i).i); }
         public void _setSize(int width, int height) {
             g = null;
-            window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom)); }
+            window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom));
+        }
         public void setInvisible(boolean b) { window.setVisible(!b); }
         protected void _setMinimized(boolean b) { if (Log.on) Log.info(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); }
         protected void _setMaximized(boolean b) {
         public void setInvisible(boolean b) { window.setVisible(!b); }
         protected void _setMinimized(boolean b) { if (Log.on) Log.info(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); }
         protected void _setMaximized(boolean b) {
@@ -317,29 +318,36 @@ public class AWT extends JVM {
 
         class InnerFrame extends Frame {
             public InnerFrame() throws java.lang.UnsupportedOperationException { }
 
         class InnerFrame extends Frame {
             public InnerFrame() throws java.lang.UnsupportedOperationException { }
-            public Dimension getMinimumSize() { return new Dimension(root.minwidth(), root.minheight()); }
-            public void update(Graphics gr) { paint(gr); }
+            public Dimension getMinimumSize() { return new Dimension(root.minwidth, root.minheight); }
+            public void update(Graphics gr) {
+                Rectangle r = gr.getClipBounds();
+                super.update(gr);
+                dirtify(r);
+            }
             public void paint(Graphics gr) {
                 // Mac OS X Jdk1.4 Bug: after a componentResized(), you must wait for the paint() before you redraw
                 Rectangle r = gr.getClipBounds();
             public void paint(Graphics gr) {
                 // Mac OS X Jdk1.4 Bug: after a componentResized(), you must wait for the paint() before you redraw
                 Rectangle r = gr.getClipBounds();
-
+                super.paint(gr);
+                dirtify(r);
+            }
+            private void dirtify(java.awt.Rectangle r) {
+                if (r != null) {
+                    Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
+                } else {
+                    Dirty(0, 0,
+                          Math.max(getWidth() - insets.left - insets.right, root.width),
+                          Math.min(getHeight() - insets.top - insets.bottom, root.height));
+                }
                 // ugly hack for Java1.4 dynamicLayout on Win32 -- this catches expansions during smooth resize
                 // ugly hack for Java1.4 dynamicLayout on Win32 -- this catches expansions during smooth resize
-                int newwidth = Math.max(r.x - insets.left + r.width, root.width);
-                int newheight = Math.max(r.y - insets.top + r.height, root.height);
-                if (newwidth > root.width || newheight > root.height)
-                    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);
-                g = gr;
-                blit(r.x - insets.left, r.y - insets.top, r.width, r.height);
-                g.setClip(0, 0, getWidth(), getHeight());
+                int newwidth = Math.max(getWidth() - insets.left - insets.right, root.width);
+                int newheight = Math.max(getHeight() - insets.top - insets.bottom, root.height);
+                if (newwidth != root.width || newheight != root.height) componentResized(newwidth, newheight);
             }
         }
 
         class InnerWindow extends Window {
             public InnerWindow() throws java.lang.UnsupportedOperationException { super(new Frame()); }
             }
         }
 
         class InnerWindow extends Window {
             public InnerWindow() throws java.lang.UnsupportedOperationException { super(new Frame()); }
-            public Dimension getMinimumSize() { return new Dimension(root.minwidth(), root.minheight()); }
+            public Dimension getMinimumSize() { return new Dimension(root.minwidth, root.minheight); }
             public void update(Graphics gr) { paint(gr); }
             public void paint(Graphics gr) {
                 g = null;
             public void update(Graphics gr) { paint(gr); }
             public void paint(Graphics gr) {
                 g = null;
@@ -362,6 +370,12 @@ public class AWT extends JVM {
             super.render();
         }
 
             super.render();
         }
 
+        Insets getInsets() {
+            Insets ret = window.getInsets();
+            if (System.getProperty("os.name", "").equals("Mac OS X")) ret.bottom = -1 * ret.top;
+            return ret;
+        }
+
         AWTSurface(Box root, boolean framed) {
             super(root);
             try {
         AWTSurface(Box root, boolean framed) {
             super(root);
             try {
@@ -374,7 +388,7 @@ public class AWT extends JVM {
                 if (Log.on) Log.info(this, e);
             }
 
                 if (Log.on) Log.info(this, e);
             }
 
-            insets = window.getInsets();
+            insets = getInsets();
             
             window.addMouseListener(this);
             window.addKeyListener(this);
             
             window.addMouseListener(this);
             window.addKeyListener(this);
@@ -440,14 +454,15 @@ public class AWT extends JVM {
 
         public void componentResized(ComponentEvent e) {
             // we have to periodically do this; I don't know why
 
         public void componentResized(ComponentEvent e) {
             // we have to periodically do this; I don't know why
-            insets = window.getInsets();
+            insets = getInsets();
             componentResized(window.getWidth() - insets.left - insets.right, window.getHeight() - insets.top - insets.bottom);
         }
 
         public void componentResized(int newwidth, int newheight) {
             SizeChange(newwidth, newheight);
             componentResized(window.getWidth() - insets.left - insets.right, window.getHeight() - insets.top - insets.bottom);
         }
 
         public void componentResized(int newwidth, int newheight) {
             SizeChange(newwidth, newheight);
-            //if (newwidth > root.width) Dirty(root.width, 0, newwidth-root.width, newheight);
-            //if (newheight > root.height) Dirty(0, root.height, newwidth, newheight-root.height);
+            if (newwidth > root.width) Dirty(root.width, 0, newwidth-root.width, newheight);
+            if (newheight > root.height) Dirty(0, root.height, newwidth, newheight-root.height);
+            Refresh();
         }
 
         public void keyTyped(KeyEvent k) { }
         }
 
         public void keyTyped(KeyEvent k) { }