MuseScore/libmscore/text.h

170 lines
5 KiB
C
Raw Normal View History

2012-05-26 14:26:10 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// 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"
#include "mscore.h"
2012-05-26 14:26:10 +02:00
class MuseScoreView;
class TextProp;
struct SymCode;
//---------------------------------------------------------
2012-12-04 15:51:06 +01:00
// @@ MText
2012-07-12 11:36:01 +02:00
// @P text QString
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Text : public SimpleText {
Q_OBJECT
2013-02-26 15:50:36 +01:00
Q_PROPERTY(QString text READ text WRITE undoSetText)
2012-05-26 14:26:10 +02:00
QTextDocument* _doc;
int _styleIndex; // set to TEXT_STYLE_UNSTYLED if not styled
2013-02-18 14:47:16 +01:00
static QTextCursor* _cursor;
2012-05-26 14:26:10 +02:00
void createDoc();
void setUnstyledText(const QString& s);
void layoutEdit();
2012-10-24 14:31:04 +02:00
bool isSimpleText() const;
2012-05-26 14:26:10 +02:00
protected:
bool setCursor(const QPointF& p, QTextCursor::MoveMode mm = QTextCursor::MoveAnchor);
public:
Text(Score* = 0);
2012-05-26 14:26:10 +02:00
Text(const Text&);
~Text();
2013-02-14 16:27:36 +01:00
virtual void draw(QPainter*) const;
2012-05-26 14:26:10 +02:00
Text &operator=(const Text&);
virtual Text* clone() const { return new Text(*this); }
virtual ElementType type() const { return TEXT; }
2013-02-26 15:50:36 +01:00
void setText(const QString&);
void undoSetText(const QString&);
2012-05-26 14:26:10 +02:00
void setText(const QTextDocumentFragment&);
void setHtml(const QString& s);
2013-02-26 15:50:36 +01:00
QString text() const;
2012-05-26 14:26:10 +02:00
QString getHtml() const;
QTextDocumentFragment getFragment() const;
bool sizeIsSpatiumDependent() const;
void setSizeIsSpatiumDependent(int v);
void setFrameWidth(Spatium val);
void setPaddingWidth(Spatium val);
2012-05-26 14:26:10 +02:00
void setFrameColor(const QColor& val);
void setFrameRound(int val);
void setCircle(bool val);
void setHasFrame(bool);
qreal xoff() const;
qreal yoff() 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 startEdit(MuseScoreView*, const QPointF&);
virtual bool edit(MuseScoreView*, int grip, int key, Qt::KeyboardModifiers, const QString&);
QTextCursor* startCursorEdit();
void endCursorEdit();
virtual void endEdit();
void addChar(int code);
2012-05-26 14:26:10 +02:00
void setBlockFormat(const QTextBlockFormat&);
virtual void write(Xml& xml) const;
2013-01-11 18:10:18 +01:00
virtual void read(XmlReader&);
2012-05-26 14:26:10 +02:00
void writeProperties(Xml& xml, bool writeText = true) const;
2013-01-11 18:10:18 +01:00
bool readProperties(XmlReader& node);
2012-05-26 14:26:10 +02:00
virtual void layout();
2012-10-26 20:44:13 +02:00
void layout1();
2012-05-26 14:26:10 +02:00
virtual QPainterPath shape() const;
virtual bool mousePress(const QPointF&, QMouseEvent* ev);
qreal lineSpacing() const;
qreal lineHeight() const;
2013-02-14 16:27:36 +01:00
void moveCursorToStart();
2012-05-26 14:26:10 +02:00
void moveCursorToEnd();
virtual QLineF dragAnchor() const;
void setAbove(bool val);
virtual qreal baseLine() const;
virtual void paste();
void replaceSpecialChars();
2012-05-26 14:26:10 +02:00
virtual void spatiumChanged(qreal oldValue, qreal newValue);
void dragTo(const QPointF&p);
bool styled() const { return _styleIndex != TEXT_STYLE_UNSTYLED; }
2012-05-26 14:26:10 +02:00
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;
void spellCheckUnderline(bool);
void insertText(const QString& s);
void undo();
void redo();
QString selection() const;
QFont curFont() const;
bool curItalic() const;
bool curBold() const;
bool curUnderline() const;
bool curSubscript() const;
bool curSuperscript() const;
void setCurFontPointSize(double value);
void setCurFontFamily(const QString& s);
void setCurUnderline(bool val);
void setCurItalic(bool val);
void setCurBold(bool val);
void setCurSuperscript(bool val);
void setCurSubscript(bool val);
void setCurHalign(int val);
void orderedList();
void unorderedList();
void indentLess();
void indentMore();
2012-05-26 14:26:10 +02:00
virtual bool systemFlag() const;
2013-04-10 12:08:29 +02:00
virtual void textChanged() {}
2012-05-26 14:26:10 +02:00
QVariant getProperty(P_ID propertyId) const;
bool setProperty(P_ID propertyId, const QVariant& v);
};
#endif