geany  1.38
About: Geany is a text editor (using GTK2) with basic features of an integrated development environment (syntax highlighting, code folding, symbol name auto-completion, ...). F: office T: editor programming GTK+ IDE
  Fossies Dox: geany-1.38.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Style.cxx
Go to the documentation of this file.
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.
7
8#include <stdexcept>
9#include <vector>
10#include <memory>
11
12#include "Platform.h"
13
14#include "Scintilla.h"
15#include "Style.h"
16
17using namespace Scintilla;
18
19FontAlias::FontAlias() noexcept {
20}
21
22FontAlias::FontAlias(const FontAlias &other) noexcept : Font() {
23 SetID(other.fid);
24}
25
27 SetID(FontID{});
28 // ~Font will not release the actual font resource since it is now 0
29}
30
31void FontAlias::MakeAlias(const Font &fontOrigin) noexcept {
32 SetID(fontOrigin.GetID());
33}
34
35void FontAlias::ClearFont() noexcept {
36 SetID(FontID{});
37}
38
39bool FontSpecification::operator==(const FontSpecification &other) const noexcept {
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;
46}
47
48bool FontSpecification::operator<(const FontSpecification &other) const noexcept {
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;
62}
63
66}
67
69 ascent = 1;
70 descent = 1;
71 capitalHeight = 1;
72 aveCharWidth = 1;
73 spaceWidth = 1;
74 sizeZoomed = 2;
75}
76
78 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
80 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
81}
82
83Style::Style(const Style &source) noexcept : FontSpecification(), FontMeasurements() {
84 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
85 0, nullptr, 0,
86 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
87 fore = source.fore;
88 back = source.back;
89 characterSet = source.characterSet;
90 weight = source.weight;
91 italic = source.italic;
92 size = source.size;
93 fontName = source.fontName;
94 eolFilled = source.eolFilled;
95 underline = source.underline;
96 caseForce = source.caseForce;
97 visible = source.visible;
98 changeable = source.changeable;
99 hotspot = source.hotspot;
100}
101
103}
104
105Style &Style::operator=(const Style &source) noexcept {
106 if (this == &source)
107 return * this;
108 Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
109 0, nullptr, SC_CHARSET_DEFAULT,
110 SC_WEIGHT_NORMAL, false, false, false, caseMixed, true, true, false);
111 fore = source.fore;
112 back = source.back;
113 characterSet = source.characterSet;
114 weight = source.weight;
115 italic = source.italic;
116 size = source.size;
117 fontName = source.fontName;
118 eolFilled = source.eolFilled;
119 underline = source.underline;
120 caseForce = source.caseForce;
121 visible = source.visible;
122 changeable = source.changeable;
123 return *this;
124}
125
126void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
127 const char *fontName_, int characterSet_,
128 int weight_, bool italic_, bool eolFilled_,
129 bool underline_, ecaseForced caseForce_,
130 bool visible_, bool changeable_, bool hotspot_) noexcept {
131 fore = fore_;
132 back = back_;
133 characterSet = characterSet_;
134 weight = weight_;
135 italic = italic_;
136 size = size_;
137 fontName = fontName_;
138 eolFilled = eolFilled_;
139 underline = underline_;
140 caseForce = caseForce_;
141 visible = visible_;
142 changeable = changeable_;
143 hotspot = hotspot_;
144 font.ClearFont();
146}
147
148void Style::ClearTo(const Style &source) noexcept {
149 Clear(
150 source.fore,
151 source.back,
152 source.size,
153 source.fontName,
154 source.characterSet,
155 source.weight,
156 source.italic,
157 source.eolFilled,
158 source.underline,
159 source.caseForce,
160 source.visible,
161 source.changeable,
162 source.hotspot);
163}
164
165void Style::Copy(const Font &font_, const FontMeasurements &fm_) noexcept {
166 font.MakeAlias(font_);
167 (FontMeasurements &)(*this) = fm_;
168}
Interface to platform facilities.
Interface to the edit control.
#define SC_WEIGHT_NORMAL
Definition: Scintilla.h:260
#define SC_FONT_SIZE_MULTIPLIER
Definition: Scintilla.h:257
#define SC_CHARSET_DEFAULT
Definition: Scintilla.h:208
Defines the font and colour style for a class of text.
FontAlias() noexcept
Definition: Style.cxx:19
void MakeAlias(const Font &fontOrigin) noexcept
Definition: Style.cxx:31
~FontAlias() override
Definition: Style.cxx:26
void ClearFont() noexcept
Definition: Style.cxx:35
void SetID(FontID fid_) noexcept
Definition: Platform.h:332
static int DefaultFontSize()
Definition: PlatGTK.cxx:2004
void Clear(ColourDesired fore_, ColourDesired back_, int size_, const char *fontName_, int characterSet_, int weight_, bool italic_, bool eolFilled_, bool underline_, ecaseForced caseForce_, bool visible_, bool changeable_, bool hotspot_) noexcept
Definition: Style.cxx:126
void Copy(const Font &font_, const FontMeasurements &fm_) noexcept
Definition: Style.cxx:165
Style & operator=(const Style &source) noexcept
Definition: Style.cxx:105
void ClearTo(const Style &source) noexcept
Definition: Style.cxx:148
Styling buffer using one element for each run rather than using a filled buffer.
Definition: Converter.h:9
void * FontID
Definition: Platform.h:87
void ClearMeasurements() noexcept
Definition: Style.cxx:68
unsigned int ascent
Definition: Style.h:47
XYPOSITION spaceWidth
Definition: Style.h:51
unsigned int descent
Definition: Style.h:48
FontMeasurements() noexcept
Definition: Style.cxx:64
XYPOSITION aveCharWidth
Definition: Style.h:50
XYPOSITION capitalHeight
Definition: Style.h:49
bool operator==(const FontSpecification &other) const noexcept
Definition: Style.cxx:39
bool operator<(const FontSpecification &other) const noexcept
Definition: Style.cxx:48