diff options
author | Sravan Kumar Lakkimsetti | 2020-08-31 09:01:22 +0000 |
---|---|---|
committer | Sravan Kumar Lakkimsetti | 2020-08-31 09:13:29 +0000 |
commit | 9134ea044f3c935940417340484f77ef3a7ba974 (patch) | |
tree | 706957d0a4cb71f4e374eb37be94b7b79462bc99 | |
parent | a9c2bc63575f013ca3ce9ec27441e2b3e0835b9e (diff) | |
download | eclipse.platform.swt-9134ea044f3c935940417340484f77ef3a7ba974.tar.gz eclipse.platform.swt-9134ea044f3c935940417340484f77ef3a7ba974.tar.xz eclipse.platform.swt-9134ea044f3c935940417340484f77ef3a7ba974.zip |
Bug 566508 - [Mac] Quick Search dialog has cropped text in result
columns
Revert "Bug 566043 - Unreadable project names in import wizard"
This reverts commit a437eb620e4c0c7a898525a093200722e9088eca.
Revert "Bug 300147 - TreeItem.getTextBounds() returns width of longest
visible item"
This reverts commit 225a4f64d5557f0d0511ef5bbff18a358c42862f.
Change-Id: Ie248fd11906863a356e910cec39ecbc6789193f7
Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableItem.java | 46 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java | 93 |
2 files changed, 83 insertions, 56 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableItem.java index e09d0bdadb..a535a9852c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableItem.java @@ -131,13 +131,36 @@ int calculateWidth (int index, GC gc, boolean rowSelected) { if (index == 0 && width != -1) return width; Font font = null; if (cellFont != null) font = cellFont[index]; + if (font == null) font = this.font; + if (font == null) font = parent.font; + if (font == null) font = parent.defaultFont(); String text = index == 0 ? this.text : (strings == null ? "" : strings [index]); if ((text != null) && (text.length() > TEXT_LIMIT)) { text = text.substring(0, TEXT_LIMIT - ELLIPSIS.length()) + ELLIPSIS; } - NSSize size = getTextExtent(text, font); Image image = index == 0 ? this.image : (images == null ? null : images [index]); + NSCell cell = parent.dataCell; + if (font.extraTraits != 0) { + NSAttributedString attribStr = parent.createString(text, font, null, 0, false, true, false); + cell.setAttributedStringValue(attribStr); + attribStr.release(); + } else { + cell.setFont (font.handle); + NSString str = (NSString) new NSString().alloc(); + str = str.initWithString(text != null ? text : ""); + cell.setTitle (str); + str.release(); + } + + /* This code is inlined for performance */ + objc_super super_struct = new objc_super(); + super_struct.receiver = cell.id; + super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass); + NSSize size = new NSSize(); + OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize); if (image != null) size.width += parent.imageBounds.width + Table.IMAGE_GAP; +// cell.setImage (image != null ? image.handle : null); +// NSSize size = cell.cellSize (); int width = (int)Math.ceil (size.width); boolean sendMeasure = true; @@ -263,16 +286,8 @@ public Rectangle getBounds () { if (image != null) { titleRect.x += parent.imageBounds.width + Table.IMAGE_GAP; } - Font f = (cellFont != null ? cellFont[columnIndex] : null); - NSSize size = getTextExtent(text, f); - NSRect columnRect = widget.rectOfColumn (columnIndex); - size.width = Math.min (size.width, columnRect.width - (titleRect.x - columnRect.x)); - return new Rectangle ((int)titleRect.x, (int)titleRect.y, (int)Math.ceil (size.width), (int)Math.ceil (titleRect.height)); -} - -NSSize getTextExtent(String inStr, Font inCellFont) { Font font = null; - if (cellFont != null) font = inCellFont; + if (cellFont != null) font = cellFont[columnIndex]; if (font == null) font = this.font; if (font == null) font = parent.font; if (font == null) font = parent.defaultFont (); @@ -296,7 +311,10 @@ NSSize getTextExtent(String inStr, Font inCellFont) { super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass); NSSize size = new NSSize(); OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize); - return size; +// NSSize size = cell.cellSize (); + NSRect columnRect = widget.rectOfColumn (columnIndex); + size.width = Math.min (size.width, columnRect.width - (titleRect.x - columnRect.x)); + return new Rectangle ((int)titleRect.x, (int)titleRect.y, (int)Math.ceil (size.width), (int)Math.ceil (titleRect.height)); } /** @@ -607,8 +625,6 @@ public Rectangle getTextBounds (int index) { NSTableView tableView = (NSTableView) parent.view; Image image = index == 0 ? this.image : (images != null) ? images [index] : null; - Font f = (cellFont != null ? cellFont[index] : null); - NSSize size = getTextExtent(getText(index), f); if (parent.columnCount == 0) { index = (parent.style & SWT.CHECK) != 0 ? 1 : 0; } else { @@ -617,11 +633,11 @@ public Rectangle getTextBounds (int index) { } NSRect rect = tableView.frameOfCellAtColumn (index, parent.indexOf (this)); rect.x += Table.TEXT_GAP; - rect.width = size.width; - rect.height = size.height; + rect.width -= Table.TEXT_GAP; if (image != null) { int offset = parent.imageBounds.width + Table.IMAGE_GAP; rect.x += offset; + rect.width -= offset; } return new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java index 8cb2effd10..1a331c0ecc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java @@ -211,13 +211,36 @@ int calculateWidth (int index, GC gc) { if (index == 0 && width != -1) return width; Font font = null; if (cellFont != null) font = cellFont[index]; + if (font == null) font = this.font; + if (font == null) font = parent.font; + if (font == null) font = parent.defaultFont(); String text = index == 0 ? this.text : (strings == null ? "" : strings [index]); if ((text != null) && (text.length() > TEXT_LIMIT)) { text = text.substring(0, TEXT_LIMIT - ELLIPSIS.length()) + ELLIPSIS; } - NSSize size = getTextExtent(text, font); Image image = index == 0 ? this.image : (images == null ? null : images [index]); + NSCell cell = parent.dataCell; + if (font.extraTraits != 0) { + NSAttributedString attribStr = parent.createString(text, font, null, 0, false, true, false); + cell.setAttributedStringValue(attribStr); + attribStr.release(); + } else { + cell.setFont (font.handle); + NSString str = (NSString) new NSString().alloc(); + str = str.initWithString(text != null ? text : ""); + cell.setTitle (str); + str.release(); + } + + /* This code is inlined for performance */ + objc_super super_struct = new objc_super(); + super_struct.receiver = cell.id; + super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass); + NSSize size = new NSSize(); + OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize); if (image != null) size.width += parent.imageBounds.width + Tree.IMAGE_GAP; +// cell.setImage (image != null ? image.handle : null); +// NSSize size = cell.cellSize (); int width = (int)Math.ceil (size.width); boolean sendMeasure = true; @@ -234,7 +257,6 @@ int calculateWidth (int index, GC gc) { int height = (int)widget.rowHeight (); event.width = width; event.height = height; - NSCell cell = parent.dataCell; event.detail = (cell.isHighlighted() && ((style & SWT.HIDE_SELECTION) == 0 || parent.hasFocus())) ? SWT.SELECTED : 0; parent.sendEvent (SWT.MeasureItem, event); if (height < event.height) { @@ -426,10 +448,32 @@ public Rectangle getBounds () { if (image != null) { titleRect.x += parent.imageBounds.width + Tree.IMAGE_GAP; } - - Font f = (cellFont != null ? cellFont[columnIndex] : null); - NSSize size = getTextExtent(text, f); - + Font font = null; + if (cellFont != null) font = cellFont[columnIndex]; + if (font == null) font = this.font; + if (font == null) font = parent.font; + if (font == null) font = parent.defaultFont (); + NSCell cell = parent.dataCell; + cell.setImage (null); + if (font.extraTraits != 0) { + NSAttributedString attribStr = parent.createString (text, font, null, 0, false, true, false); + cell.setAttributedStringValue (attribStr); + attribStr.release (); + } else { + cell.setFont (font.handle); + NSString str = (NSString) new NSString().alloc(); + str = str.initWithString(text); + cell.setTitle (str); + str.release(); + } + // Inlined for performance. Also prevents a NPE or potential loop, because cellSize() will + // eventually send another MeasureItem event. + objc_super super_struct = new objc_super(); + super_struct.receiver = cell.id; + super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass); + NSSize size = new NSSize(); + OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize); +// NSSize size = cell.cellSize (); NSRect columnRect = widget.rectOfColumn (columnIndex); size.width = Math.min (size.width, columnRect.width - (titleRect.x - columnRect.x)); return new Rectangle ((int)titleRect.x, (int)titleRect.y, (int)Math.ceil (size.width), (int)Math.ceil (titleRect.height)); @@ -839,56 +883,23 @@ public Rectangle getTextBounds (int index) { parent.checkItems (); NSOutlineView outlineView = (NSOutlineView) parent.view; Image image = index == 0 ? this.image : (images != null) ? images [index] : null; - Font f = (cellFont != null ? cellFont[index] : null); - String text = index == 0 ? this.text : (strings == null ? "" : strings [index]); - NSSize size = getTextExtent(text, f); if (parent.columnCount == 0) { index = (parent.style & SWT.CHECK) != 0 ? 1 : 0; } else { TreeColumn column = parent.getColumn (index); index = parent.indexOf (column.nsColumn); } - NSRect rect = outlineView.frameOfCellAtColumn (index, outlineView.rowForItem (handle)); rect.x += Tree.TEXT_GAP; - rect.width = size.width; - rect.height = size.height; + rect.width -= Tree.TEXT_GAP; if (image != null) { int offset = parent.imageBounds.width + Tree.IMAGE_GAP; rect.x += offset; + rect.width -= offset; } return new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height); } -NSSize getTextExtent(String inStr, Font inCellFont) { - Font font = null; - if (inCellFont != null) font = inCellFont; - if (font == null) font = this.font; - if (font == null) font = parent.font; - if (font == null) font = parent.defaultFont (); - NSCell cell = parent.dataCell; - cell.setImage (null); - if (font.extraTraits != 0) { - NSAttributedString attribStr = parent.createString (inStr, font, null, 0, false, true, false); - cell.setAttributedStringValue (attribStr); - attribStr.release (); - } else { - cell.setFont (font.handle); - NSString str = (NSString) new NSString().alloc(); - str = str.initWithString(inStr); - cell.setTitle (str); - str.release(); - } - // Inlined for performance. Also prevents a NPE or potential loop, because cellSize() will - // eventually send another MeasureItem event. - objc_super super_struct = new objc_super(); - super_struct.receiver = cell.id; - super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass); - NSSize size = new NSSize(); - OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize); - return size; -} - /** * Searches the receiver's list starting at the first item * (index 0) until an item is found that is equal to the |