/*---------------- FILE HEADER --------------------------------------- This file is part of Geoide. Copyright (C) 2005-2006 by: IDgis B.V. http://www.idgis.nl This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: Herman Assink IDgis bv P.O. Box 15 7450 AA Holten The Netherlands E-Mail: herman.assink@idgis.nl * @version 1.4.0 * @author IDgis team * ------------------------------------------------------------------------*/ import nl.idgis.giclient.gui.ContainerContent; import nl.idgis.giclient.util.Strings; class nl.idgis.giclient.framework.Frame extends MovieClip { static var paneList:Array = new Array(); static var checkedPaneCount = 0; static var topMostClickedDepth = -32768; static var topMostClickedPane = null; var controller = null; var level = null; var hasShader; var boundingBox_mc; var maxWidth; var maxHeight; var titleText_mc; var resizable; var isScrolling; var colordark:Number; var colorlight:Number; private var topLeftColor:Number = 0x000000; private var backGroundColor:Number = 0x000000; private var closeTextWidth; var sluitVensterOnder_mc; var sluitVensterBoven_mc; var paneComponent; var achtergrond_mc; var resizeGrip_mc; var resizeCursor_mc; var titleArea_mc; var scrollpane_mc; var scrollContent; var paneTitle; var ruler; var textStyle; var styleTable; var randRechts_mc; var randLinks_mc; var randOnder_mc; var randBoven_mc; var hoekRechtsOnder_mc; var hoekLinksOnder_mc; var hoekRechtsBoven_mc; var hoekLinksBoven_mc; var hoekBuitenRechtsBoven_mc; var doorzichtig; var schaduwRechts_mc; var schaduwOnder_mc; var schaduwLinksBinnen_mc; var schaduwBovenBinnen_mc; var enable; var width; var height; var minimalWidth; var minimalHeight; var minWidth; var minHeight; var anchorX; var anchorY; var contentProperties:Object; function Frame() { topLeftColor = colordark; backGroundColor = colorlight; drawAll(); } function onLoad():Void { } private function drawAll():Void { this.controller = this; this.level = 1; this.attachMovie("PaneBack","achtergrond_mc",this.level++, {controller:this}); this.attachMovie("SchaduwVert","schaduwRechts_mc",this.level++, {controller:this}); this.attachMovie("SchaduwVert","schaduwLinksBinnen_mc",this.level++, {controller:this}); this.attachMovie("SchaduwHor","schaduwOnder_mc",this.level++, {controller:this}); this.attachMovie("SchaduwHor","schaduwBovenBinnen_mc",this.level++, {controller:this}); this.attachMovie("Rand","randRechts_mc",this.level++, {controller:this}); this.attachMovie("Rand","randOnder_mc",this.level++, {controller:this}); this.attachMovie("Rand","randLinks_mc",this.level++, {controller:this}); this.attachMovie("Rand","titleArea_mc",this.level++, {controller:this}); this.attachMovie("hoekRechtsOnder","hoekRechtsOnder_mc",this.level++, {controller:this}); this.attachMovie("hoekLinksOnder","hoekLinksOnder_mc",this.level++, {controller:this}); this.attachMovie("hoekRechtsBoven","hoekRechtsBoven_mc",this.level++, {controller:this}); this.attachMovie("hoekLinksBoven","hoekLinksBoven_mc",this.level++, {controller:this}); this.attachMovie("GeoideScrollPaneSymbol", "scrollpane_mc", this.level++, {controller:this}); this.attachMovie("GeoideLabelSymbol", "titleText_mc", this.level++, {controller:this}); this.attachMovie("ResizeGrip", "resizeGrip_mc", this.level++, {controller:this}); this.attachMovie("ResizeCursor", "resizeCursor_mc", this.level++, {controller:this}); if (this.hasShader == null || this.hasShader == true) { // no or //this.attachMovie("buttonSluitVenster","sluitVensterOnder_mc",this.level++, {controller:this}); var format:TextFormat = new TextFormat(); format.font = "_sans"; format.size = 6; var str:String = Strings.getFile("Geoide").getString("CloseWindow"); var extend:Object = format.getTextExtent(str); closeTextWidth = extend["textFieldWidth"] * 2; this.createEmptyMovieClip("sluitVensterOnder_mc", this.level++); var field:TextField = MovieClip(this.sluitVensterOnder_mc).createTextField("text", 0, 0, 0, 200, 10); field.setNewTextFormat(format); field.textColor = 0xffffff; field.text = str; this.attachMovie("SluitKnop","sluitVensterBoven_mc",this.level++, {controller:this}); } if (this.boundingBox_mc == undefined) { this.attachMovie("FBoundingBoxSymbol", "boundingBox_mc", this.level++); } this.boundingBox_mc.controller = this; this.boundingBox_mc._visible = false; // Max and Min size are -1, indicating to use the full size of the Stage and simply title bar and widgets, respectively this.maxWidth = -1; this.maxHeight = -1; this.minWidth = -1; this.minHeight = -1; this.titleText_mc.labelField.autoSize = "left"; if (this.resizable == undefined) { this.resizable = true; } if (this.isScrolling == undefined) { this.isScrolling = true; } this.sluitVensterOnder_mc.paneComponent = this.paneComponent; this.sluitVensterBoven_mc.paneComponent = this.paneComponent; this.sluitVensterOnder_mc.onRelease = function() { this.paneComponent.hidePane(null,this._parent); //this.paneComponent.hidePane(this._parent.attrInfoLayer); // TODO more general pane identifier }; this.sluitVensterBoven_mc.onRelease = function() { //this.paneComponent.hidePane(this._parent.attrInfoLayer); // TODO more general pane identifier this.paneComponent.hidePane(null,this._parent); }; //onRollOver en OnRollOut, nodig vanwege juiste afhandeling onmousemove //in de mapviewer this.achtergrond_mc.onRollOver = function(){ }; this.achtergrond_mc.onRollOver = function(){ }; this.achtergrond_mc.useHandCursor = false; this.resizeGrip_mc.onPress = this.resizeTrackBegin; this.resizeGrip_mc.onRelease = this.resizeTrackEnd; this.resizeGrip_mc.onReleaseOutside = this.resizeTrackEnd; this.resizeCursor_mc._visible = false; this.resizeGrip_mc.onRollOver = this.setResizeCursor; this.resizeGrip_mc.onRollOut = this.restoreCursor; this.setResizable(this.resizable); this.titleArea_mc.onPress = this.titleTrackBegin; this.titleArea_mc.onRelease = this.titleTrackEnd; this.titleArea_mc.onReleaseOutside = this.titleTrackEnd; this.titleText_mc.onPress = this.titleTrackBegin; this.titleText_mc.onRelease = this.titleTrackEnd; this.titleText_mc.onReleaseOutside = this.titleTrackEnd; this.scrollpane_mc.setDragContent(false);//???? this.scrollpane_mc.refreshPane(); if (this.scrollContent != "") { this.setScrollContent(this.scrollContent); } this.setScrolling(this.isScrolling); this.setPaneTitle(this.paneTitle); this.setRuler(this.ruler); // not needed if viewer uses refreshScrollContent this.setSize(this.width, this.height); // Z-Order Handling this.boundingBox_mc.onMouseDown = function() { this._parent.boundingClickCheck(); }; paneList.push(this); checkedPaneCount = 0; topMostClickedDepth = -32768; } // ::: PUBLIC METHODS function getColor():Number { return topLeftColor; } function getBackGroundColor():Number { return backGroundColor; } function setEnabled(enabledFlag) { var enabled = (arguments.length>0) ? enabledFlag : true; this["titleArea_mc"].enabled = enabled; this["titleText_mc"].enabled = enabled; this["vensterSluiten_mc"].enabled = enabled; this["scrollpane_mc"].enabled = enabled; this["resizeGrip_mc"].enabled = enabled; this["boundingBox_mc"].enabled = enabled; //super.setEnabled(enabledFlag); } //IDgis functie om de Ruler van de draggablePane in te kunnen stellen function setRuler(ruler) { this.getScrollContent().setRuler(ruler); } function getScrollContent() { return this.scrollpane_mc.getScrollContent(); } function setScrollContent(target) { this.scrollpane_mc.setScrollContent(target); getScrollContent().setFrame(this); } function setDragContent(dragFlag) { this.scrollpane_mc.setDragContent(dragFlag);//????wat is dragcontent } function getScrollPosition() { return this.scrollpane_mc.getScrollPosition(); } function setScrollPosition(x, y) { this.scrollpane_mc.setScrollPosition(x, y); } function setScrolling(prop) { this.scrollpane_mc.setHScroll(prop); this.scrollpane_mc.setVScroll(prop); this.isScrolling = prop; } function setVScroll(prop){ this.scrollpane_mc.setVScroll(prop); } function setHScroll(prop){ this.scrollpane_mc.setHScroll(prop); } function getScrolling() { return this.isScrolling; } function refreshScrollContent() { this.setRuler(this.ruler); this.setSize(width,height); this.scrollpane_mc.refreshPane(); } function getPaneMaximums() { var xMax = this.maxWidth; var yMax = this.maxHeight; return {x:xMax, y:yMax}; } function getPaneMinimums() { var xMin = this.minWidth; var yMin = this.minHeight; return {x:xMin, y:yMin}; } function setPaneMaximumSize(w, h) { this.maxWidth = w; this.maxHeight = h; } function setPaneMinimumSize(w, h) { this.minWidth = w; this.minHeight = h; } function setResizable(resizable) { this.resizable = resizable; this.resizeGrip_mc._visible = resizable; } function getResizable() { return this.resizable; } function setSize(w, h) { if (arguments.length < 2 || isNaN(w) || isNaN(h)) return; // width is limited to that of the min scroll pane size w = Math.max(w,60); h = Math.max(h,60); this._xscale = 100; this._yscale = 100; doSetSize(w, h, false); this.boundingBox_mc._width = w + 20; this.boundingBox_mc._height = h + 40; this.boundingBox_mc._x = -10; this.boundingBox_mc._y = -20; this.formatFrame(this._x, this._y, w, h); if(isScrolling){ if(ContainerContent(this.scrollpane_mc.tmp_mc).getContentWidth() > width|| ContainerContent(this.scrollpane_mc.tmp_mc).getContentWidth() == -1){ setHScroll(true); } else { setHScroll(false); } if(ContainerContent(this.scrollpane_mc.tmp_mc).getContentHeight() > height || ContainerContent(this.scrollpane_mc.tmp_mc).getContentHeight() == -1){ setVScroll(true); } else { setVScroll(false); } this.getScrollContent().onResizeFrame(width,height); } } function getWidth():Number{ return this.width; } function getHeight():Number{ return this.height; } function doSetSize(w:Number, h:Number, noEvent:Boolean):Void { var oldWidth:Number = width; var oldHeight:Number = height; width = w; height = h; if (noEvent != true) { var ed = new mx.events.UIEventDispatcher(); ed.dispatchEvent({type:"resize", oldWidth:oldWidth, oldHeight:oldHeight}); } } function setContentSize(w, h) { // Shortcut routine for setting pane size based on desired content area var newWidth = w + 5; if (this.controller.isScrolling && !this.controller.isVScrolling ) newWidth += this.controller.scrollpane_mc.vScrollBar_mc._width; var newHeight = h + 5; //this.controller.getTitlebarHeight(); if (this.controller.isScrolling) newHeight += this.controller.scrollpane_mc.hScrollBar_mc._height; this.setPaneSize(newWidth,newHeight); } function setPaneSize(w, h) { // Min/Max checking var newWidth = w; var newHeight = h; if (newWidth == undefined) newWidth = 320; if (newHeight == undefined) newHeight = 240; if (this.maxWidth>0 && newWidth>this.maxWidth) { newWidth = this.maxWidth; } if (this.minWidth>0 && newWidth0 && newHeight>this.maxHeight) { newHeight = this.maxHeight; } if (this.minHeight>0 && newHeight closeBoxOffset) { this.titleText_mc._x = closeBoxOffset - this.titleText_mc._width; } } function formatFrame(x, y, w, h) { var randbreed = 20; var randsmal = 10; var titleHeight = 20; var thisWidth = w; var thisHeight = h; var my_color; //geef alle componenten de juiste kleuren met variabelen topLeftColor en backGroundColor my_color = new Color(this.randRechts_mc); my_color.setRGB(this.topLeftColor); my_color = new Color(this.randOnder_mc); my_color.setRGB(this.topLeftColor); my_color = new Color(this.randLinks_mc); my_color.setRGB(this.topLeftColor); my_color = new Color(this.titleArea_mc); my_color.setRGB(this.topLeftColor); my_color = new Color(this.hoekRechtsOnder_mc["hoekBuitenRechtsOnder"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.hoekLinksOnder_mc["hoekBuitenLinksOnder"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.hoekLinksBoven_mc["hoekBuitenLinksBoven"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.hoekRechtsBoven_mc["hoekBuitenRechtsBoven"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.achtergrond_mc); my_color.setRGB(this.backGroundColor); if(this.doorzichtig == false){ var myColorTransform:Object = {aa:100, ab:255}; my_color.setTransform(myColorTransform); } my_color = new Color(this.scrollpane_mc["hScrollBar_mc"]["geoideScrollTrack_mc"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.scrollpane_mc["vScrollBar_mc"]["geoideScrollTrack_mc"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.scrollpane_mc["hScrollBar_mc"]["geoideScrollBall_mc"]["ballBack_mc"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.scrollpane_mc["vScrollBar_mc"]["geoideScrollBall_mc"]["ballBack_mc"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.scrollpane_mc["hScrollBar_mc"]["geoideScrollBall_mc"]["pijlenBoven"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.scrollpane_mc["hScrollBar_mc"]["geoideScrollBall_mc"]["pijlenOnder"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.scrollpane_mc["vScrollBar_mc"]["geoideScrollBall_mc"]["pijlenBoven"]); my_color.setRGB(this.topLeftColor); my_color = new Color(this.scrollpane_mc["vScrollBar_mc"]["geoideScrollBall_mc"]["pijlenOnder"]); my_color.setRGB(this.topLeftColor); this.achtergrond_mc._width = thisWidth + 2*randsmal -8; this.achtergrond_mc._height = thisHeight + 2*randbreed -8; this.achtergrond_mc._x = -randsmal + 4; this.achtergrond_mc._y =-randbreed + 4; this.randRechts_mc._width = randsmal ; this.randRechts_mc._height = thisHeight - 27.5; this.randRechts_mc._x = thisWidth; this.randRechts_mc._y = -randsmal + 24; this.randLinks_mc._width = randsmal; this.randLinks_mc._height = thisHeight - 27.5; this.randLinks_mc._x = - randsmal; this.randLinks_mc._y = -randsmal + 24; this.randOnder_mc._width = thisWidth - 27.5; this.randOnder_mc._height = randbreed; this.randOnder_mc._x = -randsmal + 24; this.randOnder_mc._y = thisHeight; this.titleArea_mc._width = thisWidth; this.titleArea_mc._height = titleHeight; this.titleArea_mc._x = 0; this.titleArea_mc._y = - titleHeight; this.schaduwRechts_mc._width = 4; this.schaduwRechts_mc._height = thisHeight - 28; this.schaduwRechts_mc._x = thisWidth + randsmal; this.schaduwRechts_mc._y = -randsmal + 24; this.schaduwOnder_mc._height = 4; this.schaduwOnder_mc._width = thisWidth - 28; this.schaduwOnder_mc._x = -randsmal + 24; this.schaduwOnder_mc._y = thisHeight + randbreed; this.schaduwLinksBinnen_mc._width = 4; this.schaduwLinksBinnen_mc._height = thisHeight - 28; this.schaduwLinksBinnen_mc._x = 0; this.schaduwLinksBinnen_mc._y = 14; this.schaduwBovenBinnen_mc._height = 4; this.schaduwBovenBinnen_mc._width = thisWidth - 28; this.schaduwBovenBinnen_mc._x = -randsmal + 24; this.schaduwBovenBinnen_mc._y = 0; this.hoekRechtsOnder_mc._x = thisWidth - 14; this.hoekRechtsOnder_mc._y = thisHeight - 14; this.hoekLinksOnder_mc._x = - randsmal; this.hoekLinksOnder_mc._y = thisHeight - 14; this.hoekRechtsBoven_mc._x = thisWidth - 14; this.hoekRechtsBoven_mc._y = - titleHeight; this.hoekLinksBoven_mc._x = - randsmal; this.hoekLinksBoven_mc._y = - titleHeight; this.sluitVensterOnder_mc._width = closeTextWidth; this.sluitVensterOnder_mc._height = 16; this.sluitVensterOnder_mc._x = thisWidth/2 - this.sluitVensterOnder_mc._width/2; this.sluitVensterOnder_mc._y = thisHeight + randbreed/2 - this.sluitVensterOnder_mc._height/2; this.sluitVensterBoven_mc._width = 12; this.sluitVensterBoven_mc._height = 12; this.sluitVensterBoven_mc._x = thisWidth - this.sluitVensterBoven_mc._width/2; this.sluitVensterBoven_mc._y = -10; this.scrollpane_mc._x = 4; this.scrollpane_mc._y = 4; this.scrollpane_mc.setSize(thisWidth -4,thisHeight -4); this.resizeGrip_mc._width = randsmal; this.resizeGrip_mc._height = randsmal; this.resizeGrip_mc._x = thisWidth - randsmal; this.resizeGrip_mc._y = thisHeight; this.formatTitle(thisWidth); this.setEnabled(this.enable); } function closeHandler() { this.defaultCloseHandler(); } function defaultCloseHandler() { return true; } function activateHandler() { this.defaultActivateHandler(); } function defaultActivateHandler() { for (var i = 0; i < paneList.length - 1; i++) { if (paneList[i] == this.controller){ var clickedPane = paneList[i]; var eclipsedPane = paneList[i + 1]; clickedPane.swapDepths(eclipsedPane); paneList[i] = eclipsedPane; paneList[i + 1] = clickedPane; } } } function defaultMinimumWidth() { minimalWidth = Math.max(this.titleText_mc._width, 95); return minimalWidth; } function defaultMinimumHeight() { minimalHeight = 80; return minimalHeight; } function setResizeCursor() { this.controller.resizeCursor_mc._x = this.controller._xmouse; this.controller.resizeCursor_mc._y = this.controller._ymouse; this.controller.resizeCursor_mc._visible = true; this.onMouseMove = this.controller.dragResizeCursor; Mouse.hide(); } function restoreCursor() { this.controller.resizeCursor_mc._visible = false; this.onMouseMove = null; Mouse.show(); } function dragResizeCursor() { this.controller.resizeCursor_mc._visible = true; this.controller.resizeCursor_mc._x = this.controller._xmouse; this.controller.resizeCursor_mc._y = this.controller._ymouse; } function activateHelper() { if (this.controller.activateHandler != null) { this.controller.activateHandler(this.controller); } } function boundingClickCheck() { checkedPaneCount++; if (this.controller.boundingBox_mc.hitTest(_root._xmouse, _root._ymouse, false)) { // This pane's bounds interesect where the click occurred if (this.controller.getDepth() > topMostClickedDepth || topMostClickedDepth == -32768) { topMostClickedDepth = this.controller.getDepth(); topMostClickedPane = this.controller; } } if (checkedPaneCount == paneList.length) { topMostClickedPane.activateHelper(); topMostClickedDepth = -32768; checkedPaneCount = 0; } } function isTopmostPane() { return (this == paneList[paneList.length - 1]); } function handleClose() { getScrollContent().remove(); //zorg eerst dat de te verwijderen laag de bovenste is for (var i = 0; i < paneList.length - 1; i++) { if (paneList[i] == this.controller){ var clickedPane = paneList[i]; var eclipsedPane = paneList[i + 1]; clickedPane.swapDepths(eclipsedPane); paneList[i] = eclipsedPane; paneList[i + 1] = clickedPane; } } //Gooi dan de laatste in de panelist weg var popped:Object; popped = paneList.pop(); } function titleTrackBegin(x, y) { if (this.controller.isTopmostPane()) this.controller.startDrag(); } function titleTrackEnd(x, y) { this.controller.stopDrag(); //this.controller.preserveNormals(); } function resizeTrackBegin() { Mouse.hide(); this.controller.resizeCursor_mc._visible = true; this.anchorX = this._xmouse; this.anchorY = this._ymouse; this.onMouseMove = function() { this.controller.dragResizeCursor(); var newWidth = this.controller.width+(this._xmouse-this.anchorX); var newHeight = this.controller.height+(this._ymouse-this.anchorY); if (newHeight