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 nextapp.echo.app.Extent;
022    import nextapp.echo.app.FillImage;
023    import nextapp.echo.app.FillImageBorder;
024    import nextapp.echo.app.Insets;
025    import static nextapp.echo.extras.app.TabPane.PROPERTY_BACKGROUND;
026    import static nextapp.echo.extras.app.TabPane.PROPERTY_IMAGE_BORDER;
027    import static nextapp.echo.extras.app.TabPane.PROPERTY_INSETS;
028    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_ACTIVE_BACKGROUND;
029    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_ACTIVE_BACKGROUND_IMAGE;
030    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_ACTIVE_BACKGROUND_INSETS;
031    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_ACTIVE_INSETS;
032    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_CLOSE_ICON;
033    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_CLOSE_ICON_ROLLOVER_ENABLED;
034    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_ICON_TEXT_MARGIN;
035    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_INACTIVE_BACKGROUND;
036    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_INACTIVE_BACKGROUND_IMAGE;
037    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_INACTIVE_BACKGROUND_INSETS;
038    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_INACTIVE_INSETS;
039    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_ROLLOVER_BACKGROUND_IMAGE;
040    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_ROLLOVER_CLOSE_ICON;
041    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_ROLLOVER_ENABLED;
042    import static nextapp.echo.extras.app.TabPane.PROPERTY_TAB_ROLLOVER_FOREGROUND;
043    
044    import echopoint.style.AbstractStyle;
045    import static echopoint.style.echo.ResourceImages.BorderBottom;
046    import static echopoint.style.echo.ResourceImages.BorderBottomLeft;
047    import static echopoint.style.echo.ResourceImages.BorderBottomRight;
048    import static echopoint.style.echo.ResourceImages.BorderLeft;
049    import static echopoint.style.echo.ResourceImages.BorderRight;
050    import static echopoint.style.echo.ResourceImages.BorderTop;
051    import static echopoint.style.echo.ResourceImages.BorderTopLeft;
052    import static echopoint.style.echo.ResourceImages.BorderTopRight;
053    import static echopoint.style.echo.ResourceImages.GradientBlue;
054    import static echopoint.style.echo.ResourceImages.LightedSilver;
055    import static echopoint.style.echo.ResourceImages.TabCloseIcon;
056    import static echopoint.style.echo.ResourceImages.TabCloseRolloverIcon;
057    import static echopoint.util.ColorKit.makeColor;
058    import static echopoint.util.ExtentKit.makeExtent;
059    
060    /**
061     * The default style to use for {@link nextapp.echo.extras.app.TabPane}
062     * components.
063     *
064     * @author Rakesh Vidyadharan 2009-11-19
065     * @version $Id: TabPaneStyle.java 255 2009-11-29 12:16:16Z sptrakesh $
066     */
067    public class TabPaneStyle extends AbstractStyle
068    {
069      private static final long serialVersionUID = 1L;
070    
071      @Override
072      protected void init()
073      {
074        super.init();
075    
076        setImageBorder();
077        setImages();
078        setInsets();
079        setSpacing();
080        setColor();
081        setRollover();
082      }
083    
084      protected void setImageBorder()
085      {
086        final FillImageBorder border = new FillImageBorder();
087        border.setContentInsets( new Insets( 4, 4, 6, 4 ) );
088        border.setBorderInsets( new Insets( 17, 23, 23, 17 ) );
089        border.setFillImage( FillImageBorder.TOP_LEFT,
090            new FillImage( BorderTopLeft ) );
091        border.setFillImage( FillImageBorder.TOP,
092            new FillImage( BorderTop ) );
093        border.setFillImage( FillImageBorder.TOP_RIGHT,
094            new FillImage( BorderTopRight ) );
095    
096        border.setFillImage( FillImageBorder.LEFT,
097            new FillImage( BorderLeft ) );
098        border.setFillImage( FillImageBorder.RIGHT,
099            new FillImage( BorderRight ) );
100    
101        border.setFillImage( FillImageBorder.BOTTOM_LEFT,
102            new FillImage( BorderBottomLeft ) );
103        border.setFillImage( FillImageBorder.BOTTOM,
104            new FillImage( BorderBottom ) );
105        border.setFillImage( FillImageBorder.BOTTOM_RIGHT,
106            new FillImage( BorderBottomRight ) );
107    
108        set( PROPERTY_IMAGE_BORDER, border );
109      }
110    
111    
112      protected void setImages()
113      {
114        set( PROPERTY_TAB_CLOSE_ICON, TabCloseIcon );
115        set( PROPERTY_TAB_CLOSE_ICON_ROLLOVER_ENABLED, true );
116        set( PROPERTY_TAB_ROLLOVER_CLOSE_ICON, TabCloseRolloverIcon );
117        set( PROPERTY_TAB_ACTIVE_BACKGROUND_IMAGE,
118            new FillImage( LightedSilver, makeExtent( "0px" ),
119                makeExtent( "53%" ), FillImage.REPEAT_HORIZONTAL ) );
120      }
121    
122      protected void setInsets()
123      {
124        set( PROPERTY_INSETS, new Insets( 0 ) );
125        set( PROPERTY_TAB_ACTIVE_INSETS, new Insets( 4, 10 ) );
126        set( PROPERTY_TAB_INACTIVE_INSETS, new Insets( 4, 10 ) );
127        set( PROPERTY_TAB_ACTIVE_BACKGROUND_INSETS, new Insets( 8, 14, 0, 8 ) );
128        set( PROPERTY_TAB_INACTIVE_BACKGROUND_INSETS, new Insets( 8, 14, 1, 8 ) );
129      }
130    
131      protected void setSpacing()
132      {
133        set( PROPERTY_TAB_ICON_TEXT_MARGIN, new Extent( 3 ) );
134      }
135    
136      protected void setColor()
137      {
138        set( PROPERTY_BACKGROUND, makeColor( "#ffffff" ) );
139        set( PROPERTY_TAB_ACTIVE_BACKGROUND, makeColor( "#ffffff" ) );
140        set( PROPERTY_TAB_INACTIVE_BACKGROUND, makeColor( "#e7e7e7" ) );
141      }
142    
143      protected void setRollover()
144      {
145        set( PROPERTY_TAB_ROLLOVER_ENABLED, true );
146        set( PROPERTY_TAB_ROLLOVER_FOREGROUND, makeColor( "#ffffff" ) );
147    
148        final FillImage inactive = new FillImage( LightedSilver,
149            new Extent( 0 ), new Extent( 53, Extent.PERCENT ),
150            FillImage.REPEAT_HORIZONTAL );
151        set( PROPERTY_TAB_INACTIVE_BACKGROUND_IMAGE, inactive );
152    
153        final FillImage rollover = new FillImage( GradientBlue,
154            makeExtent( "0px" ), makeExtent( "50%" ), FillImage.REPEAT );
155        set( PROPERTY_TAB_ROLLOVER_BACKGROUND_IMAGE, rollover );
156      }
157    }