1 // new_gui.cxx: implementation of XML-configurable GUI support.
8 #include <simgear/misc/exception.hxx>
9 #include <Main/fg_props.hxx>
11 #include "menubar.hxx"
16 ////////////////////////////////////////////////////////////////////////
17 // Implementation of NewGUI.
18 ////////////////////////////////////////////////////////////////////////
22 : _menubar(new FGMenuBar),
37 ulMakePath(path1, globals->get_fg_root().c_str(), "gui");
38 ulMakePath(path2, path1, "dialogs");
40 #if !defined(FG_OLD_MENUBAR)
48 fgTie("/sim/menubar/visibility", this,
49 &NewGUI::getMenuBarVisible, &NewGUI::setMenuBarVisible);
55 fgUntie("/sim/menubar/visibility");
59 NewGUI::update (double delta_time_sec)
65 NewGUI::display (const string &name)
67 if (_widgets.find(name) == _widgets.end())
68 SG_LOG(SG_GENERAL, SG_ALERT, "Dialog " << name << " not defined");
70 new FGDialog(_widgets[name]);
74 NewGUI::setCurrentWidget (FGDialog * widget)
76 _current_widget = widget;
80 NewGUI::getCurrentWidget ()
82 return _current_widget;
92 NewGUI::getMenuBarVisible () const
94 return _menubar->isVisible();
98 NewGUI::setMenuBarVisible (bool visible)
107 NewGUI::readDir (const char * path)
109 ulDir * dir = ulOpenDir(path);
112 SG_LOG(SG_GENERAL, SG_ALERT, "Failed to read GUI files from "
117 ulDirEnt * dirEnt = ulReadDir(dir);
118 while (dirEnt != 0) {
121 ulMakePath(subpath, path, dirEnt->d_name);
123 if (dirEnt->d_isdir && dirEnt->d_name[0] != '.') {
126 SGPropertyNode_ptr props = new SGPropertyNode;
128 readProperties(subpath, props);
129 } catch (const sg_exception &ex) {
130 SG_LOG(SG_INPUT, SG_ALERT, "Error parsing GUI file "
133 if (!props->hasValue("name")) {
134 SG_LOG(SG_INPUT, SG_WARN, "GUI file " << subpath
135 << " has no name; skipping.");
137 string name = props->getStringValue("name");
138 SG_LOG(SG_INPUT, SG_BULK, "Saving GUI node " << name);
139 _widgets[name] = props;
142 dirEnt = ulReadDir(dir);
147 // end of new_gui.cxx