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.
14 #include "Scintilla.h"
18 using namespace Scintilla
;
21 FontAlias::FontAlias() {
24 FontAlias::FontAlias(const FontAlias
&other
) : Font() {
28 FontAlias::~FontAlias() {
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() {
41 bool FontSpecification::operator==(const FontSpecification
&other
) const {
42 return fontName
== other
.fontName
&&
43 weight
== other
.weight
&&
44 italic
== other
.italic
&&
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
;
66 FontMeasurements::FontMeasurements() {
70 void FontMeasurements::Clear() {
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),
87 SC_WEIGHT_NORMAL
, false, false, false, caseMixed
, true, true, false);
90 characterSet
= source
.characterSet
;
91 weight
= source
.weight
;
92 italic
= source
.italic
;
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
;
106 Style
&Style::operator=(const Style
&source
) {
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);
114 characterSet
= source
.characterSet
;
115 weight
= source
.weight
;
116 italic
= source
.italic
;
118 fontName
= source
.fontName
;
119 eolFilled
= source
.eolFilled
;
120 underline
= source
.underline
;
121 caseForce
= source
.caseForce
;
122 visible
= source
.visible
;
123 changeable
= source
.changeable
;
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_
) {
134 characterSet
= characterSet_
;
138 fontName
= fontName_
;
139 eolFilled
= eolFilled_
;
140 underline
= underline_
;
141 caseForce
= caseForce_
;
143 changeable
= changeable_
;
146 FontMeasurements::Clear();
149 void Style::ClearTo(const Style
&source
) {
166 void Style::Copy(Font
&font_
, const FontMeasurements
&fm_
) {
167 font
.MakeAlias(font_
);
168 (FontMeasurements
&)(*this) = fm_
;