/*---------------- 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.framework.bars.ButtonBar; import nl.idgis.giclient.config.Colors; import nl.idgis.giclient.util.Debug; import nl.idgis.giclient.framework.Frame; import nl.idgis.giclient.GIClient; import nl.idgis.giclient.Ruler; import nl.idgis.giclient.util.SynchListener; import nl.idgis.giclient.io.XMLResponse; import nl.idgis.giclient.framework.bars.ButtonBarConfig; import nl.idgis.giclient.GIClientConfig; import nl.idgis.giclient.util.Strings; class nl.idgis.giclient.framework.FrameWork extends MovieClip { private var giClient:GIClient = null; // Set by init object. private var buttonBarDepths:Object = new Object(); // Hashtable. private var depth:Number = 0; static private var framesDepth:Number = 0; private var ruler:Ruler = null; static private var maxMessages = 5; static private var messageDepth = 100; static private var messageWidth = 400; static private var messageHeight = 20; static private var messageY = 100; static private var messageInterval = 4000; private var messageCount:Number; private var messageTextFields:Array = null; private var messageIntervals:Array = null; function onLoad():Void { createEmptyMovieClip("frames", 1); createEmptyMovieClip("buttonBars", 3); var initObject:Object = {_x:-300,_y:-100, _visible: false, scrollContent: "lib://Authenticator", paneTitle: "Aanmelden", isScrolling: false, resizable: false, hasShader: false, colorlight: 0xefefef, colordark: 0x828282}; initObject["paneComponent"] = this; addFrame("authenticator", initObject); this["frames"]["authenticator"].setSize(140,90); var textFormat0:TextFormat = new TextFormat(); textFormat0.font = "Arial"; textFormat0.color = 0xff0000; textFormat0.bold = true; var textFormat1:TextFormat = new TextFormat(); textFormat1.font = "Arial"; textFormat1.color = 0xffffff; textFormat1.bold = true; messageTextFields = new Array(); messageTextFields[0] = new Array(); messageTextFields[1] = new Array(); messageTextFields[2] = new Array(); messageTextFields[3] = new Array(); messageTextFields[4] = new Array(); for(var j:Number = 0; j < messageTextFields.length; j++) { for(var i:Number = 0; i < maxMessages; i++) { var nr:Number = i + ((messageTextFields.length - j - 1) * (maxMessages + 1)); messageTextFields[j][i] = this.createTextField("message" + nr, messageDepth + nr, getMessageX(j), getMessageY(j, i), messageWidth, messageHeight); TextField(messageTextFields[j][i]).setNewTextFormat(j == 0 ? textFormat0 : textFormat1); TextField(messageTextFields[j][i]).selectable = false; //TextField(messageTextFields[j][i]).text = "message" + i; } } messageCount = -1; messageIntervals = new Array(); Stage.addListener(this); giClient.onLoadFrameWork(); } private function getMessageY(j:Number, i:Number) : Number { var retval:Number = Stage.height - messageY - i * messageHeight; switch(j) { case 3: retval -= 1; break; case 4: retval += 1; } return retval; } private function getMessageX(j:Number) : Number { var retval:Number = Stage.width + 10; switch(j) { case 1: retval -= 1; break; case 2: retval += 1; } return retval; } function onResize() { for(var j:Number = 0; j < messageTextFields.length; j++) { for(var i:Number = 0; i < messageTextFields[j].length; i++) { var textField:TextField = TextField(messageTextFields[j][i]); if(textField.text == "") { textField._x = getMessageX(j); } else { textField._x = getMessageX(j) - 10 - messageWidth; } textField._y = getMessageY(j, i); } } } function addMainFrame():Void{ attachMovie("MainFrame", "mainFrame", 2, {ruler: ruler}); } function addProgressBar():Void { var initObject:Object = null; /* initObject = new Object(); initObject["name"] = "ProgB"; initObject["xRel"] = 0; initObject["yRel"] = 100; // Don't confuse xy with _x_y. attachMovie("ProgressBar", "progressBar", 5, initObject); */ this["progressBar"].setRuler(ruler); } function addScaleBar():Void{ var initObject:Object = null; initObject = new Object(); initObject["name"] = "ScalB"; initObject["xRel"] = 100; initObject["yRel"] = 100; // Don't confuse xy with _x_y. attachMovie("ScaleBar", "scaleBar", 4, initObject); this["scaleBar"].setRuler(ruler); } function addTimeBar():Void{ //Create TimeBar var initObject:Object = null; initObject = new Object(); initObject["name"] = "ScalB"; initObject["xRel"] = 50; initObject["yRel"] = 0; // Don't confuse xy with _x_y. attachMovie("Timebar", "timeBar", 5, initObject); this["timeBar"].setRuler(ruler); } static function addFrame(name:String, initObject:Object):Frame { var movieClip:MovieClip; if(initObject.frameClass!=null){ movieClip = _root["frameWork"]["frames"].attachMovie(initObject.frameClass, name, framesDepth++, initObject); } else { movieClip = _root["frameWork"]["frames"].attachMovie("Frame", name, framesDepth++, initObject); } return Frame(movieClip); } function addButtonBar(buttonBarConfig:ButtonBarConfig):ButtonBar { var name:String = buttonBarConfig.getName(); var buttonBar:ButtonBar = null; if (buttonBarDepths[name] == null) { buttonBar = buttonBarConfig.inflate(this["buttonBars"], this["buttonBars"].getNextHighestDepth()); buttonBarDepths[name] = buttonBar.getDepth(); } else { buttonBar = buttonBarConfig.inflate(this["buttonBars"], buttonBarDepths[name]); } return buttonBar; } private var isBusy:Boolean = false; private var busyTypes:Object = new Object(); private function getBusyType(type:String) : Array { var busyType:Array = busyTypes[type]; if(busyType == null) { busyType = new Array(); busyTypes[type] = busyType; } return busyType; } private function checkBusy() { for(var s:String in busyTypes) { if(Array(busyTypes[s]).length > 0) { return; } } isBusy = false; hideProgressIndicator(); } public function setBusy(type:String, id:String) { var busyType:Array = getBusyType(type); for(var i:Number = 0; i < busyType.length; i++) { if(busyType[i] == id) { return; } } busyType.push(id); if(!isBusy) { isBusy = true; showProgressIndicator(); } } public function resetBusyType(type:String) { busyTypes[type] = new Array(); checkBusy(); } public function resetBusy(type:String, id:String) { var busyType:Array = getBusyType(type); for(var i:Number = 0; i < busyType.length; i++) { if(busyType[i] == id) { busyType.splice(i, 1); break; } } checkBusy(); } private function showProgressIndicator():Void { var mc:MovieClip = this["buttonBars"]["LogosButtonBar_mc"]["GeoideButtonPosition_mc"]["AboutViewerButton_mc"]["base"]; mc.play(); } private function hideProgressIndicator():Void { var mc:MovieClip = this["buttonBars"]["LogosButtonBar_mc"]["GeoideButtonPosition_mc"]["AboutViewerButton_mc"]["base"]; mc.gotoAndStop(1); } function authenticate(xmlResponse:XMLResponse, userName:String):Void { this["frames"]["authenticator"].getScrollContent().setXMLResponse(xmlResponse); // temp solution this["frames"]["authenticator"].getScrollContent().setUserName(userName); // temp solution this["frames"]["authenticator"]._visible = true; this["frames"]["authenticator"]._x = 325; // temp solution this["frames"]["authenticator"]._y = 250; // temp solution } function state(statement:String, debugStatementsLevel:Number):Void { if (Debug.getStatementsLevel() >= debugStatementsLevel) { if (this["frames"]["staterPane"] == null) { var initObject:Object = {scrollContent: "lib://Stater" , paneTitle: /*"Foutmelding"*/ Strings.getFile("Geoide").getString("ErrorMessage"), isScrolling: true, resizable: true, hasShader: true, colorlight:0xffecef, colordark:0xeebbbb, _x:200, _y:100}; initObject["paneComponent"] = this; addFrame("staterPane", initObject); this["frames"]["staterPane"].contentProperties.statement = statement; this["frames"]["staterPane"].setSize(400,300); } this["frames"]["staterPane"].getScrollContent().setStatement(statement, debugStatementsLevel); } } static function giTrace(traceStr:String, classMethod:String, fileName:String, lineNo:Number):Void { if (_root["frameWork"]["frames"]["staterPane"] == null) { var initObject:Object = {scrollContent: "lib://Stater" , paneTitle: /*"Foutmelding"*/ Strings.getFile("Geoide").getString("ErrorMessage"), isScrolling: true, resizable: true, hasShader: true, colorlight:0xffecef, colordark:0xeebbbb, _x:200, _y:100}; initObject["paneComponent"] = _root["frameWork"]; addFrame("staterPane", initObject); _root["frameWork"]["frames"]["staterPane"].contentProperties.statement = traceStr; _root["frameWork"]["frames"]["staterPane"].setSize(600,300); } _root["frameWork"]["frames"]["staterPane"].getScrollContent().setStatement(traceStr + ";method: " + classMethod + ";line: " + lineNo, 0); } function makeFrame(type:String, paneInitObject:Object,width:Number, height:Number):Void { if (this["frames"][type] == null) { var initObject:Object = paneInitObject; initObject["paneComponent"] = this; initObject["colorlight"] = Colors.defaultLightColor; initObject["colordark"] = Colors.defaultDarkColor; addFrame(type, initObject); this["frames"][type].setSize(width,height); } } function makeUserMessageFrame(userMessage:String, frameTitle:String):Void { if (this["frames"]["userMessageFrame"] == null) { var initObject:Object = {scrollContent: "lib://UserMessage" , paneTitle: frameTitle, isScrolling:true, resizable:true, hasShader: true, colorlight:0x88a3ca, colordark:0x00639f,doorzichtig:false, _x:200, _y:100}; initObject["paneComponent"] = this; initObject["contentProperties"] = new Object(); initObject["contentProperties"]["userMessage"] = userMessage; addFrame("userMessageFrame", initObject); this["frames"]["userMessageFrame"].setSize(300,150); } } function hidePane(ok:String, frame:MovieClip):Void { // TODO own hide handler for each frame if (this["frames"]["confirmationFrame"] != null) { var synchListener:SynchListener = this["frames"]["confirmationFrame"].contentProperties.synchListener; this["frames"]["confirmationFrame"].handleClose(); this["frames"]["confirmationFrame"].removeMovieClip(); var target:Object = new Object(); if (ok == "OK") { target["answer"] = "OK"; } else { target["answer"] = "CANCEL"; } synchListener.onSynch(target, "HIDE_PANE"); } else { frame.handleClose(); frame.removeMovieClip(); } } function setRuler(ruler:Ruler):Void { this.ruler = ruler; } private function removeMessage():Void { for(var j:Number = 0; j < messageTextFields.length; j++) { TextField(messageTextFields[j][messageCount]).text = ""; TextField(messageTextFields[j][messageCount])._x = Stage.width + 10; } clearInterval(messageIntervals[messageCount]); messageCount--; } function message(message:String):Void { if(messageCount == maxMessages - 1) { removeMessage(); } for(var i:Number = messageCount + 1; i > 0; i--) { messageIntervals[i] = messageIntervals[i - 1]; } for(var j:Number = 0; j < messageTextFields.length; j++) { for(var i:Number = messageCount + 1; i > 0; i--) { TextField(messageTextFields[j][i])._x = getMessageX(j) - 10 - messageWidth; TextField(messageTextFields[j][i]).text = TextField(messageTextFields[j][i - 1]).text; } TextField(messageTextFields[j][0]).text = message; TextField(messageTextFields[j][0])._x = getMessageX(j) - 10 - messageWidth; } messageIntervals[0] = setInterval(this, "removeMessage", messageInterval); messageCount++; } function hideButtonBar(name:String):Void { if(this["buttonBars"][name + "_mc"]) { MovieClip(this["buttonBars"][name + "_mc"])._visible = false; } } function showButtonBar(name:String):Void { if(this["buttonBars"][name + "_mc"]) { MovieClip(this["buttonBars"][name + "_mc"])._visible = true; } } }