svgui  1.9
SingleColourLayer.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 2007 QMUL.
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 _SINGLE_COLOUR_LAYER_H_
00017 #define _SINGLE_COLOUR_LAYER_H_
00018 
00019 #include "Layer.h"
00020 #include <QColor>
00021 #include <vector>
00022 #include <map>
00023 
00024 class SingleColourLayer : public Layer
00025 {
00026     Q_OBJECT
00027     
00028 public:
00034     virtual void setBaseColour(int);
00035 
00040     virtual int getBaseColour() const;
00041 
00047     virtual bool hasLightBackground() const;
00048 
00052     virtual ColourSignificance getLayerColourSignificance() const {
00053         return ColourDistinguishes;
00054     }
00055 
00056     virtual QPixmap getLayerPresentationPixmap(QSize size) const;
00057 
00058     virtual PropertyList getProperties() const;
00059     virtual QString getPropertyLabel(const PropertyName &) const;
00060     virtual PropertyType getPropertyType(const PropertyName &) const;
00061     virtual QString getPropertyGroupName(const PropertyName &) const;
00062     virtual int getPropertyRangeAndValue(const PropertyName &,
00063                                          int *min, int *max, int *deflt) const;
00064     virtual QString getPropertyValueLabel(const PropertyName &,
00065                                           int value) const;
00066     virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
00067     virtual void setProperty(const PropertyName &, int value);
00068 
00069     virtual void toXml(QTextStream &stream, QString indent = "",
00070                        QString extraAttributes = "") const;
00071 
00072     virtual void setProperties(const QXmlAttributes &attributes);
00073 
00074     virtual void setDefaultColourFor(View *v);
00075 
00076 protected:
00077     SingleColourLayer();
00078     virtual ~SingleColourLayer();
00079 
00080     virtual QColor getBaseQColor() const;
00081     virtual QColor getBackgroundQColor(View *v) const;
00082     virtual QColor getForegroundQColor(View *v) const;
00083     std::vector<QColor> getPartialShades(View *v) const;
00084 
00085     virtual void flagBaseColourChanged() { }
00086     virtual int getDefaultColourHint(bool /* darkBackground */,
00087                                      bool & /* impose */) { return -1; }
00088 
00089     typedef std::map<int, int> ColourRefCount;
00090     static ColourRefCount m_colourRefCount;
00091 
00092     int m_colour;
00093     bool m_colourExplicitlySet;
00094     bool m_defaultColourSet;
00095 
00096 private:
00097     void refColor();
00098     void unrefColor();
00099 };
00100 
00101 #endif