<@doc alias="layout" hierarchy="GMLDOM"> StateAnd Layout Aspect (c) SAP AG 2003-2006. All rights reserved. Aspect StateAndLayout for core.lyt:Layout; inherit core.lyt:ContainerLayout; override virtual method getRepaintRect() // // If we are inside TemporalContainerLayout, then we should occupy entire parent client area. // Otherwise 'base' should have a concrete size and position (e.g. when we're child of Scenario). // var useParent = (this.parent && this.parent.isa('core.lyt:TemporalContainerLayout')); return (useParent) ? this.parent.getContentRect() : this.getBaseRect(); end override virtual method applyLayout(focus) switch (base.layoutType) { case 'VFLOW': return this.applyLayoutVFlow(focus); case 'HFLOW': return this.applyLayoutHFlow(focus); case 'ABSOLUTE': default: return this.applyLayoutAbsolute(focus); } end virtual method applyLayoutVFlow(focus) // NOTE: Think about try-catching here // If the item that was moved is one of our child - first fix the index of all children if (focus && (focus.id in this.children)) { var arr = []; for (var iter in this.children) { var child = this.children[iter].base; // // We use child.pos instead of child.getPos(), because child.getPos fixes // negative pos values to 0, while we need their original values here in order // to set the order property correctly // var v = SPLIT(child.pos); var posy = INT(v[1]||0); arr.push({c: child, y: posy}); } SORTN(arr, 'y'); for (var i = 0, len = arr.length; i < len; i++) { arr[i].c.setProperty('index', i, true); // quiet update } } var children = this.getOrderedChildren(); var chlen = children.length; if (chlen == 0) return; var gap = this.board.marginSize; var rect = this.getContentRect(); var W = rect.w, H = rect.h var bottomY = rect.y + H; var h = (H - ((chlen - 1) * gap)) / chlen; var Y = rect.y; rect.h = INT(h); var policy = {moveH: false, moveV: true, resizeH: false, resizeV: false}; if (base.layoutReadonly) policy.moveV = false; for (var i = 0; i < chlen; i++) { var child = children[i]; rect.y = INT(Y); if (i == (chlen - 1)) rect.h = bottomY - INT(Y); // Last one can be bigger because of non-integer calculations child.setResizePolicy(policy); child.setBaseRect(rect); child.applyLayout(focus); Y += h + gap; } end virtual method applyLayoutHFlow(focus) // NOTE: Think about try-catching here // If the item that was moved is one of our child - first fix the index of all children if (focus && (focus.id in this.children)) { var arr = []; for (var iter in this.children) { var child = this.children[iter].base; // // We use child.pos instead of child.getPos(), because child.getPos fixes // negative pos values to 0, while we need their original values here in order // to set the order property correctly // var v = SPLIT(child.pos); var posx = INT(v[0]||0); arr.push({c: child, x: posx}); } SORTN(arr, 'x'); for (var i = 0, len = arr.length; i < len; i++) { arr[i].c.setProperty('index', i, true); // quiet update } } ///////////////////////////////// /* TEMP - FOR COLUMN LAYOUT PILOT var scenario = base.unit; var size = SPLIT(scenario.size); var scenarioW = INT(size[0]||640) - (2 * 8) - (2 * 8); var clcolumns = scenario.columns||3; var gapW = 8 + 8 + 8; // Form right margin + Gap + Form left margin var colW = INT((scenarioW - (clcolumns - 1) * gapW) / clcolumns); if (colW < 80) colW = 80; */ ///////////////////////////////// var children = this.getOrderedChildren(); var chlen = children.length; if (chlen == 0) return; var gap = this.board.marginSize; var rect = this.getContentRect(); var W = rect.w, H = rect.h; var rightX = rect.x + W; var w = (W - ((chlen - 1) * gap)) / chlen; var X = rect.x; rect.w = INT(w); var policy = {moveH: true, moveV: false, resizeH: false, resizeV: false}; if (base.layoutReadonly) policy.moveH = false; for (var i = 0; i < chlen; i++) { var child = children[i]; rect.x = INT(X); ///////////////////////////////// /* TEMP - FOR COLUMN LAYOUT PILOT var cols = child.base.columns||1 rect.w = 8 + (cols * colW) + (cols - 1) * gapW + 8; */ ///////////////////////////////// if (i == (chlen - 1)) rect.w = rightX - INT(X); // Last one can be bigger because of non-integer calculations child.setResizePolicy(policy); child.setBaseRect(rect); child.applyLayout(focus); X += w + gap; ///////////////////////////////// /* TEMP - FOR COLUMN LAYOUT PILOT X += rect.w + 8; */ ///////////////////////////////// } end virtual method applyLayoutAbsolute(focus) var ro = base.layoutReadonly; var policy = {moveH: !ro, moveV: !ro, resizeH: !ro, resizeV: !ro}; for (var iter in this.children) { var child = this.children[iter]; child.setResizePolicy(policy); child.applyLayout(focus); } end