Debian Codegraph @

src/com/jidesoft/plaf/office2003/Office2003Painter.java

raw
1 package com.jidesoft.plaf.office2003;
2
3 import com.jidesoft.icons.IconsFactory;
4 import com.jidesoft.plaf.LookAndFeelFactory;
5 import com.jidesoft.plaf.UIDefaultsLookup;
6 import com.jidesoft.plaf.XPUtils;
7 import com.jidesoft.plaf.basic.BasicPainter;
8 import com.jidesoft.plaf.basic.ThemePainter;
9 import com.jidesoft.swing.ComponentStateSupport;
10 import com.jidesoft.swing.JideButton;
11 import com.jidesoft.swing.JideSwingUtilities;
12 import com.jidesoft.swing.JideTabbedPane;
13 import com.jidesoft.utils.ColorUtils;
14 import com.jidesoft.utils.SystemInfo;
15
16 import javax.swing.*;
17 import javax.swing.plaf.ColorUIResource;
18 import javax.swing.plaf.UIResource;
19 import java.awt.*;
20 import java.awt.geom.RoundRectangle2D;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.Collection;
24 import java.util.Map;
25 import java.util.TreeMap;
26
27 /**
28 * Painter for Office2003 L&F.
29 * <p/>
30 * Please note, this class is an internal class which is meant to be used by other JIDE classes only. Future version
31 * might break your build if you use it.
32 */
33 public class Office2003Painter extends BasicPainter {
34
35 private static Office2003Painter _instance;
36
37 public static ThemePainter getInstance() {
38 if (_instance == null) {
39 _instance = new Office2003Painter();
40 PropertyChangeListener listener = new PropertyChangeListener() {
41 public void propertyChange(PropertyChangeEvent evt) {
42 if (Office2003Painter.isNative()) {
43 if (XPUtils.PROPERTY_COLORNAME.equals(evt.getPropertyName())) {
44 if (evt.getNewValue() != null) {
45 _instance.setColorName((String) evt.getNewValue());
46 }
47 else {
48 _instance.setColorName("");
49 }
50 }
51 else if (XPUtils.PROPERTY_THEMEACTIVE.equals(evt.getPropertyName())) {
52 if (evt.getNewValue().equals(Boolean.FALSE))
53 _instance.setColorName("");
54 else {
55 _instance.setColorName(XPUtils.getColorName());
56 }
57 }
58 }
59 }
60 };
61 Toolkit.getDefaultToolkit().addPropertyChangeListener(XPUtils.PROPERTY_COLORNAME, listener);
62 Toolkit.getDefaultToolkit().addPropertyChangeListener(XPUtils.PROPERTY_THEMEACTIVE, listener);
63
64 if (Office2003Painter.isNative()) {
65 try {
66 if (XPUtils.isXPStyleOn()) {
67 _instance.setColorName(XPUtils.getColorName());
68 }
69 else {
70 _instance.setColorName("");
71 }
72 }
73 catch (UnsupportedOperationException e) {
74 _instance.setColorName("");
75 }
76 }
77 }
78 return _instance;
79 }
80
81 private String _colorName = XPUtils.DEFAULT;
82
83 private static boolean _native = SystemInfo.isWindowsXP() || SystemInfo.isWindowsVistaAbove();
84
85 private static Office2003Theme _defaultTheme = new DefaultOffice2003Theme();
86 private static Office2003Theme _normalTheme = new Office2003Theme(XPUtils.GRAY);
87 private static Office2003Theme _blueTheme = new Office2003Theme(XPUtils.BLUE);
88 private static Office2003Theme _homeSteadTheme = new Office2003Theme(XPUtils.HOMESTEAD);
89 private static Office2003Theme _metallicTheme = new Office2003Theme(XPUtils.METALLIC);
90
91 private static Map<String, Office2003Theme> _themeCache = new TreeMap<String, Office2003Theme>();
92
93 static {
94 _themeCache.put(_defaultTheme.getThemeName(), _defaultTheme);
95 _themeCache.put(_normalTheme.getThemeName(), _normalTheme);
96 _themeCache.put(_blueTheme.getThemeName(), _blueTheme);
97 _themeCache.put(_homeSteadTheme.getThemeName(), _homeSteadTheme);
98 _themeCache.put(_metallicTheme.getThemeName(), _metallicTheme);
99
100 final int SIZE = 20;
101 final int MASK_SIZE = 11;
102
103 int products = LookAndFeelFactory.getProductsUsed();
104
105 Object uiDefaultsNormal[] = {
106 "control", new ColorUIResource(219, 216, 209),
107 "controlLt", new ColorUIResource(245, 244, 242),
108 "controlDk", new ColorUIResource(213, 210, 202),
109 "controlShadow", new ColorUIResource(128, 128, 128),
110
111 "TabbedPane.selectDk", new ColorUIResource(230, 139, 44),
112 "TabbedPane.selectLt", new ColorUIResource(255, 199, 60),
113
114 "OptionPane.bannerLt", new ColorUIResource(0, 52, 206),
115 "OptionPane.bannerDk", new ColorUIResource(45, 96, 249),
116 "OptionPane.bannerForeground", new ColorUIResource(255, 255, 255),
117
118 "Separator.foreground", new ColorUIResource(166, 166, 166),
119 "Separator.foregroundLt", new ColorUIResource(255, 255, 255),
120
121 "Gripper.foreground", new ColorUIResource(160, 160, 160),
122 "Gripper.foregroundLt", new ColorUIResource(255, 255, 255),
123
124 "Chevron.backgroundLt", new ColorUIResource(160, 160, 160),
125 "Chevron.backgroundDk", new ColorUIResource(128, 128, 128),
126
127 "Divider.backgroundLt", new ColorUIResource(110, 110, 110),
128 "Divider.backgroundDk", new ColorUIResource(90, 90, 90),
129
130 "backgroundLt", new ColorUIResource(245, 245, 244),
131 "backgroundDk", new ColorUIResource(212, 208, 200),
132
133 "selection.border", new ColorUIResource(0, 0, 128),
134
135 "MenuItem.background", new ColorUIResource(249, 248, 247),
136
137 "DockableFrameTitlePane.backgroundLt", new ColorUIResource(243, 242, 240),
138 "DockableFrameTitlePane.backgroundDk", new ColorUIResource(212, 208, 200),
139 "DockableFrameTitlePane.activeForeground", new ColorUIResource(0, 0, 0),
140 "DockableFrameTitlePane.inactiveForeground", new ColorUIResource(0, 0, 0),
141 "DockableFrame.backgroundLt", new ColorUIResource(234, 232, 228),
142 "DockableFrame.backgroundDk", new ColorUIResource(234, 232, 228),
143
144 "CommandBar.titleBarBackground", new ColorUIResource(128, 128, 128),
145 };
146 _normalTheme.putDefaults(uiDefaultsNormal);
147
148 if ((products & LookAndFeelFactory.PRODUCT_COMPONENTS) != 0) {
149 ImageIcon collapsiblePaneImage = IconsFactory.getImageIcon(Office2003WindowsUtils.class, "icons/collapsible_pane_gray.png"); // 20 x 20
150 ImageIcon collapsiblePaneMask = IconsFactory.getImageIcon(Office2003WindowsUtils.class, "icons/collapsible_pane_mask.png"); // 11 x 11
151 ImageIcon normalIcon = IconsFactory.getIcon(null, collapsiblePaneImage, 0, 0, SIZE, SIZE);
152 ImageIcon emphasizedIcon = IconsFactory.getIcon(null, collapsiblePaneImage, SIZE, 0, SIZE, SIZE);
153 ImageIcon downMark = IconsFactory.getIcon(null, collapsiblePaneMask, 0, 0, MASK_SIZE, MASK_SIZE);
154 ImageIcon upMark = IconsFactory.getIcon(null, collapsiblePaneMask, 0, MASK_SIZE, MASK_SIZE, MASK_SIZE);
155 uiDefaultsNormal = new Object[]{
156 "CollapsiblePane.contentBackground", new ColorUIResource(255, 255, 255),
157 "CollapsiblePanes.backgroundLt", new ColorUIResource(160, 160, 160),
158 "CollapsiblePanes.backgroundDk", new ColorUIResource(128, 128, 128),
159 "CollapsiblePaneTitlePane.backgroundLt", new ColorUIResource(255, 255, 255),
160 "CollapsiblePaneTitlePane.backgroundDk", new ColorUIResource(213, 210, 202),
161 "CollapsiblePaneTitlePane.foreground", new ColorUIResource(91, 91, 91),
162 "CollapsiblePaneTitlePane.foreground.focus", new ColorUIResource(137, 137, 137),
163 "CollapsiblePaneTitlePane.backgroundLt.emphasized", new ColorUIResource(68, 68, 68),
164 "CollapsiblePaneTitlePane.backgroundDk.emphasized", new ColorUIResource(94, 94, 94),
165 "CollapsiblePaneTitlePane.foreground.emphasized", new ColorUIResource(255, 255, 255),
166 "CollapsiblePaneTitlePane.foreground.focus.emphasized", new ColorUIResource(230, 230, 230),
167 "CollapsiblePane.downIcon", IconsFactory.getOverlayIcon(null, normalIcon, downMark, SwingConstants.CENTER),
168 "CollapsiblePane.upIcon", IconsFactory.getOverlayIcon(null, normalIcon, upMark, SwingConstants.CENTER),
169 "CollapsiblePane.downIcon.emphasized", IconsFactory.getOverlayIcon(null, emphasizedIcon, downMark, SwingConstants.CENTER),
170 "CollapsiblePane.upIcon.emphasized", IconsFactory.getOverlayIcon(null, emphasizedIcon, upMark, SwingConstants.CENTER),
171 "CollapsiblePane.upMask", upMark,
172 "CollapsiblePane.downMask", downMark,
173 "CollapsiblePane.titleButtonBackground", normalIcon,
174 "CollapsiblePane.titleButtonBackground.emphasized", emphasizedIcon,
175 };
176 _normalTheme.putDefaults(uiDefaultsNormal);
177 }
178
179 Object uiDefaultsBlue[] = {
180 "control", new ColorUIResource(196, 219, 249),
181 "controlLt", new ColorUIResource(218, 234, 253),
182 "controlDk", new ColorUIResource(129, 169, 226),
183 "controlShadow", new ColorUIResource(59, 67, 156),
184
185 "TabbedPane.selectDk", new ColorUIResource(230, 139, 44),
186 "TabbedPane.selectLt", new ColorUIResource(255, 199, 60),
187
188 "OptionPane.bannerLt", new ColorUIResource(0, 52, 206),
189 "OptionPane.bannerDk", new ColorUIResource(45, 96, 249),
190 "OptionPane.bannerForeground", new ColorUIResource(255, 255, 255),
191
192 "Separator.foreground", new ColorUIResource(106, 140, 203),
193 "Separator.foregroundLt", new ColorUIResource(241, 249, 255),
194
195 "Gripper.foreground", new ColorUIResource(39, 65, 118),
196 "Gripper.foregroundLt", new ColorUIResource(255, 255, 255),
197
198 "Chevron.backgroundLt", new ColorUIResource(117, 166, 241),
199 "Chevron.backgroundDk", new ColorUIResource(0, 53, 145),
200
201 "Divider.backgroundLt", new ColorUIResource(89, 135, 214),
202 "Divider.backgroundDk", new ColorUIResource(0, 45, 150),
203
204 "backgroundLt", new ColorUIResource(195, 218, 249),
205 "backgroundDk", new ColorUIResource(158, 190, 245),
206
207 "selection.border", new ColorUIResource(0, 0, 128),
208
209 "MenuItem.background", new ColorUIResource(246, 246, 246),
210
211 "DockableFrameTitlePane.backgroundLt", new ColorUIResource(218, 234, 253),
212 "DockableFrameTitlePane.backgroundDk", new ColorUIResource(123, 164, 224),
213 "DockableFrameTitlePane.activeForeground", new ColorUIResource(0, 0, 0),
214 "DockableFrameTitlePane.inactiveForeground", new ColorUIResource(0, 0, 0),
215 "DockableFrame.backgroundLt", new ColorUIResource(221, 236, 254),
216 "DockableFrame.backgroundDk", new ColorUIResource(221, 236, 254),
217
218 "CommandBar.titleBarBackground", new ColorUIResource(42, 102, 201),
219 };
220 _blueTheme.putDefaults(uiDefaultsBlue);
221
222 if ((products & LookAndFeelFactory.PRODUCT_COMPONENTS) != 0) {
223 ImageIcon collapsiblePaneImage = IconsFactory.getImageIcon(Office2003WindowsUtils.class, "icons/collapsible_pane_blue.png"); // 20 x 20
224 ImageIcon collapsiblePaneMask = IconsFactory.getImageIcon(Office2003WindowsUtils.class, "icons/collapsible_pane_mask.png"); // 11 x 11
225 ImageIcon normalIcon = IconsFactory.getIcon(null, collapsiblePaneImage, 0, 0, SIZE, SIZE);
226 ImageIcon emphasizedIcon = IconsFactory.getIcon(null, collapsiblePaneImage, SIZE, 0, SIZE, SIZE);
227 ImageIcon upMark = IconsFactory.getIcon(null, collapsiblePaneMask, 0, MASK_SIZE, MASK_SIZE, MASK_SIZE);
228 ImageIcon downMark = IconsFactory.getIcon(null, collapsiblePaneMask, 0, 0, MASK_SIZE, MASK_SIZE);
229 uiDefaultsNormal = new Object[]{
230 "CollapsiblePane.contentBackground", new ColorUIResource(214, 223, 247),
231 "CollapsiblePanes.backgroundLt", new ColorUIResource(123, 162, 231),
232 "CollapsiblePanes.backgroundDk", new ColorUIResource(103, 125, 217),
233 "CollapsiblePaneTitlePane.backgroundLt", new ColorUIResource(255, 255, 255),
234 "CollapsiblePaneTitlePane.backgroundDk", new ColorUIResource(198, 211, 247),
235 "CollapsiblePaneTitlePane.foreground", new ColorUIResource(33, 93, 198),
236 "CollapsiblePaneTitlePane.foreground.focus", new ColorUIResource(65, 142, 254),
237 "CollapsiblePaneTitlePane.backgroundLt.emphasized", new ColorUIResource(0, 73, 181),
238 "CollapsiblePaneTitlePane.backgroundDk.emphasized", new ColorUIResource(41, 93, 206),
239
240 "CollapsiblePaneTitlePane.foreground.emphasized", new ColorUIResource(255, 255, 255),
241 "CollapsiblePaneTitlePane.foreground.focus.emphasized", new ColorUIResource(65, 142, 254),
242 "CollapsiblePane.downIcon", IconsFactory.getOverlayIcon(null, normalIcon, downMark, SwingConstants.CENTER),
243 "CollapsiblePane.upIcon", IconsFactory.getOverlayIcon(null, normalIcon, upMark, SwingConstants.CENTER),
244 "CollapsiblePane.downIcon.emphasized", IconsFactory.getOverlayIcon(null, emphasizedIcon, downMark, SwingConstants.CENTER),
245 "CollapsiblePane.upIcon.emphasized", IconsFactory.getOverlayIcon(null, emphasizedIcon, upMark, SwingConstants.CENTER),
246 "CollapsiblePane.upMask", upMark,
247 "CollapsiblePane.downMask", downMark,
248 "CollapsiblePane.titleButtonBackground", normalIcon,
249 "CollapsiblePane.titleButtonBackground.emphasized", emphasizedIcon,
250 };
251 _blueTheme.putDefaults(uiDefaultsNormal);
252 }
253
254 // green theme
255 Object uiDefaultsHomeStead[] = {
256 "control", new ColorUIResource(209, 222, 173),
257 "controlLt", new ColorUIResource(244, 247, 222),
258 "controlDk", new ColorUIResource(183, 198, 145),
259 "controlShadow", new ColorUIResource(96, 128, 88),
260
261 "TabbedPane.selectDk", new ColorUIResource(207, 114, 37),
262 "TabbedPane.selectLt", new ColorUIResource(227, 145, 79),
263
264 "OptionPane.bannerLt", new ColorUIResource(150, 185, 120),
265 "OptionPane.bannerDk", new ColorUIResource(179, 214, 149),
266 "OptionPane.bannerForeground", new ColorUIResource(255, 255, 255),
267
268 "Separator.foreground", new ColorUIResource(96, 128, 88),
269 "Separator.foregroundLt", new ColorUIResource(244, 247, 242),
270
271 "Gripper.foreground", new ColorUIResource(81, 94, 51),
272 "Gripper.foregroundLt", new ColorUIResource(255, 255, 255),
273
274 "Chevron.backgroundLt", new ColorUIResource(176, 194, 140),
275 "Chevron.backgroundDk", new ColorUIResource(96, 119, 107),
276
277 "Divider.backgroundLt", new ColorUIResource(120, 142, 111),
278 "Divider.backgroundDk", new ColorUIResource(73, 91, 67),
279
280 "backgroundLt", new ColorUIResource(242, 240, 228),
281 "backgroundDk", new ColorUIResource(217, 217, 167),
282
283 "selection.border", new ColorUIResource(63, 93, 56),
284
285 "MenuItem.background", new ColorUIResource(244, 244, 238),
286
287 "DockableFrameTitlePane.backgroundLt", new ColorUIResource(237, 242, 212),
288 "DockableFrameTitlePane.backgroundDk", new ColorUIResource(181, 196, 143),
289 "DockableFrameTitlePane.activeForeground", new ColorUIResource(0, 0, 0),
290 "DockableFrameTitlePane.inactiveForeground", new ColorUIResource(0, 0, 0),
291 "DockableFrame.backgroundLt", new ColorUIResource(243, 242, 231),
292 "DockableFrame.backgroundDk", new ColorUIResource(243, 242, 231),
293
294 "CommandBar.titleBarBackground", new ColorUIResource(116, 134, 94),
295
296 };
297 _homeSteadTheme.putDefaults(uiDefaultsHomeStead);
298
299 if ((products & LookAndFeelFactory.PRODUCT_COMPONENTS) != 0) {
300 ImageIcon collapsiblePaneImage = IconsFactory.getImageIcon(Office2003WindowsUtils.class, "icons/collapsible_pane_homestead.png"); // 20 x 20
301 ImageIcon collapsiblePaneMask = IconsFactory.getImageIcon(Office2003WindowsUtils.class, "icons/collapsible_pane_mask.png"); // 11 x 11
302 ImageIcon normalIcon = IconsFactory.getIcon(null, collapsiblePaneImage, 0, 0, SIZE, SIZE);
303 ImageIcon emphasizedIcon = IconsFactory.getIcon(null, collapsiblePaneImage, SIZE, 0, SIZE, SIZE);
304 ImageIcon downMark = IconsFactory.getIcon(null, collapsiblePaneMask, 0, 0, MASK_SIZE, MASK_SIZE);
305 ImageIcon upMark = IconsFactory.getIcon(null, collapsiblePaneMask, 0, MASK_SIZE, MASK_SIZE, MASK_SIZE);
306 uiDefaultsNormal = new Object[]{
307 "CollapsiblePane.contentBackground", new ColorUIResource(246, 246, 246),
308 "CollapsiblePanes.backgroundLt", new ColorUIResource(204, 217, 173),
309 "CollapsiblePanes.backgroundDk", new ColorUIResource(165, 189, 132),
310 "CollapsiblePaneTitlePane.backgroundLt", new ColorUIResource(254, 252, 236),
311 "CollapsiblePaneTitlePane.backgroundDk", new ColorUIResource(224, 231, 184),
312 "CollapsiblePaneTitlePane.foreground", new ColorUIResource(86, 102, 45),
313 "CollapsiblePaneTitlePane.foreground.focus", new ColorUIResource(114, 146, 29),
314 "CollapsiblePaneTitlePane.backgroundLt.emphasized", new ColorUIResource(119, 140, 64),
315 "CollapsiblePaneTitlePane.backgroundDk.emphasized", new ColorUIResource(150, 168, 103),
316 "CollapsiblePaneTitlePane.foreground.emphasized", new ColorUIResource(255, 255, 255),
317 "CollapsiblePaneTitlePane.foreground.focus.emphasized", new ColorUIResource(224, 231, 151),
318 "CollapsiblePane.downIcon", IconsFactory.getOverlayIcon(null, normalIcon, downMark, SwingConstants.CENTER),
319 "CollapsiblePane.upIcon", IconsFactory.getOverlayIcon(null, normalIcon, upMark, SwingConstants.CENTER),
320 "CollapsiblePane.downIcon.emphasized", IconsFactory.getOverlayIcon(null, emphasizedIcon, downMark, SwingConstants.CENTER),
321 "CollapsiblePane.upIcon.emphasized", IconsFactory.getOverlayIcon(null, emphasizedIcon, upMark, SwingConstants.CENTER),
322 "CollapsiblePane.upMask", upMark,
323 "CollapsiblePane.downMask", downMark,
324 "CollapsiblePane.titleButtonBackground", normalIcon,
325 "CollapsiblePane.titleButtonBackground.emphasized", emphasizedIcon,
326 };
327 _homeSteadTheme.putDefaults(uiDefaultsNormal);
328 }
329
330 Object uiDefaultsMetallic[] = {
331 "control", new ColorUIResource(219, 218, 228),
332 "controlLt", new ColorUIResource(243, 244, 250),
333 "controlDk", new ColorUIResource(153, 151, 181),
334 "controlShadow", new ColorUIResource(124, 124, 148),
335
336 "TabbedPane.selectDk", new ColorUIResource(230, 139, 44),
337 "TabbedPane.selectLt", new ColorUIResource(255, 200, 60),
338
339 "OptionPane.bannerLt", new ColorUIResource(181, 195, 222),
340 "OptionPane.bannerDk", new ColorUIResource(120, 140, 167),
341 "OptionPane.bannerForeground", new ColorUIResource(255, 255, 255),
342
343 "Separator.foreground", new ColorUIResource(110, 109, 143),
344 "Separator.foregroundLt", new ColorUIResource(255, 255, 255),
345
346 "Gripper.foreground", new ColorUIResource(84, 84, 117),
347 "Gripper.foregroundLt", new ColorUIResource(255, 255, 255),
348
349 "Chevron.backgroundLt", new ColorUIResource(179, 178, 200),
350 "Chevron.backgroundDk", new ColorUIResource(118, 116, 146),
351
352 "Divider.backgroundLt", new ColorUIResource(168, 167, 191),
353 "Divider.backgroundDk", new ColorUIResource(119, 118, 151),
354
355 "backgroundLt", new ColorUIResource(243, 243, 247),
356 "backgroundDk", new ColorUIResource(215, 215, 229),
357
358 "selection.border", new ColorUIResource(75, 75, 111),
359
360 "MenuItem.background", new ColorUIResource(253, 250, 255),
361
362 "DockableFrameTitlePane.backgroundLt", new ColorUIResource(240, 240, 248),
363 "DockableFrameTitlePane.backgroundDk", new ColorUIResource(147, 145, 176),
364 "DockableFrameTitlePane.activeForeground", new ColorUIResource(0, 0, 0),
365 "DockableFrameTitlePane.inactiveForeground", new ColorUIResource(0, 0, 0),
366 "DockableFrame.backgroundLt", new ColorUIResource(238, 238, 244),
367 "DockableFrame.backgroundDk", new ColorUIResource(238, 238, 244),
368
369 "CommandBar.titleBarBackground", new ColorUIResource(122, 121, 153),
370 };
371 _metallicTheme.putDefaults(uiDefaultsMetallic);
372
373 if ((products & LookAndFeelFactory.PRODUCT_COMPONENTS) != 0) {
374 ImageIcon collapsiblePaneImage = IconsFactory.getImageIcon(Office2003WindowsUtils.class, "icons/collapsible_pane_metallic.png"); // 20 x 20
375 ImageIcon collapsiblePaneMask = IconsFactory.getImageIcon(Office2003WindowsUtils.class, "icons/collapsible_pane_mask.png"); // 11 x 11
376 ImageIcon normalIcon = IconsFactory.getIcon(null, collapsiblePaneImage, 0, 0, SIZE, SIZE);
377 ImageIcon emphasizedIcon = IconsFactory.getIcon(null, collapsiblePaneImage, SIZE, 0, SIZE, SIZE);
378 ImageIcon downMark = IconsFactory.getIcon(null, collapsiblePaneMask, 0, 0, MASK_SIZE, MASK_SIZE);
379 ImageIcon upMark = IconsFactory.getIcon(null, collapsiblePaneMask, 0, MASK_SIZE, MASK_SIZE, MASK_SIZE);
380 uiDefaultsNormal = new Object[]{
381 "CollapsiblePane.contentBackground", new ColorUIResource(240, 241, 245),
382 "CollapsiblePanes.backgroundLt", new ColorUIResource(196, 200, 212),
383 "CollapsiblePanes.backgroundDk", new ColorUIResource(177, 179, 200),
384 "CollapsiblePaneTitlePane.backgroundLt", new ColorUIResource(255, 255, 255),
385 "CollapsiblePaneTitlePane.backgroundDk", new ColorUIResource(214, 215, 224),
386 "CollapsiblePaneTitlePane.foreground", new ColorUIResource(63, 61, 61),
387 "CollapsiblePaneTitlePane.foreground.focus", new ColorUIResource(126, 124, 124),
388 "CollapsiblePaneTitlePane.backgroundLt.emphasized", new ColorUIResource(119, 119, 145),
389 "CollapsiblePaneTitlePane.backgroundDk.emphasized", new ColorUIResource(180, 182, 199),
390 "CollapsiblePaneTitlePane.foreground.emphasized", new ColorUIResource(255, 255, 255),
391 "CollapsiblePaneTitlePane.foreground.focus.emphasized", new ColorUIResource(230, 230, 230),
392
393 "CollapsiblePane.downIcon", IconsFactory.getOverlayIcon(null, normalIcon, downMark, SwingConstants.CENTER),
394 "CollapsiblePane.upIcon", IconsFactory.getOverlayIcon(null, normalIcon, upMark, SwingConstants.CENTER),
395 "CollapsiblePane.downIcon.emphasized", IconsFactory.getOverlayIcon(null, emphasizedIcon, downMark, SwingConstants.CENTER),
396 "CollapsiblePane.upIcon.emphasized", IconsFactory.getOverlayIcon(null, emphasizedIcon, upMark, SwingConstants.CENTER),
397 "CollapsiblePane.upMask", upMark,
398 "CollapsiblePane.downMask", downMark,
399 "CollapsiblePane.titleButtonBackground", normalIcon,
400 "CollapsiblePane.titleButtonBackground.emphasized", emphasizedIcon,
401 };
402 _metallicTheme.putDefaults(uiDefaultsNormal);
403 }
404 }
405
406 protected Office2003Painter() {
407 }
408
409 public void addTheme(Office2003Theme theme) {
410 _themeCache.put(theme.getThemeName(), theme);
411 }
412
413 public Office2003Theme getTheme(String themeName) {
414 return _themeCache.get(themeName);
415 }
416
417 public void removeTheme(String themeName) {
418 _themeCache.remove(themeName);
419 }
420
421 public Collection<Office2003Theme> getAvailableThemes() {
422 return _themeCache.values();
423 }
424
425 @Override
426 public void installDefaults() {
427 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
428 if (highContrast) {
429 super.installDefaults();
430 }
431 }
432
433 @Override
434 public void uninstallDefaults() {
435 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
436 if (highContrast) {
437 super.uninstallDefaults();
438 }
439 }
440
441 public String getColorName() {
442 return _colorName;
443 }
444
445 public void setColorName(String colorName) {
446 _colorName = colorName;
447 }
448
449 public static boolean isNative() {
450 return _native;
451 }
452
453 public static void setNative(boolean aNative) {
454 _native = aNative;
455 }
456
457 public Office2003Theme getCurrentTheme() {
458 if (getColorName() == null || getColorName().trim().length() == 0 || _themeCache.get(getColorName()) == null) {
459 return _themeCache.get(XPUtils.DEFAULT);
460 }
461 else {
462 return _themeCache.get(getColorName());
463 }
464 }
465
466 @Override
467 public void paintButtonBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state, boolean showBorder) {
468 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
469 if (highContrast) {
470 super.paintButtonBackground(c, g, rect, orientation, state, showBorder);
471 return;
472 }
473
474 Color startColor = null;
475 Color endColor = null;
476 Color background = null;
477 switch (state) {
478 case STATE_DEFAULT:
479 background = c.getBackground();
480 if (!(background instanceof UIResource)) {
481 startColor = ColorUtils.getDerivedColor(background, 0.6f);
482 endColor = ColorUtils.getDerivedColor(background, 0.4f);
483 showBorder = false;
484 }
485 else {
486 startColor = getCurrentTheme().getColor("controlLt");
487 endColor = getCurrentTheme().getColor("controlDk");
488 }
489
490 break;
491 case STATE_ROLLOVER:
492 if (c instanceof ComponentStateSupport) {
493 background = ((ComponentStateSupport) c).getBackgroundOfState(state);
494 }
495 if (background != null && !(background instanceof UIResource)) {
496 startColor = ColorUtils.getDerivedColor(background, 0.6f);
497 endColor = ColorUtils.getDerivedColor(background, 0.4f);
498 }
499 else {
500 startColor = getCurrentTheme().getColor("selection.RolloverLt");
501 endColor = getCurrentTheme().getColor("selection.RolloverDk");
502 }
503 break;
504 case STATE_SELECTED:
505 if (c instanceof ComponentStateSupport) {
506 background = ((ComponentStateSupport) c).getBackgroundOfState(state);
507 }
508 if (background != null && !(background instanceof UIResource)) {
509 startColor = ColorUtils.getDerivedColor(background, 0.6f);
510 endColor = ColorUtils.getDerivedColor(background, 0.4f);
511 }
512 else {
513 startColor = getCurrentTheme().getColor("selection.SelectedLt");
514 endColor = getCurrentTheme().getColor("selection.SelectedDk");
515 }
516 break;
517 case STATE_DISABLE_SELECTED:
518 if (c instanceof ComponentStateSupport) {
519 background = ((ComponentStateSupport) c).getBackgroundOfState(state);
520 }
521 if (background != null && !(background instanceof UIResource)) {
522 startColor = ColorUtils.toGrayscale(ColorUtils.getDerivedColor(background, 0.6f));
523 endColor = ColorUtils.toGrayscale(ColorUtils.getDerivedColor(background, 0.4f));
524 }
525 else {
526 startColor = ColorUtils.toGrayscale(getCurrentTheme().getColor("selection.SelectedLt"));
527 endColor = ColorUtils.toGrayscale(getCurrentTheme().getColor("selection.SelectedDk"));
528 }
529 break;
530 case STATE_PRESSED:
531 if (c instanceof ComponentStateSupport) {
532 background = ((ComponentStateSupport) c).getBackgroundOfState(state);
533 }
534 if (background != null && !(background instanceof UIResource)) {
535 startColor = ColorUtils.getDerivedColor(background, 0.4f);
536 endColor = ColorUtils.getDerivedColor(background, 0.6f);
537 }
538 else {
539 startColor = getCurrentTheme().getColor("selection.PressedDk");
540 endColor = getCurrentTheme().getColor("selection.PressedLt");
541 }
542 break;
543 }
544
545 if (startColor != null && endColor != null) {
546 paintBackground(c, (Graphics2D) g, rect, showBorder ? getCurrentTheme().getColor("selection.border") : null, startColor, endColor, orientation);
547 }
548 }
549
550 protected void paintBackground(JComponent c, Graphics2D g2d, Rectangle rect, Color borderColor, Color startColor, Color endColor, int orientation) {
551 if (borderColor != null) {
552 if (startColor != null && endColor != null) {
553 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x, rect.y, rect.width, rect.height), startColor, endColor, orientation == SwingConstants.HORIZONTAL);
554 }
555 boolean paintDefaultBorder = true;
556 Object o = c.getClientProperty("JideButton.paintDefaultBorder");
557 if (o instanceof Boolean) {
558 paintDefaultBorder = (Boolean) o;
559 }
560 if (paintDefaultBorder) {
561 Color oldColor = g2d.getColor();
562 g2d.setColor(borderColor);
563 Object position = c.getClientProperty(JideButton.CLIENT_PROPERTY_SEGMENT_POSITION);
564 if (position == null || JideButton.SEGMENT_POSITION_ONLY.equals(position)) {
565 g2d.drawRect(rect.x, rect.y, rect.width - 1, rect.height - 1);
566 }
567 else if (JideButton.SEGMENT_POSITION_FIRST.equals(position)) {
568 if (orientation == SwingConstants.HORIZONTAL) {
569 g2d.drawRect(rect.x, rect.y, rect.width, rect.height - 1);
570 }
571 else {
572 g2d.drawRect(rect.x, rect.y, rect.width - 1, rect.height);
573 }
574 }
575 else if (JideButton.SEGMENT_POSITION_MIDDLE.equals(position)) {
576 if (orientation == SwingConstants.HORIZONTAL) {
577 g2d.drawRect(rect.x, rect.y, rect.width, rect.height - 1);
578 }
579 else {
580 g2d.drawRect(rect.x, rect.y, rect.width - 1, rect.height);
581 }
582 }
583 else if (JideButton.SEGMENT_POSITION_LAST.equals(position)) {
584 if (orientation == SwingConstants.HORIZONTAL) {
585 g2d.drawRect(rect.x, rect.y, rect.width - 1, rect.height - 1);
586 }
587 else {
588 g2d.drawRect(rect.x, rect.y, rect.width - 1, rect.height - 1);
589 }
590 }
591 g2d.setColor(oldColor);
592 }
593 }
594 else {
595 if (startColor != null && endColor != null) {
596 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x, rect.y, rect.width, rect.height), startColor, endColor, orientation == SwingConstants.HORIZONTAL);
597 }
598 }
599 }
600
601 @Override
602 public void paintChevronBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
603 Graphics2D g2d = (Graphics2D) g;
604 if (state == STATE_DEFAULT) {
605 paintChevron(c, g2d, getCurrentTheme().getColor("Chevron.backgroundLt"), getCurrentTheme().getColor("Chevron.backgroundDk"), rect, orientation);
606 }
607 else if (state == STATE_ROLLOVER) {
608 paintChevron(c, g2d, getCurrentTheme().getColor("selection.RolloverLt"), getCurrentTheme().getColor("selection.RolloverDk"), rect, orientation);
609 }
610 else if (state == STATE_SELECTED) {
611 paintChevron(c, g2d, getCurrentTheme().getColor("selection.SelectedDk"), getCurrentTheme().getColor("selection.SelectedLt"), rect, orientation);
612 }
613 else if (state == STATE_PRESSED) {
614 paintChevron(c, g2d, getCurrentTheme().getColor("selection.PressedDk"), getCurrentTheme().getColor("selection.PressedLt"), rect, orientation);
615 }
616 }
617
618 @Override
619 public void paintDividerBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
620 Graphics2D g2d = (Graphics2D) g;
621 JideSwingUtilities.fillGradient(g2d, rect,
622 getCurrentTheme().getColor("Divider.backgroundLt"), getCurrentTheme().getColor("Divider.backgroundDk"), true);
623 }
624
625 protected void paintChevron(JComponent c, Graphics2D g2d, Color color1, Color color2, Rectangle rect, int orientation) {
626 if (orientation == SwingConstants.HORIZONTAL) {
627 // don't use fast gradient painter as it has some problem
628 if (!c.getComponentOrientation().isLeftToRight()) {
629 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x, rect.y + 2, rect.width - 2, rect.height - 4), color1, color2, true);
630 g2d.setColor(color1);
631 g2d.drawLine(rect.x + 2, rect.y, rect.x + rect.width - 1, rect.y);
632 g2d.drawLine(rect.x + 1, rect.y + 1, rect.x + rect.width - 2, rect.y + 1);
633 g2d.setColor(color2);
634 g2d.drawLine(rect.x + 1, rect.y + rect.height - 2, rect.x + rect.width - 2, rect.y + rect.height - 2);
635 g2d.drawLine(rect.x + 2, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1);
636 }
637 else {
638 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x + 2, rect.y + 2, rect.width - 2, rect.height - 4), color1, color2, true);
639 g2d.setColor(color1);
640 g2d.drawLine(rect.x, rect.y, rect.x + rect.width - 3, rect.y);
641 g2d.drawLine(rect.x + 1, rect.y + 1, rect.x + rect.width - 2, rect.y + 1);
642 g2d.setColor(color2);
643 g2d.drawLine(rect.x + 1, rect.y + rect.height - 2, rect.x + rect.width - 2, rect.y + rect.height - 2);
644 g2d.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 3, rect.y + rect.height - 1);
645 }
646 }
647 else {
648 // don't use fast gradient painter as it has some problem
649 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 2), color1, color2, false);
650 g2d.setColor(color1);
651 g2d.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height - 3);
652 g2d.drawLine(rect.x + 1, rect.y + 1, rect.x + 1, rect.y + rect.height - 2);
653 g2d.setColor(color2);
654 g2d.drawLine(rect.x + rect.width - 2, rect.y + 1, rect.x + rect.width - 2, rect.y + rect.height - 2);
655 g2d.drawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.y + rect.height - 3);
656 }
657 }
658
659 @Override
660 public Color getColor(Object key) {
661 return getCurrentTheme().getColor(key);
662 }
663
664 @Override
665 public void paintCommandBarBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
666 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
667 if (highContrast) {
668 super.paintCommandBarBackground(c, g, rect, orientation, state);
669 return;
670 }
671
672 Graphics2D g2d = (Graphics2D) g;
673 JideSwingUtilities.fillGradient(g2d, new RoundRectangle2D.Float(rect.x, rect.y, rect.width, rect.height, 4, 4),
674 getCurrentTheme().getColor("controlLt"), getCurrentTheme().getColor("controlDk"), orientation == SwingConstants.HORIZONTAL);
675 g2d.setColor(getCurrentTheme().getColor("controlShadow"));
676 if (orientation == SwingConstants.HORIZONTAL) {
677 g2d.drawLine(rect.x + 2, rect.y + rect.height - 1, rect.x + rect.width - 3, rect.y + rect.height - 1);
678 }
679 else {
680 g2d.drawLine(rect.x + rect.width - 1, rect.y + 2, rect.x + rect.width - 1, rect.y + rect.height - 3);
681 }
682 }
683
684 @Override
685 public void paintFloatingCommandBarBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
686 Graphics2D g2d = (Graphics2D) g;
687 JideSwingUtilities.fillGradient(g2d, rect,
688 getCurrentTheme().getColor("controlLt"), getCurrentTheme().getColor("controlDk"), orientation == SwingConstants.HORIZONTAL);
689 }
690
691 @Override
692 public void paintMenuShadow(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
693 Graphics2D g2d = (Graphics2D) g;
694 if (c.getComponentOrientation().isLeftToRight()) {
695 JideSwingUtilities.fillGradient(g2d, rect, getCurrentTheme().getColor("controlLt"), getCurrentTheme().getColor("controlDk"), orientation != SwingConstants.HORIZONTAL);
696 }
697 else {
698 JideSwingUtilities.fillGradient(g2d, rect, getCurrentTheme().getColor("controlDk"), getCurrentTheme().getColor("controlLt"), orientation != SwingConstants.HORIZONTAL);
699 }
700 }
701
702 @Override
703 public Color getControl() {
704 return getCurrentTheme().getColor("control");
705 }
706
707 @Override
708 public Color getControlLt() {
709 return getCurrentTheme().getColor("controlLt");
710 }
711
712 @Override
713 public Color getControlDk() {
714 return getCurrentTheme().getColor("controlDk");
715 }
716
717 @Override
718 public Color getControlShadow() {
719 return getCurrentTheme().getColor("controlShadow");
720 }
721
722 @Override
723 public Color getGripperForeground() {
724 return getCurrentTheme().getColor("Gripper.foreground");
725 }
726
727 @Override
728 public Color getGripperForegroundLt() {
729 return getCurrentTheme().getColor("Gripper.foregroundLt");
730 }
731
732 @Override
733 public Color getSeparatorForeground() {
734 return getCurrentTheme().getColor("Separator.foreground");
735 }
736
737 @Override
738 public Color getSeparatorForegroundLt() {
739 return getCurrentTheme().getColor("Separator.foregroundLt");
740 }
741
742 @Override
743 public Color getCollapsiblePaneContentBackground() {
744 return getCurrentTheme().getColor("CollapsiblePane.contentBackground");
745 }
746
747 @Override
748 public Color getCollapsiblePaneTitleForeground() {
749 return getCurrentTheme().getColor("CollapsiblePaneTitlePane.foreground");
750 }
751
752 @Override
753 public Color getCollapsiblePaneFocusTitleForeground() {
754 return getCurrentTheme().getColor("CollapsiblePaneTitlePane.foreground.focus");
755 }
756
757 @Override
758 public Color getCollapsiblePaneTitleForegroundEmphasized() {
759 return getCurrentTheme().getColor("CollapsiblePaneTitlePane.foreground.emphasized");
760 }
761
762 @Override
763 public Color getCollapsiblePaneFocusTitleForegroundEmphasized() {
764 return getCurrentTheme().getColor("CollapsiblePaneTitlePane.foreground.focus.emphasized");
765 }
766
767 @Override
768 public ImageIcon getCollapsiblePaneUpIcon() {
769 return (ImageIcon) getCurrentTheme().getIcon("CollapsiblePane.upIcon");
770 }
771
772 @Override
773 public ImageIcon getCollapsiblePaneDownIcon() {
774 return (ImageIcon) getCurrentTheme().getIcon("CollapsiblePane.downIcon");
775 }
776
777 @Override
778 public ImageIcon getCollapsiblePaneUpIconEmphasized() {
779 return (ImageIcon) getCurrentTheme().getIcon("CollapsiblePane.upIcon.emphasized");
780 }
781
782 @Override
783 public ImageIcon getCollapsiblePaneDownIconEmphasized() {
784 return (ImageIcon) getCurrentTheme().getIcon("CollapsiblePane.downIcon.emphasized");
785 }
786
787 @Override
788 public ImageIcon getCollapsiblePaneTitleButtonBackground() {
789 return (ImageIcon) getCurrentTheme().getIcon("CollapsiblePane.titleButtonBackground");
790 }
791
792 @Override
793 public ImageIcon getCollapsiblePaneTitleButtonBackgroundEmphasized() {
794 return (ImageIcon) getCurrentTheme().getIcon("CollapsiblePane.titleButtonBackground.emphasized");
795 }
796
797 @Override
798 public ImageIcon getCollapsiblePaneUpMask() {
799 return (ImageIcon) getCurrentTheme().getIcon("CollapsiblePane.upMask");
800 }
801
802 @Override
803 public ImageIcon getCollapsiblePaneDownMask() {
804 return (ImageIcon) getCurrentTheme().getIcon("CollapsiblePane.downMask");
805 }
806
807 @Override
808 public Color getBackgroundDk() {
809 return getCurrentTheme().getColor("backgroundDk");
810 }
811
812 @Override
813 public Color getBackgroundLt() {
814 return getCurrentTheme().getColor("backgroundLt");
815 }
816
817 @Override
818 public Color getSelectionSelectedDk() {
819 return getCurrentTheme().getColor("selection.SelectedDk");
820 }
821
822 @Override
823 public Color getSelectionSelectedLt() {
824 return getCurrentTheme().getColor("selection.SelectedLt");
825 }
826
827 @Override
828 public Color getMenuItemBorderColor() {
829 return getCurrentTheme().getColor("selection.border");
830 }
831
832 @Override
833 public Color getMenuItemBackground() {
834 return getCurrentTheme().getColor("MenuItem.background");
835 }
836
837 @Override
838 public Color getCommandBarTitleBarBackground() {
839 return getCurrentTheme().getColor("CommandBar.titleBarBackground");
840 }
841
842 @Override
843 public Color getDockableFrameTitleBarActiveForeground() {
844 return getCurrentTheme().getColor("DockableFrameTitlePane.activeForeground");
845 }
846
847 @Override
848 public Color getDockableFrameTitleBarInactiveForeground() {
849 return getCurrentTheme().getColor("DockableFrameTitlePane.inactiveForeground");
850 }
851
852 @Override
853 public Color getTitleBarBackground() {
854 return getCurrentTheme().getColor("DockableFrameTitlePane.backgroundDk");
855 }
856
857 @Override
858 public Color getOptionPaneBannerForeground() {
859 return getCurrentTheme().getColor("OptionPane.bannerForeground");
860 }
861
862 @Override
863 public Color getTabbedPaneSelectDk() {
864 return getCurrentTheme().getColor("TabbedPane.selectDk");
865 }
866
867 @Override
868 public Color getTabbedPaneSelectLt() {
869 return getCurrentTheme().getColor("TabbedPane.selectLt");
870 }
871
872 @Override
873 public Color getOptionPaneBannerDk() {
874 return getCurrentTheme().getColor("OptionPane.bannerDk");
875 }
876
877 @Override
878 public Color getOptionPaneBannerLt() {
879 return getCurrentTheme().getColor("OptionPane.bannerLt");
880 }
881
882 @Override
883 public void paintContentBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
884 Graphics2D g2d = (Graphics2D) g;
885 JideSwingUtilities.fillGradient(g2d, rect, getBackgroundDk(), getBackgroundLt(), false);
886 }
887
888 @Override
889 public void paintGripper(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
890 if (rect.width > 30) {
891 orientation = SwingConstants.VERTICAL;
892 }
893 else if (rect.height > 30) {
894 orientation = SwingConstants.HORIZONTAL;
895 }
896
897 int h = (orientation == SwingConstants.HORIZONTAL) ? rect.height : rect.width;
898 int count = Math.min(9, (h - 6) / 4);
899 int y = rect.y;
900 int x = rect.x;
901
902 if (orientation == SwingConstants.HORIZONTAL) {
903 y += rect.height / 2 - count * 2;
904 x += rect.width / 2 - 1;
905 }
906 else {
907 x += rect.width / 2 - count * 2;
908 y += rect.height / 2 - 1;
909 }
910
911 for (int i = 0; i < count; i++) {
912 g.setColor(getGripperForegroundLt());
913 g.fillRect(x + 1, y + 1, 2, 2);
914 g.setColor(getGripperForeground());
915 g.fillRect(x, y, 2, 2);
916 if (orientation == SwingConstants.HORIZONTAL) {
917 y += 4;
918 }
919 else {
920 x += 4;
921 }
922 }
923 }
924
925 @Override
926 public void paintChevronMore(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
927 int startX = rect.x + 4;
928 int startY = rect.x + 5;
929
930 int oppositeOrientation = orientation == SwingConstants.HORIZONTAL ? SwingConstants.VERTICAL : SwingConstants.HORIZONTAL;
931
932 if (orientation == SwingConstants.HORIZONTAL) {
933 if (!c.getComponentOrientation().isLeftToRight()) {
934 startX = rect.width - 8;
935 startX--;
936 startY++;
937 JideSwingUtilities.paintArrow(c, g, Color.WHITE, startX, startY, 3, oppositeOrientation);
938 startX -= 4;
939 JideSwingUtilities.paintArrow(c, g, Color.WHITE, startX, startY, 3, oppositeOrientation);
940 startX++;
941 startX += 4;
942 startY--;
943 JideSwingUtilities.paintArrow(c, g, Color.BLACK, startX, startY, 3, oppositeOrientation);
944 startX -= 4;
945 JideSwingUtilities.paintArrow(c, g, Color.BLACK, startX, startY, 3, oppositeOrientation);
946 }
947 else {
948 startX++;
949 startY++;
950 JideSwingUtilities.paintArrow(g, Color.WHITE, startX, startY, 3, oppositeOrientation);
951 startX += 4;
952 JideSwingUtilities.paintArrow(g, Color.WHITE, startX, startY, 3, oppositeOrientation);
953 startX--;
954 startX -= 4;
955 startY--;
956 JideSwingUtilities.paintArrow(g, Color.BLACK, startX, startY, 3, oppositeOrientation);
957 startX += 4;
958 JideSwingUtilities.paintArrow(g, Color.BLACK, startX, startY, 3, oppositeOrientation);
959 }
960 }
961 else if (orientation == SwingConstants.VERTICAL) {
962 startX++;
963 startY++;
964 JideSwingUtilities.paintArrow(g, Color.WHITE, startX, startY, 3, oppositeOrientation);
965 startY += 4;
966 JideSwingUtilities.paintArrow(g, Color.WHITE, startX, startY, 3, oppositeOrientation);
967 startX--;
968 startY--;
969 startY -= 4;
970 JideSwingUtilities.paintArrow(g, Color.BLACK, startX, startY, 3, oppositeOrientation);
971 startY += 4;
972 JideSwingUtilities.paintArrow(g, Color.BLACK, startX, startY, 3, oppositeOrientation);
973 }
974 }
975
976 @Override
977 public void paintChevronOption(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
978 int startX;
979 int startY;
980 if (orientation == SwingConstants.HORIZONTAL) {
981 if (!c.getComponentOrientation().isLeftToRight()) {
982 startX = rect.x + 2;
983 startY = rect.y + rect.height - 10;
984 }
985 else {
986 startX = rect.x + rect.width - 8;
987 startY = rect.y + rect.height - 10;
988 }
989 }
990 else if (orientation == SwingConstants.VERTICAL) {
991 startX = rect.x + rect.width - 10;
992 startY = rect.y + rect.height - 8;
993 }
994 else {
995 return;
996 }
997
998 startX++;
999 startY++;
1000 g.setColor(Color.WHITE);
1001 paintDown(g, startX, startY, orientation);
1002
1003 startX--;
1004 startY--;
1005 g.setColor(Color.BLACK);
1006 paintDown(g, startX, startY, orientation);
1007 }
1008
1009 private void paintDown(Graphics g, int startX, int startY, int orientation) {
1010 if (orientation == SwingConstants.HORIZONTAL) {
1011 g.drawLine(startX, startY, startX + 4, startY);
1012 JideSwingUtilities.paintArrow(g, g.getColor(), startX, startY + 3, 5, SwingConstants.HORIZONTAL);
1013 }
1014 else {
1015 g.drawLine(startX, startY, startX, startY + 4);
1016 JideSwingUtilities.paintArrow(g, g.getColor(), startX + 3, startY, 5, orientation);
1017 }
1018 }
1019
1020 @Override
1021 public void paintDockableFrameBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1022 if (!c.isOpaque()) {
1023 return;
1024 }
1025 Graphics2D g2d = (Graphics2D) g;
1026 JideSwingUtilities.fillGradient(g2d,
1027 new Rectangle(rect.x, rect.y, rect.width, rect.height),
1028 getCurrentTheme().getColor("DockableFrame.backgroundLt"),
1029 getCurrentTheme().getColor("DockableFrame.backgroundDk"),
1030 orientation == SwingConstants.HORIZONTAL);
1031 }
1032
1033 @Override
1034 public void paintDockableFrameTitlePane(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1035 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
1036 if (highContrast) {
1037 super.paintDockableFrameTitlePane(c, g, rect, orientation, state);
1038 return;
1039 }
1040
1041 int x = rect.x;
1042 int y = rect.y;
1043 int w = rect.width;
1044 int h = rect.height;
1045 if (c.getBorder() != null) {
1046 Insets insets = c.getBorder().getBorderInsets(c);
1047 x += insets.left;
1048 y += insets.top;
1049 w -= insets.right + insets.left;
1050 h -= insets.top + insets.bottom;
1051 }
1052 rect = new Rectangle(x, y, w, h);
1053
1054 boolean active = state == STATE_SELECTED;
1055 Graphics2D g2d = (Graphics2D) g;
1056 JideSwingUtilities.fillGradient(g2d, rect,
1057 active ? getCurrentTheme().getColor("selection.SelectedLt") : getCurrentTheme().getColor("DockableFrameTitlePane.backgroundLt"),
1058 active ? getCurrentTheme().getColor("selection.SelectedDk") : getCurrentTheme().getColor("DockableFrameTitlePane.backgroundDk"),
1059 orientation == SwingConstants.HORIZONTAL);
1060 }
1061
1062 private void paintCollapsiblePaneTitlePane(Graphics2D g2d, Color colorLt, Color colorDk, int orientation, Rectangle rect) {
1063 Color old = g2d.getColor();
1064 g2d.setColor(colorLt);
1065 switch (orientation) {
1066 case SwingConstants.EAST:
1067 g2d.drawLine(rect.x + 2, rect.y, rect.x + rect.width - 1, rect.y);
1068 g2d.drawLine(rect.x + 1, rect.y + 1, rect.x + rect.width - 1, rect.y + 1);
1069 JideSwingUtilities.fillGradient(g2d,
1070 new Rectangle(rect.x, rect.y + 2, rect.width, rect.height - 4),
1071 colorLt,
1072 colorDk,
1073 true);
1074 g2d.setColor(colorDk);
1075 g2d.drawLine(rect.x + 1, rect.y + rect.height - 2, rect.x + rect.width - 1, rect.y + rect.height - 2);
1076 g2d.drawLine(rect.x + 2, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1);
1077 break;
1078 case SwingConstants.WEST:
1079 g2d.drawLine(rect.x, rect.y, rect.x + rect.width - 3, rect.y);
1080 g2d.drawLine(rect.x, rect.y + 1, rect.x + rect.width - 1, rect.y + 1);
1081 JideSwingUtilities.fillGradient(g2d,
1082 new Rectangle(rect.x, rect.y + 2, rect.width, rect.height - 4),
1083 colorLt,
1084 colorDk,
1085 true);
1086 g2d.setColor(colorDk);
1087 g2d.drawLine(rect.x, rect.y + rect.height - 2, rect.x + rect.width - 1, rect.y + rect.height - 2);
1088 g2d.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 2, rect.y + rect.height - 1);
1089 break;
1090 case SwingConstants.NORTH:
1091 g2d.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height - 2);
1092 g2d.drawLine(rect.x + 1, rect.y, rect.x + 1, rect.y + rect.height - 1);
1093 JideSwingUtilities.fillGradient(g2d,
1094 new Rectangle(rect.x + 2, rect.y, rect.width - 4, rect.height),
1095 colorLt,
1096 colorDk,
1097 false);
1098 g2d.setColor(colorDk);
1099 g2d.drawLine(rect.x + rect.width - 2, rect.y, rect.x + rect.width - 2, rect.y + rect.height - 1);
1100 g2d.drawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.y + rect.height - 2);
1101 break;
1102 case SwingConstants.SOUTH:
1103 g2d.drawLine(rect.x, rect.y + 2, rect.x, rect.y + rect.height - 1);
1104 g2d.drawLine(rect.x + 1, rect.y + 1, rect.x + 1, rect.y + rect.height - 1);
1105 JideSwingUtilities.fillGradient(g2d,
1106 new Rectangle(rect.x + 2, rect.y, rect.width - 4, rect.height),
1107 colorLt,
1108 colorDk,
1109 false);
1110 g2d.setColor(colorDk);
1111 g2d.drawLine(rect.x + rect.width - 2, rect.y + 1, rect.x + rect.width - 2, rect.y + rect.height - 1);
1112 g2d.drawLine(rect.x + rect.width - 1, rect.y + 2, rect.x + rect.width - 1, rect.y + rect.height - 1);
1113 break;
1114 }
1115 g2d.setColor(old);
1116 }
1117
1118 @Override
1119 public void paintCollapsiblePaneTitlePaneBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1120 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
1121 if (highContrast) {
1122 super.paintCollapsiblePaneTitlePaneBackground(c, g, rect, orientation, state);
1123 return;
1124 }
1125 Graphics2D g2d = (Graphics2D) g;
1126 Color background = c.getBackground();
1127 Color colorLt;
1128 Color colorDk;
1129 if (!(background instanceof UIResource)) {
1130 colorLt = ColorUtils.getDerivedColor(background, 0.6f);
1131 colorDk = ColorUtils.getDerivedColor(background, 0.5f);
1132 }
1133 else {
1134 colorLt = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundLt");
1135 colorDk = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundDk");
1136 }
1137 paintCollapsiblePaneTitlePane(g2d, colorLt, colorDk, orientation, rect);
1138 }
1139
1140
1141 @Override
1142 public void paintCollapsiblePaneTitlePaneBackgroundEmphasized(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1143 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
1144 if (highContrast) {
1145 super.paintCollapsiblePaneTitlePaneBackgroundEmphasized(c, g, rect, orientation, state);
1146 return;
1147 }
1148 Graphics2D g2d = (Graphics2D) g;
1149 Color background = c.getBackground();
1150 Color colorLt;
1151 Color colorDk;
1152 if (!(background instanceof UIResource)) {
1153 colorLt = ColorUtils.getDerivedColor(background, 0.5f);
1154 colorDk = ColorUtils.getDerivedColor(background, 0.4f);
1155 }
1156 else {
1157 colorLt = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundLt.emphasized");
1158 colorDk = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundDk.emphasized");
1159 }
1160 paintCollapsiblePaneTitlePane(g2d, colorLt, colorDk, orientation, rect);
1161 }
1162
1163 @Override
1164 public void paintCollapsiblePanesBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1165 if (!c.isOpaque()) {
1166 return;
1167 }
1168 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
1169 if (highContrast) {
1170 super.paintCollapsiblePanesBackground(c, g, rect, orientation, state);
1171 return;
1172 }
1173 Graphics2D g2d = (Graphics2D) g;
1174 if (!(c.getBackground() instanceof UIResource)) {
1175 JideSwingUtilities.fillGradient(g2d,
1176 new Rectangle(rect.x, rect.y, rect.width, rect.height),
1177 ColorUtils.getDerivedColor(c.getBackground(), 0.6f),
1178 c.getBackground(),
1179 orientation == SwingConstants.HORIZONTAL);
1180 }
1181 else {
1182 JideSwingUtilities.fillGradient(g2d,
1183 new Rectangle(rect.x, rect.y, rect.width, rect.height),
1184 getCurrentTheme().getColor("CollapsiblePanes.backgroundLt"),
1185 getCurrentTheme().getColor("CollapsiblePanes.backgroundDk"),
1186 orientation == SwingConstants.HORIZONTAL);
1187 }
1188
1189 }
1190
1191 private void paintCollapsiblePaneTitlePanePlain(Graphics2D g2d, Color colorDk, Color colorLt, int orientation, Rectangle rect) {
1192 Rectangle rectangle;
1193 switch (orientation) {
1194 case SwingConstants.EAST:
1195 rectangle = new Rectangle(rect.x + rect.width - 1, rect.y, 1, rect.height);
1196 break;
1197 case SwingConstants.WEST:
1198 rectangle = new Rectangle(rect.x, rect.y, 1, rect.height);
1199 break;
1200 case SwingConstants.NORTH:
1201 rectangle = new Rectangle(rect.x, rect.y, rect.width, 1);
1202 break;
1203 case SwingConstants.SOUTH:
1204 default:
1205 rectangle = new Rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1);
1206 break;
1207 }
1208 JideSwingUtilities.fillGradient(g2d, rectangle,
1209 colorLt,
1210 colorDk,
1211 orientation == SwingConstants.NORTH || orientation == SwingConstants.SOUTH);
1212 }
1213
1214 @Override
1215 public void paintCollapsiblePaneTitlePaneBackgroundPlainEmphasized(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1216 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
1217 if (highContrast) {
1218 super.paintCollapsiblePaneTitlePaneBackgroundPlainEmphasized(c, g, rect, orientation, state);
1219 return;
1220 }
1221 Graphics2D g2d = (Graphics2D) g;
1222 Color colorLt = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundLt.emphasized");
1223 Color colorDk = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundDk.emphasized");
1224 paintCollapsiblePaneTitlePanePlain(g2d, colorDk, colorLt, orientation, rect);
1225 }
1226
1227
1228 @Override
1229 public void paintCollapsiblePaneTitlePaneBackgroundPlain(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1230 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
1231 if (highContrast) {
1232 super.paintCollapsiblePaneTitlePaneBackgroundPlain(c, g, rect, orientation, state);
1233 return;
1234 }
1235 Graphics2D g2d = (Graphics2D) g;
1236 Color colorLt = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundLt");
1237 Color colorDk = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundDk");
1238 paintCollapsiblePaneTitlePanePlain(g2d, colorDk, colorLt, orientation, rect);
1239 }
1240
1241 @Override
1242 public void paintCollapsiblePaneTitlePaneBackgroundSeparatorEmphasized(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1243 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
1244 if (highContrast) {
1245 super.paintCollapsiblePaneTitlePaneBackgroundSeparatorEmphasized(c, g, rect, orientation, state);
1246 return;
1247 }
1248 Graphics2D g2d = (Graphics2D) g;
1249 Color colorLt = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundLt.emphasized");
1250 Color colorDk = getCurrentTheme().getColor("CollapsiblePaneTitlePane.backgroundDk.emphasized");
1251 JideSwingUtilities.fillGradient(g2d,
1252 new Rectangle(rect.x, rect.y, rect.width, rect.height),
1253 colorDk,
1254 colorLt,
1255 orientation == SwingConstants.NORTH || orientation == SwingConstants.SOUTH);
1256 }
1257
1258 @Override
1259 public void paintCollapsiblePaneTitlePaneBackgroundSeparator(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1260 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
1261 if (highContrast) {
1262 super.paintCollapsiblePaneTitlePaneBackgroundSeparator(c, g, rect, orientation, state);
1263 return;
1264 }
1265 Graphics2D g2d = (Graphics2D) g;
1266 Color colorLt = getCurrentTheme().getColor("backgroundLt");
1267 Color colorDk = getCurrentTheme().getColor("backgroundDk");
1268 JideSwingUtilities.fillGradient(g2d,
1269 new Rectangle(rect.x, rect.y, rect.width, rect.height),
1270 colorLt,
1271 colorDk,
1272 orientation == SwingConstants.NORTH || orientation == SwingConstants.SOUTH);
1273 }
1274
1275
1276 @Override
1277 public void paintTabAreaBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1278 Boolean highContrast = UIManager.getBoolean("Theme.highContrast");
1279 if (highContrast) {
1280 super.paintTabAreaBackground(c, g, rect, orientation, state);
1281 return;
1282 }
1283
1284 if (c instanceof JideTabbedPane && ((JideTabbedPane) c).getColorTheme() != JideTabbedPane.COLOR_THEME_OFFICE2003) {
1285 super.paintTabAreaBackground(c, g, rect, orientation, state);
1286 }
1287 else {
1288 // set color of the tab area
1289 if (c.isOpaque()) {
1290 Object o = c.getClientProperty("JideTabbedPane.gradientTabArea");
1291 boolean useGradient = o instanceof Boolean ? (Boolean) o : UIDefaultsLookup.getBoolean("JideTabbedPane.gradientTabArea", true);
1292 if (c instanceof JideTabbedPane && useGradient) {
1293 Graphics2D g2d = (Graphics2D) g;
1294 Color startColor = getTabAreaBackgroundDk();
1295 Color endColor = getTabAreaBackgroundLt();
1296 int placement = ((JideTabbedPane) c).getTabPlacement();
1297 switch (placement) {
1298 case TOP:
1299 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x, rect.y, rect.width, rect.height), startColor, endColor, true);
1300 break;
1301 case BOTTOM:
1302 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x, rect.y, rect.width, rect.height), endColor, startColor, true);
1303 break;
1304 case LEFT:
1305 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x, rect.y, rect.width, rect.height), startColor, endColor, false);
1306 break;
1307 case RIGHT:
1308 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x, rect.y, rect.width, rect.height), endColor, startColor, false);
1309 break;
1310 }
1311 }
1312 else {
1313 g.setColor(UIDefaultsLookup.getColor("control"));
1314 g.fillRect(rect.x, rect.y, rect.width, rect.height);
1315 }
1316 }
1317 }
1318 }
1319
1320 @Override
1321 public void paintHeaderBoxBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1322 super.paintHeaderBoxBackground(c, g, rect, orientation, state);
1323 if (state == STATE_ROLLOVER) {
1324 g.setColor(ColorUtils.getDerivedColor(getCurrentTheme().getColor("selection.Rollover"), 0.30f));
1325 g.drawLine(rect.x + 1, rect.y + rect.height - 3, rect.x + rect.width - 2, rect.y + rect.height - 3);
1326 g.setColor(ColorUtils.getDerivedColor(getCurrentTheme().getColor("selection.Rollover"), 0.35f));
1327 g.drawLine(rect.x + 2, rect.y + rect.height - 2, rect.x + rect.width - 3, rect.y + rect.height - 2);
1328 g.setColor(ColorUtils.getDerivedColor(getCurrentTheme().getColor("selection.Rollover"), 0.40f));
1329 g.drawLine(rect.x + 3, rect.y + rect.height - 1, rect.x + rect.width - 4, rect.y + rect.height - 1);
1330 }
1331 }
1332
1333 @Override
1334 public void paintToolBarSeparator(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1335 int h = (orientation == SwingConstants.HORIZONTAL) ? rect.height : rect.width;
1336 h -= 9;
1337 int x;
1338 int y;
1339
1340 if (JideSwingUtilities.getOrientationOf(c) == SwingConstants.HORIZONTAL) {
1341 y = rect.y + 5;
1342 x = rect.x + 1;
1343 g.setColor(getSeparatorForeground());
1344 g.drawLine(x, y, x, y + h);
1345 g.setColor(getSeparatorForegroundLt());
1346 g.drawLine(x + 1, y + 1, x + 1, y + h + 1);
1347 }
1348 else {
1349 y = rect.y + 1;
1350 x = rect.x + 5;
1351 g.setColor(getSeparatorForeground());
1352 g.drawLine(x, y, x + h, y);
1353 g.setColor(getSeparatorForegroundLt());
1354 g.drawLine(x + 1, y + 1, x + 1 + h, y + 1);
1355 }
1356 }
1357
1358 @Override
1359 public void paintPopupMenuSeparator(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1360 int defaultShadowWidth = UIDefaultsLookup.getInt("MenuItem.shadowWidth");
1361 int defaultTextIconGap = UIDefaultsLookup.getInt("MenuItem.textIconGap");
1362
1363 if (c.getComponentOrientation().isLeftToRight()) {
1364 paintMenuShadow(c, g, new Rectangle(rect.x, rect.y, defaultShadowWidth, rect.height), SwingConstants.HORIZONTAL, ThemePainter.STATE_DEFAULT);
1365
1366 g.setColor(getMenuItemBackground());
1367 g.fillRect(rect.x + defaultShadowWidth, rect.y, rect.width - defaultShadowWidth, rect.height);
1368
1369 g.setColor(getSeparatorForeground());
1370 g.drawLine(rect.x + defaultShadowWidth + defaultTextIconGap, rect.y + 1, rect.x + rect.width, rect.y + 1);
1371 }
1372 else {
1373 paintMenuShadow(c, g, new Rectangle(rect.x + rect.width - defaultShadowWidth, rect.y, defaultShadowWidth, rect.height), SwingConstants.HORIZONTAL, ThemePainter.STATE_DEFAULT);
1374
1375 g.setColor(getMenuItemBackground());
1376 g.fillRect(rect.x, rect.y, rect.width - defaultShadowWidth, rect.height);
1377
1378 g.setColor(getSeparatorForeground());
1379 g.drawLine(rect.x, rect.y + 1, rect.x + rect.width - defaultShadowWidth - defaultTextIconGap, rect.y + 1);
1380 }
1381 }
1382
1383 public void paintStatusBarSeparator(JComponent c, Graphics g, Rectangle rect, int orientation, int state) {
1384 int h = (orientation == SwingConstants.HORIZONTAL) ? c.getHeight() : c.getWidth();
1385 h -= 3;
1386 int y;
1387 int x;
1388
1389 if (orientation == SwingConstants.HORIZONTAL) {
1390 x = rect.x;
1391 y = rect.y + 1;
1392 g.setColor(UIDefaultsLookup.getColor("controlShadow"));
1393 g.drawLine(x, y, x, y + h);
1394 g.setColor(UIDefaultsLookup.getColor("controlLtHighlight"));
1395 g.drawLine(x + 1, y, x + 1, y + h);
1396 }
1397 else {
1398 x = rect.x + 1;
1399 y = rect.y;
1400 g.setColor(UIDefaultsLookup.getColor("controlShadow"));
1401 g.drawLine(x, y, x + h, y);
1402 g.setColor(UIDefaultsLookup.getColor("controlLtHighlight"));
1403 g.drawLine(x, y + 1, x + h, y + 1);
1404 }
1405
1406 }
1407
1408 public void fillBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state, Color color) {
1409 Graphics2D g2d = (Graphics2D) g.create();
1410 if (orientation == SwingConstants.HORIZONTAL) {
1411 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x, rect.y, rect.width, rect.height), ColorUtils.getDerivedColor(color, 0.60f),
1412 ColorUtils.getDerivedColor(color, 0.40f), true);
1413 }
1414 else {
1415 JideSwingUtilities.fillGradient(g2d, new Rectangle(rect.x, rect.y, rect.width, rect.height), ColorUtils.getDerivedColor(color, 0.55f),
1416 color, false);
1417 }
1418 g2d.dispose();
1419 }
1420 }