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