summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/photon/org
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2002-02-09 00:37:45 +0000
committerSilenio Quarti <silenio>2002-02-09 00:37:45 +0000
commita7fde4ef9d2adcc5e3ca7f3f1eeba3ca343ab9a7 (patch)
tree27efec8676ebc6c8c20daf7a87814e2a08b9fa51 /bundles/org.eclipse.swt/Eclipse SWT/photon/org
parent1a193fed7fb8f834ff006a600108343edb183958 (diff)
downloadeclipse.platform.swt-a7fde4ef9d2adcc5e3ca7f3f1eeba3ca343ab9a7.tar.gz
eclipse.platform.swt-a7fde4ef9d2adcc5e3ca7f3f1eeba3ca343ab9a7.tar.xz
eclipse.platform.swt-a7fde4ef9d2adcc5e3ca7f3f1eeba3ca343ab9a7.zip
computeSize fix
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/photon/org')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java14
3 files changed, 44 insertions, 18 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
index de91a0586d..a3673d784e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
@@ -115,29 +115,48 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
OS.PtWidgetPreferredSize(handle, dim);
int width = dim.w;
int height = dim.h;
- int text = OS.PtWidgetChildBack(handle);
- OS.PtWidgetPreferredSize(text, dim);
+ int textWidget = OS.PtWidgetChildBack(handle);
+ OS.PtWidgetPreferredSize(textWidget, dim);
height += dim.h;
PhRect_t rect = new PhRect_t ();
PhArea_t area = new PhArea_t ();
- OS.PtSetAreaFromWidgetCanvas (text, rect, area);
+ OS.PtSetAreaFromWidgetCanvas (textWidget, rect, area);
width += area.size_w;
+
+ /* Calculate maximum text width */
int [] args = new int [] {
OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
OS.Pt_ARG_ITEMS, 0, 0,
OS.Pt_ARG_TEXT_FONT, 0, 0,
+ OS.Pt_ARG_TEXT_STRING, 0, 0,
};
OS.PtGetResources (handle, args.length / 3, args);
int maxWidth = 0;
rect = new PhRect_t();
- int [] items = new int [1];
- for (int i = 0; i < args [1]; i++) {
- OS.memmove (items, args [4] + (i * 4), 4);
- int length = OS.strlen (items [0]);
- OS.PfExtentText(rect, null, args [7], items [0], length);
- maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
- }
+ int str = args [10];
+ int font = args [7];
+ if (str != 0) {
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, font, str, length);
+ maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
+ }
+ }
+ int count = args [1];
+ int [] buffer = new int [1];
+ for (int i = 0; i < count; i++) {
+ OS.memmove (buffer, args [4] + (i * 4), 4);
+ str = buffer [0];
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, font, str, length);
+ maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
+ }
+ }
+ if (maxWidth == 0) maxWidth = DEFAULT_WIDTH;
+
width += maxWidth;
+
if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
rect = new PhRect_t ();
area = new PhArea_t ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
index fdd6a06b2d..a968bf31f2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
@@ -143,9 +143,12 @@ Point getTitleSize() {
OS.PtGetResources (handle, args.length / 3, args);
if ((OS.Pt_ARG_CONTAINER_FLAGS & OS.Pt_SHOW_TITLE) != 0) {
PhRect_t rect = new PhRect_t();
- if (args [1] != 0) {
- int length = OS.strlen (args [1]);
- OS.PfExtentText(rect, null, args [4], args [1], length);
+ int str = args [1];
+ if (str != 0) {
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, args [4], str, length);
+ }
}
int inset = 4;
width = inset + rect.lr_x - rect.ul_x + 1;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
index 7107538e9c..c120fb3228 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
@@ -185,12 +185,16 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
};
OS.PtGetResources (handle, args.length / 3, args);
PhRect_t rect = new PhRect_t();
- int [] items = new int [1];
+ int font = args [7];
+ int [] buffer = new int [1];
for (int i = 0; i < args [1]; i++) {
- OS.memmove (items, args [4] + (i * 4), 4);
- int length = OS.strlen (items [0]);
- OS.PfExtentText(rect, null, args [7], items [0], length);
- width = Math.max(width, rect.lr_x - rect.ul_x + 1);
+ OS.memmove (buffer, args [4] + (i * 4), 4);
+ int str = buffer [0];
+ int length = OS.strlen (str);
+ if (length > 0) {
+ OS.PfExtentText(rect, null, font, str, length);
+ width = Math.max(width, rect.lr_x - rect.ul_x + 1);
+ }
}
rect = new PhRect_t ();
PhArea_t area = new PhArea_t ();