svgui  1.9
SingleColourLayer.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2007 QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _SINGLE_COLOUR_LAYER_H_
17 #define _SINGLE_COLOUR_LAYER_H_
18 
19 #include "Layer.h"
20 #include <QColor>
21 #include <vector>
22 #include <map>
23 
24 class SingleColourLayer : public Layer
25 {
26  Q_OBJECT
27 
28 public:
34  virtual void setBaseColour(int);
35 
40  virtual int getBaseColour() const;
41 
47  virtual bool hasLightBackground() const;
48 
53  return ColourDistinguishes;
54  }
55 
56  virtual QPixmap getLayerPresentationPixmap(QSize size) const;
57 
58  virtual PropertyList getProperties() const;
59  virtual QString getPropertyLabel(const PropertyName &) const;
60  virtual PropertyType getPropertyType(const PropertyName &) const;
61  virtual QString getPropertyGroupName(const PropertyName &) const;
62  virtual int getPropertyRangeAndValue(const PropertyName &,
63  int *min, int *max, int *deflt) const;
64  virtual QString getPropertyValueLabel(const PropertyName &,
65  int value) const;
66  virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
67  virtual void setProperty(const PropertyName &, int value);
68 
69  virtual void toXml(QTextStream &stream, QString indent = "",
70  QString extraAttributes = "") const;
71 
72  virtual void setProperties(const QXmlAttributes &attributes);
73 
74  virtual void setDefaultColourFor(View *v);
75 
76 protected:
78  virtual ~SingleColourLayer();
79 
80  virtual QColor getBaseQColor() const;
81  virtual QColor getBackgroundQColor(View *v) const;
82  virtual QColor getForegroundQColor(View *v) const;
83  std::vector<QColor> getPartialShades(View *v) const;
84 
85  virtual void flagBaseColourChanged() { }
86  virtual int getDefaultColourHint(bool /* darkBackground */,
87  bool & /* impose */) { return -1; }
88 
89  typedef std::map<int, int> ColourRefCount;
91 
92  int m_colour;
95 
96 private:
97  void refColor();
98  void unrefColor();
99 };
100 
101 #endif
virtual void setDefaultColourFor(View *v)
virtual ColourSignificance getLayerColourSignificance() const
Implements Layer::getLayerColourSignificance()
The base class for visual representations of the data found in a Model.
Definition: Layer.h:52
virtual void flagBaseColourChanged()
virtual QPixmap getLayerPresentationPixmap(QSize size) const
virtual void setBaseColour(int)
Set the colour used to draw primary items in the layer.
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Convert the layer's data (though not those of the model it refers to) into XML for file output.
ColourSignificance
Definition: Layer.h:304
virtual QColor getForegroundQColor(View *v) const
virtual int getDefaultColourHint(bool, bool &)
virtual QColor getBaseQColor() const
std::vector< QColor > getPartialShades(View *v) const
static ColourRefCount m_colourRefCount
virtual QString getPropertyLabel(const PropertyName &) const
virtual QColor getBackgroundQColor(View *v) const
virtual QString getPropertyGroupName(const PropertyName &) const
virtual void setProperties(const QXmlAttributes &attributes)
Set the particular properties of a layer (those specific to the subclass) from a set of XML attribute...
virtual bool hasLightBackground() const
Return true if the layer currently has a dark colour on a light background, false if it has a light c...
virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const
virtual RangeMapper * getNewPropertyRangeMapper(const PropertyName &) const
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
Definition: View.h:50
virtual QString getPropertyValueLabel(const PropertyName &, int value) const
std::map< int, int > ColourRefCount
virtual PropertyList getProperties() const
virtual PropertyType getPropertyType(const PropertyName &) const
virtual int getBaseColour() const
Retrieve the current primary drawing colour, as a ColourDatabase index value.
virtual void setProperty(const PropertyName &, int value)