View | Details | Raw Unified | Return to bug 228397 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jface/viewers/StyledCellLabelProvider.java (-4 / +32 lines)
Lines 21-26 Link Here
21
import org.eclipse.swt.graphics.TextLayout;
21
import org.eclipse.swt.graphics.TextLayout;
22
import org.eclipse.swt.widgets.Display;
22
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.swt.widgets.Event;
24
import org.eclipse.swt.widgets.Widget;
24
25
25
/**
26
/**
26
 * A {@link StyledCellLabelProvider} supports styled labels by using owner
27
 * A {@link StyledCellLabelProvider} supports styled labels by using owner
Lines 67-72 Link Here
67
	
68
	
68
	private ColumnViewer viewer;
69
	private ColumnViewer viewer;
69
	private ViewerColumn column;
70
	private ViewerColumn column;
71
	
72
	private Widget itemOfLastMeasure;
70
73
71
	/**
74
	/**
72
	 * Creates a new StyledCellLabelProvider. By default, owner draw is enabled, focus is drawn and no
75
	 * Creates a new StyledCellLabelProvider. By default, owner draw is enabled, focus is drawn and no
Lines 269-274 Link Here
269
		boolean applyColors = useColors(event); // always returns false
272
		boolean applyColors = useColors(event); // always returns false
270
		
273
		
271
		TextLayout layout = getSharedTextLayout(event.display);
274
		TextLayout layout = getSharedTextLayout(event.display);
275
		
276
		int textWidthDelta = updateTextLayout(layout, cell, applyColors);
277
		/* remove-begin if bug 228695 fixed */
278
		itemOfLastMeasure = event.item;
279
		/* remove-end if bug 228695 fixed */
280
281
		event.width += textWidthDelta;
282
	}
283
284
	/**
285
	 * @param layout
286
	 * @param cell
287
	 * @param applyColors
288
	 * @return the text width delta (0 if the text layout contains no other font)
289
	 */
290
	private int updateTextLayout(TextLayout layout, ViewerCell cell,
291
			boolean applyColors) {
272
		layout.setText(""); //$NON-NLS-1$  //make sure all previous ranges are cleared (see bug 226090)
292
		layout.setText(""); //$NON-NLS-1$  //make sure all previous ranges are cleared (see bug 226090)
273
		
293
		
274
		layout.setText(cell.getText());
294
		layout.setText(cell.getText());
Lines 288-297 Link Here
288
				}
308
				}
289
			}
309
			}
290
		}
310
		}
311
		int textWidthDelta = 0;
291
		if (containsOtherFont) {
312
		if (containsOtherFont) {
292
			int textWidthDelta= layout.getBounds().width - originalTextWidth;
313
			textWidthDelta = layout.getBounds().width - originalTextWidth;
293
			event.width += textWidthDelta;
294
		}
314
		}
315
		return textWidthDelta;
295
	}
316
	}
296
	
317
	
297
	/*
318
	/*
Lines 307-312 Link Here
307
		ViewerCell cell= getViewerCell(event, element);
328
		ViewerCell cell= getViewerCell(event, element);
308
329
309
		boolean applyColors = useColors(event);
330
		boolean applyColors = useColors(event);
331
		
310
		GC gc = event.gc;
332
		GC gc = event.gc;
311
		// remember colors to restore the GC later
333
		// remember colors to restore the GC later
312
		Color oldForeground = gc.getForeground();
334
		Color oldForeground = gc.getForeground();
Lines 323-329 Link Here
323
				gc.setBackground(background);
345
				gc.setBackground(background);
324
			}
346
			}
325
		}
347
		}
326
327
		Image image = cell.getImage();
348
		Image image = cell.getImage();
328
		if (image != null) {
349
		if (image != null) {
329
			Rectangle imageBounds = cell.getImageBounds();
350
			Rectangle imageBounds = cell.getImageBounds();
Lines 341-348 Link Here
341
362
342
		Rectangle textBounds = cell.getTextBounds();
363
		Rectangle textBounds = cell.getTextBounds();
343
		if (textBounds != null) {
364
		if (textBounds != null) {
344
			// fLayout has already been configured in 'measure()'
345
			TextLayout textLayout= getSharedTextLayout(event.display);
365
			TextLayout textLayout= getSharedTextLayout(event.display);
366
367
			/* remove-begin if bug 228695 fixed */
368
			if (event.item != itemOfLastMeasure) {
369
				// fLayout has not been configured in 'measure()'
370
				updateTextLayout(textLayout, cell, applyColors);
371
				itemOfLastMeasure = event.item;
372
			}
373
			/* remove-end if bug 228695 fixed */
346
			
374
			
347
			/* remove-begin if bug 228376 fixed */
375
			/* remove-begin if bug 228376 fixed */
348
			if (!applyColors) {
376
			if (!applyColors) {

Return to bug 228397