Update Tortoise.pot
[TortoiseGit.git] / ext / scintilla / src / Style.cxx
blobe55ea2e7ea17cf4bb4130dca0b48397f977426a3
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 <stdexcept>
10 #include "Platform.h"
12 #include "Scintilla.h"
13 #include "Style.h"
15 #ifdef SCI_NAMESPACE
16 using namespace Scintilla;
17 #endif
19 FontAlias::FontAlias() {
22 FontAlias::FontAlias(const FontAlias &other) : Font() {
23 SetID(other.fid);
26 FontAlias::~FontAlias() {
27 SetID(0);
28 // ~Font will not release the actual font resource since it is now 0
31 void FontAlias::MakeAlias(Font &fontOrigin) {
32 SetID(fontOrigin.GetID());
35 void FontAlias::ClearFont() {
36 SetID(0);
39 bool FontSpecification::operator==(const FontSpecification &other) const {
40 return fontName == other.fontName &&
41 weight == other.weight &&
42 italic == other.italic &&
43 size == other.size &&
44 characterSet == other.characterSet &&
45 extraFontFlag == other.extraFontFlag;
48 bool FontSpecification::operator<(const FontSpecification &other) const {
49 if (fontName != other.fontName)
50 return fontName < other.fontName;
51 if (weight != other.weight)
52 return weight < other.weight;
53 if (italic != other.italic)
54 return italic == false;
55 if (size != other.size)
56 return size < other.size;
57 if (characterSet != other.characterSet)
58 return characterSet < other.characterSet;
59 if (extraFontFlag != other.extraFontFlag)
60 return extraFontFlag < other.extraFontFlag;
61 return false;
64 FontMeasurements::FontMeasurements() {
65 Clear();
68 void FontMeasurements::Clear() {
69 ascent = 1;
70 descent = 1;
71 capitalHeight = 1;
72 aveCharWidth = 1;
73 spaceWidth = 1;
74 sizeZoomed = 2;
77 Style::Style() : FontSpecification() {
78 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
79 Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, 0, SC_CHARSET_DEFAULT,
80 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
83 Style::Style(const Style &source) : FontSpecification(), FontMeasurements() {
84 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
85 0, 0, 0,
86 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
87 fore = source.fore;
88 back = source.back;
89 characterSet = source.characterSet;
90 weight = source.weight;
91 italic = source.italic;
92 size = source.size;
93 fontName = source.fontName;
94 eolFilled = source.eolFilled;
95 underline = source.underline;
96 caseForce = source.caseForce;
97 visible = source.visible;
98 changeable = source.changeable;
99 hotspot = source.hotspot;
102 Style::~Style() {
105 Style &Style::operator=(const Style &source) {
106 if (this == &source)
107 return * this;
108 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
109 0, 0, SC_CHARSET_DEFAULT,
110 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
111 fore = source.fore;
112 back = source.back;
113 characterSet = source.characterSet;
114 weight = source.weight;
115 italic = source.italic;
116 size = source.size;
117 fontName = source.fontName;
118 eolFilled = source.eolFilled;
119 underline = source.underline;
120 caseForce = source.caseForce;
121 visible = source.visible;
122 changeable = source.changeable;
123 return *this;
126 void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
127 const char *fontName_, int characterSet_,
128 int weight_, bool italic_, bool eolFilled_,
129 bool underline_, ecaseForced caseForce_,
130 bool visible_, bool changeable_, bool hotspot_) {
131 fore = fore_;
132 back = back_;
133 characterSet = characterSet_;
134 weight = weight_;
135 italic = italic_;
136 size = size_;
137 fontName = fontName_;
138 eolFilled = eolFilled_;
139 underline = underline_;
140 caseForce = caseForce_;
141 visible = visible_;
142 changeable = changeable_;
143 hotspot = hotspot_;
144 font.ClearFont();
145 FontMeasurements::Clear();
148 void Style::ClearTo(const Style &source) {
149 Clear(
150 source.fore,
151 source.back,
152 source.size,
153 source.fontName,
154 source.characterSet,
155 source.weight,
156 source.italic,
157 source.eolFilled,
158 source.underline,
159 source.caseForce,
160 source.visible,
161 source.changeable,
162 source.hotspot);
165 void Style::Copy(Font &font_, const FontMeasurements &fm_) {
166 font.MakeAlias(font_);
167 (FontMeasurements &)(*this) = fm_;