Lines 233-262
Link Here
|
233 |
if (index == 0 && width != -1) return width; |
233 |
if (index == 0 && width != -1) return width; |
234 |
Font font = null; |
234 |
Font font = null; |
235 |
if (cellFont != null) font = cellFont[index]; |
235 |
if (cellFont != null) font = cellFont[index]; |
236 |
if (font == null) font = this.font; |
236 |
NSSize size = getTextExtent(text, font); |
237 |
if (font == null) font = parent.font; |
|
|
238 |
if (font == null) font = parent.defaultFont(); |
239 |
String text = index == 0 ? this.text : (strings == null ? "" : strings [index]); |
240 |
Image image = index == 0 ? this.image : (images == null ? null : images [index]); |
241 |
NSCell cell = parent.dataCell; |
242 |
if (font.extraTraits != 0) { |
243 |
NSAttributedString attribStr = parent.createString(text, font, null, 0, false, true, false); |
244 |
cell.setAttributedStringValue(attribStr); |
245 |
attribStr.release(); |
246 |
} else { |
247 |
cell.setFont (font.handle); |
248 |
NSString str = (NSString) new NSString().alloc(); |
249 |
str = str.initWithString(text != null ? text : ""); |
250 |
cell.setTitle (str); |
251 |
str.release(); |
252 |
} |
253 |
|
254 |
/* This code is inlined for performance */ |
255 |
objc_super super_struct = new objc_super(); |
256 |
super_struct.receiver = cell.id; |
257 |
super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass); |
258 |
NSSize size = new NSSize(); |
259 |
OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize); |
260 |
if (image != null) size.width += parent.imageBounds.width + Tree.IMAGE_GAP; |
237 |
if (image != null) size.width += parent.imageBounds.width + Tree.IMAGE_GAP; |
261 |
// cell.setImage (image != null ? image.handle : null); |
238 |
// cell.setImage (image != null ? image.handle : null); |
262 |
// NSSize size = cell.cellSize (); |
239 |
// NSSize size = cell.cellSize (); |
Lines 447-478
Link Here
|
447 |
if (image != null) { |
424 |
if (image != null) { |
448 |
titleRect.x += parent.imageBounds.width + Tree.IMAGE_GAP; |
425 |
titleRect.x += parent.imageBounds.width + Tree.IMAGE_GAP; |
449 |
} |
426 |
} |
450 |
Font font = null; |
427 |
Font f = (cellFont != null ? cellFont[columnIndex] : null); |
451 |
if (cellFont != null) font = cellFont[columnIndex]; |
428 |
NSSize size = getTextExtent(text, f); |
452 |
if (font == null) font = this.font; |
|
|
453 |
if (font == null) font = parent.font; |
454 |
if (font == null) font = parent.defaultFont (); |
455 |
NSCell cell = parent.dataCell; |
456 |
cell.setImage (null); |
457 |
if (font.extraTraits != 0) { |
458 |
NSAttributedString attribStr = parent.createString (text, font, null, 0, false, true, false); |
459 |
cell.setAttributedStringValue (attribStr); |
460 |
attribStr.release (); |
461 |
} else { |
462 |
cell.setFont (font.handle); |
463 |
NSString str = (NSString) new NSString().alloc(); |
464 |
str = str.initWithString(text); |
465 |
cell.setTitle (str); |
466 |
str.release(); |
467 |
} |
468 |
// Inlined for performance. Also prevents a NPE or potential loop, because cellSize() will |
469 |
// eventually send another MeasureItem event. |
470 |
objc_super super_struct = new objc_super(); |
471 |
super_struct.receiver = cell.id; |
472 |
super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass); |
473 |
NSSize size = new NSSize(); |
474 |
OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize); |
475 |
// NSSize size = cell.cellSize (); |
476 |
NSRect columnRect = widget.rectOfColumn (columnIndex); |
429 |
NSRect columnRect = widget.rectOfColumn (columnIndex); |
477 |
size.width = Math.min (size.width, columnRect.width - (titleRect.x - columnRect.x)); |
430 |
size.width = Math.min (size.width, columnRect.width - (titleRect.x - columnRect.x)); |
478 |
return new Rectangle ((int)titleRect.x, (int)titleRect.y, (int)Math.ceil (size.width), (int)Math.ceil (titleRect.height)); |
431 |
return new Rectangle ((int)titleRect.x, (int)titleRect.y, (int)Math.ceil (size.width), (int)Math.ceil (titleRect.height)); |
Lines 887-903
Link Here
|
887 |
TreeColumn column = parent.getColumn (index); |
840 |
TreeColumn column = parent.getColumn (index); |
888 |
index = parent.indexOf (column.nsColumn); |
841 |
index = parent.indexOf (column.nsColumn); |
889 |
} |
842 |
} |
|
|
843 |
Font f = (cellFont != null ? cellFont[index] : null); |
844 |
NSSize size = getTextExtent(getText(index), f); |
890 |
NSRect rect = outlineView.frameOfCellAtColumn (index, outlineView.rowForItem (handle)); |
845 |
NSRect rect = outlineView.frameOfCellAtColumn (index, outlineView.rowForItem (handle)); |
891 |
rect.x += Tree.TEXT_GAP; |
846 |
rect.x += Tree.TEXT_GAP; |
892 |
rect.width -= Tree.TEXT_GAP; |
847 |
rect.width = size.width; |
|
|
848 |
rect.height = size.height; |
849 |
|
893 |
if (image != null) { |
850 |
if (image != null) { |
894 |
int offset = parent.imageBounds.width + Tree.IMAGE_GAP; |
851 |
int offset = parent.imageBounds.width + Tree.IMAGE_GAP; |
895 |
rect.x += offset; |
852 |
rect.x += offset; |
896 |
rect.width -= offset; |
|
|
897 |
} |
853 |
} |
898 |
return new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height); |
854 |
return new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height); |
899 |
} |
855 |
} |
900 |
|
856 |
|
|
|
857 |
NSSize getTextExtent(String inStr, Font inCellFont) { |
858 |
Font font = null; |
859 |
if (inCellFont != null) font = inCellFont; |
860 |
if (font == null) font = this.font; |
861 |
if (font == null) font = parent.font; |
862 |
if (font == null) font = parent.defaultFont (); |
863 |
NSCell cell = parent.dataCell; |
864 |
cell.setImage (null); |
865 |
if (font.extraTraits != 0) { |
866 |
NSAttributedString attribStr = parent.createString (inStr, font, null, 0, false, true, false); |
867 |
cell.setAttributedStringValue (attribStr); |
868 |
attribStr.release (); |
869 |
} else { |
870 |
cell.setFont (font.handle); |
871 |
NSString str = (NSString) new NSString().alloc(); |
872 |
str = str.initWithString(inStr); |
873 |
cell.setTitle (str); |
874 |
str.release(); |
875 |
} |
876 |
// Inlined for performance. Also prevents a NPE or potential loop, because cellSize() will |
877 |
// eventually send another MeasureItem event. |
878 |
objc_super super_struct = new objc_super(); |
879 |
super_struct.receiver = cell.id; |
880 |
super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass); |
881 |
NSSize size = new NSSize(); |
882 |
OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize); |
883 |
return size; |
884 |
} |
885 |
|
901 |
/** |
886 |
/** |
902 |
* Searches the receiver's list starting at the first item |
887 |
* Searches the receiver's list starting at the first item |
903 |
* (index 0) until an item is found that is equal to the |
888 |
* (index 0) until an item is found that is equal to the |