]> git.mxchange.org Git - flightgear.git/blob - src/GUI/dialog.cxx
replace depreciated plib symbols with their new forms
[flightgear.git] / src / GUI / dialog.cxx
1 // dialog.cxx: implementation of an XML-configurable dialog box.
2
3 #include <stdlib.h>             // atof()
4
5 #include <Input/input.hxx>
6
7 #include "dialog.hxx"
8 #include "new_gui.hxx"
9
10 #include "puList.hxx"
11 #include "AirportList.hxx"
12 #include "layout.hxx"
13
14 ////////////////////////////////////////////////////////////////////////
15 // Implementation of GUIInfo.
16 ////////////////////////////////////////////////////////////////////////
17
18 /**
19  * User data for a GUI object.
20  */
21 struct GUIInfo
22 {
23     GUIInfo (FGDialog * d);
24     virtual ~GUIInfo ();
25
26     FGDialog * dialog;
27     vector <FGBinding *> bindings;
28     int key;
29 };
30
31 GUIInfo::GUIInfo (FGDialog * d)
32     : dialog(d),
33       key(-1)
34 {
35 }
36
37 GUIInfo::~GUIInfo ()
38 {
39     for (unsigned int i = 0; i < bindings.size(); i++) {
40         delete bindings[i];
41         bindings[i] = 0;
42     }
43 }
44
45 \f
46 /**
47  * Key handler.
48  */
49 int fgPopup::checkKey(int key, int updown)
50 {
51     if (updown == PU_UP || !isVisible() || !isActive() || window != puGetWindow())
52         return false;
53
54     puObject *input = getActiveInputField(this);
55     if (input)
56         return input->checkKey(key, updown);
57
58     puObject *object = getKeyObject(this, key);
59     if (!object)
60         return puPopup::checkKey(key, updown);
61
62     object->invokeCallback() ;
63     return true;
64 }
65
66 puObject *fgPopup::getKeyObject(puObject *object, int key)
67 {
68     puObject *ret;
69     if(object->getType() & PUCLASS_GROUP)
70         for (puObject *obj = ((puGroup *)object)->getFirstChild();
71                 obj; obj = obj->getNextObject())
72             if ((ret = getKeyObject(obj, key)))
73                 return ret;
74
75     GUIInfo *info = (GUIInfo *)object->getUserData();
76     if (info && info->key == key)
77        return object;
78
79     return 0;
80 }
81
82 puObject *fgPopup::getActiveInputField(puObject *object)
83 {
84     puObject *ret;
85     if(object->getType() & PUCLASS_GROUP)
86         for (puObject *obj = ((puGroup *)object)->getFirstChild();
87                 obj; obj = obj->getNextObject())
88             if ((ret = getActiveInputField(obj)))
89                 return ret;
90
91     if (object->getType() & PUCLASS_INPUT && ((puInput *)object)->isAcceptingInput())
92         return object;
93
94     return 0;
95 }
96
97 /**
98  * Mouse handler.
99  */
100 int fgPopup::checkHit(int button, int updown, int x, int y)
101 {
102     int result = puPopup::checkHit(button, updown, x, y);
103
104     if ( !_draggable)
105        return result;
106
107     // This is annoying.  We would really want a true result from the
108     // superclass to indicate "handled by child object", but all it
109     // tells us is that the pointer is inside the dialog.  So do the
110     // intersection test (again) to make sure we don't start a drag
111     // when inside controls.
112
113     if(updown == PU_DOWN && !_dragging) {
114         if(!result)
115             return 0;
116
117         int hit = getHitObjects(this, x, y);
118         if(hit & (PUCLASS_BUTTON|PUCLASS_ONESHOT|PUCLASS_INPUT))
119             return result;
120
121         int px, py;
122         getPosition(&px, &py);
123         _dragging = true;
124         _dX = px - x;
125         _dY = py - y;
126     } else if(updown == PU_DRAG && _dragging) {
127         setPosition(x + _dX, y + _dY);
128     } else {
129         _dragging = false;
130     }
131     return result;
132 }
133
134 int fgPopup::getHitObjects(puObject *object, int x, int y)
135 {
136     int type = 0;
137     if(object->getType() & PUCLASS_GROUP)
138         for (puObject *obj = ((puGroup *)object)->getFirstChild();
139                 obj; obj = obj->getNextObject())
140             type |= getHitObjects(obj, x, y);
141
142     int cx, cy, cw, ch;
143     object->getAbsolutePosition(&cx, &cy);
144     object->getSize(&cw, &ch);
145     if(x >= cx && x < cx + cw && y >= cy && y < cy + ch)
146         type |= object->getType();
147     return type;
148 }
149
150
151 \f
152 ////////////////////////////////////////////////////////////////////////
153 // Callbacks.
154 ////////////////////////////////////////////////////////////////////////
155
156 /**
157  * Action callback.
158  */
159 static void
160 action_callback (puObject * object)
161 {
162     GUIInfo * info = (GUIInfo *)object->getUserData();
163     NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
164     gui->setActiveDialog(info->dialog);
165     int nBindings = info->bindings.size();
166     for (int i = 0; i < nBindings; i++) {
167         info->bindings[i]->fire();
168         if (gui->getActiveDialog() == 0)
169             break;
170     }
171     gui->setActiveDialog(0);
172 }
173
174
175 static void
176 format_callback(puObject *obj, int dx, int dy, void *n)
177 {
178     SGPropertyNode *node = (SGPropertyNode *)n;
179     const char *format = node->getStringValue("format"), *f = format;
180     bool number, l = false;
181     // make sure the format matches '[ -+#]?\d*(\.\d*)?l?[fs]'
182     for (; *f; f++) {
183         if (*f == '%') {
184             if (f[1] == '%')
185                 f++;
186             else
187                 break;
188         }
189     }
190     if (*f++ != '%')
191         return;
192     if (*f == ' ' || *f == '+' || *f == '-' || *f == '#')
193         f++;
194     while (*f && isdigit(*f))
195         f++;
196     if (*f == '.') {
197         f++;
198         while (*f && isdigit(*f))
199             f++;
200     }
201     if (*f == 'l')
202         l = true, f++;
203
204     if (*f == 'f')
205         number = true;
206     else if (*f == 's') {
207         if (l)
208             return;
209         number = false;
210     } else
211         return;
212
213     for (++f; *f; f++) {
214         if (*f == '%') {
215             if (f[1] == '%')
216                 f++;
217             else
218                 return;
219         }
220     }
221
222     char buf[256];
223     const char *src = obj->getLabel();
224
225     if (number) {
226         float value = atof(src);
227         snprintf(buf, 256, format, value);
228     } else {
229         snprintf(buf, 256, format, src);
230     }
231
232     buf[255] = '\0';
233
234     SGPropertyNode *result = node->getNode("formatted", true);
235     result->setStringValue(buf);
236     obj->setLabel(result->getStringValue());
237 }
238
239
240 \f
241 ////////////////////////////////////////////////////////////////////////
242 // Static helper functions.
243 ////////////////////////////////////////////////////////////////////////
244
245 /**
246  * Copy a property value to a PUI object.
247  */
248 static void
249 copy_to_pui (SGPropertyNode * node, puObject * object)
250 {
251     // Treat puText objects specially, so their "values" can be set
252     // from properties.
253     if(object->getType() & PUCLASS_TEXT) {
254         object->setLabel(node->getStringValue());
255         return;
256     }
257
258     switch (node->getType()) {
259     case SGPropertyNode::BOOL:
260     case SGPropertyNode::INT:
261     case SGPropertyNode::LONG:
262         object->setValue(node->getIntValue());
263         break;
264     case SGPropertyNode::FLOAT:
265     case SGPropertyNode::DOUBLE:
266         object->setValue(node->getFloatValue());
267         break;
268     default:
269         object->setValue(node->getStringValue());
270         break;
271     }
272 }
273
274
275 static void
276 copy_from_pui (puObject * object, SGPropertyNode * node)
277 {
278     // puText objects are immutable, so should not be copied out
279     if(object->getType() & PUCLASS_TEXT)
280         return;
281
282     switch (node->getType()) {
283     case SGPropertyNode::BOOL:
284     case SGPropertyNode::INT:
285     case SGPropertyNode::LONG:
286         node->setIntValue(object->getIntegerValue());
287         break;
288     case SGPropertyNode::FLOAT:
289     case SGPropertyNode::DOUBLE:
290         node->setFloatValue(object->getFloatValue());
291         break;
292     default:
293         // Special case to handle lists, as getStringValue cannot be overridden
294         if(object->getType() & PUCLASS_LIST)
295         {
296             node->setStringValue(((puList *) object)->getListStringValue());
297         }
298         else
299         {
300             node->setStringValue(object->getStringValue());
301         }
302         break;
303     }
304 }
305
306
307 \f
308 ////////////////////////////////////////////////////////////////////////
309 // Implementation of FGDialog.
310 ////////////////////////////////////////////////////////////////////////
311
312 FGDialog::FGDialog (SGPropertyNode * props)
313     : _object(0),
314       _gui((NewGUI *)globals->get_subsystem("gui"))
315 {
316     char* envp = ::getenv( "FG_FONTS" );
317     if ( envp != NULL ) {
318         _font_path.set( envp );
319     } else {
320         _font_path.set( globals->get_fg_root() );
321         _font_path.append( "Fonts" );
322     }
323
324     display(props);
325 }
326
327 FGDialog::~FGDialog ()
328 {
329     puDeleteObject(_object);
330
331     unsigned int i;
332
333                                 // Delete all the arrays we made
334                                 // and were forced to keep around
335                                 // because PUI won't do its own
336                                 // memory management.
337     for (i = 0; i < _char_arrays.size(); i++) {
338         for (int j = 0; _char_arrays[i][j] != 0; j++)
339             free(_char_arrays[i][j]); // added with strdup
340         delete[] _char_arrays[i];
341     }
342
343                                 // Delete all the info objects we
344                                 // were forced to keep around because
345                                 // PUI cannot delete its own user data.
346     for (i = 0; i < _info.size(); i++) {
347         delete (GUIInfo *)_info[i];
348         _info[i] = 0;
349     }
350
351                                 // Finally, delete the property links.
352     for (i = 0; i < _propertyObjects.size(); i++) {
353         delete _propertyObjects[i];
354         _propertyObjects[i] = 0;
355     }
356 }
357
358 void
359 FGDialog::updateValue (const char * objectName)
360 {
361     for (unsigned int i = 0; i < _propertyObjects.size(); i++) {
362         const string &name = _propertyObjects[i]->name;
363         if (name == objectName)
364             copy_to_pui(_propertyObjects[i]->node,
365                         _propertyObjects[i]->object);
366     }
367 }
368
369 void
370 FGDialog::applyValue (const char * objectName)
371 {
372     for (unsigned int i = 0; i < _propertyObjects.size(); i++) {
373         if (_propertyObjects[i]->name == objectName)
374             copy_from_pui(_propertyObjects[i]->object,
375                           _propertyObjects[i]->node);
376     }
377 }
378
379 void
380 FGDialog::updateValues ()
381 {
382     for (unsigned int i = 0; i < _propertyObjects.size(); i++)
383         copy_to_pui(_propertyObjects[i]->node, _propertyObjects[i]->object);
384 }
385
386 void
387 FGDialog::applyValues ()
388 {
389     for (unsigned int i = 0; i < _propertyObjects.size(); i++)
390         copy_from_pui(_propertyObjects[i]->object,
391                       _propertyObjects[i]->node);
392 }
393
394 void
395 FGDialog::update ()
396 {
397     for (unsigned int i = 0; i < _liveObjects.size(); i++) {
398         puObject *obj = _liveObjects[i]->object;
399         if (obj->getType() & PUCLASS_INPUT && ((puInput *)obj)->isAcceptingInput())
400             continue;
401
402         copy_to_pui(_liveObjects[i]->node, obj);
403     }
404 }
405
406 void
407 FGDialog::display (SGPropertyNode * props)
408 {
409     if (_object != 0) {
410         SG_LOG(SG_GENERAL, SG_ALERT, "This widget is already active");
411         return;
412     }
413
414     int screenw = globals->get_props()->getIntValue("/sim/startup/xsize");
415     int screenh = globals->get_props()->getIntValue("/sim/startup/ysize");
416
417     bool userx = props->hasValue("x");
418     bool usery = props->hasValue("y");
419     bool userw = props->hasValue("width");
420     bool userh = props->hasValue("height");
421
422     // Let the layout widget work in the same property subtree.
423     LayoutWidget wid(props);
424
425     puFont *fnt = _gui->getDefaultFont();
426     wid.setDefaultFont(fnt, int(fnt->getPointSize()));
427
428     int pw=0, ph=0;
429     if(!userw || !userh)
430         wid.calcPrefSize(&pw, &ph);
431     pw = props->getIntValue("width", pw);
432     ph = props->getIntValue("height", ph);
433     int px = props->getIntValue("x", (screenw - pw) / 2);
434     int py = props->getIntValue("y", (screenh - ph) / 2);
435
436     // Define "x", "y", "width" and/or "height" in the property tree if they
437     // are not specified in the configuration file.
438     wid.layout(px, py, pw, ph);
439
440     // Use the dimension and location properties as specified in the
441     // configuration file or from the layout widget.
442     _object = makeObject(props, screenw, screenh);
443
444     // Remove automatically generated properties, so the layout looks
445     // the same next time around.
446     if(!userx) props->removeChild("x");
447     if(!usery) props->removeChild("y");
448     if(!userw) props->removeChild("width");
449     if(!userh) props->removeChild("height");
450
451     if (_object != 0) {
452         _object->reveal();
453     } else {
454         SG_LOG(SG_GENERAL, SG_ALERT, "Widget "
455                << props->getStringValue("name", "[unnamed]")
456                << " does not contain a proper GUI definition");
457     }
458 }
459
460 puObject *
461 FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
462 {
463     if (props->getBoolValue("hide"))
464         return 0;
465
466     bool presetSize = props->hasValue("width") && props->hasValue("height");
467     int width = props->getIntValue("width", parentWidth);
468     int height = props->getIntValue("height", parentHeight);
469     int x = props->getIntValue("x", (parentWidth - width) / 2);
470     int y = props->getIntValue("y", (parentHeight - height) / 2);
471     string type = props->getName();
472
473     if (type == "")
474         type = "dialog";
475
476     if (type == "dialog") {
477         puPopup * obj;
478         bool draggable = props->getBoolValue("draggable", true);
479         if (props->getBoolValue("modal", false))
480             obj = new puDialogBox(x, y);
481         else
482             obj = new fgPopup(x, y, draggable);
483         setupGroup(obj, props, width, height, true);
484         setColor(obj, props);
485         return obj;
486
487     } else if (type == "group") {
488         puGroup * obj = new puGroup(x, y);
489         setupGroup(obj, props, width, height, false);
490         setColor(obj, props);
491         return obj;
492
493     } else if (type == "frame") {
494         puGroup * obj = new puGroup(x, y);
495         setupGroup(obj, props, width, height, true);
496         setColor(obj, props);
497         return obj;
498
499     } else if (type == "hrule" || type == "vrule") {
500         puFrame * obj = new puFrame(x, y, x + width, y + height);
501         obj->setBorderThickness(0);
502         setColor(obj, props, BACKGROUND|FOREGROUND|HIGHLIGHT);
503         return obj;
504
505     } else if (type == "list") {
506         puList * obj = new puList(x, y, x + width, y + height);
507         setupObject(obj, props);
508         setColor(obj, props);
509         return obj;
510
511     } else if (type == "airport-list") {
512         AirportList * obj = new AirportList(x, y, x + width, y + height);
513         setupObject(obj, props);
514         setColor(obj, props);
515         return obj;
516
517     } else if (type == "input") {
518         puInput * obj = new puInput(x, y, x + width, y + height);
519         setupObject(obj, props);
520         setColor(obj, props, FOREGROUND|LABEL);
521         return obj;
522
523     } else if (type == "text") {
524         puText * obj = new puText(x, y);
525         setupObject(obj, props);
526
527         if (props->getNode("format")) {
528             SGPropertyNode *live = props->getNode("live");
529             if (live && live->getBoolValue())
530                 obj->setRenderCallback(format_callback, props);
531             else
532                 format_callback(obj, x, y, props);
533         }
534         // Layed-out objects need their size set, and non-layout ones
535         // get a different placement.
536         if(presetSize) obj->setSize(width, height);
537         else obj->setLabelPlace(PUPLACE_LABEL_DEFAULT);
538         setColor(obj, props, LABEL);
539         return obj;
540
541     } else if (type == "checkbox") {
542         puButton * obj;
543         obj = new puButton(x, y, x + width, y + height, PUBUTTON_XCHECK);
544         setupObject(obj, props);
545         setColor(obj, props, FOREGROUND|LABEL);
546         return obj;
547
548     } else if (type == "radio") {
549         puButton * obj;
550         obj = new puButton(x, y, x + width, y + height, PUBUTTON_CIRCLE);
551         setupObject(obj, props);
552         setColor(obj, props, FOREGROUND|LABEL);
553         return obj;
554
555     } else if (type == "button") {
556         puButton * obj;
557         const char * legend = props->getStringValue("legend", "[none]");
558         if (props->getBoolValue("one-shot", true))
559             obj = new puOneShot(x, y, legend);
560         else
561             obj = new puButton(x, y, legend);
562         if(presetSize)
563             obj->setSize(width, height);
564         setupObject(obj, props);
565         setColor(obj, props);
566         return obj;
567
568     } else if (type == "combo") {
569         vector<SGPropertyNode_ptr> value_nodes = props->getChildren("value");
570         char ** entries = make_char_array(value_nodes.size());
571         for (unsigned int i = 0, j = value_nodes.size() - 1;
572              i < value_nodes.size();
573              i++, j--)
574             entries[i] = strdup((char *)value_nodes[i]->getStringValue());
575         puComboBox * obj = new puComboBox(x, y, x + width, y + height, entries,
576                            props->getBoolValue("editable", false));
577         setupObject(obj, props);
578         setColor(obj, props, FOREGROUND|LABEL);
579         return obj;
580
581     } else if (type == "slider") {
582         bool vertical = props->getBoolValue("vertical", false);
583         puSlider * obj = new puSlider(x, y, (vertical ? height : width));
584         obj->setMinValue(props->getFloatValue("min", 0.0));
585         obj->setMaxValue(props->getFloatValue("max", 1.0));
586         setupObject(obj, props);
587         if(presetSize)
588             obj->setSize(width, height);
589         setColor(obj, props, FOREGROUND|LABEL);
590         return obj;
591
592     } else if (type == "dial") {
593         puDial * obj = new puDial(x, y, width);
594         obj->setMinValue(props->getFloatValue("min", 0.0));
595         obj->setMaxValue(props->getFloatValue("max", 1.0));
596         obj->setWrap(props->getBoolValue("wrap", true));
597         setupObject(obj, props);
598         setColor(obj, props, FOREGROUND|LABEL);
599         return obj;
600
601     } else if (type == "textbox") {
602         int slider_width = props->getIntValue("slider", parentHeight);
603         int wrap = props->getBoolValue("wrap", true);
604         if (slider_width==0) slider_width=20;
605         puLargeInput * obj = new puLargeInput(x, y,
606                 x+width, x+height, 2, slider_width, wrap);
607
608         if (props->hasValue("editable")) {
609             if (props->getBoolValue("editable")==false)
610                 obj->disableInput();
611             else
612                 obj->enableInput();
613         }
614         setupObject(obj, props);
615         setColor(obj, props, FOREGROUND|LABEL);
616         return obj;
617
618     } else if (type == "select") {
619         vector<SGPropertyNode_ptr> value_nodes;
620         SGPropertyNode * selection_node =
621                 fgGetNode(props->getChild("selection")->getStringValue(), true);
622
623         for (int q = 0; q < selection_node->nChildren(); q++)
624             value_nodes.push_back(selection_node->getChild(q));
625
626         char ** entries = make_char_array(value_nodes.size());
627         for (unsigned int i = 0, j = value_nodes.size() - 1;
628              i < value_nodes.size();
629              i++, j--)
630             entries[i] = strdup((char *)value_nodes[i]->getName());
631         puSelectBox * obj =
632             new puSelectBox(x, y, x + width, y + height, entries);
633         setupObject(obj, props);
634         setColor(obj, props, FOREGROUND|LABEL);
635         return obj;
636     } else {
637         return 0;
638     }
639 }
640
641 void
642 FGDialog::setupObject (puObject * object, SGPropertyNode * props)
643 {
644     object->setLabelPlace(PUPLACE_CENTERED_RIGHT);
645
646     if (props->hasValue("legend"))
647         object->setLegend(props->getStringValue("legend"));
648
649     if (props->hasValue("label"))
650         object->setLabel(props->getStringValue("label"));
651
652     if (props->hasValue("border"))
653         object->setBorderThickness( props->getIntValue("border", 2) );
654
655     if ( SGPropertyNode *nft = props->getNode("font", false) ) {
656        SGPath path( _font_path );
657        const char *name = nft->getStringValue("name", "default");
658        float size = nft->getFloatValue("size", 13.0);
659        float slant = nft->getFloatValue("slant", 0.0);
660        path.append( name );
661        path.concat( ".txf" );
662
663        fntFont *font = new fntTexFont;
664        font->load( (char *)path.c_str() );
665
666        puFont lfnt(font, size, slant);
667        object->setLabelFont( lfnt );
668     }
669
670     if (props->hasValue("property")) {
671         const char * name = props->getStringValue("name");
672         if (name == 0)
673             name = "";
674         const char * propname = props->getStringValue("property");
675         SGPropertyNode_ptr node = fgGetNode(propname, true);
676         copy_to_pui(node, object);
677         PropertyObject* po = new PropertyObject(name, object, node);
678         _propertyObjects.push_back(po);
679         if(props->getBoolValue("live"))
680             _liveObjects.push_back(po);
681     }
682
683     SGPropertyNode * dest = fgGetNode("/sim/bindings/gui", true);
684     vector<SGPropertyNode_ptr> bindings = props->getChildren("binding");
685     if (bindings.size() > 0) {
686         GUIInfo * info = new GUIInfo(this);
687         info->key = props->getIntValue("keynum", -1);
688
689         for (unsigned int i = 0; i < bindings.size(); i++) {
690             unsigned int j = 0;
691             SGPropertyNode *binding;
692             while (dest->getChild("binding", j))
693                 j++;
694
695             binding = dest->getChild("binding", j, true);
696             copyProperties(bindings[i], binding);
697             info->bindings.push_back(new FGBinding(binding));
698         }
699         object->setCallback(action_callback);
700         object->setUserData(info);
701         _info.push_back(info);
702     }
703
704     object->makeReturnDefault(props->getBoolValue("default"));
705 }
706
707 void
708 FGDialog::setupGroup (puGroup * group, SGPropertyNode * props,
709                     int width, int height, bool makeFrame)
710 {
711     setupObject(group, props);
712
713     if (makeFrame) {
714         puFrame* f = new puFrame(0, 0, width, height);
715         setColor(f, props);
716     }
717
718     int nChildren = props->nChildren();
719     for (int i = 0; i < nChildren; i++)
720         makeObject(props->getChild(i), width, height);
721     group->close();
722 }
723
724 void
725 FGDialog::setColor(puObject * object, SGPropertyNode * props, int which)
726 {
727     string type = props->getName();
728     if (type == "")
729         type = "dialog";
730
731     FGColor *c = new FGColor(_gui->getColor("background"));
732     c->merge(_gui->getColor(type));
733     c->merge(props->getNode("color"));
734     if (c->isValid())
735         object->setColourScheme(c->red(), c->green(), c->blue(), c->alpha());
736
737     const struct {
738         int mask;
739         int id;
740         const char *name;
741         const char *cname;
742     } pucol[] = {
743         { BACKGROUND, PUCOL_BACKGROUND, "background", "color-background" },
744         { FOREGROUND, PUCOL_FOREGROUND, "foreground", "color-foreground" },
745         { HIGHLIGHT,  PUCOL_HIGHLIGHT,  "highlight",  "color-highlight" },
746         { LABEL,      PUCOL_LABEL,      "label",      "color-label" },
747         { LEGEND,     PUCOL_LEGEND,     "legend",     "color-legend" },
748         { MISC,       PUCOL_MISC,       "misc",       "color-misc" }
749     };
750
751     const int numcol = sizeof(pucol) / sizeof(pucol[0]);
752
753     for (int i = 0; i < numcol; i++) {
754         bool dirty = false;
755         c->clear();
756         c->setAlpha(1.0);
757
758         dirty |= c->merge(_gui->getColor(type + '-' + pucol[i].name));
759         if (which & pucol[i].mask)
760             dirty |= c->merge(props->getNode("color"));
761
762         if ((pucol[i].mask == LABEL) && !c->isValid())
763             dirty |= c->merge(_gui->getColor("label"));
764
765         if (c->isValid() && dirty)
766             object->setColor(pucol[i].id, c->red(), c->green(), c->blue(), c->alpha());
767     }
768 }
769
770 char **
771 FGDialog::make_char_array (int size)
772 {
773     char ** list = new char*[size+1];
774     for (int i = 0; i <= size; i++)
775         list[i] = 0;
776     _char_arrays.push_back(list);
777     return list;
778 }
779
780
781 \f
782 ////////////////////////////////////////////////////////////////////////
783 // Implementation of FGDialog::PropertyObject.
784 ////////////////////////////////////////////////////////////////////////
785
786 FGDialog::PropertyObject::PropertyObject (const char * n,
787                                            puObject * o,
788                                            SGPropertyNode_ptr p)
789     : name(n),
790       object(o),
791       node(p)
792 {
793 }
794
795
796 // end of dialog.cxx