summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt
diff options
context:
space:
mode:
authorLakshmi Shanmugam <lshanmug@in.ibm.com>2012-10-08 17:39:44 +0530
committerLakshmi Shanmugam <lshanmug@in.ibm.com>2012-10-08 17:39:44 +0530
commit2a6e0c9b702b0b502452265cc844e28c66b4245c (patch)
treed340548c209d82f62ad0d9a844687f308a1c0438 /bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt
parent259ec5fb53ced9294d0c95637b0120980998eb7d (diff)
downloadeclipse.platform.swt-2a6e0c9b702b0b502452265cc844e28c66b4245c.tar.gz
eclipse.platform.swt-2a6e0c9b702b0b502452265cc844e28c66b4245c.tar.xz
eclipse.platform.swt-2a6e0c9b702b0b502452265cc844e28c66b4245c.zip
Bug 383369-Mac cocoa combo draw wrong and spews long error message
when input multi-lines
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java45
1 files changed, 40 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
index b37b1245d1..6e157b2e24 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java
@@ -385,6 +385,22 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
cell.release ();
}
ignoreSetObject = false;
+
+ /*
+ * Attempting to create an NSComboBox with a height > 27 spews a
+ * very long warning message to stdout and draws the combo incorrectly.
+ * Limit height to frame height when combo has multiline text.
+ */
+ NSString nsStr = widget.stringValue();
+ if (nsStr != null ){
+ String str = nsStr.getString();
+ if (str != null && (str.indexOf('\n') >= 0 || str.indexOf('\r') >= 0)){
+ int frameHeight = (int) view.frame().height;
+ if (frameHeight > 0){
+ height = frameHeight;
+ }
+ }
+ }
}
/*
@@ -434,6 +450,10 @@ void createHandle () {
NSComboBox widget = (NSComboBox)new SWTComboBox().alloc();
widget.init();
widget.setDelegate(widget);
+ NSCell cell = widget.cell();
+ if (OS.VERSION >= 0x1060 && cell != null){
+ cell.setUsesSingleLineMode(true);
+ }
view = widget;
}
}
@@ -1383,14 +1403,29 @@ void setBounds (int x, int y, int width, int height, boolean move, boolean resiz
/*
* Feature in Cocoa. Attempting to create an NSComboBox with a
* height > 27 spews a very long warning message to stdout and
- * often draws the combo incorrectly. The workaround is to limit
- * the height of editable Combos to the height that is required
- * to display their text.
+ * often draws the combo incorrectly.
+ * The workaround is to limit the height of editable Combos to the
+ * height that is required to display their text. For multiline text,
+ * limit the height to frame height.
*/
if ((style & SWT.READ_ONLY) == 0) {
NSControl widget = (NSControl)view;
- NSSize size = widget.cell ().cellSize ();
- height = Math.min (height, (int)Math.ceil (size.height));
+ int hLimit = 0;
+ NSString nsStr = widget.stringValue();
+ if (nsStr != null ){
+ String str = nsStr.getString();
+ if (str != null && (str.indexOf('\n') >= 0 || str.indexOf('\r') >= 0)) {
+ int frameHeight = (int) view.frame().height;
+ if (frameHeight > 0) {
+ hLimit = frameHeight;
+ }
+ }
+ }
+ if (hLimit == 0) {
+ NSSize size = widget.cell ().cellSize ();
+ hLimit = (int)Math.ceil (size.height);
+ }
+ height = Math.min (height, hLimit);
}
super.setBounds (x, y, width, height, move, resize);
}