svgui  1.9
TimeRulerLayer.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _TIME_RULER_H_
00017 #define _TIME_RULER_H_
00018 
00019 #include "SingleColourLayer.h"
00020 
00021 #include <QRect>
00022 #include <QColor>
00023 
00024 class View;
00025 class Model;
00026 class QPainter;
00027 
00028 class TimeRulerLayer : public SingleColourLayer
00029 {
00030     Q_OBJECT
00031 
00032 public:
00033     TimeRulerLayer();
00034 
00035     virtual void paint(View *v, QPainter &paint, QRect rect) const;
00036 
00037     void setModel(Model *);
00038     virtual const Model *getModel() const { return m_model; }
00039 
00040     enum LabelHeight { LabelTop, LabelMiddle, LabelBottom };
00041     void setLabelHeight(LabelHeight h) { m_labelHeight = h; }
00042     LabelHeight getLabelHeight() const { return m_labelHeight; }
00043 
00044     virtual bool snapToFeatureFrame(View *, int &, int &, SnapType) const;
00045 
00046     virtual ColourSignificance getLayerColourSignificance() const {
00047         return ColourIrrelevant;
00048     }
00049 
00050     virtual bool getValueExtents(float &, float &, bool &, QString &) const {
00051         return false;
00052     }
00053 
00054     virtual QString getLayerPresentationName() const;
00055 
00056     virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
00057 
00058     virtual void toXml(QTextStream &stream, QString indent = "",
00059                        QString extraAttributes = "") const;
00060 
00061     void setProperties(const QXmlAttributes &attributes);
00062 
00063 protected:
00064     Model *m_model;
00065     LabelHeight m_labelHeight;
00066 
00067     virtual int getDefaultColourHint(bool dark, bool &impose);
00068 
00069     int getMajorTickSpacing(View *, bool &quarterTicks) const;
00070 };
00071 
00072 #endif