]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/new_gui.hxx
Add a new command, "dialog-new", allowing external code (e.g. Nasal
[flightgear.git] / src / GUI / new_gui.hxx
index 7936c8a17c5f77bbf864caeb00435fb052f37462..5aec7c5388ba976a046a05457da62e6690e76b7d 100644 (file)
@@ -10,7 +10,8 @@
 #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);
@@ -18,7 +19,6 @@ SG_USING_STD(vector);
 #include <map>
 SG_USING_STD(map);
 
-#include <Main/fgfs.hxx>
 #include <Main/fg_props.hxx>
 
 class FGMenuBar;
@@ -32,10 +32,10 @@ class FGBinding;
  * 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:
 
@@ -54,6 +54,11 @@ public:
      */
     virtual void init ();
 
+    /**
+     * Reinitialize the GUI subsystem.
+     */
+    virtual void reinit ();
+
     /**
      * Bind properties for the GUI subsystem.
      *
@@ -75,13 +80,26 @@ public:
      */
     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.
@@ -90,12 +108,22 @@ public:
 
 
     /**
-     * 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.
@@ -137,11 +165,15 @@ protected:
 
 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;
 
 };