QtBase  v6.3.1
qtextoption.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QTEXTOPTION_H
41 #define QTEXTOPTION_H
42 
43 #include <QtGui/qtguiglobal.h>
44 #include <QtCore/qnamespace.h>
45 #include <QtCore/qchar.h>
46 #include <QtCore/qmetatype.h>
47 
48 
50 
51 struct QTextOptionPrivate;
52 
53 class Q_GUI_EXPORT QTextOption
54 {
55 public:
56  enum TabType {
60  DelimiterTab
61  };
62 
63  struct Q_GUI_EXPORT Tab {
64  inline Tab() : position(80), type(QTextOption::LeftTab) { }
65  inline Tab(qreal pos, TabType tabType, QChar delim = QChar())
66  : position(pos), type(tabType), delimiter(delim) {}
67 
68  inline bool operator==(const Tab &other) const {
69  return type == other.type
70  && qFuzzyCompare(position, other.position)
71  && delimiter == other.delimiter;
72  }
73 
74  inline bool operator!=(const Tab &other) const {
75  return !operator==(other);
76  }
77 
81  };
82 
83  QTextOption();
85  ~QTextOption();
86 
87  QTextOption(const QTextOption &o);
88  QTextOption &operator=(const QTextOption &o);
89 
91  inline Qt::Alignment alignment() const { return Qt::Alignment(align); }
92 
93  inline void setTextDirection(Qt::LayoutDirection aDirection) { this->direction = aDirection; }
95 
96  enum WrapMode {
101  WrapAtWordBoundaryOrAnywhere
102  };
103  inline void setWrapMode(WrapMode wrap) { wordWrap = wrap; }
104  inline WrapMode wrapMode() const { return static_cast<WrapMode>(wordWrap); }
105 
106  enum Flag {
107  ShowTabsAndSpaces = 0x1,
108  ShowLineAndParagraphSeparators = 0x2,
109  AddSpaceForLineAndParagraphSeparators = 0x4,
110  SuppressColors = 0x8,
111  ShowDocumentTerminator = 0x10,
112  IncludeTrailingSpaces = 0x80000000
113  };
114  Q_DECLARE_FLAGS(Flags, Flag)
115  inline void setFlags(Flags flags);
116  inline Flags flags() const { return Flags(f); }
117 
118  inline void setTabStopDistance(qreal tabStopDistance);
119  inline qreal tabStopDistance() const { return tab; }
120 
121  void setTabArray(const QList<qreal> &tabStops);
122  QList<qreal> tabArray() const;
123 
124  void setTabs(const QList<Tab> &tabStops);
125  QList<Tab> tabs() const;
126 
127  void setUseDesignMetrics(bool b) { design = b; }
128  bool useDesignMetrics() const { return design; }
129 
130 private:
131  uint align : 9;
132  uint wordWrap : 4;
133  uint design : 1;
134  uint direction : 2;
135  uint unused : 16;
136  uint f;
137  qreal tab;
139 };
140 
142 
144 { align = aalignment; }
145 
146 inline void QTextOption::setFlags(Flags aflags)
147 { f = aflags; }
148 
150 { tab = atabStop; }
151 
153 
154 QT_DECL_METATYPE_EXTERN_TAGGED(QTextOption::Tab, QTextOption_Tab, Q_GUI_EXPORT)
155 
156 #endif // QTEXTOPTION_H
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:84
The QTextOption class provides a description of general rich text properties. \inmodule QtGui.
Definition: qtextoption.h:54
void setFlags(Flags flags)
Definition: qtextoption.h:146
void setTextDirection(Qt::LayoutDirection aDirection)
Definition: qtextoption.h:93
WrapMode wrapMode() const
Definition: qtextoption.h:104
Qt::Alignment alignment() const
Definition: qtextoption.h:91
qreal tabStopDistance() const
Definition: qtextoption.h:119
Qt::LayoutDirection textDirection() const
Definition: qtextoption.h:94
void setWrapMode(WrapMode wrap)
Definition: qtextoption.h:103
void setUseDesignMetrics(bool b)
Definition: qtextoption.h:127
Flags flags() const
Definition: qtextoption.h:116
bool useDesignMetrics() const
Definition: qtextoption.h:128
void setTabStopDistance(qreal tabStopDistance)
Definition: qtextoption.h:149
uint alignment
direction
union Alignment_ Alignment
#define inline
Definition: md4c.c:45
QHighDpiScaling::Point position(T, QHighDpiScaling::Point::Kind)
Definition: qnamespace.h:55
LayoutDirection
Definition: qnamespace.h:1462
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition: qflags.h:210
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition: qflags.h:227
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition: qfloat16.h:233
Flags
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
unsigned int uint
Definition: qglobal.h:334
bool operator==(const QMakeBaseKey &one, const QMakeBaseKey &two)
#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
Definition: qmetatype.h:1273
GLenum type
Definition: qopengl.h:270
GLboolean GLboolean GLboolean b
GLfloat GLfloat f
GLbitfield flags
label setAlignment(Qt::AlignLeft|Qt::AlignTop)
[0]
QSharedPointer< T > other(t)
[5]
Tab(qreal pos, TabType tabType, QChar delim=QChar())
Definition: qtextoption.h:65
bool operator!=(const Tab &other) const
Definition: qtextoption.h:74
bool operator==(const Tab &other) const
Definition: qtextoption.h:68