Mercurial > projects > dwt2
comparison org.eclipse.jface/src/org/eclipse/jface/resource/JFaceColors.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, 2006 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.jface.resource.JFaceColors; | |
14 | |
15 import org.eclipse.jface.resource.JFaceResources; | |
16 | |
17 import org.eclipse.swt.SWT; | |
18 import org.eclipse.swt.graphics.Color; | |
19 import org.eclipse.swt.widgets.Control; | |
20 import org.eclipse.swt.widgets.Display; | |
21 import org.eclipse.jface.preference.JFacePreferences; | |
22 | |
23 import java.lang.all; | |
24 import java.util.Set; | |
25 | |
26 /** | |
27 * JFaceColors is the class that stores references | |
28 * to all of the colors used by JFace. | |
29 */ | |
30 public class JFaceColors { | |
31 | |
32 /** | |
33 * @param display the display the color is from | |
34 * @return the Color used for banner backgrounds | |
35 * @see SWT#COLOR_LIST_BACKGROUND | |
36 * @see Display#getSystemColor(int) | |
37 */ | |
38 public static Color getBannerBackground(Display display) { | |
39 return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); | |
40 } | |
41 | |
42 /** | |
43 * @param display the display the color is from | |
44 * @return the Color used for banner foregrounds | |
45 * @see SWT#COLOR_LIST_FOREGROUND | |
46 * @see Display#getSystemColor(int) | |
47 */ | |
48 public static Color getBannerForeground(Display display) { | |
49 return display.getSystemColor(SWT.COLOR_LIST_FOREGROUND); | |
50 } | |
51 | |
52 /** | |
53 * @param display the display the color is from | |
54 * @return the background Color for widgets that display errors. | |
55 * @see SWT#COLOR_WIDGET_BACKGROUND | |
56 * @see Display#getSystemColor(int) | |
57 */ | |
58 public static Color getErrorBackground(Display display) { | |
59 return display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); | |
60 } | |
61 | |
62 /** | |
63 * @param display the display the color is from | |
64 * @return the border Color for widgets that display errors. | |
65 * @see SWT#COLOR_WIDGET_DARK_SHADOW | |
66 * @see Display#getSystemColor(int) | |
67 */ | |
68 public static Color getErrorBorder(Display display) { | |
69 return display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW); | |
70 } | |
71 | |
72 /** | |
73 * @param display the display the color is from | |
74 * @return the default color to use for displaying errors. | |
75 * @see ColorRegistry#get(String) | |
76 * @see JFacePreferences#ERROR_COLOR | |
77 */ | |
78 public static Color getErrorText(Display display) { | |
79 return JFaceResources.getColorRegistry().get( | |
80 JFacePreferences.ERROR_COLOR); | |
81 } | |
82 | |
83 /** | |
84 * @param display the display the color is from | |
85 * @return the default color to use for displaying hyperlinks. | |
86 * @see ColorRegistry#get(String) | |
87 * @see JFacePreferences#HYPERLINK_COLOR | |
88 */ | |
89 public static Color getHyperlinkText(Display display) { | |
90 return JFaceResources.getColorRegistry().get( | |
91 JFacePreferences.HYPERLINK_COLOR); | |
92 } | |
93 | |
94 /** | |
95 * @param display the display the color is from | |
96 * @return the default color to use for displaying active hyperlinks. | |
97 * @see ColorRegistry#get(String) | |
98 * @see JFacePreferences#ACTIVE_HYPERLINK_COLOR | |
99 */ | |
100 public static Color getActiveHyperlinkText(Display display) { | |
101 return JFaceResources.getColorRegistry().get( | |
102 JFacePreferences.ACTIVE_HYPERLINK_COLOR); | |
103 } | |
104 | |
105 /** | |
106 * Clear out the cached color for name. This is generally | |
107 * done when the color preferences changed and any cached colors | |
108 * may be disposed. Users of the colors in this class should add a IPropertyChangeListener | |
109 * to detect when any of these colors change. | |
110 * @param colorName name of the color | |
111 * | |
112 * @deprecated JFaceColors no longer maintains a cache of colors. This job | |
113 * is now handled by the ColorRegistry. | |
114 */ | |
115 public static void clearColor(String colorName) { | |
116 //no-op | |
117 } | |
118 | |
119 /** | |
120 * Dispose of all allocated colors. Called on workbench | |
121 * shutdown. | |
122 * | |
123 * @deprecated JFaceColors no longer maintains a cache of colors. This job | |
124 * is now handled by the ColorRegistry. | |
125 */ | |
126 public static void disposeColors() { | |
127 //no-op | |
128 } | |
129 | |
130 /** | |
131 * Set the foreground and background colors of the | |
132 * control to the specified values. If the values are | |
133 * null than ignore them. | |
134 * @param control the control the foreground and/or background color should be set | |
135 * | |
136 * @param foreground Color the foreground color (maybe <code>null</code>) | |
137 * @param background Color the background color (maybe <code>null</code>) | |
138 */ | |
139 public static void setColors(Control control, Color foreground, | |
140 Color background) { | |
141 if (foreground !is null) { | |
142 control.setForeground(foreground); | |
143 } | |
144 if (background !is null) { | |
145 control.setBackground(background); | |
146 } | |
147 } | |
148 | |
149 } |