]> git.mxchange.org Git - flightgear.git/commitdiff
allow top level <font> definition that applies to text in the whole dialog
authormfranz <mfranz>
Fri, 27 Jan 2006 12:57:13 +0000 (12:57 +0000)
committermfranz <mfranz>
Fri, 27 Jan 2006 12:57:13 +0000 (12:57 +0000)
and makes the layouter use this font's metrics

src/GUI/dialog.cxx
src/GUI/dialog.hxx

index f6f48a7835b6dc8f419bedf74845bef057daded7..450b1977fac722756b2f1adc88fef4250e6b897b 100644 (file)
@@ -420,8 +420,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;
@@ -681,6 +687,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")) {
index 295945e95d3d1990fe756addb67d58e3427fca46..ef0cd4e939c57131e12c946825a92118f6e23427 100644 (file)
@@ -142,6 +142,10 @@ private:
     // The GUI subsystem.
     NewGUI * _gui;
 
+    // The dialog font. Defaults to the global gui font, but can get
+    // overridden by a top level font definition.
+    puFont * _font;
+
     // PUI provides no way for userdata to be deleted automatically
     // with a GUI object, so we have to keep track of all the special
     // data we allocated and then free it manually when the dialog