/
text.h
147 lines (120 loc) · 4.49 KB
/
text.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//=============================================================================
// MuseScore
// Music Composition & Notation
// $Id: text.h 5500 2012-03-28 16:28:26Z wschweer $
//
// Copyright (C) 2002-2011 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#ifndef __TEXT_H__
#define __TEXT_H__
#include "elementlayout.h"
#include "simpletext.h"
class MuseScoreView;
class TextProp;
struct SymCode;
//---------------------------------------------------------
// @@ Text
// @P text QString
//---------------------------------------------------------
class Text : public SimpleText {
Q_OBJECT
Q_PROPERTY(QString text READ getText WRITE setText)
QTextDocument* _doc;
int _styleIndex;
void createDoc();
void setUnstyledText(const QString& s);
void layoutEdit();
protected:
bool _editMode;
QTextCursor* _cursor;
bool setCursor(const QPointF& p, QTextCursor::MoveMode mm = QTextCursor::MoveAnchor);
public:
Text(Score* = 0);
Text(const Text&);
~Text();
Text &operator=(const Text&);
virtual Text* clone() const { return new Text(*this); }
virtual ElementType type() const { return TEXT; }
void setText(const QString& s);
void setText(const QTextDocumentFragment&);
void setHtml(const QString& s);
QString getText() const;
QString getHtml() const;
QTextDocumentFragment getFragment() const;
bool sizeIsSpatiumDependent() const;
void setSizeIsSpatiumDependent(int v);
void setFrameWidth(qreal val);
void setPaddingWidth(qreal val);
void setFrameColor(const QColor& val);
void setFrameRound(int val);
void setCircle(bool val);
void setHasFrame(bool);
qreal xoff() const;
qreal yoff() const;
Align align() const;
OffsetType offsetType() const;
QPointF reloff() const;
void setAlign(Align val);
void setXoff(qreal val);
void setYoff(qreal val);
void setOffsetType(OffsetType val);
void setRxoff(qreal v);
void setRyoff(qreal v);
void setReloff(const QPointF&);
QFont font() const;
void setFont(const QFont&);
void setItalic(bool);
void setBold(bool);
void setSize(qreal);
virtual void draw(QPainter*) const;
virtual void startEdit(MuseScoreView*, const QPointF&);
virtual bool edit(MuseScoreView*, int grip, int key, Qt::KeyboardModifiers, const QString&);
QTextCursor* startCursorEdit();
void endCursorEdit();
virtual void endEdit();
void addSymbol(const SymCode&, QTextCursor* c = 0);
void addChar(int code, QTextCursor* cur = 0);
void setBlockFormat(const QTextBlockFormat&);
virtual void write(Xml& xml) const;
virtual void read(const QDomElement&);
void writeProperties(Xml& xml, bool writeText = true) const;
bool readProperties(const QDomElement& node);
virtual void layout();
virtual QPainterPath shape() const;
virtual bool mousePress(const QPointF&, QMouseEvent* ev);
qreal lineSpacing() const;
qreal lineHeight() const;
void moveCursorToEnd();
void moveCursor(int val);
virtual QLineF dragAnchor() const;
void setAbove(bool val);
virtual qreal baseLine() const;
virtual void paste();
bool replaceSpecialChars();
virtual void spatiumChanged(qreal oldValue, qreal newValue);
void dragTo(const QPointF&p);
bool editMode() const { return _editMode; }
bool styled() const { return _styleIndex != -1; }
int textStyleType() const { return _styleIndex; }
void setTextStyleType(int);
void setUnstyled();
bool isEmpty() const;
void setModified(bool v);
void clear();
QRectF pageRectangle() const;
virtual void styleChanged();
virtual void setScore(Score* s);
friend class TextProperties;
virtual void textChanged() {}
QTextCursor* cursor() { return _cursor; }
QTextDocument* doc() const { return _doc; }
virtual bool systemFlag() const;
QVariant getProperty(P_ID propertyId) const;
bool setProperty(P_ID propertyId, const QVariant& v);
};
#endif