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>
30 * Information about a GUI widget.
34 GUIInfo (GUIWidget * w);
38 vector <FGBinding *> bindings;
43 * Top-level GUI widget.
51 * Construct a new GUI widget configured by a property tree.
53 GUIWidget (SGPropertyNode_ptr props);
59 virtual ~GUIWidget ();
63 * Update the values of all GUI objects with a specific name.
65 * This method copies from the property to the GUI object.
67 * @param objectName The name of the GUI object(s) to update.
68 * Use the empty name for all unnamed objects.
70 virtual void updateValue (const char * objectName);
74 * Apply the values of all GUI objects with a specific name.
76 * This method copies from the GUI object to the property.
78 * @param objectName The name of the GUI object(s) to update.
79 * Use the empty name for all unnamed objects.
81 virtual void applyValue (const char * objectName);
85 * Update the values of all GUI objects.
87 * This method copies from the properties to the GUI objects.
89 virtual void updateValues ();
93 * Apply the values of all GUI objects.
95 * This method copies from the GUI objects to the properties.
97 virtual void applyValues ();
101 GUIWidget (const GUIWidget &); // just for safety
103 void display (SGPropertyNode_ptr props);
104 puObject * makeObject (SGPropertyNode * props,
105 int parentWidth, int parentHeight);
106 void setupObject (puObject * object, SGPropertyNode * props);
107 void setupGroup (puGroup * group, SGPropertyNode * props,
108 int width, int height, bool makeFrame = false);
111 vector<GUIInfo *> _info;
112 struct PropertyObject {
113 PropertyObject (const char * name,
115 SGPropertyNode_ptr node);
118 SGPropertyNode_ptr node;
120 vector<PropertyObject *> _propertyObjects;
124 class NewGUI : public FGSubsystem
130 virtual void init ();
131 virtual void update (double delta_time_sec);
132 virtual void display (const string &name);
134 virtual void setCurrentWidget (GUIWidget * widget);
135 virtual GUIWidget * getCurrentWidget ();
137 virtual FGMenuBar * getMenuBar ();
142 void readDir (const char * path);
144 FGMenuBar * _menubar;
145 GUIWidget * _current_widget;
146 map<string,SGPropertyNode_ptr> _widgets;
151 #endif // __NEW_GUI_HXX
153 // end of new_gui.hxx