Mercurial > projects > dwt2
comparison org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/TextHyperlinkSegment.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children | dbfb303e8fb0 |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2008 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.ui.internal.forms.widgets.TextHyperlinkSegment; | |
14 | |
15 import org.eclipse.ui.internal.forms.widgets.TextSegment; | |
16 import org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment; | |
17 import org.eclipse.ui.internal.forms.widgets.SelectionData; | |
18 | |
19 import org.eclipse.swt.graphics.Color; | |
20 import org.eclipse.swt.graphics.GC; | |
21 import org.eclipse.swt.graphics.Rectangle; | |
22 import org.eclipse.ui.forms.HyperlinkSettings; | |
23 | |
24 import java.lang.all; | |
25 import java.util.Set; | |
26 | |
27 /** | |
28 * @version 1.0 | |
29 * @author | |
30 */ | |
31 public class TextHyperlinkSegment : TextSegment, | |
32 IHyperlinkSegment { | |
33 private String href; | |
34 | |
35 private String tooltipText; | |
36 | |
37 //private static final String LINK_FG = "c.___link_fg"; | |
38 | |
39 private HyperlinkSettings settings; | |
40 | |
41 // reimpl for interface | |
42 String getText(){ | |
43 return super.getText(); | |
44 } | |
45 void paintFocus(GC gc, Color bg, Color fg, bool selected, Rectangle repaintRegion){ | |
46 super.paintFocus(gc,bg,fg,selected,repaintRegion); | |
47 } | |
48 bool contains(int x, int y){ | |
49 return super.contains(x,y); | |
50 } | |
51 bool intersects(Rectangle rect){ | |
52 return super.intersects(rect); | |
53 } | |
54 | |
55 public this(String text, HyperlinkSettings settings, | |
56 String fontId) { | |
57 super(text, fontId); | |
58 this.settings = settings; | |
59 underline = settings.getHyperlinkUnderlineMode() is HyperlinkSettings.UNDERLINE_ALWAYS; | |
60 } | |
61 | |
62 /* | |
63 * @see IObjectReference#getObjectId() | |
64 */ | |
65 public String getHref() { | |
66 return href; | |
67 } | |
68 | |
69 public void setHref(String href) { | |
70 this.href = href; | |
71 } | |
72 | |
73 /* | |
74 * public void paint(GC gc, int width, Locator locator, Hashtable | |
75 * resourceTable, bool selected, SelectionData selData) { | |
76 * resourceTable.put(LINK_FG, settings.getForeground()); | |
77 * setColorId(LINK_FG); super.paint(gc, width, locator, resourceTable, | |
78 * selected, selData); } | |
79 */ | |
80 | |
81 public void paint(GC gc, bool hover, Hashtable resourceTable, | |
82 bool selected, SelectionData selData, Rectangle repaintRegion) { | |
83 bool rolloverMode = settings.getHyperlinkUnderlineMode() is HyperlinkSettings.UNDERLINE_HOVER; | |
84 Color savedFg = gc.getForeground(); | |
85 Color newFg = hover ? settings.getActiveForeground() : settings | |
86 .getForeground(); | |
87 if (newFg !is null) | |
88 gc.setForeground(newFg); | |
89 super.paint(gc, hover, resourceTable, selected, rolloverMode, selData, | |
90 repaintRegion); | |
91 gc.setForeground(savedFg); | |
92 } | |
93 | |
94 protected void drawString(GC gc, String s, int clipX, int clipY) { | |
95 gc.drawString(s, clipX, clipY, false); | |
96 } | |
97 | |
98 public String getTooltipText() { | |
99 return tooltipText; | |
100 } | |
101 | |
102 public void setTooltipText(String tooltip) { | |
103 this.tooltipText = tooltip; | |
104 } | |
105 | |
106 public bool isSelectable() { | |
107 return true; | |
108 } | |
109 | |
110 public bool isFocusSelectable(Hashtable resourceTable) { | |
111 return true; | |
112 } | |
113 | |
114 public bool setFocus(Hashtable resourceTable, bool direction) { | |
115 return true; | |
116 } | |
117 } |