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: ClassicDockingTheme.java,v 1.11 2007/01/28 21:25:10 jesper Exp $
023: package net.infonode.docking.theme;
024:
025: import net.infonode.docking.properties.RootWindowProperties;
026: import net.infonode.gui.border.EdgeBorder;
027: import net.infonode.gui.colorprovider.UIManagerColorProvider;
028: import net.infonode.tabbedpanel.TabSelectTrigger;
029: import net.infonode.tabbedpanel.TabbedPanel;
030: import net.infonode.tabbedpanel.TabbedPanelProperties;
031: import net.infonode.tabbedpanel.TabbedUtils;
032: import net.infonode.tabbedpanel.theme.ClassicTheme;
033: import net.infonode.tabbedpanel.titledtab.TitledTabProperties;
034: import net.infonode.util.Direction;
035:
036: import javax.swing.border.Border;
037: import javax.swing.border.CompoundBorder;
038: import java.awt.*;
039:
040: /**
041: * A theme with a "classic" look with round edges for the tabs.
042: *
043: * @author $Author: jesper $
044: * @version $Revision: 1.11 $
045: * @since IDW 1.2.0
046: */
047: public class ClassicDockingTheme extends DockingWindowsTheme {
048: private RootWindowProperties rootWindowProperties = new RootWindowProperties();
049:
050: /**
051: * Creates a ClassicDockingTheme.
052: */
053: public ClassicDockingTheme() {
054: ClassicTheme theme = new ClassicTheme();
055:
056: TabbedPanelProperties tabbedPanelProperties = theme
057: .getTabbedPanelProperties();
058: TitledTabProperties titledTabProperties = theme
059: .getTitledTabProperties();
060:
061: Border insetsBorder = new Border() {
062: public boolean isBorderOpaque() {
063: return false;
064: }
065:
066: public void paintBorder(Component c, Graphics g, int x,
067: int y, int width, int height) {
068: }
069:
070: public Insets getBorderInsets(Component c) {
071: TabbedPanel tp = TabbedUtils.getParentTabbedPanel(c);
072: if (tp != null) {
073: Direction d = tp.getProperties()
074: .getTabAreaOrientation();
075: return new Insets(d == Direction.UP ? 2 : 0,
076: d == Direction.LEFT ? 2 : 0,
077: d == Direction.DOWN ? 2 : 0,
078: d == Direction.RIGHT ? 2 : 0);
079: }
080: return new Insets(0, 0, 0, 0);
081: }
082: };
083:
084: // Tab window
085: rootWindowProperties.getTabWindowProperties()
086: .getTabbedPanelProperties().setTabSelectTrigger(
087: TabSelectTrigger.MOUSE_PRESS).addSuperObject(
088: tabbedPanelProperties)
089: .getTabAreaComponentsProperties()
090: .getComponentProperties().setInsets(
091: new Insets(0, 0, 0, 0));
092: rootWindowProperties.getTabWindowProperties()
093: .getTabProperties().getTitledTabProperties()
094: .addSuperObject(titledTabProperties);
095:
096: // Window bar
097: rootWindowProperties.getWindowBarProperties()
098: .getTabWindowProperties().getTabbedPanelProperties()
099: .addSuperObject(tabbedPanelProperties);
100: rootWindowProperties.getWindowBarProperties()
101: .getTabWindowProperties().getTabProperties()
102: .getTitledTabProperties().addSuperObject(
103: titledTabProperties);
104:
105: rootWindowProperties.getWindowBarProperties()
106: .getTabWindowProperties().getTabbedPanelProperties()
107: .getTabAreaComponentsProperties()
108: .getComponentProperties().setBorder(
109: new CompoundBorder(insetsBorder, theme
110: .createTabBorder(true, false, true)));
111:
112: rootWindowProperties.getWindowBarProperties()
113: .getComponentProperties().setInsets(
114: new Insets(0, 0, 2, 0));
115:
116: rootWindowProperties.getWindowBarProperties()
117: .getTabWindowProperties().getTabProperties()
118: .getTitledTabProperties().getNormalProperties()
119: .getComponentProperties().setBorder(
120: theme.createInsetsTabBorder(true, false, true));
121:
122: // Tweak root window
123: rootWindowProperties
124: .getWindowAreaProperties()
125: .setBackgroundColor(null)
126: .setInsets(new Insets(0, 0, 0, 0))
127: .setBorder(
128: new EdgeBorder(
129: UIManagerColorProvider.TABBED_PANE_DARK_SHADOW,
130: UIManagerColorProvider.TABBED_PANE_HIGHLIGHT,
131: true, true, true, true));
132: rootWindowProperties.setDragRectangleBorderWidth(3);
133: rootWindowProperties.getViewProperties()
134: .getViewTitleBarProperties().getNormalProperties()
135: .getShapedPanelProperties()
136: .setDirection(Direction.DOWN);
137: }
138:
139: /**
140: * Gets the theme name
141: *
142: * @return name
143: */
144: public String getName() {
145: return "Classic Theme";
146: }
147:
148: /**
149: * Gets the theme RootWindowProperties
150: *
151: * @return the RootWindowProperties
152: */
153: public RootWindowProperties getRootWindowProperties() {
154: return rootWindowProperties;
155: }
156: }
|