1 // new_gui.hxx - XML-configurable GUI subsystem.
4 #define __NEW_GUI_HXX 1
7 # error This library requires C++
12 #include <simgear/compiler.h> // for SG_USING_STD
13 #include <simgear/misc/props.hxx>
21 #include <Main/fgfs.hxx>
22 #include <Main/fg_props.hxx>
23 #include <Input/input.hxx>
29 * Information about a GUI widget.
33 GUIInfo (GUIWidget * w);
37 vector <FGBinding *> bindings;
42 * Top-level GUI widget.
50 * Construct a new GUI widget configured by a property tree.
52 GUIWidget (SGPropertyNode_ptr props);
58 virtual ~GUIWidget ();
62 * Update the values of all GUI objects with a specific name.
64 * This method copies from the property to the GUI object.
66 * @param objectName The name of the GUI object(s) to update.
67 * Use the empty name for all unnamed objects.
69 virtual void updateValue (const char * objectName);
73 * Apply the values of all GUI objects with a specific name.
75 * This method copies from the GUI object to the property.
77 * @param objectName The name of the GUI object(s) to update.
78 * Use the empty name for all unnamed objects.
80 virtual void applyValue (const char * objectName);
84 * Update the values of all GUI objects.
86 * This method copies from the properties to the GUI objects.
88 virtual void updateValues ();
92 * Apply the values of all GUI objects.
94 * This method copies from the GUI objects to the properties.
96 virtual void applyValues ();
100 GUIWidget (const GUIWidget &); // just for safety
102 void display (SGPropertyNode_ptr props);
103 puObject * makeObject (SGPropertyNode * props,
104 int parentWidth, int parentHeight);
105 void setupObject (puObject * object, SGPropertyNode * props);
106 void setupGroup (puGroup * group, SGPropertyNode * props,
107 int width, int height, bool makeFrame = false);
110 vector<GUIInfo *> _info;
111 struct PropertyObject {
112 PropertyObject (const char * name,
114 SGPropertyNode_ptr node);
117 SGPropertyNode_ptr node;
119 vector<PropertyObject *> _propertyObjects;
123 class NewGUI : public FGSubsystem
129 virtual void init ();
130 virtual void update (double delta_time_sec);
131 virtual void display (const string &name);
133 virtual void setCurrentWidget (GUIWidget * widget);
134 virtual GUIWidget * getCurrentWidget ();
139 void readDir (const char * path);
141 GUIWidget * _current_widget;
142 map<string,SGPropertyNode_ptr> _widgets;
147 #endif // __NEW_GUI_HXX
149 // end of new_gui.hxx