GuiApplication::resetGui(): Recreate Mac nenubar.
[lyx.git] / src / FontInfo.h
blobab1fab670dc18cdddef2c2f0cc58d134e9f9408e
1 // -*- C++ -*-
2 /**
3 * \file src/FontInfo.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author Angus Leeming
10 * \author Dekel Tsur
12 * Full author contact details are available in file CREDITS.
15 #ifndef FONT_PROPERTIES_H
16 #define FONT_PROPERTIES_H
18 #ifdef TEX2LYX
19 #include "tex2lyx/Font.h"
20 #else
22 #include "ColorCode.h"
23 #include "FontEnums.h"
25 namespace lyx {
27 ///
28 class FontInfo
30 public:
31 ///
32 FontInfo();
33 ///
34 FontInfo(
35 FontFamily family,
36 FontSeries series,
37 FontShape shape,
38 FontSize size,
39 ColorCode color,
40 ColorCode background,
41 FontState emph,
42 FontState underbar,
43 FontState noun,
44 FontState number
45 ): family_(family), series_(series), shape_(shape), size_(size),
46 color_(color), background_(background), emph_(emph),
47 underbar_(underbar), noun_(noun), number_(number)
50 /// Decreases font size by one
51 FontInfo & decSize();
52 /// Increases font size by one
53 FontInfo & incSize();
55 /// Accessor methods.
56 ///@{
57 FontFamily family() const { return family_; }
58 void setFamily(FontFamily f) { family_ = f; }
59 FontSeries series() const { return series_; }
60 void setSeries(FontSeries s) { series_ = s; }
61 FontShape shape() const { return shape_; }
62 void setShape(FontShape s) { shape_ = s; }
63 FontSize size() const { return size_; }
64 void setSize(FontSize s) { size_ = s; }
65 FontState emph() const { return emph_; }
66 void setEmph(FontState e) { emph_ = e; }
67 FontState underbar() const { return underbar_; }
68 void setUnderbar(FontState u) { underbar_ = u; }
69 FontState noun() const { return noun_; }
70 void setNoun(FontState n) { noun_ = n; }
71 FontState number() const { return number_; }
72 void setNumber(FontState n) { number_ = n; }
73 ColorCode color() const { return color_; }
74 void setColor(ColorCode c) { color_ = c; }
75 ColorCode background() const { return background_; }
76 void setBackground(ColorCode b) { background_ = b; }
77 ///@}
79 ///
80 void update(FontInfo const & newfont, bool toggleall);
82 /** Reduce font to fall back to template where possible.
83 Equal fields are reduced to INHERIT */
84 void reduce(FontInfo const & tmplt);
86 /// Realize font from a template (INHERIT are realized)
87 FontInfo & realize(FontInfo const & tmplt);
88 /// Is a given font fully resolved?
89 bool resolved() const;
91 ///
92 ColorCode realColor() const;
94 /// Converts logical attributes to concrete shape attribute
95 /// Try hard to inline this as it shows up with 4.6 % in the profiler.
96 FontShape realShape() const
98 if (noun_ == FONT_ON)
99 return SMALLCAPS_SHAPE;
100 if (emph_ == FONT_ON)
101 return (shape_ == UP_SHAPE) ? ITALIC_SHAPE : UP_SHAPE;
102 return shape_;
105 bool isSymbolFont() const
107 switch (family_) {
108 case SYMBOL_FAMILY:
109 case CMSY_FAMILY:
110 case CMM_FAMILY:
111 case CMEX_FAMILY:
112 case MSA_FAMILY:
113 case MSB_FAMILY:
114 case WASY_FAMILY:
115 case ESINT_FAMILY:
116 return true;
117 default:
118 return false;
122 private:
123 friend bool operator==(FontInfo const & lhs, FontInfo const & rhs);
126 FontFamily family_;
128 FontSeries series_;
130 FontShape shape_;
132 FontSize size_;
134 ColorCode color_;
136 ColorCode background_;
138 FontState emph_;
140 FontState underbar_;
142 FontState noun_;
144 FontState number_;
148 inline bool operator==(FontInfo const & lhs, FontInfo const & rhs)
150 return lhs.family_ == rhs.family_
151 && lhs.series_ == rhs.series_
152 && lhs.shape_ == rhs.shape_
153 && lhs.size_ == rhs.size_
154 && lhs.color_ == rhs.color_
155 && lhs.background_ == rhs.background_
156 && lhs.emph_ == rhs.emph_
157 && lhs.underbar_ == rhs.underbar_
158 && lhs.noun_ == rhs.noun_
159 && lhs.number_ == rhs.number_;
163 inline bool operator!=(FontInfo const & lhs, FontInfo const & rhs)
165 return !operator==(lhs, rhs);
168 /// Sane font.
169 extern FontInfo const sane_font;
170 /// All inherit font.
171 extern FontInfo const inherit_font;
172 /// All ignore font.
173 extern FontInfo const ignore_font;
175 } // namespace lyx
177 #endif // TEX2LYX_FONT_H
178 #endif