Chris@277
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@277
|
2
|
Chris@277
|
3 /*
|
Chris@277
|
4 Sonic Visualiser
|
Chris@277
|
5 An audio file viewer and annotation editor.
|
Chris@277
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@277
|
7 This file copyright 2007 QMUL.
|
Chris@277
|
8
|
Chris@277
|
9 This program is free software; you can redistribute it and/or
|
Chris@277
|
10 modify it under the terms of the GNU General Public License as
|
Chris@277
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@277
|
12 License, or (at your option) any later version. See the file
|
Chris@277
|
13 COPYING included with this distribution for more information.
|
Chris@277
|
14 */
|
Chris@277
|
15
|
Chris@277
|
16 #ifndef _COLOUR_DATABASE_H_
|
Chris@277
|
17 #define _COLOUR_DATABASE_H_
|
Chris@277
|
18
|
Chris@277
|
19 #include <QObject>
|
Chris@277
|
20 #include <QString>
|
Chris@277
|
21 #include <QColor>
|
Chris@277
|
22 #include <vector>
|
Chris@277
|
23
|
Chris@277
|
24 class ColourDatabase : public QObject
|
Chris@277
|
25 {
|
Chris@277
|
26 Q_OBJECT
|
Chris@277
|
27
|
Chris@277
|
28 public:
|
Chris@277
|
29 static ColourDatabase *getInstance();
|
Chris@277
|
30
|
Chris@277
|
31 int getColourCount() const;
|
Chris@277
|
32 QString getColourName(int c) const;
|
Chris@277
|
33 QColor getColour(int c) const;
|
Chris@277
|
34 QColor getColour(QString name) const;
|
Chris@277
|
35 int getColourIndex(QString name) const; // -1 -> not found
|
Chris@277
|
36 int getColourIndex(QColor c) const; // returns first index of possibly many
|
Chris@277
|
37 bool haveColour(QColor c) const;
|
Chris@277
|
38
|
Chris@277
|
39 bool useDarkBackground(int c) const;
|
Chris@277
|
40 void setUseDarkBackground(int c, bool dark);
|
Chris@277
|
41
|
Chris@277
|
42 int addColour(QColor, QString); // returns index
|
Chris@277
|
43 void removeColour(QString);
|
Chris@277
|
44
|
Chris@277
|
45 // returned colour is not necessarily in database
|
Chris@277
|
46 QColor getContrastingColour(int c) const;
|
Chris@277
|
47
|
Chris@277
|
48 // for use in XML export
|
Chris@277
|
49 void getStringValues(int index,
|
Chris@277
|
50 QString &colourName,
|
Chris@277
|
51 QString &colourSpec,
|
Chris@277
|
52 QString &darkbg) const;
|
Chris@277
|
53
|
Chris@277
|
54 // for use in XML import
|
Chris@277
|
55 int putStringValues(QString colourName,
|
Chris@277
|
56 QString colourSpec,
|
Chris@277
|
57 QString darkbg);
|
Chris@277
|
58
|
Chris@277
|
59 // for use by PropertyContainer getPropertyRangeAndValue methods
|
Chris@277
|
60 void getColourPropertyRange(int *min, int *max) const;
|
Chris@277
|
61
|
Chris@277
|
62 signals:
|
Chris@277
|
63 void colourDatabaseChanged();
|
Chris@277
|
64
|
Chris@277
|
65 protected:
|
Chris@277
|
66 ColourDatabase();
|
Chris@277
|
67
|
Chris@277
|
68 struct ColourRec {
|
Chris@277
|
69 QColor colour;
|
Chris@277
|
70 QString name;
|
Chris@277
|
71 bool darkbg;
|
Chris@277
|
72 };
|
Chris@277
|
73
|
Chris@277
|
74 typedef std::vector<ColourRec> ColourList;
|
Chris@277
|
75 ColourList m_colours;
|
Chris@277
|
76
|
Chris@277
|
77 static ColourDatabase m_instance;
|
Chris@277
|
78 };
|
Chris@277
|
79
|
Chris@277
|
80 #endif
|