#include <plib/pu.h>
#include <simgear/compiler.h> // for SG_USING_STD
-#include <simgear/misc/props.hxx>
+#include <simgear/props/props.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <vector>
SG_USING_STD(vector);
#include <map>
SG_USING_STD(map);
-#include <Main/fgfs.hxx>
#include <Main/fg_props.hxx>
class FGMenuBar;
* This subsystem manages the graphical user interface for FlightGear.
* It creates a menubar from the XML configuration file in
* $FG_ROOT/gui/menubar.xml, then stores the configuration properties
- * for XML-configured dialog boxes in $FG_ROOT/gui/dialogs/*. It
+ * for XML-configured dialog boxes found in $FG_ROOT/gui/dialogs/. It
* can show or hide the menubar, and can display any dialog by name.
*/
-class NewGUI : public FGSubsystem
+class NewGUI : public SGSubsystem
{
public:
*/
virtual void init ();
+ /**
+ * Reinitialize the GUI subsystem.
+ */
+ virtual void reinit ();
+
/**
* Bind properties for the GUI subsystem.
*
*/
virtual void update (double delta_time_sec);
+ /**
+ * Creates a new dialog box, using the same property format as the
+ * gui/dialogs configuration files. Does not display the
+ * resulting dialog. If a pre-existing dialog of the same name
+ * exists, it will be deleted. The node argument will be stored
+ * in the GUI subsystem using SGPropertNode_ptr reference counting.
+ * It should not be deleted by user code.
+ *
+ * @param node A property node containing the dialog definition
+ */
+ virtual void newDialog (SGPropertyNode* node);
+
/**
* Display a dialog box.
*
* At initialization time, the subsystem reads all of the XML
- * configuration files from $FG_ROOT/gui/dialogs/*. The
- * configuration for each dialog specifies a name, and this method
- * invokes the dialog with the name specified (if it exists).
+ * configuration files from the directory $FG_ROOT/gui/dialogs/.
+ * The configuration for each dialog specifies a name, and this
+ * method invokes the dialog with the name specified (if it
+ * exists).
*
* @param name The name of the dialog box.
* @return true if the dialog exists, false otherwise.
/**
- * Close the currently-active dialog, if any.
+ * Close the currenty active dialog. This function is intended to
+ * be called from code (pui callbacks, for instance) that registers
+ * its dialog object as active via setActiveDialog(). Other
+ * user-level code should use the closeDialog(name) API.
*
- * @return true if a dialog was active, false otherwise.
+ * @return true if a dialog was active, false otherwise
*/
virtual bool closeActiveDialog ();
+ /**
+ * Close a named dialog, if it is open.
+ *
+ * @param name The name of the dialog box.
+ * @return true if the dialog was active, false otherwise.
+ */
+ virtual bool closeDialog (const string &name);
/**
* Return a pointer to the current menubar.
private:
+ // Free all allocated memory.
+ void clear ();
+
// Read all the configuration files in a directory.
void readDir (const char * path);
FGMenuBar * _menubar;
FGDialog * _active_dialog;
+ map<string,FGDialog *> _active_dialogs;
map<string,SGPropertyNode_ptr> _dialog_props;
};