MuseScore/libmscore/style_p.h

135 lines
4.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 __STYLE_P_H__
#define __STYLE_P_H__
//
// private header for MStyle
//
#include "elementlayout.h"
#include "articulation.h"
#include "page.h"
#include "chordlist.h"
2012-05-26 14:26:10 +02:00
2013-05-13 18:49:17 +02:00
namespace Ms {
2012-05-26 14:26:10 +02:00
class Xml;
struct ChordDescription;
//---------------------------------------------------------
// TextStyleData
//---------------------------------------------------------
class TextStyleData : public QSharedData, public ElementLayout {
2012-05-26 14:26:10 +02:00
protected:
qreal frameWidthMM; // for compatibility with old scores
qreal paddingWidthMM;
2012-05-26 14:26:10 +02:00
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;
2012-05-26 14:26:10 +02:00
int frameRound;
QColor frameColor;
bool circle;
bool systemFlag;
QColor foregroundColor;
2014-03-13 11:55:55 +01:00
QColor backgroundColor; // only for frame
2012-05-26 14:26:10 +02:00
public:
TextStyleData(QString _name, QString _family, qreal _size,
bool _bold, bool _italic, bool _underline,
Align _align,
const QPointF& _off, OffsetType _ot,
2012-05-26 14:26:10 +02:00
bool sizeSpatiumDependent,
bool hasFrame, Spatium fw, Spatium pw, int fr,
2012-05-26 14:26:10 +02:00
QColor co, bool circle, bool systemFlag,
QColor fg, QColor bg);
2012-05-26 14:26:10 +02:00
TextStyleData();
void write(Xml&) const;
void writeProperties(Xml& xml) const;
2014-03-14 11:30:19 +01:00
void writeProperties(Xml& xml, const TextStyleData&) const;
2014-03-14 16:16:43 +01:00
void restyle(const TextStyleData& os, const TextStyleData& ns);
2013-01-11 18:10:18 +01:00
void read(XmlReader&);
bool readProperties(XmlReader& v);
2012-05-26 14:26:10 +02:00
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:
2013-08-09 11:42:24 +02:00
QVector<QVariant> _values;
ChordList _chordList;
2012-05-26 14:26:10 +02:00
QList<TextStyle> _textStyles;
PageFormat _pageFormat;
qreal _spatium;
ArticulationAnchor _articulationAnchor[int(ArticulationType::ARTICULATIONS)];
2012-05-26 14:26:10 +02:00
bool _customChordList; // if true, chordlist will be saved as part of score
2014-05-26 15:31:36 +02:00
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;
2012-05-26 14:26:10 +02:00
const TextStyle& textStyle(const QString&) const;
TextStyleType textStyleType(const QString&) const;
2012-05-26 14:26:10 +02:00
void setTextStyle(const TextStyle& ts);
public:
StyleData();
StyleData(const StyleData&);
~StyleData();
bool load(QFile* qf);
2013-01-11 18:10:18 +01:00
void load(XmlReader& e);
2012-05-26 14:26:10 +02:00
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; }
2012-05-26 14:26:10 +02:00
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; }
friend class TextStyle;
2012-05-26 14:26:10 +02:00
};
2013-05-13 18:49:17 +02:00
} // namespace Ms
2012-05-26 14:26:10 +02:00
#endif