2002/04/30 21:18:27
[org.ibex.core.git] / src / org / xwt / Platform.java
index 173ae0c..a4b67db 100644 (file)
@@ -51,7 +51,8 @@ public class Platform {
             else if (vendor.startsWith("Free Software Foundation")) platform_class = "Win32";
             else if (version.startsWith("1.1") && vendor.startsWith("Netscape")) platform_class = "Netscape";
             else if (version.startsWith("1.1") && vendor.startsWith("Microsoft")) platform_class = "Microsoft";
-            else if (!version.startsWith("1.0") && !version.startsWith("1.1")) platform_class = "Java2";
+            else if (version.startsWith("1.4")) platform_class = "Java14";
+            else if (!version.startsWith("1.0") && !version.startsWith("1.1")) platform_class = "Java12";
 
             if (platform_class != null) {
                 platform = (Platform)Class.forName("org.xwt.plat." + platform_class).newInstance();
@@ -156,6 +157,11 @@ public class Platform {
 
     protected boolean _needsAutoClick() { return false; }
 
+    protected void _newBrowserWindow(String url) {
+        if (Log.on) Log.log(this, "Platform " + platform.getClass().getName() + " cannot open browser windows");
+        return;
+    }
+
     // Static methods -- thunk to the instance /////////////////////////////////////////////////////////////////////////
 
     /** if true, org.xwt.Surface should generate Click messages automatically when a Release happens after a Press and the mouse has not moved much */
@@ -173,8 +179,8 @@ public class Platform {
     /** returns the maximum ascent of all glyphs in a given platform-specific font */
     public static int getMaxAscent(String font) { return platform._getMaxAscent(font); }
 
-    /** returns the maximum descent of all glyphs in a given platform-specific font */
-    public static int getMaxDescent(String font) { return platform._getMaxDescent(font); }
+    /** returns the maximum descent of all glyphs in a given platform-specific font. Three pixel minimum ensures space for underline. */
+    public static int getMaxDescent(String font) { return Math.max(3, platform._getMaxDescent(font)); }
 
     /** returns the maximum number of threads that the XWT engine can create without adversely affecting the host OS */
     public static int maxThreads() { return platform._maxThreads(); }
@@ -212,6 +218,16 @@ public class Platform {
     /** creates and returns a picture */
     public static Picture createPicture(ImageDecoder i) { return platform._createPicture(i.getData(), i.getWidth(), i.getHeight()); }
 
+    /** creates and returns a picture */
+    public static void newBrowserWindow(String url) {
+        if (!(url.startsWith("https://") || url.startsWith("http://") || url.startsWith("ftp://") || url.startsWith("mailto:"))) {
+            if (Log.on) Log.log(Platform.class, "xwt.newBrowserWindow() only supports http and https urls");
+            return;
+        }
+        if (Log.on) Log.log(Platform.class, "newBrowserWindow, url = " + url);
+        platform._newBrowserWindow(url);
+    }
+
     /** quits XWT */
     public static void exit() {
         Log.log(Platform.class, "exiting via Platform.exit()");
@@ -292,10 +308,10 @@ public class Platform {
                 i = j;
                 while(i < font.length()) {
                     switch (font.charAt(i)) {
-                    case 'b': bold = true;
-                    case 'i': italic = true;
-                    case 'd': dotted_underline = true;
-                    case 'u': underline = true;
+                    case 'b': bold = true; break;
+                    case 'i': italic = true; break;
+                    case 'd': dotted_underline = true; break;
+                    case 'u': underline = true; break;
                     }
                     i++;
                 }