- // 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 */
- public static boolean needsAutoClick() { return platform._needsAutoClick(); }
-
- /** if true, org.xwt.Surface should generate DoubleClick messages automatically when needed */
- public static boolean needsAutoDoubleClick() { return platform._needsAutoDoubleClick(); }
-
- /** should return true if it is safe to supress full-surface dirties immediately after a window resize */
- public static String getDefaultFont() { return platform._getDefaultFont(); }
-
- /** should return true if it is safe to supress full-surface dirties immediately after a window resize */
- public static boolean supressDirtyOnResize() { return platform._supressDirtyOnResize(); }
-
- /** returns the width of a string in a platform-specific font */
- public static int stringWidth(String font, String text) { return platform._stringWidth(font, text); }
-
- /** 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. 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(); }
-
- /** returns a list of all platform-specific fonts available */
- public static String[] listFonts() { return platform._listFonts(); }
-
- /** creates a weak reference */
- public static org.xwt.Weak getWeak(Object o) { return platform._getWeak(o); }
-
- /** opens a connection to the resource identified by URL u, and returns an InputStream */
- public static InputStream urlToInputStream(URL u) throws IOException { return platform._urlToInputStream(u); }
-
- /** returns the contents of the clipboard */
- public static Object getClipBoard() { return clipboardReadEnabled ? platform._getClipBoard() : null; }
-
- /** sets the contents of the clipboard */
- public static void setClipBoard(String s) { platform._setClipBoard(s); }
-
- /** creates a socket object, with or without ssl encryption */
- public static Socket getSocket(String host, int port, boolean ssl, boolean negotiate) throws IOException {
- return platform._getSocket(host, port, ssl, negotiate);
+ /** returns the value of the environment variable key, or null if no such key exists */
+ public static String getEnv(String key) { return platform._getEnv(key); }
+ protected String _getEnv(String key) {
+ try {
+ String os = System.getProperty("os.name").toLowerCase();
+ Process p;
+ if (os.indexOf("windows 9") != -1 || os.indexOf("windows me") != -1) {
+ // hack -- jdk1.2/1.3 on Win32 pop open an ugly DOS box; 1.4 does not
+ if (platform.getClass().getName().endsWith("Java12")) return null;
+ p = Runtime.getRuntime().exec("command.com /c set");
+ } else if (os.indexOf("windows") > -1) {
+ // hack -- jdk1.2/1.3 on Win32 pop open an ugly DOS box; 1.4 does not
+ if (platform.getClass().getName().endsWith("Java12")) return null;
+ p = Runtime.getRuntime().exec("cmd.exe /c set");
+ } else {
+ p = Runtime.getRuntime().exec("env");
+ }
+ BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String s;
+ while ((s = br.readLine()) != null)
+ if (s.startsWith(key + "="))
+ return s.substring(key.length() + 1);
+ } catch (Exception e) {
+ Log.info(this, "Exception while reading from environment:");
+ Log.info(this, e);
+ }
+ return null;