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
|
//=============================================================================
// 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 __STYLE_P_H__
#define __STYLE_P_H__
//
// private header for MStyle
//
#include "elementlayout.h"
#include "articulation.h"
#include "page.h"
#include "chordlist.h"
namespace Ms {
class Xml;
struct ChordDescription;
//---------------------------------------------------------
// TextStyleData
//---------------------------------------------------------
class TextStyleData : public QSharedData, public ElementLayout {
protected:
qreal frameWidthMM; // for compatibility with old scores
qreal paddingWidthMM;
QString name; // style name
QString family; // font face
qreal size;
bool bold;
bool italic;
bool underline;
bool sizeIsSpatiumDependent; // text point size depends on _spatium unit
bool hasFrame;
Spatium frameWidth;
Spatium paddingWidth;
int frameRound;
QColor frameColor;
bool circle;
bool systemFlag;
QColor foregroundColor;
QColor backgroundColor; // only for frame
public:
TextStyleData(QString _name, QString _family, qreal _size,
bool _bold, bool _italic, bool _underline,
Align _align,
const QPointF& _off, OffsetType _ot,
bool sizeSpatiumDependent,
bool hasFrame, Spatium fw, Spatium pw, int fr,
QColor co, bool circle, bool systemFlag,
QColor fg, QColor bg);
TextStyleData();
void write(Xml&) const;
void writeProperties(Xml& xml) const;
void writeProperties(Xml& xml, const TextStyleData&) const;
void restyle(const TextStyleData& os, const TextStyleData& ns);
void read(XmlReader&);
bool readProperties(XmlReader& v);
QFont font(qreal space) const;
QFont fontPx(qreal spatium) const;
QRectF bbox(qreal space, const QString& s) const { return fontMetrics(space).boundingRect(s); }
QFontMetricsF fontMetrics(qreal space) const { return QFontMetricsF(font(space)); }
bool operator!=(const TextStyleData& s) const;
friend class TextStyle;
};
//---------------------------------------------------------
// StyleData
// this structure contains all style elements
//---------------------------------------------------------
class StyleData : public QSharedData {
protected:
QVector<QVariant> _values;
ChordList _chordList;
QList<TextStyle> _textStyles;
PageFormat _pageFormat;
qreal _spatium;
ArticulationAnchor _articulationAnchor[int(ArticulationType::ARTICULATIONS)];
MScore::OrnamentStyle _ornamentStyle = MScore::OrnamentStyle::DEFAULT;
bool _customChordList; // if true, chordlist will be saved as part of score
void set(StyleIdx id, const QVariant& v) { _values[int(id)] = v; }
QVariant value(StyleIdx idx) const { return _values[int(idx)]; }
const TextStyle& textStyle(TextStyleType idx) const;
const TextStyle& textStyle(const QString&) const;
TextStyleType textStyleType(const QString&) const;
void setTextStyle(const TextStyle& ts);
public:
StyleData();
StyleData(const StyleData&);
~StyleData();
bool load(QFile* qf);
void load(XmlReader& e);
void save(Xml& xml, bool optimize) const;
bool isDefault(StyleIdx) const;
const ChordDescription* chordDescription(int id) const;
ChordList* chordList();
void setChordList(ChordList*, bool custom); // Style gets ownership of ChordList
PageFormat* pageFormat() { return &_pageFormat; }
const PageFormat* pageFormat() const { return &_pageFormat; }
void setPageFormat(const PageFormat& pf);
friend class MStyle;
qreal spatium() const { return _spatium; }
void setSpatium(qreal v) { _spatium = v; }
ArticulationAnchor articulationAnchor(int id) const { return _articulationAnchor[id]; }
void setArticulationAnchor(int id, ArticulationAnchor val) { _articulationAnchor[id] = val; }
MScore::OrnamentStyle ornamentStyle() { return _ornamentStyle ; }
void setOrnamentStyle(MScore::OrnamentStyle val) { _ornamentStyle = val; }
friend class TextStyle;
};
} // namespace Ms
#endif
|