aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com/sun/javafx
diff options
context:
space:
mode:
authortrembovetski <[email protected]>2009-08-20 10:32:13 -0700
committertrembovetski <[email protected]>2009-08-20 10:32:13 -0700
commit29b675c229e3d797f2c454803e289765b0bc801c (patch)
tree7a18a750f9ee3b4cb009f5d19e5751cc73420857 /src/newt/classes/com/sun/javafx
parent7bed517f4ebf9323b1ee96d6194579792ed5dfd9 (diff)
newt: one more attempt to commit insets-related changes
Diffstat (limited to 'src/newt/classes/com/sun/javafx')
-rw-r--r--src/newt/classes/com/sun/javafx/newt/Insets.java13
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java33
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java48
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java15
4 files changed, 104 insertions, 5 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/Insets.java b/src/newt/classes/com/sun/javafx/newt/Insets.java
index 653ae8a10..7d379cd92 100644
--- a/src/newt/classes/com/sun/javafx/newt/Insets.java
+++ b/src/newt/classes/com/sun/javafx/newt/Insets.java
@@ -33,10 +33,11 @@
package com.sun.javafx.newt;
/**
- *
+ * Simple class representing insets.
+ *
* @author tdv
*/
-public class Insets {
+public class Insets implements Cloneable {
public int top;
public int left;
public int bottom;
@@ -93,4 +94,12 @@ public class Insets {
",bottom=" + bottom + ",right=" + right + "]";
}
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException ex) {
+ throw new InternalError();
+ }
+ }
+
}
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index 8970298d6..46eaf402f 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -306,14 +306,33 @@ public abstract class Window implements NativeWindow
return config;
}
+ /**
+ * Returns the width of the client area of this window
+ * @return width of the client area
+ */
public int getWidth() {
return width;
}
+ /**
+ * Returns the height of the client area of this window
+ * @return height of the client area
+ */
public int getHeight() {
return height;
}
+ /**
+ * Returns the insets for this native window (the difference between the
+ * size of the toplevel window with the decorations and the client area).
+ *
+ * @return insets for this platform window
+ */
+ // this probably belongs to NativeWindow interface
+ public Insets getInsets() {
+ return new Insets(0,0,0,0);
+ }
+
/** If this Window actually wraps one from another toolkit such as
the AWT, this will return a non-null value. */
public Object getWrappedWindow() {
@@ -381,7 +400,21 @@ public abstract class Window implements NativeWindow
}
public abstract void setVisible(boolean visible);
+ /**
+ * Sets the size of the client area of the window, excluding decorations
+ * Total size of the window will be
+ * {@code width+insets.left+insets.right, height+insets.top+insets.bottom}
+ * @param width of the client area of the window
+ * @param height of the client area of the window
+ */
public abstract void setSize(int width, int height);
+ /**
+ * Sets the location of the top left corner of the window, including
+ * decorations (so the client area will be placed at
+ * {@code x+insets.left,y+insets.top}.
+ * @param x coord of the top left corner
+ * @param y coord of the top left corner
+ */
public abstract void setPosition(int x, int y);
public abstract boolean setFullscreen(boolean fullscreen);
diff --git a/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java b/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java
index 704b578c4..ca7954a1c 100755
--- a/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/macosx/MacWindow.java
@@ -130,6 +130,7 @@ public class MacWindow extends Window {
private volatile long surfaceHandle;
// non fullscreen dimensions ..
private int nfs_width, nfs_height, nfs_x, nfs_y;
+ private final Insets insets = new Insets(0,0,0,0);
static {
MacDisplay.initSingleton();
@@ -183,6 +184,31 @@ public class MacWindow extends Window {
}
}
+ class EnsureWindowCreatedAction implements Runnable {
+ public void run() {
+ nsViewLock.lock();
+ try {
+ createWindow(false);
+ } finally {
+ nsViewLock.unlock();
+ }
+ }
+ }
+ private EnsureWindowCreatedAction ensureWindowCreatedAction =
+ new EnsureWindowCreatedAction();
+
+ public Insets getInsets() {
+ // in order to properly calculate insets we need the window to be
+ // created
+ MainThread.invoke(true, ensureWindowCreatedAction);
+ nsViewLock.lock();
+ try {
+ return (Insets) insets.clone();
+ } finally {
+ nsViewLock.unlock();
+ }
+ }
+
private ToolkitLock nsViewLock = new ToolkitLock() {
private Thread owner;
private int recursionCount;
@@ -233,6 +259,9 @@ public class MacWindow extends Window {
if(DEBUG_IMPLEMENTATION) System.out.println("MacWindow.VisibleAction "+visible+" "+Thread.currentThread().getName());
if (visible) {
createWindow(false);
+ if (windowHandle != 0) {
+ makeKeyAndOrderFront(windowHandle);
+ }
} else {
if (windowHandle != 0) {
orderOut(windowHandle);
@@ -344,6 +373,9 @@ public class MacWindow extends Window {
System.err.println("MacWindow fs: "+fullscreen+" "+x+"/"+y+" "+width+"x"+height);
}
createWindow(true);
+ if (windowHandle != 0) {
+ makeKeyAndOrderFront(windowHandle);
+ }
} finally {
nsViewLock.unlock();
}
@@ -386,6 +418,19 @@ public class MacWindow extends Window {
sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
}
+ private void insetsChanged(int left, int top, int right, int bottom) {
+ if (DEBUG_IMPLEMENTATION) {
+ System.out.println(Thread.currentThread().getName()+
+ " Insets changed to " + left + ", " + top + ", " + right + ", " + bottom);
+ }
+ if (left != -1 && top != -1 && right != -1 && bottom != -1) {
+ insets.left = left;
+ insets.top = top;
+ insets.right = right;
+ insets.bottom = bottom;
+ }
+ }
+
private void positionChanged(int newX, int newY) {
if (DEBUG_IMPLEMENTATION) {
System.out.println(Thread.currentThread().getName()+" Position changed to " + newX + ", " + newY);
@@ -527,7 +572,8 @@ public class MacWindow extends Window {
}
surfaceHandle = contentView(windowHandle);
setTitle0(windowHandle, getTitle());
- makeKeyAndOrderFront(windowHandle);
+ // don't make the window visible on window creation
+// makeKeyAndOrderFront(windowHandle);
sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED);
sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index 18dc7dae3..f725874ef 100755
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -34,9 +34,7 @@
package com.sun.javafx.newt.windows;
import javax.media.nativewindow.*;
-
import com.sun.javafx.newt.*;
-import com.sun.javafx.newt.impl.*;
public class WindowsWindow extends Window {
@@ -45,6 +43,7 @@ public class WindowsWindow extends Window {
private long windowHandleClose;
// non fullscreen dimensions ..
private int nfs_width, nfs_height, nfs_x, nfs_y;
+ private final Insets insets = new Insets(0, 0, 0, 0);
static {
WindowsDisplay.initSingleton();
@@ -204,6 +203,10 @@ public class WindowsWindow extends Window {
}
}
+ public Insets getInsets() {
+ return (Insets)insets.clone();
+ }
+
//----------------------------------------------------------------------
// Internals only
//
@@ -223,6 +226,14 @@ public class WindowsWindow extends Window {
private static native void setTitle(long windowHandle, String title);
private static native void requestFocus(long windowHandle);
+ private void insetsChanged(int left, int top, int right, int bottom) {
+ if (left != -1 && top != -1 && right != -1 && bottom != -1) {
+ insets.left = left;
+ insets.top = top;
+ insets.right = right;
+ insets.bottom = bottom;
+ }
+ }
private void sizeChanged(int newWidth, int newHeight) {
width = newWidth;
height = newHeight;