Howto:Creating a Canvas GUI Widget: Difference between revisions

Jump to navigation Jump to search
Line 241: Line 241:
+    TestMap.setRange(35);
+    TestMap.setRange(35);
+     
+     
+    TestMap.setTranslation(160/2, 120/2);
+    TestMap.setTranslation(640/2, 480/2);
+    var r = func(name,vis=1,zindex=nil) return caller(0)[0];
+    var r = func(name,vis=1,zindex=nil) return caller(0)[0];
+    foreach(var type; [r('VOR'),r('APT'), r('APS') ] )
+    foreach(var type; [r('VOR'),r('APT'), r('APS') ] )
Line 254: Line 254:
+  }
+  }
+};
+};
diff --git a/Nasal/canvas/gui/styles/DefaultStyle.nas b/Nasal/canvas/gui/styles/DefaultStyle.nas
index 4d3de27..1f26dd4 100644
--- a/Nasal/canvas/gui/styles/DefaultStyle.nas
+++ b/Nasal/canvas/gui/styles/DefaultStyle.nas
@@ -451,3 +451,20 @@ DefaultStyle.widgets["scroll-area"] = {
    model._scroller_delta[dir] = model._size[dir] - model._scroller_size[dir];
  }
};
+
+DefaultStyle.widgets.map = {
+    new: func(parent, cfg){
+        me._root = parent.createChild("group", "map");
+    },
+    setSize: func(model, w, h){
+        # ...
+        # code for changing size
+        # ...
+
+        return me;
+    },
+    update: func(model){
+      }
+    # other APIs below, e.g., setBackground()
+};
+
</syntaxhighlight>
</syntaxhighlight>


Navigation menu