]> git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/Style.cxx
56312314ffc2457d6c4a8e059325ea9629527820
[wxWidgets.git] / src / stc / scintilla / src / Style.cxx
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.
5
6 #include <string.h>
7
8 #include "Platform.h"
9
10 #include "Style.h"
11
12 Style::Style() {
13 Clear();
14 }
15
16 Style::~Style() {
17 font.Release();
18 }
19
20 Style &Style::operator=(const Style &source) {
21 if (this == &source)
22 return *this;
23 Clear();
24 fore.desired = source.fore.desired;
25 back.desired = source.back.desired;
26 bold = source.bold;
27 italic = source.italic;
28 size = source.size;
29 strcpy(fontName, source.fontName);
30 eolFilled = source.eolFilled;
31 return *this;
32 }
33
34 void Style::Clear(Colour fore_, Colour back_, int size_, const char *fontName_,
35 bool bold_, bool italic_, bool eolFilled_) {
36 fore.desired = fore_;
37 back.desired = back_;
38 bold = bold_;
39 italic = italic_;
40 size = size_;
41 strcpy(fontName, fontName_);
42 eolFilled = eolFilled_;
43 font.Release();
44 }
45
46 void Style::Realise(Surface &surface, int zoomLevel) {
47 int sizeZoomed = size + zoomLevel;
48 if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
49 sizeZoomed = 2;
50
51 int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72;
52 font.Create(fontName, deviceHeight, bold, italic);
53
54 ascent = surface.Ascent(font);
55 descent = surface.Descent(font);
56 // Probably more typographically correct to include leading
57 // but that means more complex drawing as leading must be erased
58 //lineHeight = surface.ExternalLeading() + surface.Height();
59 externalLeading = surface.ExternalLeading(font);
60 lineHeight = surface.Height(font);
61 aveCharWidth = surface.AverageCharWidth(font);
62 spaceWidth = surface.WidthChar(font, ' ');
63 }