summaryrefslogtreecommitdiff
path: root/swat2/style/qooxdoo/widgets/widgets/QxBoxLayout.js
blob: 9d3e7bb47b419a0b94556782b3975f1d91ccdc34 (plain)
1
2
/* Copyright (c): 2002-2005 (Germany): United Internet, 1&1, GMX, Schlund+Partner, Alturo */
function QxBoxLayout(vOrientation,vBlockAlign,vChildrenAlign){QxLayout.call(this);this.setWidth("auto");this.setHeight("auto");if(isValid(vOrientation)){this.setOrientation(vOrientation);};if(isValid(vBlockAlign)){this.getOrientation()=="horizontal"?this.setHorizontalBlockAlign(vBlockAlign):this.setVerticalChildrenAlign(vChildrenAlign);};if(isValid(vChildrenAlign)){this.getOrientation()=="horizontal"?this.setHorizontalChildrenAlign(vChildrenAlign):this.setVerticalChildrenAlign(vChildrenAlign);};};QxBoxLayout.extend(QxLayout,"QxBoxLayout");QxBoxLayout.addProperty({name:"horizontalBlockAlign",type:String,defaultValue:"left"});QxBoxLayout.addProperty({name:"verticalBlockAlign",type:String,defaultValue:"top"});QxBoxLayout.addProperty({name:"orientation",type:String,defaultValue:"horizontal"});QxBoxLayout.addProperty({name:"horizontalChildrenAlign",type:String,defaultValue:"center"});QxBoxLayout.addProperty({name:"verticalChildrenAlign",type:String,defaultValue:"middle"});QxBoxLayout.addProperty({name:"spacing",type:Number,defaultValue:0});QxBoxLayout.addProperty({name:"ignoreOrthogonalMargin",type:Boolean,defaultValue:false});proto._d1=function(){switch(this.getOrientation()){case "horizontal":var inner=this.getInnerWidth();var sum=0;var ch=this.getChildren();var chl=ch.length;var chc;var w;var spacing=this.getSpacing();var p=[];for(var i=0;i<chl;i++){p.push(sum);chc=ch[i];sum+=chc.getMarginLeft()+chc.getAnyWidth()+chc.getMarginRight()+spacing;};sum-=spacing;var startpos=this.getPaddingLeft();switch(this.getHorizontalBlockAlign()){case "center":startpos+=(inner-sum)/2;break;case "right":startpos+=inner-sum;break;};for(var i=0;i<chl;i++){ch[i]._d3Horizontal(startpos+p[i]);};break;case "vertical":var inner=this.getInnerWidth();var ch=this.getChildren();var chl=ch.length;var chc;var glob=this.getHorizontalChildrenAlign();var ign=this.getIgnoreOrthogonalMargin();var cust,pos;for(var i=0;i<chl;i++){chc=ch[i];cust=chc.getHorizontalAlign();pos=this.getPaddingLeft();switch(isValidString(cust)?cust:glob){case "right":pos+=inner-chc.getAnyWidth();break;case "center":pos+=Math.floor((inner-chc.getAnyWidth())/2);break;};if(ign){pos-=chc.getMarginLeft();};chc._d3Horizontal(pos);};break;};return true;};proto._d2=function(){switch(this.getOrientation()){case "horizontal":var inner=this.getInnerHeight();var ch=this.getChildren();var chl=ch.length;var chc;var glob=this.getVerticalChildrenAlign();var ign=this.getIgnoreOrthogonalMargin();var cust,pos;for(var i=0;i<chl;i++){chc=ch[i];cust=chc.getVerticalAlign();pos=this.getPaddingTop();switch(isValidString(cust)?cust:glob){case "bottom":pos+=inner-chc.getAnyHeight();break;case "middle":pos+=Math.floor((inner-chc.getAnyHeight())/2);break;};if(ign){pos-=chc.getMarginTop();};chc._d3Vertical(pos);};break;case "vertical":var inner=this.getInnerHeight();var sum=0;var ch=this.getChildren();var chl=ch.length;var chc;var h;var spacing=this.getSpacing();var p=[];for(var i=0;i<chl;i++){p.push(sum);chc=ch[i];sum+=chc.getMarginTop()+chc.getAnyHeight()+chc.getMarginBottom()+spacing;};sum-=spacing;var startpos=this.getPaddingTop();switch(this.getVerticalBlockAlign()){case "middle":startpos+=(inner-sum)/2;break;case "bottom":startpos+=inner-sum;break;};for(var i=0;i<chl;i++){ch[i]._d3Vertical(startpos+p[i]);};break;};return true;};proto._modifyOrientation=function(_b1,_b2,_b3,_b4){if(this._wasVisible){this.getWidth()=="auto"?this._setChildrenDependWidth(this,"orientation"):this._d1("orientation");this.getHeight()=="auto"?this._setChildrenDependHeight(this,"orientation"):this._d2("orientation");};return true;};proto._modifySpacing=function(_b1,_b2,_b3,_b4){if(this._wasVisible){if(this.getOrientation()=="horizontal"){this.getWidth()=="auto"?this._setChildrenDependWidth(null,"spacing"):this._d1("spacing");}else {this.getHeight()=="auto"?this._setChildrenDependHeight(null,"spacing"):this._d2("spacing");};};return true;};proto._modifyIgnoreOrthogonalMargin=function(_b1,_b2,_b3,_b4){if(this._wasVisible){if(this.getOrientation()!="horizontal"){this._d1("spacing");}else {this._d2("spacing");};};return true;};proto._modifyHorizontalBlockAlign=function(_b1,_b2,_b3,_b4){return this._wasVisible?this._d1("block-align"):true;};proto._modifyVerticalBlockAlign=function(_b1,_b2,_b3,_b4){return this._wasVisible?this._d2("block-align"):true;};proto._modifyHorizontalChildrenAlign=function(_b1,_b2,_b3,_b4){return this._wasVisible?this._d1("children-align"):true;};proto._modifyVerticalChildrenAlign=function(_b1,_b2,_b3,_b4){return this._wasVisible?this._d2("children-align"):true;};proto._d5Width=function(_e4,_e5){if(this.getOrientation()=="vertical"){return QxWidget.prototype._d5Width.call(this,_e4,_e5);};var w=0;var spacing=this.getSpacing();var ch=this.getChildren();var chl=ch.length;var chc;for(var i=0;i<chl;i++){chc=ch[i];w+=chc.getMarginLeft()+chc.getAnyWidth()+chc.getMarginRight()+spacing;};return w-spacing;};proto._d5Height=function(_e4,_e5){if(this.getOrientation()=="horizontal"){return QxWidget.prototype._d5Height.call(this,_e4,_e5);};var h=0;var spacing=this.getSpacing();var ch=this.getChildren();var chl=ch.length;var chc;for(var i=0;i<chl;i++){chc=ch[i];h+=chc.getMarginTop()+chc.getAnyHeight()+chc.getMarginBottom()+spacing;};return h-spacing;};