| 1 |
/* |
| 2 |
* @(#)$fileName |
| 3 |
* |
| 4 |
* Copyright 2002 - 2004 JIDE Software Inc. All rights reserved. |
| 5 |
*/ |
| 6 |
package com.jidesoft.plaf.eclipse; |
| 7 |
|
| 8 |
import com.jidesoft.plaf.UIDefaultsLookup; |
| 9 |
import com.jidesoft.plaf.basic.BasicPainter; |
| 10 |
import com.jidesoft.plaf.basic.ThemePainter; |
| 11 |
import com.jidesoft.swing.JideSwingUtilities; |
| 12 |
|
| 13 |
import javax.swing.*; |
| 14 |
import java.awt.*; |
| 15 |
|
| 16 |
/** |
| 17 |
* Painter for Eclipse L&F. |
| 18 |
* <p/> |
| 19 |
* Please note, this class is an internal class which is meant to be used by other JIDE classes only. Future version might break your build if you use it. |
| 20 |
*/ |
| 21 |
public class EclipsePainter extends BasicPainter { |
| 22 |
|
| 23 |
private static EclipsePainter _instance; |
| 24 |
|
| 25 |
public static ThemePainter getInstance() { |
| 26 |
if (_instance == null) { |
| 27 |
_instance = new EclipsePainter(); |
| 28 |
} |
| 29 |
return _instance; |
| 30 |
} |
| 31 |
|
| 32 |
protected Color _shadowColor; |
| 33 |
protected Color _darkShadowColor; |
| 34 |
protected Color _highlight; |
| 35 |
protected Color _lightHighlightColor; |
| 36 |
|
| 37 |
protected EclipsePainter() { |
| 38 |
_shadowColor = UIDefaultsLookup.getColor("controlShadow"); |
| 39 |
_darkShadowColor = UIDefaultsLookup.getColor("controlDkShadow"); |
| 40 |
_highlight = UIDefaultsLookup.getColor("controlHighlight"); |
| 41 |
_lightHighlightColor = UIDefaultsLookup.getColor("controlLtHighlight"); |
| 42 |
} |
| 43 |
|
| 44 |
@Override |
| 45 |
public void paintButtonBackground(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 46 |
Color oldColor = g.getColor(); |
| 47 |
if (state == STATE_DEFAULT) { |
| 48 |
} |
| 49 |
else if (state == STATE_ROLLOVER) { |
| 50 |
if (orientation == HORIZONTAL) { |
| 51 |
g.setColor(_lightHighlightColor); // inner 3D border |
| 52 |
g.drawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y); |
| 53 |
g.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height - 1); |
| 54 |
|
| 55 |
g.setColor(_shadowColor); // black drop shadow __| |
| 56 |
g.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); |
| 57 |
g.drawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.x + rect.height - 1); |
| 58 |
} |
| 59 |
else { |
| 60 |
g.setColor(_lightHighlightColor); // black drop shadow __| |
| 61 |
g.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height - 1); |
| 62 |
g.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); |
| 63 |
|
| 64 |
g.setColor(_shadowColor); // inner 3D border |
| 65 |
g.drawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y); |
| 66 |
g.drawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.x + rect.height - 1); |
| 67 |
} |
| 68 |
} |
| 69 |
else if (state == STATE_SELECTED) { |
| 70 |
EclipseUtils.fillRectWithHatch((Graphics2D) g, |
| 71 |
new Rectangle(2, 2, rect.width - 4, rect.height - 4), UIDefaultsLookup.getColor("JideButton.background")); |
| 72 |
|
| 73 |
if (orientation == HORIZONTAL) { |
| 74 |
g.setColor(_shadowColor); // inner 3D border |
| 75 |
g.drawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y); |
| 76 |
g.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height - 1); |
| 77 |
|
| 78 |
g.setColor(_lightHighlightColor); // black drop shadow __| |
| 79 |
g.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); |
| 80 |
g.drawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.y + rect.height - 1); |
| 81 |
} |
| 82 |
else { |
| 83 |
g.setColor(_shadowColor); // inner 3D border |
| 84 |
g.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height - 1); |
| 85 |
g.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); |
| 86 |
|
| 87 |
g.setColor(_lightHighlightColor); // black drop shadow __| |
| 88 |
g.drawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y); |
| 89 |
g.drawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.y + rect.height - 1); |
| 90 |
|
| 91 |
} |
| 92 |
} |
| 93 |
else if (state == STATE_PRESSED) { |
| 94 |
g.setColor(_shadowColor); // inner 3D border |
| 95 |
g.drawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y); |
| 96 |
g.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height - 1); |
| 97 |
|
| 98 |
g.setColor(_lightHighlightColor); // black drop shadow __| |
| 99 |
g.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1); |
| 100 |
g.drawLine(rect.x + rect.width - 1, rect.y, rect.x + rect.width - 1, rect.y + rect.height - 1); |
| 101 |
} |
| 102 |
g.setColor(oldColor); |
| 103 |
} |
| 104 |
|
| 105 |
@Override |
| 106 |
public void paintSelectedMenu(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 107 |
} |
| 108 |
|
| 109 |
@Override |
| 110 |
public void paintGripper(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 111 |
int h = (orientation == SwingConstants.HORIZONTAL) ? rect.height : rect.width; |
| 112 |
h -= 4; |
| 113 |
|
| 114 |
int y = rect.y + 2; |
| 115 |
int x = rect.x + 2; |
| 116 |
|
| 117 |
Color oldColor = g.getColor(); |
| 118 |
if (orientation == SwingConstants.HORIZONTAL) { |
| 119 |
g.setColor(_lightHighlightColor); |
| 120 |
g.drawLine(x, y, x, y + h); |
| 121 |
g.drawLine(x, y, x + 2, y); |
| 122 |
g.setColor(_shadowColor); |
| 123 |
g.drawLine(x + 2, y, x + 2, y + h); |
| 124 |
g.drawLine(x, y + h, x + 2, y + h); |
| 125 |
g.setColor(UIDefaultsLookup.getColor("JideButton.background")); // was "control" |
| 126 |
g.drawLine(x + 1, y + 1, x + 1, y + h - 1); |
| 127 |
} |
| 128 |
else { |
| 129 |
g.setColor(_lightHighlightColor); |
| 130 |
g.drawLine(x, y, x + h, y); |
| 131 |
g.drawLine(x, y, x, y + 2); |
| 132 |
g.setColor(_shadowColor); |
| 133 |
g.drawLine(x, y + 2, x + h, y + 2); |
| 134 |
g.drawLine(x + h, y, x + h, y + 2); |
| 135 |
g.setColor(UIDefaultsLookup.getColor("JideButton.background")); // was "control" |
| 136 |
g.drawLine(x + 1, y + 1, x + h - 1, y + 1); |
| 137 |
} |
| 138 |
g.setColor(oldColor); |
| 139 |
} |
| 140 |
|
| 141 |
@Override |
| 142 |
public void paintDockableFrameTitlePane(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 143 |
int x = rect.x; |
| 144 |
int y = rect.y; |
| 145 |
int w = c.getWidth(); |
| 146 |
int h = rect.height; |
| 147 |
if (c.getBorder() != null) { |
| 148 |
Insets insets = c.getBorder().getBorderInsets(c); |
| 149 |
x += insets.left; |
| 150 |
y += insets.top; |
| 151 |
w -= insets.right + insets.left; |
| 152 |
h -= insets.top + insets.bottom; |
| 153 |
} |
| 154 |
|
| 155 |
g.setColor(Color.white); |
| 156 |
g.drawLine(x, y, x + w, y); |
| 157 |
g.drawLine(x, y, x, y + h - 1); |
| 158 |
|
| 159 |
g.setColor(Color.gray); |
| 160 |
g.drawLine(x, y + h - 1, x + w, y + h - 1); |
| 161 |
|
| 162 |
if (state == STATE_SELECTED) { |
| 163 |
int width = rect.width; |
| 164 |
Graphics2D g2d = (Graphics2D) g; |
| 165 |
JideSwingUtilities.fillGradient(g2d, new Rectangle(x + 1, y + 1, width / 2, h - 2), UIDefaultsLookup.getColor("DockableFrame.activeTitleBackground"), UIDefaultsLookup.getColor("DockableFrame.activeTitleBackground2"), false); |
| 166 |
JideSwingUtilities.fillGradient(g2d, new Rectangle(x + 1 + width / 2, y + 1, width / 2, h - 2), UIDefaultsLookup.getColor("DockableFrame.activeTitleBackground2"), UIDefaultsLookup.getColor("DockableFrame.background"), false); |
| 167 |
} |
| 168 |
// else if (state == STATE_DEFAULT) { |
| 169 |
// int width = rect.width; |
| 170 |
// Graphics2D g2d = (Graphics2D) g; |
| 171 |
// JideSwingUtilities.fillGradient(g2d, new Rectangle(x + 1, y + 1, width, h - 2), UIManagerLookup.getColor("DockableFrame.inactiveTitleBackground"), UIManagerLookup.getColor("DockableFrame.background"), false); |
| 172 |
// } |
| 173 |
} |
| 174 |
|
| 175 |
@Override |
| 176 |
public void paintToolBarSeparator(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 177 |
int h = (orientation == SwingConstants.HORIZONTAL) ? c.getHeight() : c.getWidth(); |
| 178 |
h -= 5; |
| 179 |
int y; |
| 180 |
int x; |
| 181 |
|
| 182 |
if (JideSwingUtilities.getOrientationOf(c) == SwingConstants.HORIZONTAL) { |
| 183 |
y = rect.y + 3; |
| 184 |
x = rect.x + 1; |
| 185 |
g.setColor(_shadowColor); |
| 186 |
g.drawLine(x, y, x, y + h); |
| 187 |
g.setColor(_lightHighlightColor); |
| 188 |
g.drawLine(x + 1, y + 1, x + 1, y + h + 1); |
| 189 |
} |
| 190 |
else { |
| 191 |
y = rect.y + 1; |
| 192 |
x = rect.x + 3; |
| 193 |
g.setColor(_shadowColor); |
| 194 |
g.drawLine(x, y, x + h, y); |
| 195 |
g.setColor(_lightHighlightColor); |
| 196 |
g.drawLine(x + 1, y + 1, x + 1 + h, y + 1); |
| 197 |
} |
| 198 |
} |
| 199 |
} |
| 200 |
|