Disable the "Blend Alpha" menu item if not in overlap mode
[TortoiseGit.git] / ext / scintilla / src / Style.cxx
blob2552276016c281bd7e88e667f8e936a027c08846
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 "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 aveCharWidth = 1;
72 spaceWidth = 1;
73 sizeZoomed = 2;
76 Style::Style() : FontSpecification() {
77 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
78 Platform::DefaultFontSize() * SC_FONT_SIZE_MULTIPLIER, 0, SC_CHARSET_DEFAULT,
79 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
82 Style::Style(const Style &source) : FontSpecification(), FontMeasurements() {
83 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
84 0, 0, 0,
85 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
86 fore = source.fore;
87 back = source.back;
88 characterSet = source.characterSet;
89 weight = source.weight;
90 italic = source.italic;
91 size = source.size;
92 fontName = source.fontName;
93 eolFilled = source.eolFilled;
94 underline = source.underline;
95 caseForce = source.caseForce;
96 visible = source.visible;
97 changeable = source.changeable;
98 hotspot = source.hotspot;
101 Style::~Style() {
104 Style &Style::operator=(const Style &source) {
105 if (this == &source)
106 return * this;
107 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
108 0, 0, SC_CHARSET_DEFAULT,
109 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
110 fore = source.fore;
111 back = source.back;
112 characterSet = source.characterSet;
113 weight = source.weight;
114 italic = source.italic;
115 size = source.size;
116 fontName = source.fontName;
117 eolFilled = source.eolFilled;
118 underline = source.underline;
119 caseForce = source.caseForce;
120 visible = source.visible;
121 changeable = source.changeable;
122 return *this;
125 void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
126 const char *fontName_, int characterSet_,
127 int weight_, bool italic_, bool eolFilled_,
128 bool underline_, ecaseForced caseForce_,
129 bool visible_, bool changeable_, bool hotspot_) {
130 fore = fore_;
131 back = back_;
132 characterSet = characterSet_;
133 weight = weight_;
134 italic = italic_;
135 size = size_;
136 fontName = fontName_;
137 eolFilled = eolFilled_;
138 underline = underline_;
139 caseForce = caseForce_;
140 visible = visible_;
141 changeable = changeable_;
142 hotspot = hotspot_;
143 font.ClearFont();
144 FontMeasurements::Clear();
147 void Style::ClearTo(const Style &source) {
148 Clear(
149 source.fore,
150 source.back,
151 source.size,
152 source.fontName,
153 source.characterSet,
154 source.weight,
155 source.italic,
156 source.eolFilled,
157 source.underline,
158 source.caseForce,
159 source.visible,
160 source.changeable,
161 source.hotspot);
164 void Style::Copy(Font &font_, const FontMeasurements &fm_) {
165 font.MakeAlias(font_);
166 #if PLAT_WX
167 font.SetAscent(fm_.ascent);
168 #endif
169 (FontMeasurements &)(*this) = fm_;