Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover2002-03-15 18:05:17 +0000
committerSteve Northover2002-03-15 18:05:17 +0000
commitb919844cab9404aecf29c1e8709e2c6e3d154d5a (patch)
tree2a01f9973bf166d3bd0fd3e12b38fa5ffa56ae72
parentb314fb5955a55b76fc9b9106f1d0943b3e19c3f7 (diff)
downloadeclipse.platform.swt-b919844cab9404aecf29c1e8709e2c6e3d154d5a.tar.gz
eclipse.platform.swt-b919844cab9404aecf29c1e8709e2c6e3d154d5a.tar.xz
eclipse.platform.swt-b919844cab9404aecf29c1e8709e2c6e3d154d5a.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java99
5 files changed, 143 insertions, 25 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c
index 7e4441b7eb..7a0023c3ce 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/swt-gdk.c
@@ -1075,3 +1075,33 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_GDK_1CURRENT_1TIME
{
return (jint) GDK_CURRENT_TIME;
}
+
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1get_1frame_1extents
+ (JNIEnv *env, jclass that, jint window, jobject rectangle)
+{
+ DECL_GLOB(pGlob)
+ GdkRectangle rectangle_struct, *rectangle1 = NULL;
+ if (rectangle) {
+ rectangle1 = &rectangle_struct;
+ cacheGdkRectangleFids(env, rectangle, &PGLOB(GdkRectangleFc));
+ getGdkRectangleFields(env, rectangle, rectangle1, &PGLOB(GdkRectangleFc));
+ }
+ gdk_window_get_frame_extents((GdkWindow*)window, rectangle1);
+ if (rectangle) {
+ setGdkRectangleFields(env, rectangle, rectangle1, &PGLOB(GdkRectangleFc));
+ }
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1process_1all_1updates
+ (JNIEnv *env, jclass that)
+{
+ gdk_window_process_all_updates();
+}
+
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_gtk_OS_gdk_1window_1process_1updates
+ (JNIEnv *env, jclass that, jint window, jboolean update_children)
+{
+ gdk_window_process_updates((GdkWindow*)window, (gboolean)update_children);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 2823c06148..0466c69aaf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -767,4 +767,9 @@ public static final native void memmove(int dest, GtkStyle src, int size);
public static final native void memmove(int dest, GtkAdjustment src); // sure needed
public static final native void memmove(int dest, GtkCListColumn src, int size);
+public static final native void gdk_window_get_frame_extents(int window, GdkRectangle rect);
+public static final native void gdk_window_process_all_updates();
+public static final native void gdk_window_process_updates(int window, boolean update_children);
+//public static final native boolean gtk_widget_translate_coordinates(int src_widget, int dest_widget, int src_x, int src_y, int [] dest_x, int [] dest_y);
+
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 8dabf17b2d..c38e264f19 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -594,13 +594,13 @@ public void setLayoutData (Object layoutData) {
* </ul>
*/
public Point toControl (Point point) {
- checkWidget();
-/* int[] x = new int[1], y = new int[1];
- OS.gdk_window_get_origin(_gdkWindow(), x,y);
- int ctlX = point.x - x[0];
- int ctlY = point.y - y[0];*/
- /* FIXME */
- return new Point (0, 0);
+ checkWidget ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int eventHandle = eventHandle ();
+ int window = OS.GTK_WIDGET_WINDOW (eventHandle);
+ int [] x = new int [1], y = new int [1];
+ OS.gdk_window_get_origin (window, x, y);
+ return new Point (point.x - x[0], point.y - y[0]);
}
/**
* Returns a point which is the result of converting the
@@ -618,12 +618,13 @@ public Point toControl (Point point) {
* </ul>
*/
public Point toDisplay (Point point) {
- checkWidget();/*
- int[] x = new int[1], y = new int[1];
- OS.gdk_window_get_origin(_gdkWindow(), x,y);
- return new Point (x[0]+point.x, y[0]+point.y);*/
- /* FIXME */
- return new Point (0,0);
+ checkWidget();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int eventHandle = eventHandle ();
+ int window = OS.GTK_WIDGET_WINDOW (eventHandle);
+ int [] x = new int [1], y = new int [1];
+ OS.gdk_window_get_origin (window, x, y);
+ return new Point (x [0] + point.x, y[0] + point.y);
}
// === End of GEOMETRY Category ===
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index dacd5b361f..fd1d90708b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -202,6 +202,13 @@ public class Display extends Device {
String [] keys;
Object [] values;
+ /* Initial Guesses for Shell Trimmings. */
+ int borderTrimWidth = 4, borderTrimHeight = 4;
+ int resizeTrimWidth = 6, resizeTrimHeight = 6;
+ int titleBorderTrimWidth = 5, titleBorderTrimHeight = 28;
+ int titleResizeTrimWidth = 6, titleResizeTrimHeight = 29;
+ int titleTrimWidth = 0, titleTrimHeight = 23;
+
/*
* TEMPORARY CODE. Install the runnable that
* gets the current display. This code will
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 8f2cd3c97f..67a929240a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -262,7 +262,15 @@ public Shell (Shell parent, int style) {
this (null, parent, style);
}
-
+static int checkStyle (int style) {
+ style = Decorations.checkStyle (style);
+ int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
+ int bits = style & ~mask;
+ if ((style & SWT.SYSTEM_MODAL) != 0) return bits | SWT.SYSTEM_MODAL;
+ if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;
+ if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;
+ return bits;
+}
/**
* Adds the listener to the collection of listeners who will
@@ -294,6 +302,47 @@ public void addShellListener (ShellListener listener) {
addListener (SWT.Deactivate, typedListener);
}
+void adjustTrim () {
+ int [] width = new int [1], height = new int [1];
+ OS.gtk_window_get_size (shellHandle, width, height);
+ int window = OS.GTK_WIDGET_WINDOW (shellHandle);
+ GdkRectangle rect = new GdkRectangle ();
+ OS.gdk_window_get_frame_extents (window, rect);
+ int trimWidth = Math.max (0, rect.width - width [0]);
+ int trimHeight = Math.max (0, rect.height - height [0]);
+ boolean hasTitle = false, hasResize = false, hasBorder = false;
+ if ((style & SWT.NO_TRIM) == 0) {
+ hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
+ hasResize = (style & SWT.RESIZE) != 0;
+ hasBorder = (style & SWT.BORDER) != 0;
+ }
+ if (hasTitle) {
+ if (hasResize) {
+ display.titleResizeTrimWidth = trimWidth;
+ display.titleResizeTrimHeight = trimHeight;
+ return;
+ }
+ if (hasBorder) {
+ display.titleBorderTrimWidth = trimWidth;
+ display.titleBorderTrimHeight = trimHeight;
+ return;
+ }
+ display.titleTrimWidth = trimWidth;
+ display.titleTrimHeight = trimHeight;
+ return;
+ }
+ if (hasResize) {
+ display.resizeTrimWidth = trimWidth;
+ display.resizeTrimHeight = trimHeight;
+ return;
+ }
+ if (hasBorder) {
+ display.borderTrimWidth = trimWidth;
+ display.borderTrimHeight = trimHeight;
+ return;
+ }
+}
+
/**
* Requests that the window manager close the receiver in
* the same way it would be closed when the user clicks on
@@ -426,9 +475,9 @@ Point _getLocation() {
}
Point _getSize() {
- int[] x = new int[1]; int[] y = new int[1];
- OS.gtk_window_get_size(shellHandle, x, y);
- return new Point(x[0], y[0]);
+ int [] width = new int [1], height = new int [1];
+ OS.gtk_window_get_size (shellHandle, width, height);
+ return new Point (width [0] + trimWidth (), height [0] + trimHeight ());
}
public Rectangle getClientArea () {
@@ -440,13 +489,7 @@ public Rectangle getClientArea () {
void _setSize(int width, int height) {
OS.gtk_signal_handler_block_by_data (shellHandle, SWT.Resize);
- OS.gtk_window_resize(shellHandle, width, height);
- boolean done = false;
- Point s = _getSize();
- while ((s.x!=width) || (s.y!=height)) {
- OS.gtk_main_iteration();
- s = _getSize();
- }
+ OS.gtk_window_resize (shellHandle, width - trimWidth (), height - trimHeight ());
OS.gtk_signal_handler_unblock_by_data (shellHandle, SWT.Resize);
}
@@ -742,15 +785,47 @@ public void setText (String string) {
public void setVisible (boolean visible) {
checkWidget();
if (visible) {
+ sendEvent (SWT.Show);
OS.gtk_widget_show_now (shellHandle);
display.update();
- sendEvent (SWT.Show);
+ adjustTrim ();
} else {
OS.gtk_widget_hide (shellHandle);
sendEvent (SWT.Hide);
}
}
+int trimHeight () {
+ if ((style & SWT.NO_TRIM) != 0) return 0;
+ boolean hasTitle = false, hasResize = false, hasBorder = false;
+ hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
+ hasResize = (style & SWT.RESIZE) != 0;
+ hasBorder = (style & SWT.BORDER) != 0;
+ if (hasTitle) {
+ if (hasResize) return display.titleResizeTrimHeight;
+ if (hasBorder) return display.titleBorderTrimHeight;
+ return display.titleTrimHeight;
+ }
+ if (hasResize) return display.resizeTrimHeight;
+ if (hasBorder) return display.borderTrimHeight;
+ return 0;
+}
+
+int trimWidth () {
+ if ((style & SWT.NO_TRIM) != 0) return 0;
+ boolean hasTitle = false, hasResize = false, hasBorder = false;
+ hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
+ hasResize = (style & SWT.RESIZE) != 0;
+ hasBorder = (style & SWT.BORDER) != 0;
+ if (hasTitle) {
+ if (hasResize) return display.titleResizeTrimWidth;
+ if (hasBorder) return display.titleBorderTrimWidth;
+ return display.titleTrimWidth;
+ }
+ if (hasResize) return display.resizeTrimWidth;
+ if (hasBorder) return display.borderTrimWidth;
+ return 0;
+}
/*
* === DESTRUCTION ===

Back to the top