View | Details | Raw Unified | Return to bug 300147
Collapse All | Expand All

(-)Eclipse SWT/cocoa/org/eclipse/swt/widgets/TableItem.java (-52 / +37 lines)
Lines 128-157 Link Here
128
	if (index == 0 && width != -1) return width;
128
	if (index == 0 && width != -1) return width;
129
	Font font = null;
129
	Font font = null;
130
	if (cellFont != null) font = cellFont[index];
130
	if (cellFont != null) font = cellFont[index];
131
	if (font == null) font = this.font;
131
	NSSize size = getTextExtent(text, font);
132
	if (font == null) font = parent.font;
133
	if (font == null) font = parent.defaultFont();
134
	String text = index == 0 ? this.text : (strings == null ? "" : strings [index]);
135
	Image image = index == 0 ? this.image : (images == null ? null : images [index]);
136
	NSCell cell = parent.dataCell;
137
	if (font.extraTraits != 0) {
138
		NSAttributedString attribStr = parent.createString(text, font, null, 0, false, true, false);
139
		cell.setAttributedStringValue(attribStr);
140
		attribStr.release();
141
	} else {
142
		cell.setFont (font.handle);
143
		NSString str = (NSString) new NSString().alloc();
144
		str = str.initWithString(text != null ? text : "");
145
		cell.setTitle (str);
146
		str.release();
147
	}
148
149
	/* This code is inlined for performance */
150
	objc_super super_struct = new objc_super();
151
	super_struct.receiver = cell.id;
152
	super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass);
153
	NSSize size = new NSSize();
154
	OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize);
155
	if (image != null) size.width += parent.imageBounds.width + Table.IMAGE_GAP;
132
	if (image != null) size.width += parent.imageBounds.width + Table.IMAGE_GAP;
156
//	cell.setImage (image != null ? image.handle : null);
133
//	cell.setImage (image != null ? image.handle : null);
157
//	NSSize size = cell.cellSize ();
134
//	NSSize size = cell.cellSize ();
Lines 274-305 Link Here
274
	if (image != null) {
251
	if (image != null) {
275
		titleRect.x += parent.imageBounds.width + Table.IMAGE_GAP;
252
		titleRect.x += parent.imageBounds.width + Table.IMAGE_GAP;
276
	}
253
	}
277
	Font font = null;
254
	Font f = (cellFont != null ? cellFont[columnIndex] : null);
278
	if (cellFont != null) font = cellFont[columnIndex];
255
	NSSize size = getTextExtent(text, f);
279
	if (font == null) font = this.font;
280
	if (font == null) font = parent.font;
281
	if (font == null) font = parent.defaultFont ();
282
	NSCell cell = parent.dataCell;
283
	cell.setImage (null);
284
	if (font.extraTraits != 0) {
285
		NSAttributedString attribStr = parent.createString (text, font, null, 0, false, true, false);
286
		cell.setAttributedStringValue (attribStr);
287
		attribStr.release ();
288
	} else {
289
		cell.setFont (font.handle);
290
		NSString str = (NSString) new NSString().alloc();
291
		str = str.initWithString(text);
292
		cell.setTitle (str);
293
		str.release();
294
	}
295
	// Inlined for performance.  Also prevents a NPE or potential loop, because cellSize() will
296
	// eventually send another MeasureItem event.
297
	objc_super super_struct = new objc_super();
298
	super_struct.receiver = cell.id;
299
	super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass);
300
	NSSize size = new NSSize();
301
	OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize);
302
//	NSSize size = cell.cellSize ();
303
	NSRect columnRect = widget.rectOfColumn (columnIndex);
256
	NSRect columnRect = widget.rectOfColumn (columnIndex);
304
	size.width = Math.min (size.width, columnRect.width - (titleRect.x - columnRect.x));
257
	size.width = Math.min (size.width, columnRect.width - (titleRect.x - columnRect.x));
305
	return new Rectangle ((int)titleRect.x, (int)titleRect.y, (int)Math.ceil (size.width), (int)Math.ceil (titleRect.height));
258
	return new Rectangle ((int)titleRect.x, (int)titleRect.y, (int)Math.ceil (size.width), (int)Math.ceil (titleRect.height));
Lines 616-632 Link Here
616
		TableColumn column = parent.getColumn (index);
569
		TableColumn column = parent.getColumn (index);
617
		index = parent.indexOf (column.nsColumn);
570
		index = parent.indexOf (column.nsColumn);
618
	}
571
	}
572
	Font f = (cellFont != null ? cellFont[index] : null);
573
	NSSize size = getTextExtent(getText(index), f);
619
	NSRect rect = tableView.frameOfCellAtColumn (index, parent.indexOf (this));
574
	NSRect rect = tableView.frameOfCellAtColumn (index, parent.indexOf (this));
620
	rect.x += Table.TEXT_GAP;
575
	rect.x += Table.TEXT_GAP;
621
	rect.width -= Table.TEXT_GAP;
576
	rect.width = size.width;
577
	rect.height = size.height;
578
	
622
	if (image != null) {
579
	if (image != null) {
623
		int offset = parent.imageBounds.width + Table.IMAGE_GAP;
580
		int offset = parent.imageBounds.width + Table.IMAGE_GAP;
624
		rect.x += offset;
581
		rect.x += offset;
625
		rect.width -= offset;
626
	}
582
	}
627
	return new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height);
583
	return new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height);
628
}
584
}
629
585
586
NSSize getTextExtent(String inStr, Font inCellFont) {
587
	Font font = null;
588
	if (inCellFont != null) font = inCellFont;
589
	if (font == null) font = this.font;
590
	if (font == null) font = parent.font;
591
	if (font == null) font = parent.defaultFont ();
592
	NSCell cell = parent.dataCell;
593
	cell.setImage (null);
594
	if (font.extraTraits != 0) {
595
		NSAttributedString attribStr = parent.createString (inStr, font, null, 0, false, true, false);
596
		cell.setAttributedStringValue (attribStr);
597
		attribStr.release ();
598
	} else {
599
		cell.setFont (font.handle);
600
		NSString str = (NSString) new NSString().alloc();
601
		str = str.initWithString(inStr);
602
		cell.setTitle (str);
603
		str.release();
604
	}
605
	// Inlined for performance.  Also prevents a NPE or potential loop, because cellSize() will
606
	// eventually send another MeasureItem event.
607
	objc_super super_struct = new objc_super();
608
	super_struct.receiver = cell.id;
609
	super_struct.super_class = OS.objc_msgSend(cell.id, OS.sel_superclass);
610
	NSSize size = new NSSize();
611
	OS.objc_msgSendSuper_stret(size, super_struct, OS.sel_cellSize);
612
	return size;
613
}
614
630
boolean isDrawing () {
615
boolean isDrawing () {
631
	return getDrawing() && parent.isDrawing ();
616
	return getDrawing() && parent.isDrawing ();
632
}
617
}
(-)Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java (-52 / +37 lines)
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 

Return to bug 300147