From: <ls...@us...> - 2009-01-31 17:13:53
|
Revision: 4936 http://jnode.svn.sourceforge.net/jnode/?rev=4936&view=rev Author: lsantha Date: 2009-01-31 17:13:45 +0000 (Sat, 31 Jan 2009) Log Message: ----------- Swingpeer improvements. Modified Paths: -------------- trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingBaseWindow.java trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingComponentPeer.java trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingFramePeer.java Modified: trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingBaseWindow.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingBaseWindow.java 2009-01-31 13:03:43 UTC (rev 4935) +++ trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingBaseWindow.java 2009-01-31 17:13:45 UTC (rev 4936) @@ -31,6 +31,8 @@ import java.awt.Insets; import java.awt.Point; import java.awt.Window; +import java.awt.Cursor; +import java.awt.Dialog; import java.beans.PropertyVetoException; import javax.swing.JComponent; import javax.swing.JDialog; @@ -60,6 +62,7 @@ * The swing peer implementation */ private SwingBaseWindowPeer<awtT, swingPeerT> swingPeer; + boolean requestingFocus = false; public SwingBaseWindow(awtT target) { this.target = target; @@ -87,13 +90,39 @@ public void paint(Graphics g) { super.paint(g); if (target instanceof RootPaneContainer && isVisible()) { - //target.paint(g.create()); - swingPeer.postPaintEvent(); - //JNodeToolkit.postToTarget(new PaintEvent(target, PaintEvent.UPDATE, target.getBounds()), target); + target.paint(g); + //todo isolates related + //swingPeer.postPaintEvent(); + //JRootPane rp = ((RootPaneContainer) target).getRootPane(); + //JNodeToolkit.postToTarget(new PaintEvent(rp, PaintEvent.UPDATE, rp.getBounds()), rp); } } @Override + public void repaint(long tm, int x, int y, int width, int height) { + super.repaint(tm, x, y, width, height); + if (target instanceof RootPaneContainer && isVisible()) { + target.repaint(tm, x, y, width, height); + //todo isolates related + //swingPeer.postPaintEvent(); + //JRootPane rp = ((RootPaneContainer) target).getRootPane(); + //JNodeToolkit.postToTarget(new PaintEvent(rp, PaintEvent.PAINT, new Rectangle(x, y, width, height)), rp); + } + } + + @Override + public void update(Graphics g) { + super.update(g); + if (target instanceof RootPaneContainer && isVisible()) { + target.update(g); + //todo isolates related + //swingPeer.postPaintEvent(); + //JRootPane rp = ((RootPaneContainer) target).getRootPane(); + //JNodeToolkit.postToTarget(new PaintEvent(rp, PaintEvent.UPDATE, rp.getBounds()), rp); + } + } + + @Override public void setMaximum(boolean b) throws PropertyVetoException { super.setMaximum(b); target.setBounds(this.getBounds()); @@ -176,11 +205,6 @@ super.repaint(); } - @Override - public void update(Graphics g) { - super.update(g); - } - /** * @see java.awt.Component#invalidate() */ @@ -211,6 +235,77 @@ SwingUtilities.updateComponentTreeUI(target); } + private boolean settingCursor; + + @Override + public void setCursor(Cursor cursor) { + super.setCursor(cursor); + if (!settingCursor) { + settingCursor = true; + target.setCursor(cursor); + settingCursor = false; + } + } + + @Override + public void requestFocus() { + if (target instanceof JFrame) { + if (!requestingFocus) { + requestingFocus = true; + target.requestFocus(); + requestingFocus = false; + } + } else + super.requestFocus(); + } + + @Override + public boolean requestFocus(boolean temporary) { + if (target instanceof JFrame) { + if (!requestingFocus) { + requestingFocus = true; + target.requestFocus(); + requestingFocus = false; + } + return true; + } else + return super.requestFocus(temporary); + } + + @Override + public boolean requestFocusInWindow() { + if (target instanceof JFrame) { + if (!requestingFocus) { + requestingFocus = true; + boolean ret = target.requestFocusInWindow(); + requestingFocus = false; + return ret; + } + return true; + } else + return super.requestFocusInWindow(); + } + + @Override + protected boolean requestFocusInWindow(boolean temporary) { + if (target instanceof JFrame) { + if (!requestingFocus) { + requestingFocus = true; + boolean ret = target.requestFocusInWindow(); + requestingFocus = false; + return ret; + } + return true; + } else + return super.requestFocusInWindow(temporary); + } + + @Override + public void setIcon(boolean b) throws PropertyVetoException { + super.setIcon(b); + target.setBounds(this.getBounds()); + } + final class NullContentPane extends JComponent { @Override public void update(Graphics g) { @@ -219,9 +314,10 @@ @Override public void paint(Graphics g) { - if (target instanceof Frame && !(target instanceof JFrame)) { + if ((target instanceof Frame && !(target instanceof JFrame)) || + (target instanceof Dialog && !(target instanceof JDialog))) { SwingBaseWindow sf = SwingBaseWindow.this; - Frame f = (Frame) target; + Window f = target; Color bg = f.getBackground(); if (bg == null) bg = UIManager.getColor("window"); Modified: trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingComponentPeer.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingComponentPeer.java 2009-01-31 13:03:43 UTC (rev 4935) +++ trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingComponentPeer.java 2009-01-31 17:13:45 UTC (rev 4936) @@ -230,11 +230,21 @@ if (event.getID() == PaintEvent.PAINT) { if (!(targetComponent instanceof java.awt.Window)) peerComponent.paint(g); - targetComponent.paint(g); + //todo isolates related + //if(targetComponent instanceof RootPaneContainer) { + // JRootPane jRootPane = ((RootPaneContainer) targetComponent).getRootPane(); + //jRootPane.paintImmediately(0,0, jRootPane.getWidth(), jRootPane.getHeight()); + //} } else { if (!(targetComponent instanceof java.awt.Window)) peerComponent.update(g); - targetComponent.update(g); + //todo isolates related + //if(targetComponent instanceof RootPaneContainer) + // ((RootPaneContainer) targetComponent).getRootPane().update(g); + //if(targetComponent instanceof RootPaneContainer) { + // JRootPane jRootPane = ((RootPaneContainer) targetComponent).getRootPane(); + // jRootPane.paintImmediately(0,0, jRootPane.getWidth(), jRootPane.getHeight()); + //} } g.dispose(); } Modified: trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingFramePeer.java =================================================================== --- trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingFramePeer.java 2009-01-31 13:03:43 UTC (rev 4935) +++ trunk/gui/src/awt/org/jnode/awt/swingpeers/SwingFramePeer.java 2009-01-31 17:13:45 UTC (rev 4936) @@ -21,7 +21,6 @@ package org.jnode.awt.swingpeers; -import java.awt.Cursor; import java.awt.Frame; import java.awt.Graphics; import java.awt.Image; @@ -29,7 +28,6 @@ import java.awt.Rectangle; import java.awt.peer.FramePeer; import java.beans.PropertyVetoException; -import javax.swing.JFrame; final class SwingFrame extends SwingBaseWindow<Frame, SwingFrame> { @@ -38,22 +36,6 @@ } @Override - public void repaint(long tm, int x, int y, int width, int height) { - super.repaint(tm, x, y, width, height); - } - - @Override - public void update(Graphics g) { - super.update(g); - } - - @Override - public void setIcon(boolean b) throws PropertyVetoException { - super.setIcon(b); - target.setBounds(this.getBounds()); - } - - @Override public void paintAll(Graphics g) { super.paintAll(g); } @@ -63,82 +45,6 @@ protected void paintComponent(Graphics g) { super.paintComponent(g); } - - @Override - protected void validateTree() { - super.validateTree(); - if (target instanceof JFrame) - ((JFrame) target).getRootPane().validate(); - } - - boolean requestingFocus = false; - - @Override - public void requestFocus() { - if (target instanceof JFrame) { - if (!requestingFocus) { - requestingFocus = true; - target.requestFocus(); - requestingFocus = false; - } - } else - super.requestFocus(); - } - - @Override - public boolean requestFocus(boolean temporary) { - if (target instanceof JFrame) { - if (!requestingFocus) { - requestingFocus = true; - target.requestFocus(); - requestingFocus = false; - } - return true; - } else - return super.requestFocus(temporary); - } - - @Override - public boolean requestFocusInWindow() { - if (target instanceof JFrame) { - if (!requestingFocus) { - requestingFocus = true; - boolean ret = target.requestFocusInWindow(); - requestingFocus = false; - return ret; - } - return true; - } else - return super.requestFocusInWindow(); - } - - @Override - protected boolean requestFocusInWindow(boolean temporary) { - if (target instanceof JFrame) { - if (!requestingFocus) { - requestingFocus = true; - boolean ret = target.requestFocusInWindow(); - requestingFocus = false; - return ret; - } - return true; - } else - return super.requestFocusInWindow(temporary); - } - - boolean settingCursor; - - @Override - public void setCursor(Cursor cursor) { - super.setCursor(cursor); - if (!settingCursor) { - settingCursor = true; - target.setCursor(cursor); - settingCursor = false; - } - } - - } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |