1 // dialog.hxx - XML-configured dialog box.
7 # error This library requires C++
12 #include <simgear/compiler.h> // for SG_USING_STD
13 #include <simgear/misc/props.hxx>
23 * An XML-configured dialog box.
25 * The GUI manager stores only the property tree for the dialog
26 * boxes. This class creates a PUI dialog box on demand from
27 * the properties in that tree. The manager recreates the dialog
28 * every time it needs to show it.
35 * Construct a new GUI widget configured by a property tree.
37 * The configuration properties are not part of the main
38 * FlightGear property tree; the GUI manager reads them
39 * from individual configuration files.
41 * @param props A property tree describing the dialog.
43 FGDialog (SGPropertyNode * props);
53 * Update the values of all GUI objects with a specific name.
55 * This method copies values from the FlightGear property tree to
58 * @param objectName The name of the GUI object(s) to update.
59 * Use the empty name for all unnamed objects.
61 virtual void updateValue (const char * objectName);
65 * Apply the values of all GUI objects with a specific name.
67 * This method copies values from the GUI object(s) to the
68 * FlightGear property tree.
70 * @param objectName The name of the GUI object(s) to update.
71 * Use the empty name for all unnamed objects.
73 virtual void applyValue (const char * objectName);
77 * Update the values of all GUI objects.
79 * This method copies values from the FlightGear property tree to
82 virtual void updateValues ();
86 * Apply the values of all GUI objects.
88 * This method copies from the GUI objects to the FlightGear
89 * property tree properties.
91 virtual void applyValues ();
96 // Private copy constructor to avoid unpleasant surprises.
97 FGDialog (const FGDialog &);
100 void display (SGPropertyNode * props);
102 // Build the dialog or a subobject of it.
103 puObject * makeObject (SGPropertyNode * props,
104 int parentWidth, int parentHeight);
106 // Common configuration for all GUI objects.
107 void setupObject (puObject * object, SGPropertyNode * props);
109 // Common configuration for all GUI group objects.
110 void setupGroup (puGroup * group, SGPropertyNode * props,
111 int width, int height, bool makeFrame = false);
113 // The top-level PUI object.
116 // PUI provides no way for userdata to be deleted automatically
117 // with a GUI object, so we have to keep track of all the special
118 // data we allocated and then free it manually when the dialog
120 vector<void *> _info;
121 struct PropertyObject {
122 PropertyObject (const char * name,
124 SGPropertyNode_ptr node);
127 SGPropertyNode_ptr node;
129 vector<PropertyObject *> _propertyObjects;
131 // PUI doesn't copy arrays, so we have to allocate string arrays
132 // and then keep pointers so that we can delete them when the
134 char ** make_char_array (int size);
135 vector<char **> _char_arrays;
138 #endif // __DIALOG_HXX