From cabf53537a9fb05e1697c00459bc05b24c4ae89c Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 27 Jan 2006 12:57:13 +0000 Subject: [PATCH] allow top level definition that applies to text in the whole dialog and makes the layouter use this font's metrics --- src/GUI/dialog.cxx | 12 ++++++++++-- src/GUI/dialog.hxx | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/GUI/dialog.cxx b/src/GUI/dialog.cxx index f6f48a783..450b1977f 100644 --- a/src/GUI/dialog.cxx +++ b/src/GUI/dialog.cxx @@ -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")) { diff --git a/src/GUI/dialog.hxx b/src/GUI/dialog.hxx index 295945e95..ef0cd4e93 100644 --- a/src/GUI/dialog.hxx +++ b/src/GUI/dialog.hxx @@ -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 -- 2.39.5