]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/dialog.cxx
Add missing include files needed by the new math code under windows
[flightgear.git] / src / GUI / dialog.cxx
index a76dbe1c782fb545ebea879522ecd7f6527161cb..451cee38da02f4a7a165fe313372586f9db655d4 100644 (file)
@@ -1,5 +1,9 @@
 // dialog.cxx: implementation of an XML-configurable dialog box.
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
 #include <stdlib.h>            // atof()
 
 #include <Input/input.hxx>
@@ -317,21 +321,18 @@ copy_from_pui (puObject * object, SGPropertyNode * node)
 
 FGDialog::FGDialog (SGPropertyNode * props)
     : _object(0),
-      _gui((NewGUI *)globals->get_subsystem("gui"))
+      _gui((NewGUI *)globals->get_subsystem("gui")),
+      _props(props)
 {
-    char* envp = ::getenv( "FG_FONTS" );
-    if ( envp != NULL ) {
-        _font_path.set( envp );
-    } else {
-        _font_path.set( globals->get_fg_root() );
-        _font_path.append( "Fonts" );
-    }
-
     display(props);
 }
 
 FGDialog::~FGDialog ()
 {
+    int x, y;
+    _object->getAbsolutePosition(&x, &y);
+    _props->setIntValue("lastx", x);
+    _props->setIntValue("lasty", y);
     puDeleteObject(_object);
 
     unsigned int i;
@@ -428,8 +429,14 @@ FGDialog::display (SGPropertyNode * props)
     // Let the layout widget work in the same property subtree.
     LayoutWidget wid(props);
 
-    puFont *fnt = _gui->getDefaultFont();
-    wid.setDefaultFont(fnt, int(fnt->getPointSize()));
+    SGPropertyNode *fontnode = props->getNode("font");
+    if (fontnode) {
+        FGFontCache *fc = _gui->get_fontcache();
+        _font = fc->get(fontnode);
+    } else {
+        _font = _gui->getDefaultFont();
+    }
+    wid.setDefaultFont(_font, int(_font->getPointSize()));
 
     int pw=0, ph=0;
     int px, py, savex, savey;
@@ -442,9 +449,9 @@ FGDialog::display (SGPropertyNode * props)
 
     // Negative x/y coordinates are interpreted as distance from the top/right
     // corner rather than bottom/left.
-    if (px < 0)
+    if (userx && px < 0)
         px = screenw - pw + px;
-    if (py < 0)
+    if (usery && py < 0)
         py = screenh - ph + py;
 
     // Define "x", "y", "width" and/or "height" in the property tree if they
@@ -689,6 +696,8 @@ FGDialog::setupObject (puObject * object, SGPropertyNode * props)
        FGFontCache *fc = _gui->get_fontcache();
        puFont *lfnt = fc->get(nft);
        object->setLabelFont(*lfnt);
+    } else {
+       object->setLabelFont(*_font);
     }
 
     if (props->hasValue("property")) {