001/*
002 * $Id: TaskPaneContainerAddon.java 3500 2009-09-10 10:28:24Z kleopatra $
003 *
004 * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005 * Santa Clara, California 95054, U.S.A. All rights reserved.
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 * 
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015 * Lesser General Public License for more details.
016 * 
017 * You should have received a copy of the GNU Lesser General Public
018 * License along with this library; if not, write to the Free Software
019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020 */
021package org.jdesktop.swingx.plaf;
022
023import java.awt.Color;
024import java.awt.GradientPaint;
025import java.awt.Toolkit;
026
027import javax.swing.BorderFactory;
028import javax.swing.plaf.BorderUIResource;
029import javax.swing.plaf.ColorUIResource;
030import javax.swing.plaf.metal.MetalLookAndFeel;
031
032import org.jdesktop.swingx.JXTaskPaneContainer;
033import org.jdesktop.swingx.painter.MattePainter;
034import org.jdesktop.swingx.plaf.windows.WindowsClassicLookAndFeelAddons;
035import org.jdesktop.swingx.plaf.windows.WindowsLookAndFeelAddons;
036import org.jdesktop.swingx.util.OS;
037
038/**
039 * Addon for <code>JXTaskPaneContainer</code>. This addon defines the following properties:
040 * <table>
041 * <tr><td>TaskPaneContainer.background</td><td>background color</td></tr>
042 * <tr><td>TaskPaneContainer.backgroundPainter</td><td>background painter</td></tr>
043 * <tr><td>TaskPaneContainer.border</td><td>container border</td></tr>
044 * <tr><td>TaskPaneContainer.font</td><td>font (currently unused)</td></tr>
045 * <tr><td>TaskPaneContainer.foreground</td><td>foreground color (currently unused)</td></tr>
046 * </table>
047 *  
048 * @author <a href="mailto:fred@L2FProd.com">Frederic Lavigne</a>
049 * @author Karl Schaefer
050 */
051public class TaskPaneContainerAddon extends AbstractComponentAddon {
052
053  public TaskPaneContainerAddon() {
054    super("JXTaskPaneContainer");
055  }
056
057  @Override
058  protected void addBasicDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
059    super.addBasicDefaults(addon, defaults);
060    
061    defaults.add(JXTaskPaneContainer.uiClassID, "org.jdesktop.swingx.plaf.basic.BasicTaskPaneContainerUI");
062    defaults.add("TaskPaneContainer.background", UIManagerExt.getSafeColor("Desktop.background",
063                        new ColorUIResource(Color.decode("#005C5C"))));
064    defaults.add("TaskPaneContainer.border", new BorderUIResource(BorderFactory.createEmptyBorder(10, 10, 0, 10)));
065  }
066
067  /**
068   * {@inheritDoc}
069   */
070  @Override
071  protected void addMetalDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
072    super.addMetalDefaults(addon, defaults);
073    
074    defaults.add("TaskPaneContainer.background", MetalLookAndFeel.getDesktopColor());
075  }
076  
077  /**
078   * {@inheritDoc}
079   */
080  @Override
081  protected void addWindowsDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
082    super.addWindowsDefaults(addon, defaults);
083    if (addon instanceof WindowsClassicLookAndFeelAddons) {
084      defaults.add("TaskPaneContainer.background", UIManagerExt.getSafeColor("List.background",
085                new ColorUIResource(Color.decode("#005C5C"))));
086    } else if (addon instanceof WindowsLookAndFeelAddons) {     
087      String xpStyle = OS.getWindowsVisualStyle();
088      ColorUIResource background;
089      Color backgroundGradientStart;
090      Color backgroundGradientEnd;
091      
092      if (WindowsLookAndFeelAddons.HOMESTEAD_VISUAL_STYLE
093        .equalsIgnoreCase(xpStyle)) {        
094        background = new ColorUIResource(201, 215, 170);
095        backgroundGradientStart = new Color(204, 217, 173);
096        backgroundGradientEnd = new Color(165, 189, 132);
097      } else if (WindowsLookAndFeelAddons.SILVER_VISUAL_STYLE
098        .equalsIgnoreCase(xpStyle)) {
099        background = new ColorUIResource(192, 195, 209);
100        backgroundGradientStart = new Color(196, 200, 212);
101        backgroundGradientEnd = new Color(177, 179, 200);
102      } else {        
103        if (OS.isWindowsVista()) {
104          final Toolkit toolkit = Toolkit.getDefaultToolkit();
105          background = new ColorUIResource((Color)toolkit.getDesktopProperty("win.3d.backgroundColor"));
106          backgroundGradientStart = (Color)toolkit.getDesktopProperty("win.frame.activeCaptionColor");
107          backgroundGradientEnd = (Color)toolkit.getDesktopProperty("win.frame.inactiveCaptionColor");
108        } else {
109          background = new ColorUIResource(117, 150, 227);
110          backgroundGradientStart = new ColorUIResource(123, 162, 231);
111          backgroundGradientEnd = new ColorUIResource(99, 117, 214);
112        }
113      }      
114      
115      defaults.add("TaskPaneContainer.backgroundPainter", new PainterUIResource<JXTaskPaneContainer>(
116              new MattePainter(new GradientPaint(
117                      0f, 0f, backgroundGradientStart,
118                      0f, 1f, backgroundGradientEnd),
119                      true)));
120      defaults.add("TaskPaneContainer.background", background);
121    }
122  }
123
124  /**
125   * {@inheritDoc}
126   */
127  @Override
128  protected void addMacDefaults(LookAndFeelAddons addon, DefaultsList defaults) {
129    super.addMacDefaults(addon, defaults);
130    
131    defaults.add("TaskPaneContainer.background", new ColorUIResource(238, 238, 238));
132  }
133
134    @Override
135    protected void addNimbusDefaults(LookAndFeelAddons addon,
136            DefaultsList defaults) {
137        super.addNimbusDefaults(addon, defaults);
138        // dynamically changing the LaF to Nimbus does not refresh correctly the
139        // control colors if they are not hard-coded due to Nimbus DerivedColors
140        // lazy initialization
141//        defaults.add("TaskPaneContainer.background", new ColorUIResource(
142//                UIManager.getColor("control")));
143        defaults.add("TaskPaneContainer.background", new ColorUIResource(214,217,223));
144    }
145
146}