2021-12-28 22:13:54 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2021 Ola Rinta-Koski
|
2023-03-29 16:53:28 +00:00
|
|
|
* Copyright (C) 2021-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-12-28 22:13:54 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TEXT_ATTRIBUTES_H
|
|
|
|
#define TEXT_ATTRIBUTES_H
|
|
|
|
|
|
|
|
#include <math/vector2d.h>
|
2022-03-31 18:43:08 +00:00
|
|
|
#include <gal/color4d.h>
|
2023-08-06 19:20:53 +00:00
|
|
|
#include <geometry/eda_angle.h>
|
2021-12-28 22:13:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace KIFONT
|
|
|
|
{
|
|
|
|
class FONT;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Graphic Text alignments:
|
|
|
|
//
|
|
|
|
// NB: values -1,0,1 are used in computations, do not change them
|
|
|
|
//
|
|
|
|
|
|
|
|
enum GR_TEXT_H_ALIGN_T
|
|
|
|
{
|
|
|
|
GR_TEXT_H_ALIGN_LEFT = -1,
|
|
|
|
GR_TEXT_H_ALIGN_CENTER = 0,
|
|
|
|
GR_TEXT_H_ALIGN_RIGHT = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GR_TEXT_V_ALIGN_T
|
|
|
|
{
|
|
|
|
GR_TEXT_V_ALIGN_TOP = -1,
|
|
|
|
GR_TEXT_V_ALIGN_CENTER = 0,
|
|
|
|
GR_TEXT_V_ALIGN_BOTTOM = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define TO_HJUSTIFY( x ) static_cast<GR_TEXT_H_ALIGN_T>( x )
|
|
|
|
#define TO_VJUSTIFY( x ) static_cast<GR_TEXT_V_ALIGN_T>( x )
|
|
|
|
|
|
|
|
|
|
|
|
class TEXT_ATTRIBUTES
|
|
|
|
{
|
|
|
|
public:
|
2023-03-29 16:53:28 +00:00
|
|
|
TEXT_ATTRIBUTES( KIFONT::FONT* aFont = nullptr );
|
|
|
|
|
|
|
|
int Compare( const TEXT_ATTRIBUTES& aRhs ) const;
|
|
|
|
|
|
|
|
bool operator==( const TEXT_ATTRIBUTES& aRhs ) const { return Compare( aRhs ) == 0; }
|
|
|
|
bool operator>( const TEXT_ATTRIBUTES& aRhs ) const { return Compare( aRhs ) > 0; }
|
|
|
|
bool operator<( const TEXT_ATTRIBUTES& aRhs ) const { return Compare( aRhs ) < 0; }
|
|
|
|
|
|
|
|
KIFONT::FONT* m_Font;
|
|
|
|
GR_TEXT_H_ALIGN_T m_Halign;
|
|
|
|
GR_TEXT_V_ALIGN_T m_Valign;
|
|
|
|
EDA_ANGLE m_Angle;
|
|
|
|
double m_LineSpacing;
|
|
|
|
int m_StrokeWidth;
|
|
|
|
bool m_Italic;
|
|
|
|
bool m_Bold;
|
|
|
|
bool m_Underlined;
|
|
|
|
KIGFX::COLOR4D m_Color;
|
|
|
|
bool m_Visible;
|
|
|
|
bool m_Mirrored;
|
|
|
|
bool m_Multiline;
|
2022-05-14 12:12:03 +00:00
|
|
|
VECTOR2I m_Size;
|
2021-12-28 22:13:54 +00:00
|
|
|
|
2023-08-06 19:20:53 +00:00
|
|
|
// If true, keep rotation angle between -90...90 degrees for readability
|
2023-03-29 16:53:28 +00:00
|
|
|
bool m_KeepUpright;
|
2021-12-28 22:13:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-03-29 16:53:28 +00:00
|
|
|
extern std::ostream& operator<<( std::ostream& aStream, const TEXT_ATTRIBUTES& aAttributes );
|
|
|
|
|
|
|
|
|
2023-04-04 19:28:34 +00:00
|
|
|
template<>
|
|
|
|
struct std::hash<TEXT_ATTRIBUTES>
|
|
|
|
{
|
|
|
|
std::size_t operator()( const TEXT_ATTRIBUTES& aAttributes ) const
|
|
|
|
{
|
2023-04-06 12:48:02 +00:00
|
|
|
return hash_val( aAttributes.m_Font, aAttributes.m_Halign, aAttributes.m_Valign,
|
|
|
|
aAttributes.m_Angle.AsDegrees(), aAttributes.m_LineSpacing,
|
|
|
|
aAttributes.m_StrokeWidth, aAttributes.m_Italic, aAttributes.m_Bold,
|
|
|
|
aAttributes.m_Underlined, aAttributes.m_Color, aAttributes.m_Visible,
|
|
|
|
aAttributes.m_Mirrored, aAttributes.m_Multiline, aAttributes.m_Size.x,
|
|
|
|
aAttributes.m_Size.y );
|
2023-04-04 19:28:34 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-12-28 22:13:54 +00:00
|
|
|
#endif //TEXT_ATTRIBUTES_H
|