Seamly2D
Code documentation
vtextmanager.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vpatternpiecedata.cpp
4  ** @author Bojan Kverh
5  ** @date July 19, 2016
6  **
7  ** @brief
8  ** @copyright
9  ** This source code is part of the Valentine project, a pattern making
10  ** program, whose allow create and modeling patterns of clothing.
11  ** Copyright (C) 2013-2015 Seamly2D project
12  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
13  **
14  ** Seamly2D is free software: you can redistribute it and/or modify
15  ** it under the terms of the GNU General Public License as published by
16  ** the Free Software Foundation, either version 3 of the License, or
17  ** (at your option) any later version.
18  **
19  ** Seamly2D is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  ** GNU General Public License for more details.
23  **
24  ** You should have received a copy of the GNU General Public License
25  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #ifndef VTEXTMANAGER_H
30 #define VTEXTMANAGER_H
31 
32 #include <QDate>
33 #include <QFont>
34 #include <QList>
35 #include <QString>
36 #include <QStringList>
37 #include <Qt>
38 #include <QtGlobal>
39 #include <QCoreApplication>
40 
41 class VPieceLabelData;
42 class VAbstractPattern;
43 
44 #define MIN_FONT_SIZE 5
45 #define MAX_FONT_SIZE 128
46 
47 /**
48  * @brief The TextLine struct holds the information about one text line
49  */
50 struct TextLine
51 {
52  QString m_text;
53  int m_iFontSize; // 0 means default
54  bool bold;
55  bool italic;
56  Qt::Alignment m_eAlign;
57 
58  TextLine();
59 };
60 
61 /**
62  * @brief The VTextManager class this class is used to determine whether a collection of
63  * text lines can fit into specified bounding box and with what font size
64  */
66 {
67  Q_DECLARE_TR_FUNCTIONS(VTextManager)
68 public:
69  VTextManager();
70  virtual ~VTextManager() = default;
71 
72  VTextManager(const VTextManager &text);
73  VTextManager &operator=(const VTextManager &text);
74 
75  virtual int GetSpacing() const;
76 
77  void setFont(const QFont& font);
78  const QFont& GetFont() const;
79  void SetFontSize(int iFS);
80  void FitFontSize(qreal fW, qreal fH);
81 
83  int GetSourceLinesCount() const;
84  const TextLine& GetSourceLine(int i) const;
85 
86  void Update(const QString& qsName, const VPieceLabelData& data);
87  void Update(VAbstractPattern* pDoc);
88 
89 private:
90  QFont m_font;
92 
94 };
95 
96 #endif // VTEXTMANAGER_H
The VPieceLabelData class holds some information about a single piece like letter,...
The VTextManager class this class is used to determine whether a collection of text lines can fit int...
Definition: vtextmanager.h:66
VTextManager & operator=(const VTextManager &text)
int GetSourceLinesCount() const
VTextManager::GetSourceLinesCount returns the number of input text lines.
virtual int GetSpacing() const
GetSpacing returns the vertical spacing between the lines.
VTextManager()
VTextManager::VTextManager constructor.
const QFont & GetFont() const
GetFont returns the text base font.
const TextLine & GetSourceLine(int i) const
VTextManager::GetSourceLine returns the reference to i-th text line.
QList< TextLine > GetAllSourceLines() const
void Update(const QString &qsName, const VPieceLabelData &data)
VTextManager::Update updates the text lines with detail data.
virtual ~VTextManager()=default
QList< TextLine > m_liLines
Definition: vtextmanager.h:91
static QList< TextLine > m_patternLabelLines
Definition: vtextmanager.h:93
void setFont(const QFont &font)
SetFont set the text base font.
void FitFontSize(qreal fW, qreal fH)
VTextManager::FitFontSize sets the font size just big enough, so that the text fits into rectangle of...
void SetFontSize(int iFS)
SetFontSize sets the font size.
The TextLine struct holds the information about one text line.
Definition: vtextmanager.h:51
QString m_text
Definition: vtextmanager.h:52
TextLine()
TextLine::TextLine default constructor.
bool bold
Definition: vtextmanager.h:54
int m_iFontSize
Definition: vtextmanager.h:53
Qt::Alignment m_eAlign
Definition: vtextmanager.h:56
bool italic
Definition: vtextmanager.h:55