KiCad PCB EDA Suite
Loading...
Searching...
No Matches
text_attributes.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation, either version 3 of the License, or (at your
9
* option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#include <
font/text_attributes.h
>
21
#include <
font/outline_font.h
>
22
23
24
TEXT_ATTRIBUTES::TEXT_ATTRIBUTES
(
KIFONT::FONT
* aFont ) :
25
m_Font( aFont ),
26
m_Halign(
GR_TEXT_H_ALIGN_CENTER
),
27
m_Valign(
GR_TEXT_V_ALIGN_CENTER
),
28
m_Angle(
ANGLE_0
),
29
m_LineSpacing( 1.0 ),
30
m_StrokeWidth( 0 ),
31
m_Italic( false ),
32
m_Bold( false ),
33
m_Underlined( false ),
34
m_Color(
KIGFX
::COLOR4D::
UNSPECIFIED
),
35
m_Visible( true ),
36
m_Mirrored( false ),
37
m_Multiline( true ),
38
m_KeepUpright( false )
39
{
40
}
41
42
43
int
TEXT_ATTRIBUTES::Compare
(
const
TEXT_ATTRIBUTES
& aRhs )
const
44
{
45
wxString fontName;
46
47
if
(
m_Font
)
48
fontName =
m_Font
->
GetName
();
49
50
wxString rhsFontName;
51
52
if
( aRhs.
m_Font
)
53
rhsFontName = aRhs.
m_Font
->
GetName
();
54
55
int
retv = fontName.Cmp( rhsFontName );
56
57
if
( retv )
58
return
retv;
59
60
if
(
m_Size
.
x
!= aRhs.
m_Size
.
x
)
61
return
m_Size
.
x
- aRhs.
m_Size
.
x
;
62
63
if
(
m_Size
.
y
!= aRhs.
m_Size
.
y
)
64
return
m_Size
.
y
- aRhs.
m_Size
.
y
;
65
66
if
(
m_StrokeWidth
!= aRhs.
m_StrokeWidth
)
67
return
m_StrokeWidth
- aRhs.
m_StrokeWidth
;
68
69
if
(
m_Angle
.
AsDegrees
() != aRhs.
m_Angle
.
AsDegrees
() )
70
return
m_Angle
.
AsDegrees
() < aRhs.
m_Angle
.
AsDegrees
() ? -1 : 1;
71
72
if
(
m_LineSpacing
!= aRhs.
m_LineSpacing
)
73
return
m_LineSpacing
< aRhs.
m_LineSpacing
? -1 : 1;
74
75
if
(
m_Halign
!= aRhs.
m_Halign
)
76
return
m_Halign
- aRhs.
m_Halign
;
77
78
if
(
m_Valign
!= aRhs.
m_Valign
)
79
return
m_Valign
- aRhs.
m_Valign
;
80
81
if
(
m_Italic
!= aRhs.
m_Italic
)
82
return
m_Italic
- aRhs.
m_Italic
;
83
84
if
(
m_Bold
!= aRhs.
m_Bold
)
85
return
m_Bold
- aRhs.
m_Bold
;
86
87
if
(
m_Underlined
!= aRhs.
m_Underlined
)
88
return
m_Underlined
- aRhs.
m_Underlined
;
89
90
retv =
m_Color
.
Compare
( aRhs.
m_Color
);
91
92
if
( retv )
93
return
retv;
94
95
if
(
m_Visible
!= aRhs.
m_Visible
)
96
return
m_Visible
- aRhs.
m_Visible
;
97
98
if
(
m_Mirrored
!= aRhs.
m_Mirrored
)
99
return
m_Mirrored
- aRhs.
m_Mirrored
;
100
101
if
(
m_Multiline
!= aRhs.
m_Multiline
)
102
return
m_Multiline
- aRhs.
m_Multiline
;
103
104
return
m_KeepUpright
- aRhs.
m_KeepUpright
;
105
}
106
107
108
std::ostream&
operator<<
( std::ostream& aStream,
const
TEXT_ATTRIBUTES
& aAttributes )
109
{
110
aStream <<
"Font: \""
;
111
112
if
( aAttributes.
m_Font
)
113
aStream << *aAttributes.
m_Font
;
114
else
115
aStream <<
"UNDEFINED"
;
116
117
aStream <<
"\"\n"
;
118
aStream <<
"Horizontal Alignment: "
<< aAttributes.
m_Halign
<< std::endl
119
<<
"Vertical Alignment: "
<< aAttributes.
m_Valign
<< std::endl
120
<<
"Angle: "
<< aAttributes.
m_Angle
<< std::endl
121
<<
"Line Spacing: "
<< aAttributes.
m_LineSpacing
<< std::endl
122
<<
"Stroke Width: "
<< aAttributes.
m_StrokeWidth
<< std::endl
123
<<
"Italic: "
<< aAttributes.
m_Italic
<< std::endl
124
<<
"Bold: "
<< aAttributes.
m_Bold
<< std::endl
125
<<
"Underline: "
<< aAttributes.
m_Underlined
<< std::endl
126
<<
"Color: "
<< aAttributes.
m_Color
<< std::endl
127
<<
"Visible "
<< aAttributes.
m_Visible
<< std::endl
128
<<
"Mirrored "
<< aAttributes.
m_Mirrored
<< std::endl
129
<<
"Multilined: "
<< aAttributes.
m_Multiline
<< std::endl
130
<<
"Size: "
<< aAttributes.
m_Size
<< std::endl
131
<<
"Keep Upright: "
<< aAttributes.
m_KeepUpright
<< std::endl;
132
133
return
aStream;
134
}
ASCH_PORT_IOTYPE::UNSPECIFIED
@ UNSPECIFIED
EDA_ANGLE::AsDegrees
double AsDegrees() const
Definition:
eda_angle.h:113
KIFONT::FONT
FONT is an abstract base class for both outline and stroke fonts.
Definition:
font.h:131
KIFONT::FONT::GetName
const wxString & GetName() const
Definition:
font.h:149
KIGFX::COLOR4D::Compare
int Compare(const COLOR4D &aRhs) const
Definition:
color4d.cpp:588
TEXT_ATTRIBUTES
Definition:
text_attributes.h:121
TEXT_ATTRIBUTES::m_LineSpacing
double m_LineSpacing
Definition:
text_attributes.h:135
TEXT_ATTRIBUTES::m_Visible
bool m_Visible
Definition:
text_attributes.h:141
TEXT_ATTRIBUTES::m_StrokeWidth
int m_StrokeWidth
Definition:
text_attributes.h:136
TEXT_ATTRIBUTES::m_KeepUpright
bool m_KeepUpright
Definition:
text_attributes.h:147
TEXT_ATTRIBUTES::m_Italic
bool m_Italic
Definition:
text_attributes.h:137
TEXT_ATTRIBUTES::m_Color
KIGFX::COLOR4D m_Color
Definition:
text_attributes.h:140
TEXT_ATTRIBUTES::m_Bold
bool m_Bold
Definition:
text_attributes.h:138
TEXT_ATTRIBUTES::m_Underlined
bool m_Underlined
Definition:
text_attributes.h:139
TEXT_ATTRIBUTES::TEXT_ATTRIBUTES
TEXT_ATTRIBUTES(KIFONT::FONT *aFont=nullptr)
Definition:
text_attributes.cpp:24
TEXT_ATTRIBUTES::m_Multiline
bool m_Multiline
Definition:
text_attributes.h:143
TEXT_ATTRIBUTES::Compare
int Compare(const TEXT_ATTRIBUTES &aRhs) const
Definition:
text_attributes.cpp:43
TEXT_ATTRIBUTES::m_Halign
GR_TEXT_H_ALIGN_T m_Halign
Definition:
text_attributes.h:132
TEXT_ATTRIBUTES::m_Valign
GR_TEXT_V_ALIGN_T m_Valign
Definition:
text_attributes.h:133
TEXT_ATTRIBUTES::m_Font
KIFONT::FONT * m_Font
Definition:
text_attributes.h:131
TEXT_ATTRIBUTES::m_Angle
EDA_ANGLE m_Angle
Definition:
text_attributes.h:134
TEXT_ATTRIBUTES::m_Size
VECTOR2I m_Size
Definition:
text_attributes.h:144
TEXT_ATTRIBUTES::m_Mirrored
bool m_Mirrored
Definition:
text_attributes.h:142
VECTOR2::x
T x
Definition:
vector2d.h:79
VECTOR2::y
T y
Definition:
vector2d.h:79
ANGLE_0
static constexpr EDA_ANGLE ANGLE_0
Definition:
eda_angle.h:401
operator<<
std::ostream & operator<<(std::ostream &aStream, const EDA_TEXT &aText)
Definition:
eda_text.cpp:1195
KIGFX
The Cairo implementation of the graphics abstraction layer.
Definition:
color4d.cpp:247
outline_font.h
text_attributes.h
GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_CENTER
Definition:
text_attributes.h:45
GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_CENTER
Definition:
text_attributes.h:54
src
common
font
text_attributes.cpp
Generated on Sat Oct 12 2024 00:05:39 for KiCad PCB EDA Suite by
1.9.6