From 591001a24e6038bb31d706250e4d96475a46c050 Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 13 Jul 2005 10:16:42 +0000 Subject: [PATCH] - make tabula rasa on re-init - check /sim/current-gui for where to get gui colors (default "/sim/gui[0]") - call getFont() with gui font address (default "/sim/gui[0]/font") --- src/GUI/new_gui.cxx | 36 ++++++++++++++++++++---------------- src/GUI/new_gui.hxx | 2 +- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/GUI/new_gui.cxx b/src/GUI/new_gui.cxx index e9f19e29e..0e62c99c9 100644 --- a/src/GUI/new_gui.cxx +++ b/src/GUI/new_gui.cxx @@ -32,15 +32,6 @@ NewGUI::NewGUI () _menubar(new FGMenuBar), _active_dialog(0) { - // set up the traditional colors as default - _colors["background"] = FGColor(0.8f, 0.8f, 0.9f, 0.85f); - _colors["foreground"] = FGColor(0.0f, 0.0f, 0.0f, 1.0f); - _colors["highlight"] = FGColor(0.7f, 0.7f, 0.7f, 1.0f); - _colors["label"] = FGColor(0.0f, 0.0f, 0.0f, 1.0f); - _colors["legend"] = FGColor(0.0f, 0.0f, 0.0f, 1.0f); - _colors["misc"] = FGColor(0.0f, 0.0f, 0.0f, 1.0f); - - setStyle(); } NewGUI::~NewGUI () @@ -51,6 +42,7 @@ NewGUI::~NewGUI () void NewGUI::init () { + setStyle(); char path1[1024]; char path2[1024]; ulMakePath(path1, globals->get_fg_root().c_str(), "gui"); @@ -274,13 +266,26 @@ NewGUI::readDir (const char * path) void NewGUI::setStyle (void) { - setupFont(); + _colors.clear(); + + // set up the traditional colors as default + _colors["background"] = FGColor(0.8f, 0.8f, 0.9f, 0.85f); + _colors["foreground"] = FGColor(0.0f, 0.0f, 0.0f, 1.0f); + _colors["highlight"] = FGColor(0.7f, 0.7f, 0.7f, 1.0f); + _colors["label"] = FGColor(0.0f, 0.0f, 0.0f, 1.0f); + _colors["legend"] = FGColor(0.0f, 0.0f, 0.0f, 1.0f); + _colors["misc"] = FGColor(0.0f, 0.0f, 0.0f, 1.0f); //puSetDefaultStyle(); - SGPropertyNode *n = fgGetNode("/sim/gui/colors"); - if (!n) - return; + string path = fgGetString("/sim/current-gui", "/sim/gui"); + string p; + + p = path + "/font"; + setupFont(fgGetNode(p.c_str(), true)); + + p = path + "/colors"; + SGPropertyNode *n = fgGetNode(p.c_str(), true); for (int i = 0; i < n->nChildren(); i++) { SGPropertyNode *child = n->getChild(i); @@ -312,9 +317,8 @@ static const struct { }; void -NewGUI::setupFont () +NewGUI::setupFont (SGPropertyNode *node) { - SGPropertyNode *node = fgGetNode("/sim/gui/font", true); string fontname = node->getStringValue("name", "Helvetica.txf"); float size = node->getFloatValue("size", 15.0); float slant = node->getFloatValue("slant", 0.0); @@ -346,7 +350,7 @@ NewGUI::setupFont () } } puSetDefaultFonts(_font, _font); - fgSetString("/sim/gui/font", fontname.c_str()); + node->setStringValue("name", fontname.c_str()); } diff --git a/src/GUI/new_gui.hxx b/src/GUI/new_gui.hxx index 081970f70..15de193d8 100644 --- a/src/GUI/new_gui.hxx +++ b/src/GUI/new_gui.hxx @@ -173,7 +173,7 @@ protected: virtual void setMenuBarVisible (bool visible); virtual void setStyle (); - virtual void setupFont (); + virtual void setupFont (SGPropertyNode *); private: fntTexFont _tex_font; -- 2.39.5