Project

General

Profile

Download (4.42 KB) Statistics
| Branch: | Tag: | Revision:
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2010 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
 *******************************************************************************/
11

    
12
package org.eclipse.gef.internal.ui.palette;
13

    
14
import org.eclipse.swt.graphics.Color;
15
import org.eclipse.swt.widgets.Display;
16

    
17
import org.eclipse.draw2d.ColorConstants;
18
import org.eclipse.draw2d.FigureUtilities;
19

    
20
/**
21
 * A class to keep miscellaneous palette color utilities.
22
 * 
23
 * @author crevells
24
 * @since 3.4
25
 */
26
public class PaletteColorUtil {
27

    
28
	public static final Color WIDGET_BACKGROUND = ColorConstants.button;
29

    
30
	public static final Color WIDGET_NORMAL_SHADOW = ColorConstants.buttonDarker;
31

    
32
	public static final Color WIDGET_DARK_SHADOW = ColorConstants.buttonDarkest;
33

    
34
	public static final Color WIDGET_LIST_BACKGROUND = ColorConstants.listBackground;
35

    
36
	public static final Color INFO_FOREGROUND = ColorConstants.tooltipForeground;
37

    
38
	public static final Color ARROW_HOVER = new Color(null, 229, 229, 219);
39

    
40
	private static final Color HOVER_COLOR = new Color(null, 252, 228, 179);
41

    
42
	private static final Color SELECTED_COLOR = new Color(null, 207, 227, 250);
43

    
44
	private static final Color HOVER_COLOR_HICONTRAST = new Color(null, 0, 128,
45
			0);
46

    
47
	private static final Color SELECTED_COLOR_HICONTRAST = new Color(null, 128,
48
			0, 128);
49

    
50
	public static final Color WIDGET_BACKGROUND_LIST_BACKGROUND_40 = FigureUtilities
51
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
52
					PaletteColorUtil.WIDGET_LIST_BACKGROUND, 0.4);
53

    
54
	public static final Color WIDGET_BACKGROUND_LIST_BACKGROUND_60 = FigureUtilities
55
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
56
					PaletteColorUtil.WIDGET_LIST_BACKGROUND, 0.6);
57

    
58
	public static final Color WIDGET_BACKGROUND_LIST_BACKGROUND_85 = FigureUtilities
59
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
60
					PaletteColorUtil.WIDGET_LIST_BACKGROUND, 0.85);
61

    
62
	public static final Color WIDGET_BACKGROUND_LIST_BACKGROUND_90 = FigureUtilities
63
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
64
					PaletteColorUtil.WIDGET_LIST_BACKGROUND, 0.9);
65

    
66
	public static final Color WIDGET_BACKGROUND_NORMAL_SHADOW_40 = FigureUtilities
67
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
68
					PaletteColorUtil.WIDGET_NORMAL_SHADOW, 0.4);
69

    
70
	public static final Color WIDGET_BACKGROUND_NORMAL_SHADOW_45 = FigureUtilities
71
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
72
					PaletteColorUtil.WIDGET_NORMAL_SHADOW, 0.45);
73

    
74
	public static final Color WIDGET_BACKGROUND_NORMAL_SHADOW_65 = FigureUtilities
75
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
76
					PaletteColorUtil.WIDGET_NORMAL_SHADOW, 0.65);
77

    
78
	public static final Color WIDGET_BACKGROUND_NORMAL_SHADOW_70 = FigureUtilities
79
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
80
					PaletteColorUtil.WIDGET_NORMAL_SHADOW, 0.7);
81

    
82
	public static final Color WIDGET_BACKGROUND_NORMAL_SHADOW_80 = FigureUtilities
83
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
84
					PaletteColorUtil.WIDGET_NORMAL_SHADOW, 0.8);
85

    
86
	public static final Color WIDGET_BACKGROUND_NORMAL_SHADOW_90 = FigureUtilities
87
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
88
					PaletteColorUtil.WIDGET_NORMAL_SHADOW, 0.9);
89

    
90
	public static final Color WIDGET_BACKGROUND_NORMAL_SHADOW_95 = FigureUtilities
91
			.mixColors(PaletteColorUtil.WIDGET_BACKGROUND,
92
					PaletteColorUtil.WIDGET_NORMAL_SHADOW, 0.95);
93

    
94
	/**
95
	 * Gets the color to be used when hovering over palette items. The color
96
	 * differs in high contrast mode.
97
	 * 
98
	 * @return the hover color
99
	 * @since 3.4
100
	 */
101
	public static Color getHoverColor() {
102
		Display display = Display.getCurrent();
103
		if (display == null) {
104
			display = Display.getDefault();
105
		}
106
		if (display.getHighContrast()) {
107
			return HOVER_COLOR_HICONTRAST;
108
		}
109
		return HOVER_COLOR;
110
	}
111

    
112
	/**
113
	 * Gets the color to be used when selecting palette items. The color differs
114
	 * in high contrast mode.
115
	 * 
116
	 * @return the selected color
117
	 * @since 3.4
118
	 */
119
	public static Color getSelectedColor() {
120
		Display display = Display.getCurrent();
121
		if (display == null) {
122
			display = Display.getDefault();
123
		}
124
		if (display.getHighContrast()) {
125
			return SELECTED_COLOR_HICONTRAST;
126
		}
127
		return SELECTED_COLOR;
128
	}
129
}
(1-1/3)