001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018
019 package echopoint.style.echo.extras;
020
021 import echopoint.style.AbstractStyle;
022 import static echopoint.style.echo.extras.ResourceImages.MenuBarBackground;
023 import static echopoint.style.echo.extras.ResourceImages.MenuBarMenuBackground;
024 import static echopoint.style.echo.extras.ResourceImages.MenuBarSelectionBackground;
025 import static echopoint.util.ColorKit.makeColor;
026 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_ANIMATION_TIME;
027 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_BACKGROUND_IMAGE;
028 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_BORDER;
029 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_FOREGROUND;
030 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_MENU_BACKGROUND;
031 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_MENU_BACKGROUND_IMAGE;
032 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_MENU_BORDER;
033 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_MENU_OPACITY;
034 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_SELECTION_BACKGROUND;
035 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_SELECTION_BACKGROUND_IMAGE;
036 import static nextapp.echo.extras.app.MenuBarPane.PROPERTY_SELECTION_FOREGROUND;
037 import nextapp.echo.app.Border;
038 import nextapp.echo.app.ResourceImageReference;
039 import nextapp.echo.app.FillImage;
040 import nextapp.echo.app.Extent;
041
042 /**
043 * The default style to apply for {@link nextapp.echo.extras.app.MenuBarPane}
044 * components. Sub-classes should over-ride either the root {@link #init}
045 * method, or the various property group configuration methods.
046 *
047 * @author Rakesh Vidyadharan 2009-05-26
048 * @version $Id: MenuBarPaneStyle.java 211 2009-05-29 02:44:50Z sptrakesh $
049 */
050 public class MenuBarPaneStyle extends AbstractStyle
051 {
052 private static final long serialVersionUID = 1L;
053
054 /**
055 * The default menu animation time.
056 *
057 * {@value}
058 */
059 public static final int ANIMATION_TIME = 150;
060
061 /** {@inheritDoc} */
062 @Override
063 protected void init()
064 {
065 super.init();
066
067 setGeneralStyles();
068 setMenuStyles();
069 setSelectionStyles();
070 }
071
072 /** Set general styles (base component styles) and animation time. */
073 protected void setGeneralStyles()
074 {
075 set( PROPERTY_ANIMATION_TIME, ANIMATION_TIME );
076 set( PROPERTY_BACKGROUND_IMAGE, new FillImage( MenuBarBackground ) );
077 set( PROPERTY_BORDER,
078 new Border( 0, makeColor( "#000000" ), Border.STYLE_SOLID ) );
079 set( PROPERTY_FOREGROUND, makeColor( "#ffffff" ) );
080 }
081
082 /** Set styles for the menu in the menu bar component. */
083 protected void setMenuStyles()
084 {
085 set( PROPERTY_MENU_BACKGROUND, makeColor( "#000000" ) );
086 set( PROPERTY_MENU_BACKGROUND_IMAGE,
087 new FillImage( MenuBarMenuBackground ) );
088 set( PROPERTY_MENU_OPACITY, 92 );
089
090 final Border.Side[] sides = new Border.Side[4];
091 sides[Border.SIDE_TOP] = new Border.Side(
092 1, makeColor( "#1f1f1f" ), Border.STYLE_SOLID );
093 sides[Border.SIDE_RIGHT] = sides[Border.SIDE_TOP];
094 sides[Border.SIDE_BOTTOM] = new Border.Side(
095 1, makeColor( "#3f3f3f" ), Border.STYLE_SOLID );
096 sides[Border.SIDE_LEFT] = sides[Border.SIDE_BOTTOM];
097
098 set( PROPERTY_MENU_BORDER, new Border( sides ) );
099 }
100
101 /** Set styles for selection of menu compnents. */
102 protected void setSelectionStyles()
103 {
104 set( PROPERTY_SELECTION_BACKGROUND, makeColor( "#fffac1" ) );
105
106 final Extent extent = new Extent( 50, Extent.PERCENT );
107 set( PROPERTY_SELECTION_BACKGROUND_IMAGE, new FillImage(
108 MenuBarSelectionBackground, extent, extent, FillImage.REPEAT ) );
109
110 set( PROPERTY_SELECTION_FOREGROUND, makeColor( "#000000" ) );
111 }
112 }