1 // Scintilla source code edit control
3 ** Defines the font and colour style for a class of text.
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.
12 #include "Scintilla.h"
16 using namespace Scintilla
;
19 FontAlias::FontAlias() {
22 FontAlias::FontAlias(const FontAlias
&other
) : Font() {
26 FontAlias::~FontAlias() {
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() {
39 bool FontSpecification::operator==(const FontSpecification
&other
) const {
40 return fontName
== other
.fontName
&&
41 weight
== other
.weight
&&
42 italic
== other
.italic
&&
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
;
64 FontMeasurements::FontMeasurements() {
68 void FontMeasurements::Clear() {
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),
86 SC_WEIGHT_NORMAL
, false, false, false, caseMixed
, true, true, false);
89 characterSet
= source
.characterSet
;
90 weight
= source
.weight
;
91 italic
= source
.italic
;
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
;
105 Style
&Style::operator=(const Style
&source
) {
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);
113 characterSet
= source
.characterSet
;
114 weight
= source
.weight
;
115 italic
= source
.italic
;
117 fontName
= source
.fontName
;
118 eolFilled
= source
.eolFilled
;
119 underline
= source
.underline
;
120 caseForce
= source
.caseForce
;
121 visible
= source
.visible
;
122 changeable
= source
.changeable
;
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_
) {
133 characterSet
= characterSet_
;
137 fontName
= fontName_
;
138 eolFilled
= eolFilled_
;
139 underline
= underline_
;
140 caseForce
= caseForce_
;
142 changeable
= changeable_
;
145 FontMeasurements::Clear();
148 void Style::ClearTo(const Style
&source
) {
165 void Style::Copy(Font
&font_
, const FontMeasurements
&fm_
) {
166 font
.MakeAlias(font_
);
167 (FontMeasurements
&)(*this) = fm_
;