]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/dialog.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / GUI / dialog.cxx
index de22f948fe0c4bede213b56167868b0ce19c565f..5370e2a22c3f2dd406bc0b320336b237fd3d288a 100644 (file)
@@ -103,7 +103,7 @@ GUIInfo::GUIInfo (FGDialog * d)
 
 GUIInfo::~GUIInfo ()
 {
-    for (int i = 0; i < bindings.size(); i++) {
+    for (unsigned int i = 0; i < bindings.size(); i++) {
         delete bindings[i];
         bindings[i] = 0;
     }
@@ -125,7 +125,7 @@ FGDialog::~FGDialog ()
 {
     puDeleteObject(_object);
 
-    int i;
+    unsigned int i;
 
                                 // Delete all the arrays we made
                                 // and were forced to keep around
@@ -155,7 +155,7 @@ FGDialog::~FGDialog ()
 void
 FGDialog::updateValue (const char * objectName)
 {
-    for (int i = 0; i < _propertyObjects.size(); i++) {
+    for (unsigned int i = 0; i < _propertyObjects.size(); i++) {
         const string &name = _propertyObjects[i]->name;
         if (name == objectName)
             copy_to_pui(_propertyObjects[i]->node,
@@ -166,7 +166,7 @@ FGDialog::updateValue (const char * objectName)
 void
 FGDialog::applyValue (const char * objectName)
 {
-    for (int i = 0; i < _propertyObjects.size(); i++) {
+    for (unsigned int i = 0; i < _propertyObjects.size(); i++) {
         if (_propertyObjects[i]->name == objectName)
             copy_from_pui(_propertyObjects[i]->object,
                           _propertyObjects[i]->node);
@@ -176,14 +176,14 @@ FGDialog::applyValue (const char * objectName)
 void
 FGDialog::updateValues ()
 {
-    for (int i = 0; i < _propertyObjects.size(); i++)
+    for (unsigned int i = 0; i < _propertyObjects.size(); i++)
         copy_to_pui(_propertyObjects[i]->node, _propertyObjects[i]->object);
 }
 
 void
 FGDialog::applyValues ()
 {
-    for (int i = 0; i < _propertyObjects.size(); i++)
+    for (unsigned int i = 0; i < _propertyObjects.size(); i++)
         copy_from_pui(_propertyObjects[i]->object,
                       _propertyObjects[i]->node);
 }
@@ -196,7 +196,9 @@ FGDialog::display (SGPropertyNode * props)
         return;
     }
 
-    _object = makeObject(props, 1024, 768);
+    _object = makeObject(props,
+                      globals->get_props()->getIntValue("/sim/startup/xsize"),
+                      globals->get_props()->getIntValue("/sim/startup/ysize"));
 
     if (_object != 0) {
         _object->reveal();
@@ -257,7 +259,7 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
     } else if (type == "combo") {
         vector<SGPropertyNode_ptr> value_nodes = props->getChildren("value");
         char ** entries = make_char_array(value_nodes.size());
-        for (int i = 0, j = value_nodes.size() - 1;
+        for (unsigned int i = 0, j = value_nodes.size() - 1;
              i < value_nodes.size();
              i++, j--)
             entries[i] = strdup((char *)value_nodes[i]->getStringValue());
@@ -280,6 +282,23 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
         dial->setWrap(props->getBoolValue("wrap", true));
         setupObject(dial, props);
         return dial;
+    } else if (type == "select") {
+        vector<SGPropertyNode_ptr> value_nodes;
+        SGPropertyNode * selection_node =
+                fgGetNode(props->getChild("selection")->getStringValue(), true);
+
+        for (int q = 0; q < selection_node->nChildren(); q++)
+            value_nodes.push_back(selection_node->getChild(q));
+
+        char ** entries = make_char_array(value_nodes.size());
+        for (unsigned int i = 0, j = value_nodes.size() - 1;
+             i < value_nodes.size();
+             i++, j--)
+            entries[i] = strdup((char *)value_nodes[i]->getName());
+        puSelectBox * select =
+            new puSelectBox(x, y, x + width, y + height, entries);
+        setupObject(select, props);
+        return select;
     } else {
         return 0;
     }
@@ -309,7 +328,7 @@ FGDialog::setupObject (puObject * object, SGPropertyNode * props)
     if (nodes.size() > 0) {
         GUIInfo * info = new GUIInfo(this);
 
-        for (int i = 0; i < nodes.size(); i++)
+        for (unsigned int i = 0; i < nodes.size(); i++)
             info->bindings.push_back(new FGBinding(nodes[i]));
         object->setCallback(action_callback);
         object->setUserData(info);