]> git.mxchange.org Git - flightgear.git/blob - src/GUI/new_gui.hxx
637f2c592687cecb968125f94a2e52ff464f8ab0
[flightgear.git] / src / GUI / new_gui.hxx
1 // new_gui.hxx - XML-configured GUI subsystem.
2
3 #ifndef __NEW_GUI_HXX
4 #define __NEW_GUI_HXX 1
5
6 #ifndef __cplusplus
7 # error This library requires C++
8 #endif
9
10 #include <plib/pu.h>
11
12 #include <simgear/compiler.h>   // for SG_USING_STD
13 #include <simgear/misc/props.hxx>
14
15 #include <vector>
16 SG_USING_STD(vector);
17
18 #include <map>
19 SG_USING_STD(map);
20
21 #include <Main/fgfs.hxx>
22 #include <Main/fg_props.hxx>
23
24 class FGMenuBar;
25 class FGDialog;
26 class FGBinding;
27
28
29 /**
30  * XML-configured GUI subsystem.
31  *
32  * This subsystem manages the graphical user interface for FlightGear.
33  * It creates a menubar from the XML configuration file in
34  * $FG_ROOT/gui/menubar.xml, then stores the configuration properties
35  * for XML-configured dialog boxes found in $FG_ROOT/gui/dialogs/.  It
36  * can show or hide the menubar, and can display any dialog by name.
37  */
38 class NewGUI : public FGSubsystem
39 {
40 public:
41
42     /**
43      * Constructor.
44      */
45     NewGUI ();
46
47     /**
48      * Destructor.
49      */
50     virtual ~NewGUI ();
51
52     /**
53      * Initialize the GUI subsystem.
54      */
55     virtual void init ();
56
57     /**
58      * Reinitialize the GUI subsystem.
59      */
60     virtual void reinit ();
61
62     /**
63      * Bind properties for the GUI subsystem.
64      *
65      * Currently, this method binds the properties for showing and
66      * hiding the menu.
67      */
68     virtual void bind ();
69
70     /**
71      * Unbind properties for the GUI subsystem.
72      */
73     virtual void unbind ();
74
75     /**
76      * Update the GUI subsystem.
77      *
78      * Currently, this method is a no-op, because nothing the GUI
79      * subsystem does is time-dependent.
80      */
81     virtual void update (double delta_time_sec);
82
83     /**
84      * Display a dialog box.
85      *
86      * At initialization time, the subsystem reads all of the XML
87      * configuration files from the directory $FG_ROOT/gui/dialogs/.
88      * The configuration for each dialog specifies a name, and this
89      * method invokes the dialog with the name specified (if it
90      * exists).
91      *
92      * @param name The name of the dialog box.
93      * @return true if the dialog exists, false otherwise.
94      */
95     virtual bool showDialog (const string &name);
96
97
98     /**
99      * Close the currently-active dialog, if any.
100      *
101      * @return true if a dialog was active, false otherwise.
102      */
103     virtual bool closeActiveDialog ();
104
105
106     /**
107      * Return a pointer to the current menubar.
108      */
109     virtual FGMenuBar * getMenuBar ();
110
111
112     /**
113      * Ignore this method.
114      *
115      * This method is for internal use only, but it has to be public
116      * so that a non-class callback can see it.
117      */
118     virtual void setActiveDialog (FGDialog * dialog);
119
120     /**
121      * Get the dialog currently active, if any.
122      *
123      * @return The active dialog, or 0 if none is active.
124      */
125     virtual FGDialog * getActiveDialog ();
126
127 protected:
128
129     /**
130      * Test if the menubar is visible.
131      *
132      * This method exists only for binding.
133      */
134     virtual bool getMenuBarVisible () const;
135
136     /**
137      * Show or hide the menubar.
138      *
139      * This method exists only for binding.
140      */
141     virtual void setMenuBarVisible (bool visible);
142
143
144 private:
145
146     // Free all allocated memory.
147     void clear ();
148
149     // Read all the configuration files in a directory.
150     void readDir (const char * path);
151
152     FGMenuBar * _menubar;
153     FGDialog * _active_dialog;
154     map<string,SGPropertyNode *> _dialog_props;
155
156 };
157
158
159 #endif // __NEW_GUI_HXX
160