Mercurial > projects > dwt2
comparison org.eclipse.ui.forms/src/org/eclipse/ui/forms/HyperlinkSettings.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 |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2005 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.forms.HyperlinkSettings; | |
14 | |
15 import org.eclipse.swt.SWT; | |
16 import org.eclipse.swt.graphics.Color; | |
17 import org.eclipse.swt.graphics.Cursor; | |
18 import org.eclipse.swt.widgets.Display; | |
19 import org.eclipse.jface.resource.JFaceColors; | |
20 import org.eclipse.ui.internal.forms.widgets.FormsResources; | |
21 | |
22 import java.lang.all; | |
23 import java.util.Set; | |
24 | |
25 /** | |
26 * Manages color and underline mode settings for a group of hyperlinks. The | |
27 * class is extended by HyperlinkGroup but is otherwise not intended to be | |
28 * subclassed. | |
29 * | |
30 * @since 3.0 | |
31 * @noextend This class is not intended to be subclassed by clients. | |
32 */ | |
33 public class HyperlinkSettings { | |
34 /** | |
35 * Underline mode to be used when hyperlinks should not be underlined. | |
36 */ | |
37 public static const int UNDERLINE_NEVER = 1; | |
38 /** | |
39 * Underline mode to be used when hyperlinks should only be underlined on | |
40 * mouse hover. | |
41 */ | |
42 public static const int UNDERLINE_HOVER = 2; | |
43 /** | |
44 * Underline mode to be used when hyperlinks should always be underlined. | |
45 */ | |
46 public static const int UNDERLINE_ALWAYS = 3; | |
47 private int hyperlinkUnderlineMode = UNDERLINE_ALWAYS; | |
48 private Color background; | |
49 private Color foreground; | |
50 private Color activeBackground; | |
51 private Color activeForeground; | |
52 /** | |
53 * The constructor. | |
54 * | |
55 * @param display | |
56 * the display to use when creating colors. | |
57 */ | |
58 public this(Display display) { | |
59 initializeDefaultForegrounds(display); | |
60 } | |
61 /** | |
62 * Initializes the hyperlink foregrounds from the JFace defaults set for the | |
63 * entire workbench. | |
64 * | |
65 * @see JFaceColors | |
66 * @param display | |
67 * the display to use when creating colors | |
68 */ | |
69 public void initializeDefaultForegrounds(Display display) { | |
70 Color fg = JFaceColors.getHyperlinkText(display); | |
71 Color afg = JFaceColors.getActiveHyperlinkText(display); | |
72 if (fg is null) | |
73 fg = display.getSystemColor(SWT.COLOR_BLUE); | |
74 setForeground(fg); | |
75 setActiveForeground(afg); | |
76 } | |
77 /** | |
78 * Returns the background to use for the active hyperlink. | |
79 * | |
80 * @return active hyperlink background | |
81 */ | |
82 public Color getActiveBackground() { | |
83 return activeBackground; | |
84 } | |
85 /** | |
86 * Returns the foreground to use for the active hyperlink. | |
87 * | |
88 * @return active hyperlink foreground | |
89 */ | |
90 public Color getActiveForeground() { | |
91 return activeForeground; | |
92 } | |
93 /** | |
94 * Returns the background to use for the normal hyperlink. | |
95 * | |
96 * @return normal hyperlink background | |
97 */ | |
98 public Color getBackground() { | |
99 return background; | |
100 } | |
101 /** | |
102 * Returns the cursor to use when the hyperlink is active. This cursor will | |
103 * be shown before hyperlink listeners have been notified of hyperlink | |
104 * activation and hidden when the notification method returns. | |
105 * | |
106 * @return the busy cursor | |
107 */ | |
108 public Cursor getBusyCursor() { | |
109 return FormsResources.getBusyCursor(); | |
110 } | |
111 /** | |
112 * Returns the cursor to use when over text. | |
113 * | |
114 * @return the text cursor | |
115 */ | |
116 public Cursor getTextCursor() { | |
117 return FormsResources.getTextCursor(); | |
118 } | |
119 /** | |
120 * Returns the foreground to use for the normal hyperlink. | |
121 * | |
122 * @return the normal hyperlink foreground | |
123 */ | |
124 public Color getForeground() { | |
125 return foreground; | |
126 } | |
127 /** | |
128 * Returns the cursor to use when hovering over the hyperlink. | |
129 * | |
130 * @return the hyperlink cursor | |
131 */ | |
132 public Cursor getHyperlinkCursor() { | |
133 return FormsResources.getHandCursor(); | |
134 } | |
135 /** | |
136 * Returns the underline mode to be used for all the hyperlinks in this | |
137 * group. | |
138 * | |
139 * @return one of UNDERLINE_NEVER, UNDERLINE_ALWAYS, UNDERLINE_HOVER | |
140 */ | |
141 public int getHyperlinkUnderlineMode() { | |
142 return hyperlinkUnderlineMode; | |
143 } | |
144 /** | |
145 * Sets the new active hyperlink background for all the links. | |
146 * | |
147 * @param newActiveBackground | |
148 * the new active background | |
149 */ | |
150 public void setActiveBackground(Color newActiveBackground) { | |
151 activeBackground = newActiveBackground; | |
152 } | |
153 /** | |
154 * Sets the new active hyperlink foreground for all the links. | |
155 * | |
156 * @param newActiveForeground | |
157 * the new active foreground | |
158 */ | |
159 public void setActiveForeground(Color newActiveForeground) { | |
160 activeForeground = newActiveForeground; | |
161 } | |
162 /** | |
163 * Sets the new hyperlink background for all the links. | |
164 * | |
165 * @param newBackground | |
166 * the new hyperlink background | |
167 */ | |
168 public void setBackground(Color newBackground) { | |
169 background = newBackground; | |
170 } | |
171 /** | |
172 * Sets the new hyperlink foreground for all the links. | |
173 * | |
174 * @param newForeground | |
175 * the new hyperlink foreground | |
176 */ | |
177 public void setForeground(Color newForeground) { | |
178 foreground = newForeground; | |
179 } | |
180 /** | |
181 * Sets the new hyperlink underline mode for all the links in this group. | |
182 * | |
183 * @param mode | |
184 * one of <code>UNDERLINE_NEVER</code>, | |
185 * <code>UNDERLINE_HOVER</code> and | |
186 * <code>UNDERLINE_ALWAYS</code>. | |
187 */ | |
188 public void setHyperlinkUnderlineMode(int mode) { | |
189 hyperlinkUnderlineMode = mode; | |
190 } | |
191 } |