13 #ifndef __TEXTBASE_H__ 14 #define __TEXTBASE_H__ 66 bool _preedit {
false };
68 qreal _fontSize { 12.0 };
90 void setFontSize(qreal val) { Q_ASSERT(val > 0.0); _fontSize = val; }
107 int _selectLine { 0 };
108 int _selectColumn { 0 };
114 bool hasSelection()
const {
return (_selectLine != _row) || (_selectColumn != _column); }
115 void clearSelection();
121 int row()
const {
return _row; }
133 QRectF cursorRect()
const;
134 bool movePosition(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor,
int count = 1);
135 void doubleClickSelect();
138 QChar currentCharacter()
const;
139 bool set(
const QPointF& p, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
140 QString selectedText()
const;
141 void updateCursorFormat();
143 void changeSelectionFormat(
FormatId id, QVariant val);
164 void draw(QPainter*,
const TextBase*)
const;
167 void changeFormat(
FormatId id, QVariant data);
188 void draw(QPainter*,
const TextBase*)
const;
190 const QList<TextFragment>&
fragments()
const {
return _fragments; }
193 QRectF boundingRect(
int col1,
int col2,
const TextBase*)
const;
196 QString
remove(
int column);
197 QString
remove(
int start,
int n);
198 int column(qreal x,
TextBase*)
const;
200 qreal xpos(
int col,
const TextBase*)
const;
203 QList<TextFragment>::iterator fragment(
int column,
int* rcol,
int* ridx);
204 qreal
y()
const {
return _y; }
205 void setY(qreal val) { _y = val; }
207 QString text(
int,
int)
const;
208 bool eol()
const {
return _eol; }
210 void changeFormat(
FormatId, QVariant val,
int start,
int n);
233 mutable QString _text;
234 mutable
bool textInvalid {
true };
237 bool layoutInvalid {
true };
241 bool _layoutToParentWidth {
false };
246 void drawSelection(QPainter*,
const QRectF&)
const;
248 void genText()
const;
249 virtual int getPropertyFlagsIdx(
Pid id)
const override;
250 QString stripText(
bool,
bool,
bool)
const;
253 QColor textColor()
const;
265 virtual bool mousePress(
EditData&)
override;
267 Text &operator=(
const Text&) =
delete;
269 virtual void draw(QPainter*)
const override;
270 virtual void drawEditMode(QPainter* p,
EditData& ed)
override;
272 void setPlainText(
const QString&);
273 void setXmlText(
const QString&);
274 QString xmlText()
const;
275 QString plainText()
const;
277 void insertText(
EditData&,
const QString&);
279 virtual void layout()
override;
280 virtual void layout1();
281 qreal lineSpacing()
const;
282 qreal lineHeight()
const;
283 virtual qreal baseLine()
const override;
285 bool empty()
const {
return xmlText().isEmpty(); }
286 void clear() { setXmlText(QString()); }
291 virtual void startEdit(
EditData&)
override;
292 virtual bool edit(
EditData&)
override;
293 virtual void editCut(
EditData&)
override;
294 virtual void editCopy(
EditData&)
override;
295 virtual void endEdit(
EditData&)
override;
296 void movePosition(
EditData&, QTextCursor::MoveOperation);
305 virtual void write(
XmlWriter& xml)
const override;
309 void writeProperties(
XmlWriter&,
bool,
bool)
const;
314 QRectF pageRectangle()
const;
318 virtual QLineF dragAnchor()
const override;
320 virtual bool acceptDrop(
EditData&)
const override;
326 static QString convertToHtml(
const QString&,
const TextStyle&);
327 static QString tagEscape(QString s);
328 static QString unEscape(QString s);
329 static QString escape(QString s);
331 virtual QString accessibleInfo()
const override;
332 virtual QString screenReaderInfo()
const override;
334 virtual int subtype()
const override;
335 virtual QString subtypeName()
const override;
337 QList<TextFragment> fragmentList()
const;
339 static bool validateText(QString& s);
342 void inputTransition(
EditData&, QInputMethodEvent*);
345 QFontMetricsF fontMetrics()
const;
348 virtual bool setProperty(
Pid propertyId,
const QVariant& v)
override;
349 virtual QVariant propertyDefault(
Pid id)
const override;
350 virtual void undoChangeProperty(
Pid id,
const QVariant& v,
PropertyFlags ps)
override;
351 virtual Pid propertyId(
const QStringRef& xmlName)
const override;
352 virtual Sid getPropertyStyle(
Pid)
const;
353 virtual void styleChanged();
354 void editInsertText(
TextCursor*,
const QString&);
360 int rows()
const {
return _layout.size(); }
374 void initTid(
Tid id);
375 void initTid(
Tid id,
bool preserveDifferent);
376 virtual void initElementStyle(
const ElementStyle*)
override;
385 bool hasCustomFormatting()
const;
bool circle() const
Definition: textbase.h:369
TextBlock & textBlock(int line)
Definition: textbase.h:358
void setLayoutInvalid()
Definition: textbase.h:364
void setTid(Tid id)
Definition: textbase.h:373
int row() const
Definition: textbase.h:121
QList< TextFragment > _fragments
Definition: textbase.h:176
Pid
Definition: property.h:62
Definition: textbase.h:151
virtual void undoChangeProperty(Pid id, const QVariant &, PropertyFlags ps)
Definition: scoreElement.cpp:291
void setItalic(bool val)
Definition: textbase.h:382
void writeProperties(XmlWriter &xml, bool writeText) const
Definition: textbase.h:308
TextBlock()
Definition: textbase.h:185
QRectF frame
Definition: textbase.h:254
qreal _lineSpacing
Definition: textbase.h:178
QFlags< ElementFlag > ElementFlags
Definition: element.h:101
FormatId
Definition: textbase.h:48
bool bold() const
Definition: textbase.h:378
Definition: textbase.h:102
QList< TextBlock > _layout
Definition: textbase.h:236
std::vector< StyledProperty > ElementStyle
Definition: style.h:1339
bool inHexState() const
Definition: textbase.h:340
void setUnderline(bool val)
Definition: textbase.h:383
SymId
Definition: sym.h:30
Base class of score layout elements.
Definition: element.h:158
bool isLayoutInvalid() const
Definition: textbase.h:365
FontStyle
Definition: types.h:468
QString convertFromHtml(TextBase *t, const QString &ss)
Definition: read114.cpp:240
QString text
Definition: textbase.h:156
QString preEdit
Definition: textbase.h:240
bool isTextInvalid() const
Definition: textbase.h:363
qreal lineSpacing() const
Definition: textbase.h:206
TextBase * text() const
Definition: textbase.h:113
bool hasSelection() const
Definition: textbase.h:114
std::array< StyledProperty, TEXT_STYLE_SIZE > TextStyle
Definition: style.h:1343
void moveCursorToEnd()
Definition: textbase.h:136
int rows() const
Definition: textbase.h:360
PropertyFlags
Definition: property.h:54
const CharFormat * format() const
Definition: textbase.h:118
bool italic() const
Definition: textbase.h:379
void setBold(bool val)
Definition: textbase.h:381
TextBase * _text
Definition: textbase.h:103
Definition: textbase.h:175
FrameType
Definition: textbase.h:32
bool isPrimed() const
Definition: textbase.h:302
Tid
Enumerates the list of built-in text substyles.
Definition: types.h:371
const QList< TextFragment > & fragments() const
Definition: textbase.h:190
#define M_PROPERTY(a, b, c)
Definition: property.h:36
bool underline() const
Definition: textbase.h:380
QList< TextBlock > & textBlockList()
Definition: textbase.h:359
VerticalAlignment
Definition: textbase.h:40
Definition: textbase.h:217
Definition: aeolus.cpp:26
const QRectF & boundingRect() const
Definition: textbase.h:192
Sid
Definition: style.h:33
void setFormat(const CharFormat &f)
Definition: textbase.h:119
bool square() const
Definition: textbase.h:370
QPointF pos
Definition: textbase.h:155
int column() const
Definition: textbase.h:122
void setTextInvalid()
Definition: textbase.h:362
void setLayoutToParentWidth(bool v)
Definition: textbase.h:289
void setSelectLine(int val)
Definition: textbase.h:127
MultiClick
Definition: textbase.h:56
CharFormat * format()
Definition: textbase.h:117
Definition: element.h:111
void setEol(bool val)
Definition: textbase.h:209
CharFormat _format
Definition: textbase.h:104
void setPrimed(bool primed)
Definition: textbase.h:303
const TextBlock & textBlock(int line) const
Definition: textbase.h:357
QRectF _bbox
Definition: textbase.h:179
bool layoutToParentWidth() const
Definition: textbase.h:288
Tid tid() const
Definition: textbase.h:372
QList< TextFragment > & fragments()
Definition: textbase.h:191
bool hasFrame() const
Definition: textbase.h:368
CharFormat format
Definition: textbase.h:154
int selectLine() const
Definition: textbase.h:123
Align
Definition: types.h:439
void setRow(int val)
Definition: textbase.h:125
void moveCursorToStart()
Definition: textbase.h:137
virtual void writeProperties(XmlWriter &xml) const
Definition: textbase.h:307
Pid propertyId(const QStringRef &s)
Definition: property.cpp:347
Tid _tid
Definition: textbase.h:238
bool empty() const
Definition: textbase.h:285
void setColumn(int val)
Definition: textbase.h:126
void clear()
Definition: textbase.h:286
int selectColumn() const
Definition: textbase.h:124
TextCursor(TextBase *t)
Definition: textbase.h:111
void setY(qreal val)
Definition: textbase.h:205
void setSelectColumn(int val)
Definition: textbase.h:128
qreal y() const
Definition: textbase.h:204
bool eol() const
Definition: textbase.h:208