KiCad PCB EDA Suite
Loading...
Searching...
No Matches
text_attributes.h
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 Ola Rinta-Koski
5 * Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef TEXT_ATTRIBUTES_H
22#define TEXT_ATTRIBUTES_H
23
24#include <math/vector2d.h>
25#include <gal/color4d.h>
26#include "../../libs/kimath/include/geometry/eda_angle.h"
27
28
29namespace KIFONT
30{
31class FONT;
32};
33
34
35// Graphic Text alignments:
36//
37// NB: values -1,0,1 are used in computations, do not change them
38//
39
41{
45};
46
48{
52};
53
54
55#define TO_HJUSTIFY( x ) static_cast<GR_TEXT_H_ALIGN_T>( x )
56#define TO_VJUSTIFY( x ) static_cast<GR_TEXT_V_ALIGN_T>( x )
57
58
60{
61public:
62 TEXT_ATTRIBUTES( KIFONT::FONT* aFont = nullptr );
63
64 int Compare( const TEXT_ATTRIBUTES& aRhs ) const;
65
66 bool operator==( const TEXT_ATTRIBUTES& aRhs ) const { return Compare( aRhs ) == 0; }
67 bool operator>( const TEXT_ATTRIBUTES& aRhs ) const { return Compare( aRhs ) > 0; }
68 bool operator<( const TEXT_ATTRIBUTES& aRhs ) const { return Compare( aRhs ) < 0; }
69
77 bool m_Bold;
84
89};
90
91
92extern std::ostream& operator<<( std::ostream& aStream, const TEXT_ATTRIBUTES& aAttributes );
93
94
95template<>
96struct std::hash<TEXT_ATTRIBUTES>
97{
98 std::size_t operator()( const TEXT_ATTRIBUTES& aAttributes ) const
99 {
100 return hash_val( aAttributes.m_Font, aAttributes.m_Halign, aAttributes.m_Valign,
101 aAttributes.m_Angle.AsDegrees(), aAttributes.m_LineSpacing,
102 aAttributes.m_StrokeWidth, aAttributes.m_Italic, aAttributes.m_Bold,
103 aAttributes.m_Underlined, aAttributes.m_Color, aAttributes.m_Visible,
104 aAttributes.m_Mirrored, aAttributes.m_Multiline, aAttributes.m_Size.x,
105 aAttributes.m_Size.y );
106 }
107};
108
109#endif //TEXT_ATTRIBUTES_H
double AsDegrees() const
Definition: eda_angle.h:149
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103
bool m_KeepUpright
If true, keep rotation angle between -90...90 degrees for readability.
KIGFX::COLOR4D m_Color
int Compare(const TEXT_ATTRIBUTES &aRhs) const
bool operator==(const TEXT_ATTRIBUTES &aRhs) const
GR_TEXT_H_ALIGN_T m_Halign
bool operator<(const TEXT_ATTRIBUTES &aRhs) const
bool operator>(const TEXT_ATTRIBUTES &aRhs) const
GR_TEXT_V_ALIGN_T m_Valign
KIFONT::FONT * m_Font
static std::size_t hash_val(const Types &... args)
Definition: hash.h:51
Definition: font.h:100
std::size_t operator()(const TEXT_ATTRIBUTES &aAttributes) const
GR_TEXT_H_ALIGN_T
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
std::ostream & operator<<(std::ostream &aStream, const TEXT_ATTRIBUTES &aAttributes)
GR_TEXT_V_ALIGN_T
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP