]> git.mxchange.org Git - flightgear.git/blob - src/GUI/new_gui.hxx
Fix the nmea and garmin output to a) fake a GSA sentence, b) fix a y2k bug
[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/props/props.hxx>
14 #include <simgear/structure/subsystem_mgr.hxx>
15
16 #include <vector>
17 SG_USING_STD(vector);
18
19 #include <map>
20 SG_USING_STD(map);
21
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 SGSubsystem
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      * Creates a new dialog box, using the same property format as the
85      * gui/dialogs configuration files.  Does not display the
86      * resulting dialog.  If a pre-existing dialog of the same name
87      * exists, it will be deleted.  The node argument will be stored
88      * in the GUI subsystem using SGPropertNode_ptr reference counting.
89      * It should not be deleted by user code.
90      *
91      * @param node A property node containing the dialog definition
92      */
93     virtual void newDialog (SGPropertyNode* node);
94
95     /**
96      * Display a dialog box.
97      *
98      * At initialization time, the subsystem reads all of the XML
99      * configuration files from the directory $FG_ROOT/gui/dialogs/.
100      * The configuration for each dialog specifies a name, and this
101      * method invokes the dialog with the name specified (if it
102      * exists).
103      *
104      * @param name The name of the dialog box.
105      * @return true if the dialog exists, false otherwise.
106      */
107     virtual bool showDialog (const string &name);
108
109
110     /**
111      * Close the currenty active dialog.  This function is intended to
112      * be called from code (pui callbacks, for instance) that registers
113      * its dialog object as active via setActiveDialog().  Other
114      * user-level code should use the closeDialog(name) API.
115      *
116      * @return true if a dialog was active, false otherwise
117      */
118     virtual bool closeActiveDialog ();
119
120     /**
121      * Close a named dialog, if it is open.
122      *
123      * @param name The name of the dialog box.
124      * @return true if the dialog was active, false otherwise.
125      */
126     virtual bool closeDialog (const string &name);
127
128     /**
129      * Return a pointer to the current menubar.
130      */
131     virtual FGMenuBar * getMenuBar ();
132
133
134     /**
135      * Ignore this method.
136      *
137      * This method is for internal use only, but it has to be public
138      * so that a non-class callback can see it.
139      */
140     virtual void setActiveDialog (FGDialog * dialog);
141
142     /**
143      * Get the dialog currently active, if any.
144      *
145      * @return The active dialog, or 0 if none is active.
146      */
147     virtual FGDialog * getActiveDialog ();
148
149 protected:
150
151     /**
152      * Test if the menubar is visible.
153      *
154      * This method exists only for binding.
155      */
156     virtual bool getMenuBarVisible () const;
157
158     /**
159      * Show or hide the menubar.
160      *
161      * This method exists only for binding.
162      */
163     virtual void setMenuBarVisible (bool visible);
164
165
166 private:
167
168     // Free all allocated memory.
169     void clear ();
170
171     // Read all the configuration files in a directory.
172     void readDir (const char * path);
173
174     FGMenuBar * _menubar;
175     FGDialog * _active_dialog;
176     map<string,FGDialog *> _active_dialogs;
177     map<string,SGPropertyNode_ptr> _dialog_props;
178
179 };
180
181
182 #endif // __NEW_GUI_HXX
183