summaryrefslogtreecommitdiffstats
path: root/bundles/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
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')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSCell.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java45
4 files changed, 49 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index 3372577a18..59a008c494 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -747,6 +747,10 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="setUsesSingleLineMode:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="setWraps:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSCell.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSCell.java
index 81be8e27ea..fce900e488 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSCell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSCell.java
@@ -162,6 +162,10 @@ public void setTitle(NSString aString) {
OS.objc_msgSend(this.id, OS.sel_setTitle_, aString != null ? aString.id : 0);
}
+public void setUsesSingleLineMode(boolean flag) {
+ OS.objc_msgSend(this.id, OS.sel_setUsesSingleLineMode_, flag);
+}
+
public void setWraps(boolean flag) {
OS.objc_msgSend(this.id, OS.sel_setWraps_, flag);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index cee3d8203a..4f7e502538 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -2045,6 +2045,7 @@ public static final long /*int*/ sel_setUpPrintOperationDefaultValues = sel_regi
public static final long /*int*/ sel_setUsesAlternatingRowBackgroundColors_ = sel_registerName("setUsesAlternatingRowBackgroundColors:");
public static final long /*int*/ sel_setUsesFontPanel_ = sel_registerName("setUsesFontPanel:");
public static final long /*int*/ sel_setUsesScreenFonts_ = sel_registerName("setUsesScreenFonts:");
+public static final long /*int*/sel_setUsesSingleLineMode_ = sel_registerName ("setUsesSingleLineMode:");
public static final long /*int*/ sel_setUsesThreadedAnimation_ = sel_registerName("setUsesThreadedAnimation:");
public static final long /*int*/ sel_setValue_forHTTPHeaderField_ = sel_registerName("setValue:forHTTPHeaderField:");
public static final long /*int*/ sel_setValue_forKey_ = sel_registerName("setValue:forKey:");
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);
}