001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: GradientDockingTheme.java,v 1.12 2005/12/04 13:46:05 jesper Exp $
023: package net.infonode.docking.theme;
024:
025: import net.infonode.docking.properties.RootWindowProperties;
026: import net.infonode.docking.properties.WindowBarProperties;
027: import net.infonode.gui.colorprovider.ColorMultiplier;
028: import net.infonode.gui.colorprovider.UIManagerColorProvider;
029: import net.infonode.gui.componentpainter.GradientComponentPainter;
030: import net.infonode.properties.gui.util.ComponentProperties;
031: import net.infonode.tabbedpanel.border.OpenContentBorder;
032: import net.infonode.tabbedpanel.border.TabAreaLineBorder;
033: import net.infonode.tabbedpanel.theme.GradientTheme;
034: import net.infonode.tabbedpanel.titledtab.TitledTabProperties;
035:
036: import javax.swing.border.Border;
037: import javax.swing.border.CompoundBorder;
038: import javax.swing.border.LineBorder;
039: import java.awt.*;
040:
041: /**
042: * A theme that draws gradient tab backgrounds.
043: *
044: * @author $Author: jesper $
045: * @version $Revision: 1.12 $
046: * @since IDW 1.1.0
047: */
048: public class GradientDockingTheme extends DockingWindowsTheme {
049: private boolean opaqueTabArea;
050: private boolean shadowEnabled;
051: private boolean highlightedBold;
052: private boolean focusHighlighterEnabled;
053: private Color borderColor;
054: private Color tabAreaBackgroundColor;
055: private RootWindowProperties rootProperties;
056:
057: /**
058: * Creates a default theme with opaque title bar, shadows and focus highlighter.
059: */
060: public GradientDockingTheme() {
061: this (true, true, false, true);
062: }
063:
064: /**
065: * Constructor.
066: *
067: * @param opaqueTabArea set to true if the tab area should be opaque
068: * @param shadowEnabled shadow on/off
069: * @param highlightedBold if true the highlighted tab text uses a bold font
070: * @param focusHighlighterEnabled if true the currently focused tab is highlighted
071: */
072: public GradientDockingTheme(boolean opaqueTabArea,
073: boolean shadowEnabled, boolean highlightedBold,
074: boolean focusHighlighterEnabled) {
075: this (opaqueTabArea, shadowEnabled, highlightedBold,
076: focusHighlighterEnabled, Color.BLACK);
077: }
078:
079: /**
080: * Constructor.
081: *
082: * @param opaqueTabArea set to true if the tab area should be opaque
083: * @param shadowEnabled shadow on/off
084: * @param highlightedBold if true the highlighted tab text uses a bold font
085: * @param focusHighlighterEnabled if true the currently focused tab is highlighted
086: * @param borderColor the border color
087: */
088: public GradientDockingTheme(boolean opaqueTabArea,
089: boolean shadowEnabled, boolean highlightedBold,
090: boolean focusHighlighterEnabled, Color borderColor) {
091: this (opaqueTabArea, shadowEnabled, highlightedBold,
092: focusHighlighterEnabled, borderColor,
093: GradientTheme.DEFAULT_TAB_AREA_BACKGROUND_COLOR);
094: }
095:
096: /**
097: * Constructor.
098: *
099: * @param opaqueTabArea set to true if the tab area should be opaque
100: * @param shadowEnabled shadow on/off
101: * @param highlightedBold if true the highlighted tab text uses a bold font
102: * @param focusHighlighterEnabled if true the currently focused tab is highlighted
103: * @param borderColor the border color
104: * @param tabAreaBackgroundColor the background color for the tab area and tabs in the normal state
105: */
106: public GradientDockingTheme(boolean opaqueTabArea,
107: boolean shadowEnabled, boolean highlightedBold,
108: boolean focusHighlighterEnabled, Color borderColor,
109: Color tabAreaBackgroundColor) {
110: this .opaqueTabArea = opaqueTabArea;
111: this .shadowEnabled = shadowEnabled;
112: this .highlightedBold = highlightedBold;
113: this .focusHighlighterEnabled = focusHighlighterEnabled;
114: this .borderColor = borderColor;
115: this .tabAreaBackgroundColor = tabAreaBackgroundColor;
116:
117: GradientTheme theme = new GradientTheme(opaqueTabArea,
118: shadowEnabled, borderColor);
119:
120: rootProperties = new RootWindowProperties();
121: createRootWindowProperties(theme);
122: createWindowBarProperties(theme);
123: }
124:
125: private void createRootWindowProperties(GradientTheme theme) {
126: rootProperties.getTabWindowProperties()
127: .getTabbedPanelProperties().addSuperObject(
128: theme.getTabbedPanelProperties());
129: rootProperties.getTabWindowProperties().getTabProperties()
130: .getTitledTabProperties().addSuperObject(
131: theme.getTitledTabProperties());
132:
133: rootProperties.getTabWindowProperties()
134: .getCloseButtonProperties().setVisible(false);
135:
136: if (!shadowEnabled)
137: rootProperties.getWindowAreaProperties().setInsets(
138: new Insets(6, 6, 6, 6));
139:
140: rootProperties
141: .getWindowAreaShapedPanelProperties()
142: .setComponentPainter(
143: new GradientComponentPainter(
144: UIManagerColorProvider.DESKTOP_BACKGROUND,
145: new ColorMultiplier(
146: UIManagerColorProvider.DESKTOP_BACKGROUND,
147: 0.9f),
148: new ColorMultiplier(
149: UIManagerColorProvider.DESKTOP_BACKGROUND,
150: 0.9f),
151: new ColorMultiplier(
152: UIManagerColorProvider.DESKTOP_BACKGROUND,
153: 0.8f)));
154:
155: rootProperties.getWindowAreaProperties().setBorder(
156: new LineBorder(Color.BLACK));
157:
158: if (tabAreaBackgroundColor != null)
159: rootProperties.getComponentProperties().setBackgroundColor(
160: tabAreaBackgroundColor);
161:
162: if (!shadowEnabled)
163: rootProperties.getSplitWindowProperties().setDividerSize(6);
164:
165: TitledTabProperties tabProperties = rootProperties
166: .getTabWindowProperties().getTabProperties()
167: .getTitledTabProperties();
168:
169: tabProperties.getNormalProperties().setIconVisible(false);
170: tabProperties.getHighlightedProperties().setIconVisible(true);
171:
172: if (!highlightedBold)
173: tabProperties.getHighlightedProperties()
174: .getComponentProperties().getMap()
175: .createRelativeRef(
176: ComponentProperties.FONT,
177: tabProperties.getNormalProperties()
178: .getComponentProperties().getMap(),
179: ComponentProperties.FONT);
180:
181: if (focusHighlighterEnabled) {
182: tabProperties
183: .getHighlightedProperties()
184: .getComponentProperties()
185: .setBorder(
186: new CompoundBorder(
187: opaqueTabArea ? (Border) new TabAreaLineBorder(
188: false, false, true, true)
189: : new TabAreaLineBorder(
190: borderColor),
191: theme
192: .getTabAreaComponentsGradientBorder()));
193:
194: rootProperties
195: .getTabWindowProperties()
196: .getTabProperties()
197: .getFocusedProperties()
198: .getComponentProperties()
199: .setBorder(
200: new CompoundBorder(
201: opaqueTabArea ? (Border) new TabAreaLineBorder(
202: false, false, true, true)
203: : new TabAreaLineBorder(
204: borderColor),
205: theme
206: .getHighlightedTabGradientBorder()));
207: }
208:
209: rootProperties.getTabWindowProperties()
210: .getTabbedPanelProperties()
211: .getTabAreaComponentsProperties()
212: .getComponentProperties().setInsets(
213: opaqueTabArea ? new Insets(0, 3, 0, 3)
214: : new Insets(1, 3, 1, 3));
215:
216: rootProperties.getTabWindowProperties().getTabProperties()
217: .getHighlightedButtonProperties()
218: .getCloseButtonProperties().setVisible(false);
219:
220: rootProperties.getTabWindowProperties().getTabProperties()
221: .getHighlightedButtonProperties()
222: .getMinimizeButtonProperties().setVisible(true);
223:
224: rootProperties.getTabWindowProperties().getTabProperties()
225: .getHighlightedButtonProperties()
226: .getRestoreButtonProperties().setVisible(true);
227: }
228:
229: private void createWindowBarProperties(GradientTheme theme) {
230: WindowBarProperties barProperties = rootProperties
231: .getWindowBarProperties();
232:
233: barProperties.getTabWindowProperties()
234: .getTabbedPanelProperties().getContentPanelProperties()
235: .getComponentProperties().setBorder(
236: new OpenContentBorder(Color.BLACK, 1));
237:
238: barProperties.getTabWindowProperties().getTabProperties()
239: .getNormalButtonProperties().getCloseButtonProperties()
240: .setVisible(false);
241:
242: barProperties
243: .getTabWindowProperties()
244: .getTabProperties()
245: .getTitledTabProperties()
246: .getNormalProperties()
247: .setIconVisible(true)
248: .getComponentProperties()
249: .setBorder(
250: new CompoundBorder(
251: new TabAreaLineBorder(),
252: theme
253: .getTabAreaComponentsGradientBorder()));
254:
255: barProperties.getTabWindowProperties().getTabProperties()
256: .getFocusedProperties().getComponentProperties()
257: .setBorder(
258: new CompoundBorder(new TabAreaLineBorder(
259: Color.BLACK), theme
260: .getHighlightedTabGradientBorder()));
261:
262: barProperties.getTabWindowProperties().getTabProperties()
263: .getTitledTabProperties().getHighlightedProperties()
264: .getComponentProperties().setBorder(
265: new CompoundBorder(new TabAreaLineBorder(
266: Color.BLACK), theme
267: .getHighlightedTabGradientBorder()));
268:
269: barProperties.getTabWindowProperties()
270: .getTabbedPanelProperties().setTabSpacing(-1);
271:
272: barProperties.getTabWindowProperties()
273: .getTabbedPanelProperties().getTabAreaProperties()
274: .getComponentProperties().setBorder(null)
275: .setBackgroundColor(null);
276: }
277:
278: public String getName() {
279: String str = (opaqueTabArea ? "" : "Transparent Tab Area, ")
280: + (shadowEnabled ? "" : "No Shadow, ")
281: + (focusHighlighterEnabled ? ""
282: : "No Focus Highlight, ")
283: + (highlightedBold ? "Highlighted Bold, " : "");
284: return "Gradient Theme"
285: + (str.length() > 0 ? " - "
286: + str.substring(0, str.length() - 2) : "");
287: }
288:
289: public RootWindowProperties getRootWindowProperties() {
290: return rootProperties;
291: }
292:
293: }
|