]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/dialog.cxx
Don't crash if built with --disable-atcdcl
[flightgear.git] / src / GUI / dialog.cxx
index e20a62b930015edc48be097d61e62b1215a7e781..fbf758b2979e9ed9f6f94775b7e9b6074094fa24 100644 (file)
@@ -13,7 +13,8 @@
 #include "AirportList.hxx"
 #include "property_list.hxx"
 #include "layout.hxx"
-
+#include "WaypointList.hxx"
+#include "MapWidget.hxx"
 
 enum format_type { f_INVALID, f_INT, f_LONG, f_FLOAT, f_DOUBLE, f_STRING };
 static const int FORMAT_BUFSIZE = 255;
@@ -569,9 +570,14 @@ FGDialog::updateValues (const char *objectName)
     
     puObject *widget = _propertyObjects[i]->object;
     int widgetType = widget->getType();
-    if ((widgetType & PUCLASS_LIST) && (dynamic_cast<GUI_ID *>(widget)->id & FGCLASS_LIST)) {
-      fgList *pl = static_cast<fgList*>(widget);
-      pl->update();
+    if (widgetType & PUCLASS_LIST) {
+      GUI_ID* gui_id = dynamic_cast<GUI_ID *>(widget);
+      if (gui_id && (gui_id->id & FGCLASS_LIST)) {
+        fgList *pl = static_cast<fgList*>(widget);
+        pl->update();
+      } else {
+        copy_to_pui(_propertyObjects[i]->node, widget);
+      }
     } else if (widgetType & PUCLASS_COMBOBOX) {
       fgComboBox* combo = static_cast<fgComboBox*>(widget);
       combo->update();
@@ -810,7 +816,10 @@ FGDialog::makeObject (SGPropertyNode *props, int parentWidth, int parentHeight)
         setupObject(obj, props);
         setColor(obj, props);
         return obj;
-
+    } else if (type == "map") {
+        MapWidget* mapWidget = new MapWidget(x, y, x + width, y + height);
+        setupObject(mapWidget, props);
+        return mapWidget;
     } else if (type == "combo") {
         fgComboBox *obj = new fgComboBox(x, y, x + width, y + height, props,
                 props->getBoolValue("editable", false));
@@ -873,6 +882,10 @@ FGDialog::makeObject (SGPropertyNode *props, int parentWidth, int parentHeight)
         setupObject(obj, props);
         setColor(obj, props, EDITFIELD);
         return obj;
+    } else if (type == "waypointlist") {
+        ScrolledWaypointList* obj = new ScrolledWaypointList(x, y, width, height);
+        setupObject(obj, props);
+        return obj;
     } else {
         return 0;
     }
@@ -944,12 +957,21 @@ FGDialog::setupObject (puObject *object, SGPropertyNode *props)
             name = "";
         const char *propname = props->getStringValue("property");
         SGPropertyNode_ptr node = fgGetNode(propname, true);
-        copy_to_pui(node, object);
+        if (type == "map") {
+          // mapWidget binds to a sub-tree of properties, and
+          // ignroes the puValue mechanism, so special case things here
+          MapWidget* mw = static_cast<MapWidget*>(object);
+          mw->setProperty(node);
+        } else {
+            // normal widget, creating PropertyObject
+            copy_to_pui(node, object);
+            PropertyObject *po = new PropertyObject(name, object, node);
+            _propertyObjects.push_back(po);
+            if (props->getBoolValue("live"))
+                _liveObjects.push_back(po);
+        }
+        
 
-        PropertyObject *po = new PropertyObject(name, object, node);
-        _propertyObjects.push_back(po);
-        if (props->getBoolValue("live"))
-            _liveObjects.push_back(po);
     }
 
     SGPropertyNode *dest = fgGetNode("/sim/bindings/gui", true);