OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
fontwrapper.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_WIDGETS_WRAPPER_H
2 #define OPENMW_WIDGETS_WRAPPER_H
3 
4 #include "widgets.hpp"
5 
7 
8 namespace Gui
9 {
10  template<class T>
11  class FontWrapper : public T
12  {
13  public:
14  virtual void setFontName(const std::string& name)
15  {
16  T::setFontName(name);
17  T::setPropertyOverride ("FontHeight", mFontSize);
18  }
19 
20  protected:
22  {
23  // Note: we can not use the WindowManager here, so there is a code duplication a bit.
24  int fontSize = Settings::Manager::getInt("font size", "GUI");
25  fontSize = std::min(std::max(12, fontSize), 20);
26  mFontSize = std::to_string(fontSize);
27  }
28 
29  virtual void setPropertyOverride(const std::string& _key, const std::string& _value)
30  {
31  T::setPropertyOverride (_key, _value);
32 
33  // There is a bug in MyGUI: when it initializes the FontName property, it reset the font height.
34  // We should restore it.
35  if (_key == "FontName")
36  {
37  T::setPropertyOverride ("FontHeight", mFontSize);
38  }
39  }
40 
41  std::string mFontSize;
42  };
43 }
44 
45 #endif
virtual void setFontName(const std::string &name)
Definition: fontwrapper.hpp:14
virtual void setPropertyOverride(const std::string &_key, const std::string &_value)
Definition: fontwrapper.hpp:29
FontWrapper()
Definition: fontwrapper.hpp:21
Definition: fontwrapper.hpp:11
std::string mFontSize
Definition: fontwrapper.hpp:41
static int getInt(const std::string &setting, const std::string &category)
Definition: settings.cpp:399
const char * name
Definition: crashcatcher.cpp:67