MuseScore/libmscore/symbol.h

94 lines
2.6 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 __SYMBOL_H__
#define __SYMBOL_H__
#include "bsymbol.h"
class QPainter;
2013-05-13 18:49:17 +02:00
namespace Ms {
class Segment;
class ScoreFont;
enum class SymId;
2013-05-13 18:49:17 +02:00
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ Symbol
/// Symbol constructed from builtin symbol.
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
class Symbol : public BSymbol {
Q_OBJECT
2012-05-26 14:26:10 +02:00
protected:
SymId _sym;
const ScoreFont* _scoreFont = nullptr;
2012-05-26 14:26:10 +02:00
public:
Symbol(Score* s);
Symbol(const Symbol&);
Symbol &operator=(const Symbol&);
virtual Symbol* clone() const { return new Symbol(*this); }
virtual Element::Type type() const { return Element::Type::SYMBOL; }
2012-05-26 14:26:10 +02:00
void setSym(SymId s, const ScoreFont* sf = nullptr) { _sym = s; _scoreFont = sf; }
SymId sym() const { return _sym; }
2012-05-26 14:26:10 +02:00
virtual void draw(QPainter*) const override;
virtual void write(Xml& xml) const override;
virtual void read(XmlReader&) override;
virtual void layout() override;
2012-05-26 14:26:10 +02:00
void setAbove(bool);
virtual qreal baseLine() const { return 0.0; }
Segment* segment() const { return (Segment*)parent(); }
2012-05-26 14:26:10 +02:00
};
//---------------------------------------------------------
2012-07-25 11:49:34 +02:00
// @@ FSymbol
/// Symbol constructed from a font glyph.
2012-05-26 14:26:10 +02:00
//---------------------------------------------------------
2013-01-23 14:14:09 +01:00
class FSymbol : public BSymbol {
Q_OBJECT
2012-05-26 14:26:10 +02:00
QFont _font;
int _code;
public:
FSymbol(Score* s);
FSymbol(const FSymbol&);
virtual FSymbol* clone() const { return new FSymbol(*this); }
virtual Element::Type type() const { return Element::Type::FSYMBOL; }
2012-05-26 14:26:10 +02:00
virtual void draw(QPainter*) const;
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
virtual void layout();
virtual qreal baseLine() const { return 0.0; }
Segment* segment() const { return (Segment*)parent(); }
QFont font() const { return _font; }
int code() const { return _code; }
2012-05-26 14:26:10 +02:00
void setFont(const QFont& f);
void setCode(int val) { _code = val; }
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