]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/Style.cxx
48302332164e6b46cdbae3b243ee916299149e55
1 // Scintilla source code edit control
2 // Style.cxx - defines the font and colour style for a class of text
3 // Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
4 // The License.txt file describes the conditions under which this software may be distributed.
13 aliasOfDefaultFont
= true;
14 Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
15 Platform::DefaultFontSize(), 0,
20 if (aliasOfDefaultFont
)
24 aliasOfDefaultFont
= false;
27 Style
&Style::operator=(const Style
&source
) {
30 Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
33 fore
.desired
= source
.fore
.desired
;
34 back
.desired
= source
.back
.desired
;
36 italic
= source
.italic
;
38 eolFilled
= source
.eolFilled
;
42 void Style::Clear(Colour fore_
, Colour back_
, int size_
, const char *fontName_
,
43 bool bold_
, bool italic_
, bool eolFilled_
) {
50 eolFilled
= eolFilled_
;
51 if (aliasOfDefaultFont
)
55 aliasOfDefaultFont
= false;
58 bool Style::EquivalentFontTo(const Style
*other
) const {
59 if (bold
!= other
->bold
||
60 italic
!= other
->italic
||
63 if (fontName
== other
->fontName
)
69 return strcmp(fontName
, other
->fontName
) == 0;
72 void Style::Realise(Surface
&surface
, int zoomLevel
, Style
*defaultStyle
) {
73 int sizeZoomed
= size
+ zoomLevel
;
74 if (sizeZoomed
<= 2) // Hangs if sizeZoomed <= 1
77 if (aliasOfDefaultFont
)
81 int deviceHeight
= (sizeZoomed
* surface
.LogPixelsY()) / 72;
82 aliasOfDefaultFont
= defaultStyle
&&
83 (EquivalentFontTo(defaultStyle
) || !fontName
);
84 if (aliasOfDefaultFont
) {
85 font
.SetID(defaultStyle
->font
.GetID());
86 } else if (fontName
) {
87 font
.Create(fontName
, deviceHeight
, bold
, italic
);
92 ascent
= surface
.Ascent(font
);
93 descent
= surface
.Descent(font
);
94 // Probably more typographically correct to include leading
95 // but that means more complex drawing as leading must be erased
96 //lineHeight = surface.ExternalLeading() + surface.Height();
97 externalLeading
= surface
.ExternalLeading(font
);
98 lineHeight
= surface
.Height(font
);
99 aveCharWidth
= surface
.AverageCharWidth(font
);
100 spaceWidth
= surface
.WidthChar(font
, ' ');