]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/Style.cxx
4a352679100516e02ccf6efb4182ac12c3b0b104
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 aliasOfDefaultFont
= true;
17 Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
18 Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT
,
19 false, false, false, false, caseMixed
, true);
22 Style::Style(const Style
&source
) {
23 Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
25 false, false, false, false, caseMixed
, true);
26 fore
.desired
= source
.fore
.desired
;
27 back
.desired
= source
.back
.desired
;
28 characterSet
= source
.characterSet
;
30 italic
= source
.italic
;
32 eolFilled
= source
.eolFilled
;
33 underline
= source
.underline
;
34 caseForce
= source
.caseForce
;
35 visible
= source
.visible
;
39 if (aliasOfDefaultFont
)
43 aliasOfDefaultFont
= false;
46 Style
&Style::operator=(const Style
&source
) {
49 Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
50 0, 0, SC_CHARSET_DEFAULT
,
51 false, false, false, false, caseMixed
, true);
52 fore
.desired
= source
.fore
.desired
;
53 back
.desired
= source
.back
.desired
;
54 characterSet
= source
.characterSet
;
56 italic
= source
.italic
;
58 eolFilled
= source
.eolFilled
;
59 underline
= source
.underline
;
60 caseForce
= source
.caseForce
;
61 visible
= source
.visible
;
65 void Style::Clear(Colour fore_
, Colour back_
, int size_
,
66 const char *fontName_
, int characterSet_
,
67 bool bold_
, bool italic_
, bool eolFilled_
,
68 bool underline_
, ecaseForced caseForce_
, bool visible_
) {
71 characterSet
= characterSet_
;
76 eolFilled
= eolFilled_
;
77 underline
= underline_
;
78 caseForce
= caseForce_
;
80 if (aliasOfDefaultFont
)
84 aliasOfDefaultFont
= false;
87 void Style::ClearTo(const Style
&source
) {
102 bool Style::EquivalentFontTo(const Style
*other
) const {
103 if (bold
!= other
->bold
||
104 italic
!= other
->italic
||
105 size
!= other
->size
||
106 characterSet
!= other
->characterSet
)
108 if (fontName
== other
->fontName
)
112 if (!other
->fontName
)
114 return strcmp(fontName
, other
->fontName
) == 0;
117 void Style::Realise(Surface
&surface
, int zoomLevel
, Style
*defaultStyle
) {
118 sizeZoomed
= size
+ zoomLevel
;
119 if (sizeZoomed
<= 2) // Hangs if sizeZoomed <= 1
122 if (aliasOfDefaultFont
)
126 int deviceHeight
= surface
.DeviceHeightFont(sizeZoomed
);
127 aliasOfDefaultFont
= defaultStyle
&&
128 (EquivalentFontTo(defaultStyle
) || !fontName
);
129 if (aliasOfDefaultFont
) {
130 font
.SetID(defaultStyle
->font
.GetID());
131 } else if (fontName
) {
132 font
.Create(fontName
, characterSet
, deviceHeight
, bold
, italic
);
137 ascent
= surface
.Ascent(font
);
138 descent
= surface
.Descent(font
);
139 // Probably more typographically correct to include leading
140 // but that means more complex drawing as leading must be erased
141 //lineHeight = surface.ExternalLeading() + surface.Height();
142 externalLeading
= surface
.ExternalLeading(font
);
143 lineHeight
= surface
.Height(font
);
144 aveCharWidth
= surface
.AverageCharWidth(font
);
145 spaceWidth
= surface
.WidthChar(font
, ' ');