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: SlimFlatDockingTheme.java,v 1.20 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.ViewTitleBarStateProperties;
027: import net.infonode.docking.properties.WindowBarProperties;
028: import net.infonode.docking.properties.WindowTabProperties;
029: import net.infonode.gui.icon.button.*;
030: import net.infonode.tabbedpanel.TabLayoutPolicy;
031: import net.infonode.tabbedpanel.TabbedPanelProperties;
032: import net.infonode.tabbedpanel.border.TabAreaLineBorder;
033: import net.infonode.tabbedpanel.theme.SmallFlatTheme;
034:
035: import javax.swing.*;
036: import javax.swing.border.Border;
037: import java.awt.*;
038:
039: /**
040: * A theme very slim theme that doesn't waste any screen space.
041: *
042: * @author $Author: jesper $
043: * @version $Revision: 1.20 $
044: */
045: public final class SlimFlatDockingTheme extends DockingWindowsTheme {
046: private RootWindowProperties rootWindowProperties;
047:
048: public SlimFlatDockingTheme() {
049: rootWindowProperties = createRootWindowProperties();
050: }
051:
052: public String getName() {
053: return "Slim Flat Theme";
054: }
055:
056: public RootWindowProperties getRootWindowProperties() {
057: return rootWindowProperties;
058: }
059:
060: /**
061: * Create a root window properties object with the property values for this theme.
062: *
063: * @return the root window properties object
064: */
065: public static final RootWindowProperties createRootWindowProperties() {
066: SmallFlatTheme smallFlatTheme = new SmallFlatTheme();
067:
068: RootWindowProperties rootWindowProperties = new RootWindowProperties();
069: rootWindowProperties.getWindowAreaProperties().setInsets(
070: new Insets(0, 0, 0, 0)).setBorder(null);
071:
072: rootWindowProperties.getSplitWindowProperties().setDividerSize(
073: 3);
074:
075: TabbedPanelProperties tpProperties = rootWindowProperties
076: .getTabWindowProperties().getTabbedPanelProperties();
077: tpProperties.addSuperObject(smallFlatTheme
078: .getTabbedPanelProperties());
079: tpProperties.setShadowEnabled(false).setTabLayoutPolicy(
080: TabLayoutPolicy.COMPRESSION);
081: tpProperties.getTabAreaComponentsProperties()
082: .getComponentProperties().setInsets(
083: new Insets(0, 1, 0, 1));
084:
085: WindowTabProperties tabProperties = rootWindowProperties
086: .getTabWindowProperties().getTabProperties();
087: tabProperties.getTitledTabProperties().addSuperObject(
088: smallFlatTheme.getTitledTabProperties());
089:
090: Font font = tabProperties.getTitledTabProperties()
091: .getHighlightedProperties().getComponentProperties()
092: .getFont();
093: if (font != null)
094: font = font.deriveFont(tabProperties
095: .getTitledTabProperties().getNormalProperties()
096: .getComponentProperties().getFont().getSize2D());
097: tabProperties.getTitledTabProperties()
098: .getHighlightedProperties().getComponentProperties()
099: .setFont(font);
100:
101: Icon closeIcon = new CloseIcon(8);
102: Icon restoreIcon = new RestoreIcon(8);
103: Icon minimizeIcon = new MinimizeIcon(8);
104: Icon maximizeIcon = new MaximizeIcon(8);
105: Icon dockIcon = new DockIcon(8);
106: Icon undockIcon = new UndockIcon(8);
107:
108: tabProperties.getNormalButtonProperties()
109: .getCloseButtonProperties().setIcon(closeIcon);
110: tabProperties.getNormalButtonProperties()
111: .getRestoreButtonProperties().setIcon(restoreIcon);
112: tabProperties.getNormalButtonProperties()
113: .getMinimizeButtonProperties().setIcon(minimizeIcon);
114: tabProperties.getNormalButtonProperties()
115: .getDockButtonProperties().setIcon(dockIcon);
116: tabProperties.getNormalButtonProperties()
117: .getUndockButtonProperties().setIcon(undockIcon);
118:
119: rootWindowProperties.getTabWindowProperties()
120: .getCloseButtonProperties().setIcon(closeIcon);
121: rootWindowProperties.getTabWindowProperties()
122: .getRestoreButtonProperties().setIcon(restoreIcon);
123: rootWindowProperties.getTabWindowProperties()
124: .getMinimizeButtonProperties().setIcon(minimizeIcon);
125: rootWindowProperties.getTabWindowProperties()
126: .getMaximizeButtonProperties().setIcon(maximizeIcon);
127: rootWindowProperties.getTabWindowProperties()
128: .getDockButtonProperties().setIcon(dockIcon);
129: rootWindowProperties.getTabWindowProperties()
130: .getUndockButtonProperties().setIcon(undockIcon);
131:
132: ViewTitleBarStateProperties stateProps = rootWindowProperties
133: .getViewProperties().getViewTitleBarProperties()
134: .getNormalProperties();
135: stateProps.getCloseButtonProperties().setIcon(closeIcon);
136: stateProps.getRestoreButtonProperties().setIcon(restoreIcon);
137: stateProps.getMaximizeButtonProperties().setIcon(maximizeIcon);
138: stateProps.getMinimizeButtonProperties().setIcon(minimizeIcon);
139: stateProps.getDockButtonProperties().setIcon(dockIcon);
140: stateProps.getUndockButtonProperties().setIcon(undockIcon);
141:
142: rootWindowProperties.getViewProperties()
143: .getViewTitleBarProperties().getNormalProperties()
144: .getComponentProperties().setFont(
145: tabProperties.getTitledTabProperties()
146: .getNormalProperties()
147: .getComponentProperties().getFont());
148:
149: setWindowBarProperties(rootWindowProperties
150: .getWindowBarProperties());
151:
152: return rootWindowProperties;
153: }
154:
155: private static void setWindowBarProperties(
156: WindowBarProperties windowBarProperties) {
157: windowBarProperties.setMinimumWidth(3);
158:
159: Border border = new TabAreaLineBorder(false, true, true, false);
160:
161: windowBarProperties.getTabWindowProperties().getTabProperties()
162: .getTitledTabProperties().getNormalProperties()
163: .getComponentProperties().setInsets(
164: new Insets(0, 4, 0, 4)).setBorder(border);
165:
166: windowBarProperties.getTabWindowProperties().getTabProperties()
167: .getTitledTabProperties().getHighlightedProperties()
168: .getComponentProperties().setBorder(border);
169: }
170:
171: /**
172: * Create a window bar properties object with the property values for this theme.
173: *
174: * @return the root window properties object
175: * @deprecated the window bar properties are now included in the root window properties
176: */
177: public static final WindowBarProperties createWindowBarProperties() {
178: return new WindowBarProperties();
179: }
180: }
|