+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
+package org.ibex.plat;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.*;
+import java.awt.geom.*;
+import java.net.*;
+import java.util.*;
+import org.ibex.util.*;
+import java.lang.reflect.*;
+import org.ibex.graphics.*;
+import org.ibex.core.*;
+import org.ibex.net.*;
+
+/** Platform class for Java 1.4 AWT implementations */
+public class Java4 extends Java2 {
+ protected String getDescriptiveName() { return "Java 1.4+ JVM"; }
+ public Java4() {
+ java.awt.Toolkit.getDefaultToolkit().setDynamicLayout(true);
+
+ // Properties for Apple JDK 1.4
+ System.setProperty("apple.awt.showGrowBox", "false");
+ System.setProperty("apple.awt.graphics.EnableLazyDrawing", "40");
+ System.setProperty("apple.awt.graphics.EnableLazyDrawing", "true");
+ System.setProperty("apple.awt.window.position.forceSafeUserPositioning", "true");
+ System.setProperty("apple.awt.window.position.forceSafeCreation", "true");
+ }
+ protected Surface __createSurface(final Box root, final boolean framed) { return new Java4Surface(root, framed); }
+ public static class Java4Surface extends Java2Surface implements WindowStateListener, MouseWheelListener {
+ public Java4Surface(Box root, boolean framed) {
+ super(root, true);
+ // JDK1.4 doesn't like java.lang.Window's...
+ if (!framed) ((Frame)window).setUndecorated(true);
+ window.addWindowStateListener(this);
+ window.addMouseWheelListener(this);
+ window.setVisible(true);
+ }
+ protected void makeVisible() { }
+ protected void _setMaximized(boolean m) {
+ if (frame == null) Log.info(this, "JDK 1.4 can only maximize frames, not windows");
+ else frame.setExtendedState(m ? Frame.MAXIMIZED_BOTH : (minimized ? Frame.ICONIFIED : Frame.NORMAL));
+ }
+ protected void _setMinimized(boolean m) {
+ if (frame == null) Log.info(this, "JDK 1.4 can only minimize frames, not windows");
+ else frame.setExtendedState(m ? Frame.ICONIFIED : (maximized ? Frame.MAXIMIZED_BOTH : Frame.NORMAL));
+ }
+ public void windowStateChanged(WindowEvent e) {
+ if (e.getOldState() == e.getNewState()) return;
+ if ((e.getNewState() & Frame.MAXIMIZED_BOTH) != 0) Maximized(true);
+ else if (((e.getOldState() & Frame.MAXIMIZED_BOTH) != 0) && (e.getNewState() & Frame.MAXIMIZED_BOTH) == 0)
+ Maximized(false);
+ }
+ public void mouseWheelMoved(MouseWheelEvent m) {
+ if (m.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) VScroll(m.getUnitsToScroll()); }
+ }
+}