]> git.mxchange.org Git - flightgear.git/blob - src/GUI/new_gui.hxx
7936c8a17c5f77bbf864caeb00435fb052f37462
[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 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      * Bind properties for the GUI subsystem.
59      *
60      * Currently, this method binds the properties for showing and
61      * hiding the menu.
62      */
63     virtual void bind ();
64
65     /**
66      * Unbind properties for the GUI subsystem.
67      */
68     virtual void unbind ();
69
70     /**
71      * Update the GUI subsystem.
72      *
73      * Currently, this method is a no-op, because nothing the GUI
74      * subsystem does is time-dependent.
75      */
76     virtual void update (double delta_time_sec);
77
78     /**
79      * Display a dialog box.
80      *
81      * At initialization time, the subsystem reads all of the XML
82      * configuration files from $FG_ROOT/gui/dialogs/*.  The
83      * configuration for each dialog specifies a name, and this method
84      * invokes the dialog with the name specified (if it exists).
85      *
86      * @param name The name of the dialog box.
87      * @return true if the dialog exists, false otherwise.
88      */
89     virtual bool showDialog (const string &name);
90
91
92     /**
93      * Close the currently-active dialog, if any.
94      *
95      * @return true if a dialog was active, false otherwise.
96      */
97     virtual bool closeActiveDialog ();
98
99
100     /**
101      * Return a pointer to the current menubar.
102      */
103     virtual FGMenuBar * getMenuBar ();
104
105
106     /**
107      * Ignore this method.
108      *
109      * This method is for internal use only, but it has to be public
110      * so that a non-class callback can see it.
111      */
112     virtual void setActiveDialog (FGDialog * dialog);
113
114     /**
115      * Get the dialog currently active, if any.
116      *
117      * @return The active dialog, or 0 if none is active.
118      */
119     virtual FGDialog * getActiveDialog ();
120
121 protected:
122
123     /**
124      * Test if the menubar is visible.
125      *
126      * This method exists only for binding.
127      */
128     virtual bool getMenuBarVisible () const;
129
130     /**
131      * Show or hide the menubar.
132      *
133      * This method exists only for binding.
134      */
135     virtual void setMenuBarVisible (bool visible);
136
137
138 private:
139
140     // Read all the configuration files in a directory.
141     void readDir (const char * path);
142
143     FGMenuBar * _menubar;
144     FGDialog * _active_dialog;
145     map<string,SGPropertyNode_ptr> _dialog_props;
146
147 };
148
149
150 #endif // __NEW_GUI_HXX
151