]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/Style.cxx
4314dec0acff0d569dcc694b50d35a655383c4b1
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
;
20 aliasOfDefaultFont
= true;
21 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
22 Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT
,
23 false, false, false, false, caseMixed
, true, true, false);
26 Style::Style(const Style
&source
) {
27 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
29 false, false, false, false, caseMixed
, true, true, false);
30 fore
.desired
= source
.fore
.desired
;
31 back
.desired
= source
.back
.desired
;
32 characterSet
= source
.characterSet
;
34 italic
= source
.italic
;
36 eolFilled
= source
.eolFilled
;
37 underline
= source
.underline
;
38 caseForce
= source
.caseForce
;
39 visible
= source
.visible
;
40 changeable
= source
.changeable
;
41 hotspot
= source
.hotspot
;
45 if (aliasOfDefaultFont
)
49 aliasOfDefaultFont
= false;
52 Style
&Style::operator=(const Style
&source
) {
55 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
56 0, 0, SC_CHARSET_DEFAULT
,
57 false, false, false, false, caseMixed
, true, true, false);
58 fore
.desired
= source
.fore
.desired
;
59 back
.desired
= source
.back
.desired
;
60 characterSet
= source
.characterSet
;
62 italic
= source
.italic
;
64 eolFilled
= source
.eolFilled
;
65 underline
= source
.underline
;
66 caseForce
= source
.caseForce
;
67 visible
= source
.visible
;
68 changeable
= source
.changeable
;
72 void Style::Clear(ColourDesired fore_
, ColourDesired back_
, int size_
,
73 const char *fontName_
, int characterSet_
,
74 bool bold_
, bool italic_
, bool eolFilled_
,
75 bool underline_
, ecaseForced caseForce_
,
76 bool visible_
, bool changeable_
, bool hotspot_
) {
79 characterSet
= characterSet_
;
84 eolFilled
= eolFilled_
;
85 underline
= underline_
;
86 caseForce
= caseForce_
;
88 changeable
= changeable_
;
90 if (aliasOfDefaultFont
)
94 aliasOfDefaultFont
= false;
97 void Style::ClearTo(const Style
&source
) {
114 bool Style::EquivalentFontTo(const Style
*other
) const {
115 if (bold
!= other
->bold
||
116 italic
!= other
->italic
||
117 size
!= other
->size
||
118 characterSet
!= other
->characterSet
)
120 if (fontName
== other
->fontName
)
124 if (!other
->fontName
)
126 return strcmp(fontName
, other
->fontName
) == 0;
129 void Style::Realise(Surface
&surface
, int zoomLevel
, Style
*defaultStyle
, int extraFontFlag
) {
130 sizeZoomed
= size
+ zoomLevel
;
131 if (sizeZoomed
<= 2) // Hangs if sizeZoomed <= 1
134 if (aliasOfDefaultFont
)
138 int deviceHeight
= surface
.DeviceHeightFont(sizeZoomed
);
139 aliasOfDefaultFont
= defaultStyle
&&
140 (EquivalentFontTo(defaultStyle
) || !fontName
);
141 if (aliasOfDefaultFont
) {
142 font
.SetID(defaultStyle
->font
.GetID());
143 } else if (fontName
) {
144 font
.Create(fontName
, characterSet
, deviceHeight
, bold
, italic
, extraFontFlag
);
149 ascent
= surface
.Ascent(font
);
150 descent
= surface
.Descent(font
);
151 // Probably more typographically correct to include leading
152 // but that means more complex drawing as leading must be erased
153 //lineHeight = surface.ExternalLeading() + surface.Height();
154 externalLeading
= surface
.ExternalLeading(font
);
155 lineHeight
= surface
.Height(font
);
156 aveCharWidth
= surface
.AverageCharWidth(font
);
157 spaceWidth
= surface
.WidthChar(font
, ' ');