1
0
Fork 0

Merge branch 'jmt/dialog'

This commit is contained in:
Tim Moore 2009-11-26 23:32:38 +01:00
commit 8933486a56
2 changed files with 45 additions and 17 deletions

View file

@ -555,16 +555,22 @@ FGDialog::updateValues (const char *objectName)
for (unsigned int i = 0; i < _propertyObjects.size(); i++) {
const string &name = _propertyObjects[i]->name;
if (objectName && name != objectName)
if (objectName && name != objectName) {
continue;
puObject *obj = _propertyObjects[i]->object;
if ((obj->getType() & PUCLASS_LIST) && (dynamic_cast<GUI_ID *>(obj)->id & FGCLASS_LIST)) {
fgList *pl = static_cast<fgList *>(obj);
pl->update();
} else
copy_to_pui(_propertyObjects[i]->node, obj);
}
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();
} else if (widgetType & PUCLASS_COMBOBOX) {
fgComboBox* combo = static_cast<fgComboBox*>(widget);
combo->update();
} else {
copy_to_pui(_propertyObjects[i]->node, widget);
}
} // of property objects iteration
}
void
@ -1259,11 +1265,25 @@ fgValueList::~fgValueList()
void
fgValueList::make_list()
{
vector<SGPropertyNode_ptr> value_nodes = _props->getChildren("value");
SGPropertyNode_ptr values = _props;
const char* vname = "value";
if (_props->hasChild("properties")) {
// dynamic values, read from a property's children
const char* path = _props->getStringValue("properties");
values = fgGetNode(path, true);
}
if (_props->hasChild("property-name")) {
vname = _props->getStringValue("property-name");
}
vector<SGPropertyNode_ptr> value_nodes = values->getChildren(vname);
_list = new char *[value_nodes.size() + 1];
unsigned int i;
for (i = 0; i < value_nodes.size(); i++)
for (i = 0; i < value_nodes.size(); i++) {
_list[i] = strdup((char *)value_nodes[i]->getStringValue());
}
_list[i] = 0;
}
@ -1287,4 +1307,10 @@ fgList::update()
setTopItem(top);
}
void fgComboBox::update()
{
fgValueList::update();
newList(_list);
}
// end of dialog.cxx

View file

@ -258,6 +258,8 @@ class fgComboBox : public fgValueList, public puaComboBox {
public:
fgComboBox(int x1, int y1, int x2, int y2, SGPropertyNode *p, bool editable) :
fgValueList(p), puaComboBox(x1, y1, x2, y2, _list, editable) {}
void update();
};
class fgSelectBox : public fgValueList, public puaSelectBox {