00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _TEXT_LAYER_H_
00017 #define _TEXT_LAYER_H_
00018
00019 #include "SingleColourLayer.h"
00020 #include "data/model/TextModel.h"
00021
00022 #include <QObject>
00023 #include <QColor>
00024
00025 class View;
00026 class QPainter;
00027
00028 class TextLayer : public SingleColourLayer
00029 {
00030 Q_OBJECT
00031
00032 public:
00033 TextLayer();
00034
00035 virtual void paint(View *v, QPainter &paint, QRect rect) const;
00036
00037 virtual QString getFeatureDescription(View *v, QPoint &) const;
00038
00039 virtual bool snapToFeatureFrame(View *v, int &frame,
00040 size_t &resolution,
00041 SnapType snap) const;
00042
00043 virtual void drawStart(View *v, QMouseEvent *);
00044 virtual void drawDrag(View *v, QMouseEvent *);
00045 virtual void drawEnd(View *v, QMouseEvent *);
00046
00047 virtual void eraseStart(View *v, QMouseEvent *);
00048 virtual void eraseDrag(View *v, QMouseEvent *);
00049 virtual void eraseEnd(View *v, QMouseEvent *);
00050
00051 virtual void editStart(View *v, QMouseEvent *);
00052 virtual void editDrag(View *v, QMouseEvent *);
00053 virtual void editEnd(View *v, QMouseEvent *);
00054
00055 virtual void moveSelection(Selection s, size_t newStartFrame);
00056 virtual void resizeSelection(Selection s, Selection newSize);
00057 virtual void deleteSelection(Selection s);
00058
00059 virtual void copy(View *v, Selection s, Clipboard &to);
00060 virtual bool paste(View *v, const Clipboard &from, int frameOffset,
00061 bool interactive);
00062
00063 virtual bool editOpen(View *, QMouseEvent *);
00064
00065 virtual const Model *getModel() const { return m_model; }
00066 void setModel(TextModel *model);
00067
00068 virtual PropertyList getProperties() const;
00069 virtual QString getPropertyLabel(const PropertyName &) const;
00070 virtual PropertyType getPropertyType(const PropertyName &) const;
00071 virtual int getPropertyRangeAndValue(const PropertyName &,
00072 int *min, int *max, int *deflt) const;
00073 virtual QString getPropertyValueLabel(const PropertyName &,
00074 int value) const;
00075 virtual void setProperty(const PropertyName &, int value);
00076
00077 virtual bool isLayerScrollable(const View *v) const;
00078
00079 virtual bool isLayerEditable() const { return true; }
00080
00081 virtual int getCompletion(View *) const { return m_model->getCompletion(); }
00082
00083 virtual bool getValueExtents(float &min, float &max,
00084 bool &logarithmic, QString &unit) const;
00085
00086 virtual void toXml(QTextStream &stream, QString indent = "",
00087 QString extraAttributes = "") const;
00088
00089 void setProperties(const QXmlAttributes &attributes);
00090
00091 protected:
00092 int getYForHeight(View *v, float height) const;
00093 float getHeightForY(View *v, int y) const;
00094
00095 virtual int getDefaultColourHint(bool dark, bool &impose);
00096
00097 TextModel::PointList getLocalPoints(View *v, int x, int y) const;
00098
00099 TextModel *m_model;
00100 bool m_editing;
00101 QPoint m_editOrigin;
00102 TextModel::Point m_originalPoint;
00103 TextModel::Point m_editingPoint;
00104 TextModel::EditCommand *m_editingCommand;
00105 };
00106
00107 #endif
00108