comparison layer/ColourDatabase.h @ 376:e1a9e478b7f2

* juggle some files around in order to free audioio, base, and system libraries from dependency on QtGui
author Chris Cannam
date Wed, 12 Mar 2008 17:42:56 +0000
parents
children 05d614f6e46d
comparison
equal deleted inserted replaced
375:daaf1c435d98 376:e1a9e478b7f2
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:
70 ColourDatabase();
71
72 struct ColourRec {
73 QColor colour;
74 QString name;
75 bool darkbg;
76 };
77
78 typedef std::vector<ColourRec> ColourList;
79 ColourList m_colours;
80
81 static ColourDatabase m_instance;
82 };
83
84 #endif