Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 189083
Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/viewsupport/OwnerDrawSupport.java (-5 / +16 lines)
Lines 80-94 Link Here
80
	private void performPaint(Event event) {
80
	private void performPaint(Event event) {
81
		Item item= (Item) event.item;
81
		Item item= (Item) event.item;
82
		GC gc= event.gc;
82
		GC gc= event.gc;
83
		Image image= item.getImage();
83
84
		if (image != null) {
85
			int yOffset= Math.max(0, (event.height - image.getBounds().height) / 2);
86
			gc.drawImage(image, event.x, event.y + yOffset);
87
		}
88
		ColoredString coloredLabel= getColoredLabel(item);
84
		ColoredString coloredLabel= getColoredLabel(item);
89
		boolean isSelected= (event.detail & SWT.SELECTED) != 0 && fControl.isFocusControl();
85
		boolean isSelected= (event.detail & SWT.SELECTED) != 0 && fControl.isFocusControl();
90
		if (item instanceof TreeItem) {
86
		if (item instanceof TreeItem) {
91
			TreeItem treeItem= (TreeItem) item;
87
			TreeItem treeItem= (TreeItem) item;
88
			Image image = treeItem.getImage(event.index);
89
			if (image != null) {
90
				processImage(image, gc, treeItem.getImageBounds(event.index));
91
			}
92
			Rectangle textBounds= treeItem.getTextBounds(event.index);
92
			Rectangle textBounds= treeItem.getTextBounds(event.index);
93
			Font font= treeItem.getFont(event.index);
93
			Font font= treeItem.getFont(event.index);
94
			processColoredLabel(coloredLabel, gc, textBounds, isSelected, font);
94
			processColoredLabel(coloredLabel, gc, textBounds, isSelected, font);
Lines 99-104 Link Here
99
			}
99
			}
100
		} else if (item instanceof TableItem) {
100
		} else if (item instanceof TableItem) {
101
			TableItem tableItem= (TableItem) item;
101
			TableItem tableItem= (TableItem) item;
102
			Image image = tableItem.getImage(event.index);
103
			if (image != null) {
104
				processImage(image, gc, tableItem.getImageBounds(event.index));
105
			}
102
			Rectangle textBounds= tableItem.getTextBounds(event.index);
106
			Rectangle textBounds= tableItem.getTextBounds(event.index);
103
			Font font= tableItem.getFont(event.index);
107
			Font font= tableItem.getFont(event.index);
104
			processColoredLabel(coloredLabel, gc, textBounds, isSelected, font);
108
			processColoredLabel(coloredLabel, gc, textBounds, isSelected, font);
Lines 110-115 Link Here
110
		}
114
		}
111
	}
115
	}
112
	
116
	
117
	private void processImage(Image image, GC gc, Rectangle imageBounds) {
118
		Rectangle bounds= image.getBounds();
119
		int x= imageBounds.x + Math.max(0, (imageBounds.width - bounds.width) / 2);
120
		int y= imageBounds.y + Math.max(0, (imageBounds.height - bounds.height) / 2);
121
		gc.drawImage(image, x, y);
122
	}
123
	
113
	private void processColoredLabel(ColoredString richLabel, GC gc, Rectangle textBounds, boolean isSelected, Font font) {
124
	private void processColoredLabel(ColoredString richLabel, GC gc, Rectangle textBounds, boolean isSelected, Font font) {
114
		String text= richLabel.getString();
125
		String text= richLabel.getString();
115
		fTextLayout.setText(text);
126
		fTextLayout.setText(text);

Return to bug 189083