#include "FGCocoaMenuBar.hxx"
#endif
+#if defined(SG_WINDOWS)
+#include "FGWindowsMenuBar.hxx"
+#endif
+
#include "FGPUIDialog.hxx"
#include "FGFontCache.hxx"
#include "FGColor.hxx"
void
NewGUI::init ()
{
-#if defined(SG_MAC)
- if (fgGetBool("/sim/menubar/native", true)) {
- _menubar.reset(new FGCocoaMenuBar);
- }
-#endif
- if (!_menubar.get()) {
- _menubar.reset(new FGPUIMenuBar);
- }
-
+ createMenuBarImplementation();
fgTie("/sim/menubar/visibility", this,
&NewGUI::getMenuBarVisible, &NewGUI::setMenuBarVisible);
setStyle();
SGPath p(globals->get_fg_root(), "gui/dialogs");
readDir(p);
- const std::string aircraft_dir(fgGetString("/sim/aircraft-dir"));
- readDir( SGPath(aircraft_dir, "gui/dialogs") );
+
+ SGPath aircraftDialogDir(string(fgGetString("/sim/aircraft-dir")), "gui/dialogs");
+ if (aircraftDialogDir.exists()) {
+ readDir(aircraftDialogDir);
+ }
// Fix for http://code.google.com/p/flightgear-bugs/issues/detail?id=947
fgGetNode("sim/menubar")->setAttribute(SGPropertyNode::PRESERVE, true);
void
NewGUI::shutdown()
{
+ DialogDict::iterator it = _active_dialogs.begin();
+ for (; it != _active_dialogs.end(); ++it) {
+ delete it->second;
+ }
+ _active_dialogs.clear();
+
fgUntie("/sim/menubar/visibility");
_menubar.reset();
_dialog_props.clear();
reset(false);
}
+void
+NewGUI::createMenuBarImplementation()
+{
+#if defined(SG_MAC)
+ if (fgGetBool("/sim/menubar/native", true)) {
+ _menubar.reset(new FGCocoaMenuBar);
+ }
+#endif
+#if defined(SG_WINDOWS)
+ if (fgGetBool("/sim/menubar/native", true)) {
+ // Windows-native menubar disabled for the moment, fall-through
+ // to PUI version
+ // _menubar.reset(new FGWindowsMenuBar);
+ }
+#endif
+ if (!_menubar.get()) {
+ _menubar.reset(new FGPUIMenuBar);
+ }
+}
+
void
NewGUI::reset (bool reload)
{
- map<string,FGDialog *>::iterator iter;
+ DialogDict::iterator iter;
string_list openDialogs;
// close all open dialogs and remember them ...
for (iter = _active_dialogs.begin(); iter != _active_dialogs.end(); ++iter)
setStyle();
unbind();
-#if !defined(SG_MAC)
- _menubar.reset(new FGPUIMenuBar);
-#endif
if (reload) {
_dialog_props.clear();
_dialog_names.clear();
init();
} else {
+ createMenuBarImplementation();
_menubar->init();
}
string name = nameprop->getStringValue();
_dialog_names[name] = xmlPath;
// update cached values
- cache->stampCacheFile(xmlPath);
- cache->writeStringProperty(xmlPath.str(), name);
+ if (!cache->isReadOnly()) {
+ cache->stampCacheFile(xmlPath);
+ cache->writeStringProperty(xmlPath.str(), name);
+ }
} // of directory children iteration
txn.commit();
void
NewGUI::setupFont (SGPropertyNode *node)
{
- _font = globals->get_fontcache()->get(node);
+ _font = FGFontCache::instance()->get(node);
puSetDefaultFonts(*_font, *_font);
return;
}