Merge pull request #826 from kugel-/doxygen-fixes2
[geany-mirror.git] / scintilla / src / Style.cxx
blobd8efd0ece98a80ab13e864e108820df5f7d0ff2b
1 // Scintilla source code edit control
2 /** @file Style.cxx
3 ** Defines the font and colour style for a class of text.
4 **/
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #include <string.h>
10 #include <stdexcept>
12 #include "Platform.h"
14 #include "Scintilla.h"
15 #include "Style.h"
17 #ifdef SCI_NAMESPACE
18 using namespace Scintilla;
19 #endif
21 FontAlias::FontAlias() {
24 FontAlias::FontAlias(const FontAlias &other) : Font() {
25 SetID(other.fid);
28 FontAlias::~FontAlias() {
29 SetID(0);
30 // ~Font will not release the actual font resource since it is now 0
33 void FontAlias::MakeAlias(Font &fontOrigin) {
34 SetID(fontOrigin.GetID());
37 void FontAlias::ClearFont() {
38 SetID(0);
41 bool FontSpecification::operator==(const FontSpecification &other) const {
42 return fontName == other.fontName &&
43 weight == other.weight &&
44 italic == other.italic &&
45 size == other.size &&
46 characterSet == other.characterSet &&
47 extraFontFlag == other.extraFontFlag;
50 bool FontSpecification::operator<(const FontSpecification &other) const {
51 if (fontName != other.fontName)
52 return fontName < other.fontName;
53 if (weight != other.weight)
54 return weight < other.weight;
55 if (italic != other.italic)
56 return italic == false;
57 if (size != other.size)
58 return size < other.size;
59 if (characterSet != other.characterSet)
60 return characterSet < other.characterSet;
61 if (extraFontFlag != other.extraFontFlag)
62 return extraFontFlag < other.extraFontFlag;
63 return false;
66 FontMeasurements::FontMeasurements() {
67 Clear();
70 void FontMeasurements::Clear() {
71 ascent = 1;
72 descent = 1;
73 aveCharWidth = 1;
74 spaceWidth = 1;
75 sizeZoomed = 2;
78 Style::Style() : FontSpecification() {
79 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
80 Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, 0, SC_CHARSET_DEFAULT,
81 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
84 Style::Style(const Style &source) : FontSpecification(), FontMeasurements() {
85 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
86 0, 0, 0,
87 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
88 fore = source.fore;
89 back = source.back;
90 characterSet = source.characterSet;
91 weight = source.weight;
92 italic = source.italic;
93 size = source.size;
94 fontName = source.fontName;
95 eolFilled = source.eolFilled;
96 underline = source.underline;
97 caseForce = source.caseForce;
98 visible = source.visible;
99 changeable = source.changeable;
100 hotspot = source.hotspot;
103 Style::~Style() {
106 Style &Style::operator=(const Style &source) {
107 if (this == &source)
108 return * this;
109 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
110 0, 0, SC_CHARSET_DEFAULT,
111 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
112 fore = source.fore;
113 back = source.back;
114 characterSet = source.characterSet;
115 weight = source.weight;
116 italic = source.italic;
117 size = source.size;
118 fontName = source.fontName;
119 eolFilled = source.eolFilled;
120 underline = source.underline;
121 caseForce = source.caseForce;
122 visible = source.visible;
123 changeable = source.changeable;
124 return *this;
127 void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
128 const char *fontName_, int characterSet_,
129 int weight_, bool italic_, bool eolFilled_,
130 bool underline_, ecaseForced caseForce_,
131 bool visible_, bool changeable_, bool hotspot_) {
132 fore = fore_;
133 back = back_;
134 characterSet = characterSet_;
135 weight = weight_;
136 italic = italic_;
137 size = size_;
138 fontName = fontName_;
139 eolFilled = eolFilled_;
140 underline = underline_;
141 caseForce = caseForce_;
142 visible = visible_;
143 changeable = changeable_;
144 hotspot = hotspot_;
145 font.ClearFont();
146 FontMeasurements::Clear();
149 void Style::ClearTo(const Style &source) {
150 Clear(
151 source.fore,
152 source.back,
153 source.size,
154 source.fontName,
155 source.characterSet,
156 source.weight,
157 source.italic,
158 source.eolFilled,
159 source.underline,
160 source.caseForce,
161 source.visible,
162 source.changeable,
163 source.hotspot);
166 void Style::Copy(Font &font_, const FontMeasurements &fm_) {
167 font.MakeAlias(font_);
168 (FontMeasurements &)(*this) = fm_;