summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT
diff options
context:
space:
mode:
authorBilly Biggs <bbiggs>2005-02-07 22:02:36 +0000
committerBilly Biggs <bbiggs>2005-02-07 22:02:36 +0000
commitc50367f5a47e2a6effad63f64029f1b5d0e6e7f1 (patch)
tree4d8bccd5a798a131641088d79f811845e6b823ad /bundles/org.eclipse.swt/Eclipse SWT
parent07189d4e0dc321d7a67191afc9ffcca78baa583a (diff)
downloadeclipse.platform.swt-c50367f5a47e2a6effad63f64029f1b5d0e6e7f1.tar.gz
eclipse.platform.swt-c50367f5a47e2a6effad63f64029f1b5d0e6e7f1.tar.xz
eclipse.platform.swt-c50367f5a47e2a6effad63f64029f1b5d0e6e7f1.zip
Fix computeTrim on TabFolder and Group; clean up computeSize.
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java40
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java14
5 files changed, 43 insertions, 43 deletions
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 9d8729e2c8..a4ccd21ba8 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
@@ -358,17 +358,32 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
Point computeNativeSize (int /*long*/ h, int wHint, int hHint, boolean changed) {
- int width = OS.GTK_WIDGET_WIDTH (h);
- int height = OS.GTK_WIDGET_HEIGHT (h);
- OS.gtk_widget_set_size_request (h, -1, -1);
- GtkRequisition requisition = new GtkRequisition ();
- OS.gtk_widget_size_request (h, requisition);
- OS.gtk_widget_set_size_request (h, width, height);
- width = wHint == SWT.DEFAULT ? requisition.width : wHint;
- height = hHint == SWT.DEFAULT ? requisition.height : hHint;
- return new Point (width, height);
+ int width = wHint, height = hHint;
+ if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+ GtkRequisition requisition = new GtkRequisition ();
+ OS.gtk_widget_size_request (h, requisition);
+ width = wHint == SWT.DEFAULT ? OS.GTK_WIDGET_REQUISITION_WIDTH (h) : wHint;
+ height = hHint == SWT.DEFAULT ? OS.GTK_WIDGET_REQUISITION_HEIGHT (h) : hHint;
+ }
+ return new Point (width, height);
+}
+
+void forceResize () {
+ resizeHandle (1, 1);
+ /*
+ * Force the container to allocate the size of its children.
+ */
+ int /*long*/ topHandle = topHandle ();
+ int flags = OS.GTK_WIDGET_FLAGS (topHandle);
+ OS.GTK_WIDGET_SET_FLAGS (topHandle, OS.GTK_VISIBLE);
+ int /*long*/ parentHandle = parent.parentingHandle ();
+ OS.gtk_container_resize_children (parentHandle);
+ if ((flags & OS.GTK_VISIBLE) == 0) {
+ OS.GTK_WIDGET_UNSET_FLAGS (topHandle, OS.GTK_VISIBLE);
+ }
}
+
/**
* Returns the accessible object for the receiver.
* If this is the first time this object is requested,
@@ -2712,12 +2727,7 @@ void setInitialBounds () {
OS.GTK_WIDGET_SET_X (topHandle, 0);
OS.GTK_WIDGET_SET_Y (topHandle, 0);
} else {
- resizeHandle (1, 1);
- /*
- * Force the container to allocate the size of its children.
- */
- int /*long*/ parentHandle = parent.parentingHandle ();
- OS.gtk_container_resize_children (parentHandle);
+ forceResize ();
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index 0fd3ba5f46..cf23ea8ffc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -104,6 +104,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
+ if ((state & ZERO_SIZED) != 0) forceResize ();
int clientX = OS.GTK_WIDGET_X (clientHandle);
int clientY = OS.GTK_WIDGET_Y (clientHandle);
x -= clientX;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index 9692f19f33..b4f7299394 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -104,31 +104,27 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
if (hHint == SWT.DEFAULT) hHint = DEFAULT_HEIGHT;
}
}
- int width = OS.GTK_WIDGET_WIDTH (handle);
- int height = OS.GTK_WIDGET_HEIGHT (handle);
+ boolean fixWrap = labelHandle != 0 && (style & SWT.WRAP) != 0;
int labelWidth = 0, labelHeight = 0;
- if (labelHandle != 0) {
+ if (fixWrap) {
labelWidth = OS.GTK_WIDGET_WIDTH (labelHandle);
labelHeight = OS.GTK_WIDGET_HEIGHT (labelHandle);
- OS.gtk_widget_set_size_request (labelHandle, wHint, hHint);
- }
- GtkRequisition requisition = new GtkRequisition ();
+ OS.gtk_widget_set_size_request (labelHandle, -1, -1);
+ }
+ Point size;
if (frameHandle != 0) {
- int frameWidth = OS.GTK_WIDGET_WIDTH (frameHandle);
- int frameHeight = OS.GTK_WIDGET_HEIGHT (frameHandle);
- OS.gtk_widget_set_size_request (frameHandle, -1, -1);
+ int width = OS.GTK_WIDGET_WIDTH (handle);
+ int height = OS.GTK_WIDGET_HEIGHT (handle);
OS.gtk_widget_set_size_request (handle, wHint, hHint);
- OS.gtk_widget_size_request (frameHandle, requisition);
- OS.gtk_widget_set_size_request (frameHandle, frameWidth, frameHeight);
+ size = computeNativeSize (frameHandle, -1, -1, changed);
+ OS.gtk_widget_set_size_request (handle, width, height);
} else {
- OS.gtk_widget_set_size_request (handle, wHint, hHint);
- OS.gtk_widget_size_request (handle, requisition);
+ size = computeNativeSize (handle, wHint, hHint, changed);
}
- if (labelHandle != 0) {
+ if (fixWrap) {
OS.gtk_widget_set_size_request (labelHandle, labelWidth, labelHeight);
}
- OS.gtk_widget_set_size_request (handle, width, height);
- return new Point (requisition.width, requisition.height);
+ return size;
}
void createHandle (int index) {
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 23b038f9dd..0e5131ac1c 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
@@ -982,10 +982,9 @@ void resizeBounds (int width, int height, boolean notify) {
int menuHeight = 0;
if (menuBar != null) {
int /*long*/ menuHandle = menuBar.handle;
- OS.gtk_widget_set_size_request (menuHandle, -1, -1);
GtkRequisition requisition = new GtkRequisition ();
OS.gtk_widget_size_request (menuHandle, requisition);
- menuHeight = requisition.height;
+ menuHeight = OS.GTK_WIDGET_REQUISITION_HEIGHT (menuHandle);
OS.gtk_widget_set_size_request (menuHandle, width - (border * 2), menuHeight);
height = Math.max (1, height - menuHeight);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
index d80eae03fc..9710242c0c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java
@@ -138,24 +138,18 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
Point size = super.computeSize (wHint, hHint, changed);
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
- int width = OS.GTK_WIDGET_WIDTH (handle);
- int height = OS.GTK_WIDGET_HEIGHT (handle);
- OS.gtk_widget_set_size_request (handle, wHint, hHint);
- GtkRequisition requisition = new GtkRequisition ();
boolean scrollable = OS.gtk_notebook_get_scrollable (handle);
OS.gtk_notebook_set_scrollable (handle, false);
- OS.gtk_widget_size_request (handle, requisition);
+ Point notebookSize = computeNativeSize (handle, wHint, hHint, changed);
OS.gtk_notebook_set_scrollable (handle, scrollable);
- OS.gtk_widget_set_size_request (handle, width, height);
- width = wHint == SWT.DEFAULT ? requisition.width : wHint;
- height = hHint == SWT.DEFAULT ? requisition.height : hHint;
- size.x = Math.max (width, size.x);
- size.y = Math.max (height, size.y);
+ size.x = Math.max (notebookSize.x, size.x);
+ size.y = Math.max (notebookSize.y, size.y);
return size;
}
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
+ if ((state & ZERO_SIZED) != 0) forceResize ();
int /*long*/ clientHandle = clientHandle ();
int clientX = OS.GTK_WIDGET_X (clientHandle);
int clientY = OS.GTK_WIDGET_Y (clientHandle);