/*---------------- 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.Bar; import nl.idgis.giclient.framework.bars.Position; import nl.idgis.giclient.framework.bars.PositionConfig; import nl.idgis.giclient.GIClientConfig; class nl.idgis.giclient.framework.bars.ButtonBar extends Bar { var giClientConfig:GIClientConfig = null; // Set by init object. var buttonSize:Number = 0; // Set by init object. private var depth:Number = 1; // Background is at depth 0. var horiSpacing:Number = 0; private var positions:Array = null; private var dragging:Boolean = false; private var xDrag:Number = 0; private var yDrag:Number = 0; private var posY:Number = 0; function ButtonBar() { positions = new Array(); height = 40; width = 8+ 40 + 8; if(horiSpacing == 0) { horiSpacing = buttonSize / 2.4; } } function addPosition(positionConfig:PositionConfig):Position { var position:Position = positionConfig.inflate(this, depth++); positions.push(position); return position; } function getPosition(name:String):Position { var position:Position = null; for (var i:String in positions) { position = Position(positions[i]); if (position.getName() == name) { return position; } } return null; } function onSmartPress():Void { dragging = true; xDrag = _xmouse; yDrag = _ymouse; } function onSmartRelease():Void { dragging = false; } function onMouseMove():Void { if (dragging) { if(_level0._xmouse < 0 || _level0._xmouse > Stage.width || _level0._ymouse < 0 || _level0._ymouse > Stage.height) { dragging = false; } else { var xRel:Number = (_level0._xmouse + (width / 2) - xDrag) / Stage.width * 100; var yRel:Number = (_level0._ymouse + (height / 2) - yDrag) / Stage.height * 100; setLocation(xRel, yRel); } } } private function layout():Void { var position:Position = null; var posX:Number = horiSpacing; for (var i:Number = 0; i < positions.length; i++) { position = Position(positions[i]); position._x = posX; position._y = posY; posX += (position.getButton().getWidth() + horiSpacing); } setWidth(posX); } }