From ff52ed507264067b62d19a06d3071c8f5bf61ea9 Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 28 Apr 2006 15:55:41 +0000 Subject: [PATCH] add an optional property node pointer to ObjectProperty. This is currently only used by the widget. It allows to "dialog-update" the list, which rescans the children and redraws the list widget with new contents. The old contents are only freed at dialog close, which should eventually get changed. --- src/GUI/dialog.cxx | 16 ++++++++++++---- src/GUI/dialog.hxx | 7 +++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/GUI/dialog.cxx b/src/GUI/dialog.cxx index a1ff28ae0..4befc5855 100644 --- a/src/GUI/dialog.cxx +++ b/src/GUI/dialog.cxx @@ -391,7 +391,11 @@ FGDialog::updateValues (const char * objectName) continue; puObject *obj = _propertyObjects[i]->object; - copy_to_pui(_propertyObjects[i]->node, obj); + SGPropertyNode *values = _propertyObjects[i]->values; + if (obj->getType() & PUCLASS_LIST && values) + ((puList *)obj)->newList(value_list(values)); + else + copy_to_pui(_propertyObjects[i]->node, obj); } } @@ -721,7 +725,9 @@ FGDialog::setupObject (puObject * object, SGPropertyNode * props) const char * propname = props->getStringValue("property"); SGPropertyNode_ptr node = fgGetNode(propname, true); copy_to_pui(node, object); - PropertyObject* po = new PropertyObject(name, object, node); + + SGPropertyNode * values = type == "list" ? props : 0; + PropertyObject* po = new PropertyObject(name, object, node, values); _propertyObjects.push_back(po); if(props->getBoolValue("live")) _liveObjects.push_back(po); @@ -962,10 +968,12 @@ FGDialog::destroy_char_array (char ** array) FGDialog::PropertyObject::PropertyObject (const char * n, puObject * o, - SGPropertyNode_ptr p) + SGPropertyNode_ptr p, + SGPropertyNode_ptr v) : name(n), object(o), - node(p) + node(p), + values(v) { } diff --git a/src/GUI/dialog.hxx b/src/GUI/dialog.hxx index 270d8aefb..65c010395 100644 --- a/src/GUI/dialog.hxx +++ b/src/GUI/dialog.hxx @@ -141,15 +141,18 @@ private: // PUI provides no way for userdata to be deleted automatically // with a GUI object, so we have to keep track of all the special // data we allocated and then free it manually when the dialog - // closes. + // closes. "values" is a node with "value" children and only used + // by the widget. vector _info; struct PropertyObject { PropertyObject (const char * name, puObject * object, - SGPropertyNode_ptr node); + SGPropertyNode_ptr node, + SGPropertyNode_ptr values = 0); string name; puObject * object; SGPropertyNode_ptr node; + SGPropertyNode_ptr values; }; vector _propertyObjects; vector _liveObjects; -- 2.39.5