| <?xml version="1.0" encoding="UTF-8" ?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| |
| --> |
| <library> |
| |
| <class name="baseBoundingBorderView" extends="view" width="250" y="100" height="400" |
| onmousedown="this._startDragState(this)" onmouseup="this._removeDragState(this)" > |
| |
| <!--- Can this Box be docked to others and |
| the width/height of parent compoent barrier --> |
| <attribute name="docking" value="false" type="boolean" /> |
| |
| <!--- Hard to explain but its clear if you play around |
| with that. Its the number of minimum pixels before |
| the "docking" effect will be there --> |
| <attribute name="dockingbarrier" value="15" type="number" /> |
| |
| <attribute name="boundingbarrier" value="2" type="number" /> |
| |
| <!--- the Event will be thrown if you close the Box --> |
| <event name="onclose" /> |
| |
| <!--- extra Event for this kind of view |
| will be thrown before the view inits new --> |
| <event name="preclose" /> |
| |
| <!---@keywords private the list of connected views --> |
| <attribute name="dockinglist" value="null" /> |
| |
| <!--- @keywords private temp-older of x-distance to docked-Box --> |
| <attribute name="tempXdistance" value="0" type="number" /> |
| |
| <!--- @keywords private temp-older of y-distance to docked-Box --> |
| <attribute name="tempYdistance" value="0" type="number" /> |
| |
| <!--- @keywords private is the Box minimized --> |
| <attribute name="isopen" value="true" type="boolean" /> |
| |
| <!--- @keywords private is the Box minimized --> |
| <attribute name="open" value="true" type="boolean" /> |
| |
| <attribute name="currentBoundingBox" value="null" /> |
| |
| <attribute name="verticalClassActive" value="false" type="boolean" /> |
| <attribute name="activationClassBounding" value="" type="string" /> |
| <attribute name="activationVClassBounding" value="" type="string" /> |
| |
| <attribute name="topClassPanel" value="" type="string" /> |
| <attribute name="bottomClassPanel" value="" type="string" /> |
| <attribute name="rightClassPanel" value="" type="string" /> |
| <attribute name="leftClassPanel" value="" type="string" /> |
| |
| <!-- this is the Width and Height of the vertical and horizontal class |
| it can have different values --> |
| <attribute name="hWidth" value="0" type="number" /> |
| <attribute name="hHeight" value="0" type="number" /> |
| <attribute name="vWidth" value="0" type="number" /> |
| <attribute name="vHeight" value="0" type="number" /> |
| |
| <!--- @keywords private --> |
| <attribute name="initheight" value="0" type="number" /> |
| |
| <attribute name="hasshadow" value="true" type="boolean" /> |
| |
| <attribute name="mousetracker_del" value="$once{ new LzDelegate(this, 'checkStaticBorders' )}" /> |
| |
| <!--- @keywords private store initial height so toggleopen can reset height --> |
| <handler name="oninit"> |
| this.initheight=this.height; |
| ////Debug.write("this.isopen: ",this.isopen); |
| if (!this.open) toggleopen(); |
| if (this.hasshadow) this.setShadow(); |
| </handler> |
| |
| <method name="setShadow" args="bool"> |
| this.hasshadow = bool; |
| <![CDATA[ |
| if (this.isinited){ |
| this.normalMC = this.getDisplayObject(); |
| //Debug.write(this.normalMC); |
| ////Debug.write("this.normalMC: ",this.normalMC); |
| ////Debug.write("this: ",this); |
| this.displacementMap = new flash.filters.DropShadowFilter(); |
| this.normalMC.filters = [this.displacementMap]; |
| } |
| ]]> |
| </method> |
| |
| <method name="close"> |
| if (this.onclose) this.onclose.sendEvent(); |
| this.doDestroy(); |
| </method> |
| |
| <method name="toggleopen"> |
| ////Debug.write("this.isopen",this.isopen); |
| this.setAttribute('isopen',!this.isopen); |
| if (this.isopen){ |
| _calcdockingList(); |
| for (var eg in this.dockinglist){ |
| if(this.dockinglist[eg].docking){ |
| ////Debug.write("this.dockinglist[eg]: ",this.dockinglist[eg].title); |
| ////Debug.write("open new y",this.y+this.initheight); |
| this.dockinglist[eg].toggleOpenByParent(this.initheight-22); |
| this.dockinglist[eg].setAttribute('y',this.y+this.initheight); |
| |
| } |
| } |
| this.setAttribute('height',this.initheight); |
| } else { |
| _calcdockingList(); |
| for (var eg in this.dockinglist){ |
| if(this.dockinglist[eg].docking){ |
| ////Debug.write("this.dockinglist[eg]: ",this.dockinglist[eg].title); |
| this.dockinglist[eg].toggleOpenByParent(-(this.initheight-22)); |
| this.dockinglist[eg].setAttribute('y',this.y+22); |
| } |
| } |
| this.setAttribute('height',22); |
| } |
| </method> |
| |
| <method name="toggleOpenByParent" args="changeY"> |
| ////Debug.write("+++++ toggleOpenByParent +++++ changeY: ",this.title,changeY); |
| var tempList=new Array(); |
| <![CDATA[ |
| //check for dockable stuff which is connected to this Box |
| for (var eg in this.parent.subviews){ |
| //check that you do not calc with yourself |
| if (this.parent.subviews[eg]!=this && this.parent.subviews[eg].docking){ |
| // there are 4 cases which have to be proofed to check every possible situation |
| var proof=false; |
| ////Debug.write("found some: ",this.parent.subviews[eg].title); |
| //top box-border |
| if ( ( ((this.y+this.height)-this.parent.subviews[eg].y) < 1 ) && ( ((this.y+this.height)-this.parent.subviews[eg].y) > -1 ) && ( (this.x+this.width) > this.parent.subviews[eg].x ) && ( this.x < (this.parent.subviews[eg].x+this.parent.subviews[eg].width) ) ){ |
| proof=true; |
| } |
| |
| if (proof) tempList.push(this.parent.subviews[eg]); |
| } |
| } |
| ]]> |
| ////Debug.write("tempList.length: ",tempList.length); |
| if (tempList.length!=0){ |
| for (var eg in tempList){ |
| if(tempList[eg].docking){ |
| ////Debug.write("toggleOpenByParent 1 [eg],changeY: ",tempList[eg].title,changeY); |
| tempList[eg].toggleOpenByParent(changeY); |
| tempList[eg].setAttribute('y',tempList[eg].y+changeY); |
| } |
| } |
| } |
| |
| </method> |
| |
| <!--- @keywords private --> |
| <method name="_removeDragState" args="obj"> |
| //It's important to remove the dragger and do docking stuff before you check for connencted Boxes |
| dragger.remove(); |
| if (obj==this){ |
| if (docking) arrangePosition(); |
| } else { |
| if (docking) _lookforParentOnly(obj); |
| } |
| |
| //check for connected Boxes |
| for (var eg in this.dockinglist){ |
| if(this.dockinglist[eg].docking){ |
| this.dockinglist[eg]._removeDragState(this); |
| } |
| } |
| mousetracker_del.unregisterAll(); |
| this.preclose.sendEvent(); |
| if (this.currentBoundingBox!=null) { |
| |
| if(this.currentBoundingBox.width>this.currentBoundingBox.height){ |
| if (this.currentBoundingBox.y==0){ |
| if ($debug) Debug.write("TOP"); |
| if (this.topClassPanel!=""){ |
| new lz[this.topClassPanel](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } else { |
| if ($debug) Debug.warn("No Top Panel Definied"); |
| new lz[this.activationVClassBounding](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } |
| } else if (this.currentBoundingBox.y==(parent.height-this.currentBoundingBox.height)){ |
| if ($debug) Debug.write("BOTTOM"); |
| if (this.bottomClassPanel!=""){ |
| new lz[this.bottomClassPanel](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } else { |
| new lz[this.activationVClassBounding](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } |
| } else { |
| new lz[this.activationVClassBounding](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } |
| } else { |
| if (this.currentBoundingBox.x==0){ |
| if ($debug) Debug.write("RIGHT"); |
| if (this.rightClassPanel!=""){ |
| new lz[this.rightClassPanel](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } else { |
| new lz[this.activationClassBounding](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } |
| } else if (this.currentBoundingBox.x==(parent.width-this.currentBoundingBox.width)){ |
| if ($debug) Debug.write("LEFT"); |
| if (this.leftClassPanel!=""){ |
| new lz[this.leftClassPanel](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } else { |
| new lz[this.activationClassBounding](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } |
| } else { |
| new lz[this.activationClassBounding](parent,{ |
| x:this.currentBoundingBox.x,y:this.currentBoundingBox.y |
| }); |
| } |
| } |
| this.currentBoundingBox.destroy(); |
| this.close(); |
| } else { |
| if(this.width>this.height){ |
| new lz[this.activationVClassBounding](parent,{x:this.x,y:this.y}); |
| } else { |
| new lz[this.activationClassBounding](parent,{x:this.x,y:this.y}); |
| } |
| this.close(); |
| } |
| </method> |
| |
| |
| <!--- @keywords private |
| the arg obj is needed because the dragging can be called by the Box itself |
| or by a Box which is connected to this Box! --> |
| <method name="_startDragState" args="obj"> |
| this.bringToFront(); |
| _calcdockingList(); |
| for (var eg in this.dockinglist){ |
| if(this.dockinglist[eg].docking){ |
| this.dockinglist[eg]._startDragState(this); |
| } |
| } |
| //store position cause it wasn't dragged by itself |
| if (obj!=this){ |
| storeAdjustmentToParent(obj.x,obj.y); |
| } |
| dragger.apply(); |
| mousetracker_del.register(lz.Idle,'onidle'); |
| </method> |
| |
| <!--- arranges the Box to be build into any border --> |
| <method name="checkStaticBorders" args="item"> |
| <![CDATA[ |
| if (!this.verticalClassActive){ |
| //if ($debug) Debug.write("checkStaticBorders"); |
| if (this.x<this.boundingbarrier){ |
| this.setAttribute('visibility','hidden'); |
| if (this.y<this.boundingbarrier){ |
| //if ($debug) Debug.write("a1"); |
| this.drawCurrentBoundingBox(0,0,this.vWidth,this.vHeight); |
| } else if ( (this.parent.height-(this.y+this.height))<this.boundingbarrier){ |
| //if ($debug) Debug.write("a2"); |
| this.drawCurrentBoundingBox(0,parent.height-this.vHeight,this.vWidth,this.vHeight); |
| } else { |
| //if ($debug) Debug.write("a3"); |
| this.drawCurrentBoundingBox(0,this.y,this.width,this.height); |
| } |
| } else if (this.y<this.boundingbarrier){ |
| this.setAttribute('visibility','hidden'); |
| if ( (this.parent.width-(this.x+this.height))<this.boundingbarrier){ |
| //if ($debug) Debug.write("b1"); |
| this.drawCurrentBoundingBox((this.parent.width-this.vWidth),0,this.vWidth,this.vHeight); |
| } else { |
| //if ($debug) Debug.write("b2"); |
| this.drawCurrentBoundingBox(this.x,0,this.vWidth,this.vHeight); |
| } |
| } else if ( (this.parent.width-(this.x+this.width))<this.boundingbarrier){ |
| this.setAttribute('visibility','hidden'); |
| //if ($debug) Debug.write("c"); |
| if ( (this.parent.height-(this.y+this.height))<this.boundingbarrier){ |
| this.drawCurrentBoundingBox(parent.width-this.vWidth,parent.height-this.vHeight,this.vWidth,this.vHeight); |
| } else { |
| this.drawCurrentBoundingBox(parent.width-this.width,this.y,this.width,this.height); |
| } |
| } else if ( (this.parent.height-(this.y+this.height))<this.boundingbarrier){ |
| |
| this.setAttribute('visibility','hidden'); |
| if ( (this.parent.width-(this.x+this.height))<this.boundingbarrier){ |
| //if ($debug) Debug.write("d1"); |
| this.drawCurrentBoundingBox(parent.width-this.vWidth,parent.height-this.vHeight,this.vWidth,this.vHeight); |
| } else { |
| //if ($debug) Debug.write("d2"); |
| this.drawCurrentBoundingBox(this.x,parent.height-this.vHeight,this.vWidth,this.vHeight); |
| } |
| } else { |
| //if ($debug) Debug.write("d"); |
| this.setAttribute('visibility','visible'); |
| if (this.currentBoundingBox!=null) { |
| this.currentBoundingBox.destroy(); |
| this.currentBoundingBox = null; |
| } |
| } |
| } else { |
| if (this.x<this.boundingbarrier){ |
| //if ($debug) Debug.write("a",(this.parent.height-(this.y+this.width))); |
| this.setAttribute('visibility','hidden'); |
| if (this.y<this.boundingbarrier){ |
| //if ($debug) Debug.write("a1"); |
| this.drawCurrentBoundingBox(0,0,this.width,this.height); |
| } else if ( (this.parent.height-(this.y+this.width))<this.boundingbarrier){ |
| //if ($debug) Debug.write("a2"); |
| this.drawCurrentBoundingBox(0,parent.height-this.height,this.width,this.height); |
| } else { |
| //if ($debug) Debug.write("a3"); |
| this.drawCurrentBoundingBox(0,this.y,this.hWidth,this.hHeight); |
| } |
| } else if (this.y<this.boundingbarrier){ |
| //if ($debug) Debug.write("b"); |
| this.setAttribute('visibility','hidden'); |
| if ( (this.parent.width-(this.x+this.width))<this.boundingbarrier){ |
| this.drawCurrentBoundingBox(this.parent.width-this.width,0,this.width,this.height); |
| } else { |
| this.drawCurrentBoundingBox(this.x,0,this.width,this.height); |
| } |
| } else if ( (this.parent.width-(this.x+this.width))<this.boundingbarrier){ |
| this.setAttribute('visibility','hidden'); |
| if ( (this.parent.height-(this.y+this.width))<this.boundingbarrier){ |
| this.drawCurrentBoundingBox(this.parent.width-this.width,parent.height-this.height,this.width,this.height); |
| } else { |
| this.drawCurrentBoundingBox(parent.width-this.hWidth,this.y,this.hWidth,this.hHeight); |
| } |
| } else if ( (this.parent.height-(this.y+this.height))<this.boundingbarrier){ |
| this.setAttribute('visibility','hidden'); |
| this.drawCurrentBoundingBox(this.x,parent.height-this.height,this.width,this.height); |
| } else { |
| //if ($debug) Debug.write("d"); |
| this.setAttribute('visibility','visible'); |
| if (this.currentBoundingBox!=null) { |
| this.currentBoundingBox.destroy(); |
| this.currentBoundingBox = null; |
| } |
| } |
| } |
| ]]> |
| </method> |
| |
| <method name="drawCurrentBoundingBox" args="x,y,width,height"> |
| if (this.currentBoundingBox!=null) this.currentBoundingBox.destroy(); |
| this.currentBoundingBox = new lz.panelBoundBox(parent,{x:x,y:y, |
| width:width,height:height}); |
| </method> |
| |
| <!--- Calc the List of Boxes which will be dragged and setposition if this Box |
| will be dragged,docked or minimized/maximized --> |
| <method name="_calcdockingList"> |
| //Clear list of conencted Boxes |
| this.dockinglist=new Array(); |
| <![CDATA[ |
| //check for dockable stuff which is connected to this Box |
| for (var eg in this.parent.subviews){ |
| //check that you do not calc with yourself |
| if (this.parent.subviews[eg]!=this && this.parent.subviews[eg].docking){ |
| // there are 4 cases which have to be proofed to check every possible situation |
| var proof=false; |
| |
| //top box-border |
| if ( ( ((this.y+this.height)-this.parent.subviews[eg].y) < 1 ) && ( ((this.y+this.height)-this.parent.subviews[eg].y) > -1 ) && ( (this.x+this.width) > this.parent.subviews[eg].x ) && ( this.x < (this.parent.subviews[eg].x+this.parent.subviews[eg].width) ) ){ |
| proof=true; |
| } |
| |
| if (proof) this.dockinglist.push(this.parent.subviews[eg]); |
| } |
| } |
| ]]> |
| ////Debug.write("this.dockinglist.length:",this.dockinglist.length); |
| </method> |
| |
| <!--- @keywords private --> |
| <method name="arrangePosition"> |
| //do the magic |
| //the idea is: look for all on the view container one level above this one |
| //and look for the width/height and 0/0 and look for "dockable" stuff there |
| var newx=this.x; |
| var newy=this.y; |
| |
| <![CDATA[ |
| |
| for (var eg in this.parent.subviews){ |
| //check that you do not calc with yourself |
| if (this.parent.subviews[eg]!=this && this.parent.subviews[eg].docking){ |
| // there are 4 cases which have to be proofed to check every possible situation |
| //left box-border |
| if ( ( ((this.x+this.width)-this.parent.subviews[eg].x) < this.dockingbarrier ) && ( ((this.x+this.width)-this.parent.subviews[eg].x) > -this.dockingbarrier ) && ( (this.y+this.height) > this.parent.subviews[eg].y ) && ( this.y < (this.parent.subviews[eg].y+this.parent.subviews[eg].height) ) ){ |
| newx= ( this.parent.subviews[eg].x - this.width ); |
| } |
| //right box-border |
| if ( ( ((this.parent.subviews[eg].x+this.parent.subviews[eg].width)-this.x)<this.dockingbarrier ) && ( ((this.parent.subviews[eg].x+this.parent.subviews[eg].width)-this.x)>-this.dockingbarrier ) && ( (this.y+this.height) > this.parent.subviews[eg].y ) && ( this.y < (this.parent.subviews[eg].y+this.parent.subviews[eg].height) ) ){ |
| newx= ( this.parent.subviews[eg].x + this.parent.subviews[eg].width ); |
| } |
| //top box-border |
| if ( ( ((this.y+this.height)-this.parent.subviews[eg].y) < this.dockingbarrier ) && ( ((this.y+this.height)-this.parent.subviews[eg].y) > -this.dockingbarrier ) && ( (this.x+this.width) > this.parent.subviews[eg].x ) && ( this.x < (this.parent.subviews[eg].x+this.parent.subviews[eg].width) ) ){ |
| newy = this.parent.subviews[eg].y-this.height; |
| } |
| //bottom box-border |
| if ( ( ((this.parent.subviews[eg].y+this.parent.subviews[eg].height)-this.y) < this.dockingbarrier ) && ( ((this.parent.subviews[eg].y+this.parent.subviews[eg].height)-this.y) > -this.dockingbarrier ) && ( (this.x+this.width) > this.parent.subviews[eg].x ) && ( this.x < (this.parent.subviews[eg].x+this.parent.subviews[eg].width) ) ){ |
| newy = this.parent.subviews[eg].y+this.parent.subviews[eg].height; |
| } |
| } |
| } |
| |
| //Check for Borders |
| //should be done _after_ checking for other dockable stuff so it gets |
| //priority to dock against the border of parent view |
| if (this.x<this.dockingbarrier){ |
| newx=0; |
| } |
| if (this.y<this.dockingbarrier){ |
| newy=0; |
| } |
| if ( (this.parent.width-(this.x+this.width))<this.dockingbarrier){ |
| newx=this.parent.width-this.width; |
| } |
| if ( (this.parent.height-(this.y+this.height))<this.dockingbarrier){ |
| newy=this.parent.height-this.height; |
| } |
| |
| //set position |
| this.setAttribute('x',newx); |
| this.setAttribute('y',newy); |
| if ($debug) Debug.write("Position: ",newx,newy); |
| ]]> |
| </method> |
| |
| <method name="storeAdjustmentToParent" args="objX,objY"> |
| this.tempXdistance=objX-this.x; |
| this.tempYdistance=objY-this.y; |
| </method> |
| |
| <!--- @keywords private |
| this method is needed because if the dragging end and |
| it was not dragged _itself_ it was draged just because a connected |
| dockable Box was dragged than it could be that the connected |
| Box was forced to dock against something different onmouseup |
| so you have to rearrange the old "adjustment" --> |
| <method name="_lookforParentOnly" args="obj"> |
| <![CDATA[ |
| var newx=obj.x-tempXdistance; |
| var newy=obj.y-tempYdistance; |
| |
| this.setAttribute('x',newx); |
| this.setAttribute('y',newy); |
| ]]> |
| </method> |
| |
| <dragstate name="dragger" /> |
| |
| <animator attribute="y" to="20" duration="1000" started="false" /> |
| |
| <animator name="doOut" attribute="y" to="-500" duration="1000" started="false" onstop="parent.doDestroy()" /> |
| |
| <method name="doDestroy"> |
| this.destroy(); |
| </method> |
| |
| </class> |
| |
| </library> |