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, getenv("FG_ROOT"), "gui");
38 ulMakePath(path2, path1, "dialogs");
40 #if !defined(FG_OLD_MENUBAR)
46 NewGUI::update (double delta_time_sec)
52 NewGUI::display (const string &name)
54 if (_widgets.find(name) == _widgets.end())
55 SG_LOG(SG_GENERAL, SG_ALERT, "Dialog " << name << " not defined");
57 new FGDialog(_widgets[name]);
61 NewGUI::setCurrentWidget (FGDialog * widget)
63 _current_widget = widget;
67 NewGUI::getCurrentWidget ()
69 return _current_widget;
79 NewGUI::readDir (const char * path)
81 ulDir * dir = ulOpenDir(path);
84 SG_LOG(SG_GENERAL, SG_ALERT, "Failed to read GUI files from "
89 ulDirEnt * dirEnt = ulReadDir(dir);
93 ulMakePath(subpath, path, dirEnt->d_name);
95 if (dirEnt->d_isdir && dirEnt->d_name[0] != '.') {
98 SGPropertyNode_ptr props = new SGPropertyNode;
100 readProperties(subpath, props);
101 } catch (const sg_exception &ex) {
102 SG_LOG(SG_INPUT, SG_ALERT, "Error parsing GUI file "
105 if (!props->hasValue("name")) {
106 SG_LOG(SG_INPUT, SG_WARN, "GUI file " << subpath
107 << " has no name; skipping.");
109 string name = props->getStringValue("name");
110 SG_LOG(SG_INPUT, SG_BULK, "Saving GUI node " << name);
111 _widgets[name] = props;
114 dirEnt = ulReadDir(dir);
119 // end of new_gui.cxx