/*
 * Copyright (c) 2001-2007, TIBCO Software Inc.
 * Use, modification, and distribution subject to terms of license.
 */
jsx3.require("jsx3.gui.Block");jsx3.Class.defineClass("jsx3.gui.LayoutGrid",jsx3.gui.Block,null,function(a,p){a.ORIENTATIONCOL=0;a.ORIENTATIONROW=1;a.DEFAULTORIENTATION=0;a.DEFAULTREPEAT=3;a.DEFAULTDIMENSIONS=["33%","33%","34%"];a.ABSOLUTE=0;a.ADAPTIVE=1;p.init=function(q,h,c,o,l){this.jsxsuper(q,h,c,o,l);this.setRepeat(a.DEFAULTREPEAT);this.setDimensionArray(a.DEFAULTDIMENSIONS);};p.onRemoveChild=function(q,d){this.jsxsuper(q,d);this.setDimensionArray(this.getDimensionArray(),true);};p.paintChild=function(f,r){if(!r){this.recalcBox();this.repaint();}};p.getOrientation=function(){return this.jsxorientation==null?a.DEFAULTORIENTATION:this.jsxorientation;};p.setOrientation=function(c){this.jsxorientation=c;return this;};p.getBestGuess=function(){return this.jsxbestguess;};p.setBestGuess=function(i){this.jsxbestguess=i;return this;};p.getRepeat=function(){return this.jsxrepeat;};p.setRepeat=function(g){this.jsxrepeat=g;return this;};p.getDimensionArray=function(){return this.jsxsizearray;};p.setDimensionArray=function(m,q){this.jsxsizearray=m;if(q&&m!=null){var A=A=this.getRendered();if(A!=null){this.nW({},A);}}return this;};p.tD=function(c){if(!c&&this._jsxHz instanceof Array)return this._jsxHz;var Eb=this.RL(true);var z=this.getOrientation()==a.ORIENTATIONCOL?Eb.P5():Eb.XK();var zb=0;var J=-1;var Ab=[];var hb;if((hb=this.getDimensionArray())!=null){for(var Ob=0;Ob<hb.length;Ob++){var Vb=parseInt(hb[Ob]);if(isNaN(Vb)){if(J==-1){J=Ob;}else{}Ab.push("*");}else{if(typeof(hb[Ob])=="string"&&hb[Ob].indexOf("%")>-1){var Vb=Vb/100*z;}Ab.push(Vb);zb=zb+Vb;}}if(J>-1)Ab[J]=z-zb;}this._jsxHz=Ab;return Ab;};p.IO=function(c){var Ab=this.getParent().IO(this);var Nb=Ab.width?Ab.width:Ab.parentwidth;var qb=Ab.height?Ab.height:Ab.parentheight;var V=this.tD(false);var D=c.getChildIndex();var kb=D<V.length?V[D]:0;var _=0;for(var t=0;t<D;t++)_=_+V[t];if(this.getOrientation()==a.ORIENTATIONCOL){return {boxtype:"box",left:0,top:_,width:"100%",height:"100%",parentwidth:Nb,parentheight:V[D]};}else{return {boxtype:"box",left:_,top:0,width:"100%",height:"100%",parentwidth:V[D],parentheight:qb};}};p.k7=function(l,i,f){if(this.getParent()&&(!isNaN(l.parentwidth)&&!isNaN(l.parentheight)||l.width==null&&l.height==null)){l=this.getParent().IO(this);}else{if(l==null){l={};}}var Hb=this.RL(true,l);if(i){Hb.recalculate(l,i,f);}var sb=this.tD(true);var Lb=this.getChildren();for(var K=sb.length;K<Lb.length;K++)sb[K]=0;var qc=Hb.P5();var yc=Hb.XK();if(this.getOrientation()==a.ORIENTATIONCOL){var Zb=0;for(var K=0;K<Lb.length;K++){var tc=sb[K];f.add(Lb[K],{boxtype:"box",left:0,top:Zb,width:"100%",height:"100%",parentwidth:yc,parentheight:tc},i?i.childNodes[K]:null,true);Zb=Zb+tc;}}else{var Z=0;for(var K=0;K<Lb.length;K++){var fb=sb[K];f.add(Lb[K],{boxtype:"box",left:Z,top:0,width:"100%",height:"100%",parentwidth:fb,parentheight:qc},i?i.childNodes[K]:null,true);Z=Z+fb;}}};p.T5=function(s){if(this.getParent()&&(s==null||!isNaN(s.parentwidth)&&!isNaN(s.parentheight)||!isNaN(s.width)&&!isNaN(s.height))){var s=this.getParent().IO(this);}else{if(s==null){s={};}}var gb=this.getRelativePosition()!=0&&(!this.getRelativePosition()||this.getRelativePosition()==jsx3.gui.Block.RELATIVE);if(s.boxtype==null)s.boxtype=gb||s.left==null||s.top==null?"relativebox":"box";if(s.boxtype=="relativebox"){if(s.left==null)s.left=0;if(s.top==null)s.top=0;}if(s.width==null)s.width="100%";if(s.height==null)s.height="100%";s.tagname="div";s.container="true";var Ic;if((Ic=this.getBorder())!=null&&Ic!="")s.border=Ic;return new jsx3.gui.Painted.Box(s);};p.paint=function(){this.applyDynamicProperties();var Xb=this.tD(true);var ub=this.getChildren();for(var lc=Xb.length;lc<ub.length;lc++)Xb[lc]=0;this.setOverflow(jsx3.gui.Block.OVERFLOWHIDDEN);var R=this.RL(true);var G=R.P5();var lb=R.XK();if(this.getOrientation()==a.ORIENTATIONCOL){var F=0;for(var lc=0;lc<ub.length;lc++){var Tb=Xb[lc];ub[lc].J1({left:0,top:F,width:"100%",height:"100%",parentwidth:lb,parentheight:Tb,boxtype:"box"});F=F+Tb;}}else{var ib=0;for(var lc=0;lc<ub.length;lc++){var y=Xb[lc];ub[lc].J1({left:ib,top:0,width:"100%",height:"100%",parentwidth:y,parentheight:G,boxtype:"box"});ib=ib+y;}}return this.jsxsuper();};a.getVersion=function(){return "3.0.00";};});jsx3.LayoutGrid=jsx3.gui.LayoutGrid;
