|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008 Angelo Zerr and others. |
2 |
* Copyright (c) 2008, 2009 Angelo Zerr and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 19-28
Link Here
|
| 19 |
import org.eclipse.e4.ui.css.swt.helpers.SWTElementHelpers; |
19 |
import org.eclipse.e4.ui.css.swt.helpers.SWTElementHelpers; |
| 20 |
import org.eclipse.e4.ui.css.swt.properties.GradientBackgroundListener; |
20 |
import org.eclipse.e4.ui.css.swt.properties.GradientBackgroundListener; |
| 21 |
import org.eclipse.swt.custom.CTabFolder; |
21 |
import org.eclipse.swt.custom.CTabFolder; |
|
|
22 |
import org.eclipse.swt.custom.CTabItem; |
| 22 |
import org.eclipse.swt.graphics.Color; |
23 |
import org.eclipse.swt.graphics.Color; |
| 23 |
import org.eclipse.swt.graphics.Image; |
24 |
import org.eclipse.swt.graphics.Image; |
| 24 |
import org.eclipse.swt.widgets.Button; |
25 |
import org.eclipse.swt.widgets.Button; |
| 25 |
import org.eclipse.swt.widgets.Control; |
26 |
import org.eclipse.swt.widgets.Control; |
|
|
27 |
import org.eclipse.swt.widgets.Widget; |
| 26 |
import org.w3c.dom.css.CSSValue; |
28 |
import org.w3c.dom.css.CSSValue; |
| 27 |
|
29 |
|
| 28 |
public class CSSPropertyBackgroundSWTHandler extends |
30 |
public class CSSPropertyBackgroundSWTHandler extends |
|
Lines 32-40
Link Here
|
| 32 |
|
34 |
|
| 33 |
public boolean applyCSSProperty(Object element, String property, |
35 |
public boolean applyCSSProperty(Object element, String property, |
| 34 |
CSSValue value, String pseudo, CSSEngine engine) throws Exception { |
36 |
CSSValue value, String pseudo, CSSEngine engine) throws Exception { |
| 35 |
Control control = SWTElementHelpers.getControl(element); |
37 |
Widget widget = SWTElementHelpers.getWidget(element); |
| 36 |
if (control != null) { |
38 |
if (widget != null) { |
| 37 |
super.applyCSSProperty(control, property, value, pseudo, engine); |
39 |
super.applyCSSProperty(widget, property, value, pseudo, engine); |
| 38 |
return true; |
40 |
return true; |
| 39 |
} |
41 |
} |
| 40 |
return false; |
42 |
return false; |
|
Lines 43-51
Link Here
|
| 43 |
|
45 |
|
| 44 |
public String retrieveCSSProperty(Object element, String property, |
46 |
public String retrieveCSSProperty(Object element, String property, |
| 45 |
String pseudo, CSSEngine engine) throws Exception { |
47 |
String pseudo, CSSEngine engine) throws Exception { |
| 46 |
Control control = SWTElementHelpers.getControl(element); |
48 |
Widget widget = SWTElementHelpers.getWidget(element); |
| 47 |
if (control != null) { |
49 |
if (widget != null) { |
| 48 |
return super.retrieveCSSProperty(control, property, pseudo, engine); |
50 |
return super.retrieveCSSProperty(widget, property, pseudo, engine); |
| 49 |
} |
51 |
} |
| 50 |
return null; |
52 |
return null; |
| 51 |
} |
53 |
} |
|
Lines 59-83
Link Here
|
| 59 |
*/ |
61 |
*/ |
| 60 |
public void applyCSSPropertyBackgroundColor(Object element, CSSValue value, |
62 |
public void applyCSSPropertyBackgroundColor(Object element, CSSValue value, |
| 61 |
String pseudo, CSSEngine engine) throws Exception { |
63 |
String pseudo, CSSEngine engine) throws Exception { |
| 62 |
Control control = (Control) element; |
64 |
Widget widget = (Widget) element; |
| 63 |
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { |
65 |
if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { |
| 64 |
Color newColor = (Color) engine.convert(value, Color.class, control |
66 |
Color newColor = (Color) engine.convert(value, Color.class, widget |
| 65 |
.getDisplay()); |
67 |
.getDisplay()); |
| 66 |
if (control instanceof CTabFolder && "selected".equals(pseudo)) { |
68 |
if (widget instanceof CTabItem) { |
| 67 |
((CTabFolder) control).setSelectionBackground(newColor); |
69 |
CTabFolder folder = ((CTabItem) widget).getParent(); |
| 68 |
} else { |
70 |
if ("selected".equals(pseudo)) { |
| 69 |
control.setBackground(newColor); |
71 |
folder.setSelectionBackground(newColor); |
|
|
72 |
} else { |
| 73 |
folder.setBackground(newColor); |
| 74 |
} |
| 75 |
} else if (widget instanceof Control) { |
| 76 |
((Control) widget).setBackground(newColor); |
| 70 |
} |
77 |
} |
| 71 |
} else if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { |
78 |
} else if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) { |
| 72 |
Gradient grad = (Gradient) engine.convert(value, Gradient.class, |
79 |
Gradient grad = (Gradient) engine.convert(value, Gradient.class, |
| 73 |
control.getDisplay()); |
80 |
widget.getDisplay()); |
| 74 |
if (control instanceof CTabFolder && "selected".equals(pseudo)) { |
81 |
if (widget instanceof CTabItem && "selected".equals(pseudo)) { |
| 75 |
((CTabFolder) control).setSelectionBackground( |
82 |
CTabFolder folder = ((CTabItem) widget).getParent(); |
| 76 |
CSSSWTColorHelper.getSWTColors(grad, control.getDisplay()), |
83 |
folder.setSelectionBackground( |
|
|
84 |
CSSSWTColorHelper.getSWTColors(grad, folder.getDisplay()), |
| 77 |
CSSSWTColorHelper.getPercents(grad), |
85 |
CSSSWTColorHelper.getPercents(grad), |
| 78 |
true); |
86 |
true); |
| 79 |
} else { |
87 |
} else if (widget instanceof Control) { |
| 80 |
GradientBackgroundListener.handle(control, grad); |
88 |
GradientBackgroundListener.handle((Control) widget, grad); |
| 81 |
} |
89 |
} |
| 82 |
} |
90 |
} |
| 83 |
} |
91 |
} |
|
Lines 121-128
Link Here
|
| 121 |
|
129 |
|
| 122 |
public String retrieveCSSPropertyBackgroundColor(Object element, |
130 |
public String retrieveCSSPropertyBackgroundColor(Object element, |
| 123 |
String pseudo, CSSEngine engine) throws Exception { |
131 |
String pseudo, CSSEngine engine) throws Exception { |
| 124 |
Control control = (Control) element; |
132 |
Widget widget = (Widget) element; |
| 125 |
Color color = control.getBackground(); |
133 |
Color color = null; |
|
|
134 |
if (widget instanceof CTabItem) { |
| 135 |
if ("selected".equals(pseudo)) { |
| 136 |
color = ((CTabItem) widget).getParent().getSelectionBackground(); |
| 137 |
} else { |
| 138 |
color = ((CTabItem) widget).getParent().getBackground(); |
| 139 |
} |
| 140 |
} else if (widget instanceof Control) { |
| 141 |
color = ((Control) widget).getBackground(); |
| 142 |
} |
| 126 |
return engine.convert(color, Color.class, null); |
143 |
return engine.convert(color, Color.class, null); |
| 127 |
} |
144 |
} |
| 128 |
|
145 |
|