001 
002 /*
003  *  JScripter Standard 1.0 - To Script In Java
004  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
005  *  
006  *  This program is free software: you can redistribute it and/or modify
007  *  it under the terms of the GNU Affero General Public License as published by
008  *  the Free Software Foundation, either version 3 of the License, or
009  *  (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 Affero General Public License for more details.
015  *  
016  *  You should have received a copy of the GNU Affero General Public License
017  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
018  */
019 
020 package jsx.ui.layout;
021 
022 import js.Id;
023 import js.ObjectLike;
024 import jsx.core.Variables;
025 import jsx.ui.Container;
026 
027 /**
028  * <p>Layouts children of a container in a flow.</p>
029  * <p>Note, A {@link FlowLayout} layout is composed of {@link BarLayout} layouts 
030  * although a {@link BarLayout} is also a {@link FlowLayout}.</p>
031  * 
032  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
033  */
034 public class FlowLayout extends AbsoluteLayout
035 {
036     /**
037      * <p>A global identifier for a configurable property of a {@link FlowLayout} object.</p>
038      * <p>The identified configurable property of a {@link FlowLayout} object refers to 
039      * a boolean value specifying whether the layout manager flows vertically the 
040      * children of the container for which it is doing layout.</p>
041      * @since 1.0
042      */
043     public final static Id<Boolean> VERTICAL = new Id<Boolean>();
044     /**
045      * <p>A global identifier for a configurable property of a {@link FlowLayout} object.</p>
046      * <p>The identified configurable property of a {@link FlowLayout} object refers to 
047      * an integer number specifying where the layout manager starts to arrange the 
048      * children of the container for which it is doing layout. Possible values are:
049      * <ul>
050      * <li>{@link #LEFTTOP}: Starts from top for a vertical flow and from left for a 
051      * horizontal flow. Aligns the children to left for a vertical flow and to top for 
052      * a horizontal flow. This is the default value.</li>
053      * <li>{@link #RIGHTTOP}: Starts from top for a vertical flow and from right for a 
054      * horizontal flow. Aligns the children to right for a vertical flow and to top for 
055      * a horizontal flow.</li>
056      * <li>{@link #LEFTBOTTOM}: Starts from bottom for a vertical flow and from left for a 
057      * horizontal flow. Aligns the children to left for a vertical flow and to bottom for 
058      * a horizontal flow.</li>
059      * <li>{@link #RIGHTBOTTOM}: Starts from bottom for a vertical flow and from right for a 
060      * horizontal flow. Aligns the children to right for a vertical flow and to bottom for 
061      * a horizontal flow.</li>
062      * </ul>
063      * </p>
064      * @since 1.0
065      */
066     public final static Id<Integer> ORIGIN = new Id<Integer>();
067 
068     /**
069      * <p>This constant is a legal value for the {@link #ORIGIN} configurable property 
070      * of a {@link FlowLayout} object. This is the default value.</p>
071      * @since 1.0
072      */
073     public final static int LEFTTOP = 0;
074     /**
075      * <p>This constant is a legal value for the {@link #ORIGIN} configurable property 
076      * of a {@link FlowLayout} object.</p>
077      * @since 1.0
078      */
079     public final static int RIGHTTOP = 1;
080     /**
081      * <p>This constant is a legal value for the {@link #ORIGIN} configurable property 
082      * of a {@link FlowLayout} object.</p>
083      * @since 1.0
084      */
085     public final static int LEFTBOTTOM = 2;
086     /**
087      * <p>This constant is a legal value for the {@link #ORIGIN} configurable property 
088      * of a {@link FlowLayout} object.</p>
089      * @since 1.0
090      */
091     public final static int RIGHTBOTTOM = 3;
092 
093     /**
094      * <p>The default constructor that constructs a layout manager of this type.</p>
095      * <p>This constructor invokes the default constructor of the superclass.</p>
096      * @since 1.0
097      * @see #FlowLayout(ObjectLike)
098      */
099     public FlowLayout() {
100     }
101 
102     /**
103      * <p>A typical constructor that constructs a layout manager of this type and forces 
104      * constructors of subclasses to pass initializing data.</p>
105      * <p>This constructor invokes the typical constructor of the superclass passing 
106      * the specified initializing object as the argument.</p>
107      * @param ini The initializing object.
108      * @since 1.0
109      * @see #FlowLayout()
110      */
111     public FlowLayout(ObjectLike ini) {
112         super(ini);
113         if (Variables.undefined(ini(this).var(ORIGIN))) {
114             ini(this).var(ORIGIN, LEFTTOP);
115         }
116     }
117 
118     /**
119      * <p>Layouts a container.</p>
120      * <p>This method layouts children of a container in a flow.</p>
121      * @param c The container to layout.
122      * @since 1.0
123      */
124     @Override
125     protected void doLayout(Container c) {
126     }
127 }