1 // new_gui.hxx - XML-configured GUI subsystem.
4 #define __NEW_GUI_HXX 1
7 # error This library requires C++
16 #include <simgear/compiler.h> // for SG_USING_STD
17 #include <simgear/props/props.hxx>
18 #include <simgear/structure/subsystem_mgr.hxx>
26 #include <Main/fg_props.hxx>
34 * XML-configured GUI subsystem.
36 * This subsystem manages the graphical user interface for FlightGear.
37 * It creates a menubar from the XML configuration file in
38 * $FG_ROOT/gui/menubar.xml, then stores the configuration properties
39 * for XML-configured dialog boxes found in $FG_ROOT/gui/dialogs/. It
40 * can show or hide the menubar, and can display any dialog by name.
42 class NewGUI : public SGSubsystem
57 * Initialize the GUI subsystem.
62 * Reinitialize the GUI subsystem.
64 virtual void reinit ();
67 * Bind properties for the GUI subsystem.
69 * Currently, this method binds the properties for showing and
75 * Unbind properties for the GUI subsystem.
77 virtual void unbind ();
80 * Update the GUI subsystem.
82 * Currently, this method is a no-op, because nothing the GUI
83 * subsystem does is time-dependent.
85 virtual void update (double delta_time_sec);
88 * Creates a new dialog box, using the same property format as the
89 * gui/dialogs configuration files. Does not display the
90 * resulting dialog. If a pre-existing dialog of the same name
91 * exists, it will be deleted. The node argument will be stored
92 * in the GUI subsystem using SGPropertNode_ptr reference counting.
93 * It should not be deleted by user code.
95 * @param node A property node containing the dialog definition
97 virtual void newDialog (SGPropertyNode* node);
100 * Display a dialog box.
102 * At initialization time, the subsystem reads all of the XML
103 * configuration files from the directory $FG_ROOT/gui/dialogs/.
104 * The configuration for each dialog specifies a name, and this
105 * method invokes the dialog with the name specified (if it
108 * @param name The name of the dialog box.
109 * @return true if the dialog exists, false otherwise.
111 virtual bool showDialog (const string &name);
115 * Close the currenty active dialog. This function is intended to
116 * be called from code (pui callbacks, for instance) that registers
117 * its dialog object as active via setActiveDialog(). Other
118 * user-level code should use the closeDialog(name) API.
120 * @return true if a dialog was active, false otherwise
122 virtual bool closeActiveDialog ();
125 * Close a named dialog, if it is open.
127 * @param name The name of the dialog box.
128 * @return true if the dialog was active, false otherwise.
130 virtual bool closeDialog (const string &name);
133 * Return a pointer to the current menubar.
135 virtual FGMenuBar * getMenuBar ();
139 * Ignore this method.
141 * This method is for internal use only, but it has to be public
142 * so that a non-class callback can see it.
144 virtual void setActiveDialog (FGDialog * dialog);
147 * Get the dialog currently active, if any.
149 * @return The active dialog, or 0 if none is active.
151 virtual FGDialog * getActiveDialog ();
156 * Test if the menubar is visible.
158 * This method exists only for binding.
160 virtual bool getMenuBarVisible () const;
163 * Show or hide the menubar.
165 * This method exists only for binding.
167 virtual void setMenuBarVisible (bool visible);
172 // Free all allocated memory.
175 // Read all the configuration files in a directory.
176 void readDir (const char * path);
178 FGMenuBar * _menubar;
179 FGDialog * _active_dialog;
180 map<string,FGDialog *> _active_dialogs;
181 map<string,SGPropertyNode_ptr> _dialog_props;
186 #endif // __NEW_GUI_HXX