can now change tags in the 'Advanced' mode
[potlatch2.git] / halcyon.mxml
index ab3f6d73448b0c2b63990d02c06b3148665ca47f..bd1f10b5fbc797a9071fd9e04e4def790fd8a50f 100755 (executable)
@@ -6,11 +6,17 @@
        horizontalAlign="center" 
        addedToStage="initApp()">
 
-<!--    <halcyon:CountryComboBox /> -->
+    <mx:HDividedBox width="100%" height="100%">
 
-<!--   <halcyon:Map width="400" height="200" id="theMap" /> -->
-<!-- applicationComplete -->
-<!-- rawChildren -->
+      <mx:VBox height="100%" width="25%" horizontalAlign="right">
+        <mx:HBox>
+          <mx:Button label="-" click="theMap.zoomOut();"/>
+          <mx:Button label="+" click="theMap.zoomIn();"/>
+        </mx:HBox>
+        <halcyon:TagViewer width="100%" height="100%" id="tagViewer"/>
+      </mx:VBox>
+      <mx:Canvas id="map_area" width="75%" height="100%" resize="onResizeMap()"/>
+    </mx:HDividedBox>
 
        <mx:Script><![CDATA[
                import net.systemeD.halcyon.*;
                import flash.events.MouseEvent;
                import flash.display.Sprite;
                import mx.core.IChildList;
+        import mx.containers.Canvas;
+               import mx.core.Application;
+
+        public var theMap:Map;
 
                private function initApp():void {
 
-                       Globals.vars.root=rawChildren;                  // set up global reference to root level
-                       var _root:IChildList=rawChildren;               // convenient local shorthand
+                       Globals.vars.map_area=map_area;
+                       Globals.vars.root=map_area.rawChildren;                 // set up global reference to root level
+                       var _root:IChildList=map_area.rawChildren;              // convenient local shorthand
 
                        // map backdrop object
-                       var b:Sprite=new Sprite();
-                       b.graphics.beginFill(0xFFFFEA,100);
-                       b.graphics.drawRect(0,0,200,200);
-                       b.graphics.endFill();
+            var w:uint = map_area.width;
+            var h:uint = map_area.height;
+            var b:Sprite = new Sprite();
+            b.height=h; b.width=w;
+            b.graphics.beginFill(0xFFFFEA,100); 
+            b.graphics.drawRect(0,0,w,h); 
+            b.graphics.endFill();
                        _root.addChild(b);
 
                        // add map
-                       var theMap:Map=new Map();
+                       theMap=new Map();
                        theMap.backdrop=b;
                        _root.addChild(theMap);
+            theMap.updateSize(w, h);
 
                        // add mask for map
                        var s:Sprite=new Sprite();
                        s.graphics.beginFill(0xFFFFFF,100);
-                       s.graphics.drawRect(0,0,200,200);
+                       s.graphics.drawRect(0,0,w,h);
                        s.graphics.endFill();
                        _root.addChild(s);
-
                        theMap.mask=s;
 
+                       // add crosshair
+                       /*s=new Sprite();
+                       s.graphics.lineStyle(2,0);
+                       s.graphics.moveTo(stage.stageWidth/2-20,stage.stageHeight/2);
+                       s.graphics.lineTo(stage.stageWidth/2+20,stage.stageHeight/2);
+                       s.graphics.moveTo(stage.stageWidth/2,stage.stageHeight/2-20);
+                       s.graphics.lineTo(stage.stageWidth/2,stage.stageHeight/2+20);
+                       _root.addChild(s);*/
+
                        // mouse-up handler attached to stage, so the user can release outside the map
                        stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
                        theMap.backdrop.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
                        // keyboard event attached to stage
                        stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler);
 
+                       // example listener event
+                       var myListenerObj:Object = new Object();
+                       myListenerObj.mapHandler=function(event:MapEvent):void {
+                               Globals.vars.debug.appendText("Download event fired - "+event.minlat+","+event.minlon+"\n");
+                       };
+                       theMap.addEventListener(MapEvent.DOWNLOAD, myListenerObj.mapHandler);
+
                        // add debug field
                        var t:TextField=new TextField();
                        t.width=400; t.height=100; t.border=true; 
                        t.multiline=true;
                        _root.addChild(t);
                        Globals.vars.debug=t;
+            t.visible = false;
+
+            var controller:EditController = new EditController(theMap, tagViewer);
+            controller.setActive();
                }
 
+        public function onResizeMap():void {
+            if ( theMap != null )
+                theMap.updateSize(map_area.width, map_area.height);
+        }
+
        ]]></mx:Script>
 
 </mx:Application>