1 11 package org.eclipse.ui.forms.widgets; 12 import org.eclipse.swt.SWT; 13 import org.eclipse.swt.events.PaintEvent; 14 import org.eclipse.swt.graphics.*; 15 import org.eclipse.swt.widgets.Composite; 16 29 public class TreeNode extends ToggleHyperlink { 30 38 public TreeNode(Composite parent, int style) { 39 super(parent, style); 40 innerWidth = 10; 41 innerHeight = 10; 42 } 43 protected void paint(PaintEvent e) { 44 paintHyperlink(e.gc); 45 } 46 protected void paintHyperlink(GC gc) { 47 Rectangle box = getBoxBounds(gc); 48 gc.setForeground(getDisplay().getSystemColor( 49 SWT.COLOR_WIDGET_NORMAL_SHADOW)); 50 gc.drawRectangle(box); 51 gc.setForeground(getForeground()); 52 gc.drawLine(box.x + 2, box.y + 4, box.x + 6, box.y + 4); 53 if (!isExpanded()) { 54 gc.drawLine(box.x + 4, box.y + 2, box.x + 4, box.y + 6); 55 } 56 if (paintFocus && getSelection()) { 57 gc.setForeground(getForeground()); 58 gc.drawFocus(box.x - 1, box.y - 1, box.width + 3, box.height + 3); 59 } 60 } 61 private Rectangle getBoxBounds(GC gc) { 62 int x = 1; 63 int y = 0; 64 gc.setFont(getFont()); 65 y = 2; 69 return new Rectangle(x, y, 8, 8); 70 } 71 } 72 | Popular Tags |