svgui  1.9
ColourDatabase.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 _COLOUR_DATABASE_H_
17 #define _COLOUR_DATABASE_H_
18 
19 #include <QObject>
20 #include <QString>
21 #include <QColor>
22 #include <QSize>
23 #include <QPixmap>
24 #include <vector>
25 
26 class ColourDatabase : public QObject
27 {
28  Q_OBJECT
29 
30 public:
31  static ColourDatabase *getInstance();
32 
33  int getColourCount() const;
34  QString getColourName(int c) const;
35  QColor getColour(int c) const;
36  QColor getColour(QString name) const;
37  int getColourIndex(QString name) const; // -1 -> not found
38  int getColourIndex(QColor c) const; // returns first index of possibly many
39  bool haveColour(QColor c) const;
40 
41  bool useDarkBackground(int c) const;
42  void setUseDarkBackground(int c, bool dark);
43 
44  int addColour(QColor, QString); // returns index
45  void removeColour(QString);
46 
47  // returned colour is not necessarily in database
48  QColor getContrastingColour(int c) const;
49 
50  // for use in XML export
51  void getStringValues(int index,
52  QString &colourName,
53  QString &colourSpec,
54  QString &darkbg) const;
55 
56  // for use in XML import
57  int putStringValues(QString colourName,
58  QString colourSpec,
59  QString darkbg);
60 
61  // for use by PropertyContainer getPropertyRangeAndValue methods
62  void getColourPropertyRange(int *min, int *max) const;
63 
64  QPixmap getExamplePixmap(int index, QSize size) const;
65 
66 signals:
67  void colourDatabaseChanged();
68 
69 protected:
71 
72  struct ColourRec {
73  QColor colour;
74  QString name;
75  bool darkbg;
76  };
77 
78  typedef std::vector<ColourRec> ColourList;
80 
82 };
83 
84 #endif
QString getColourName(int c) const
void colourDatabaseChanged()
bool haveColour(QColor c) const
void removeColour(QString)
QPixmap getExamplePixmap(int index, QSize size) const
void getStringValues(int index, QString &colourName, QString &colourSpec, QString &darkbg) const
std::vector< ColourRec > ColourList
int addColour(QColor, QString)
bool useDarkBackground(int c) const
static ColourDatabase m_instance
int putStringValues(QString colourName, QString colourSpec, QString darkbg)
void setUseDarkBackground(int c, bool dark)
int getColourIndex(QString name) const
int getColourCount() const
QColor getContrastingColour(int c) const
void getColourPropertyRange(int *min, int *max) const
ColourList m_colours
static ColourDatabase * getInstance()
QColor getColour(int c) const