You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.4 KiB

  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-2022 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. #ifndef TEXT_ATTRIBUTES_H
  21. #define TEXT_ATTRIBUTES_H
  22. #include <iostream>
  23. #include <wx/log.h>
  24. #include <cmath>
  25. #include <math/vector2d.h>
  26. #include <gal/color4d.h>
  27. #include "../../libs/kimath/include/geometry/eda_angle.h"
  28. class EDA_TEXT;
  29. namespace KIFONT
  30. {
  31. class FONT;
  32. };
  33. // Graphic Text alignments:
  34. //
  35. // NB: values -1,0,1 are used in computations, do not change them
  36. //
  37. enum GR_TEXT_H_ALIGN_T
  38. {
  39. GR_TEXT_H_ALIGN_LEFT = -1,
  40. GR_TEXT_H_ALIGN_CENTER = 0,
  41. GR_TEXT_H_ALIGN_RIGHT = 1
  42. };
  43. enum GR_TEXT_V_ALIGN_T
  44. {
  45. GR_TEXT_V_ALIGN_TOP = -1,
  46. GR_TEXT_V_ALIGN_CENTER = 0,
  47. GR_TEXT_V_ALIGN_BOTTOM = 1
  48. };
  49. #define TO_HJUSTIFY( x ) static_cast<GR_TEXT_H_ALIGN_T>( x )
  50. #define TO_VJUSTIFY( x ) static_cast<GR_TEXT_V_ALIGN_T>( x )
  51. class TEXT_ATTRIBUTES
  52. {
  53. public:
  54. KIFONT::FONT* m_Font = nullptr;
  55. GR_TEXT_H_ALIGN_T m_Halign = GR_TEXT_H_ALIGN_CENTER;
  56. GR_TEXT_V_ALIGN_T m_Valign = GR_TEXT_V_ALIGN_CENTER;
  57. EDA_ANGLE m_Angle = ANGLE_0;
  58. double m_LineSpacing = 1.0;
  59. int m_StrokeWidth = 0;
  60. bool m_Italic = false;
  61. bool m_Bold = false;
  62. bool m_Underlined = false;
  63. KIGFX::COLOR4D m_Color = KIGFX::COLOR4D::UNSPECIFIED;
  64. bool m_Visible = true;
  65. bool m_Mirrored = false;
  66. bool m_Multiline = true;
  67. VECTOR2I m_Size;
  68. /**
  69. * If true, keep rotation angle between -90...90 degrees for readability
  70. */
  71. bool m_KeepUpright = false;
  72. };
  73. #endif //TEXT_ATTRIBUTES_H