Chris@376: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@376: Chris@376: /* Chris@376: Sonic Visualiser Chris@376: An audio file viewer and annotation editor. Chris@376: Centre for Digital Music, Queen Mary, University of London. Chris@376: This file copyright 2007 QMUL. Chris@376: Chris@376: This program is free software; you can redistribute it and/or Chris@376: modify it under the terms of the GNU General Public License as Chris@376: published by the Free Software Foundation; either version 2 of the Chris@376: License, or (at your option) any later version. See the file Chris@376: COPYING included with this distribution for more information. Chris@376: */ Chris@376: Chris@1407: #ifndef SV_COLOUR_DATABASE_H Chris@1407: #define SV_COLOUR_DATABASE_H Chris@376: Chris@376: #include Chris@376: #include Chris@376: #include Chris@376: #include Chris@376: #include Chris@376: #include Chris@376: Chris@376: class ColourDatabase : public QObject Chris@376: { Chris@376: Q_OBJECT Chris@376: Chris@376: public: Chris@376: static ColourDatabase *getInstance(); Chris@376: Chris@376: int getColourCount() const; Chris@376: QString getColourName(int c) const; Chris@376: QColor getColour(int c) const; Chris@376: QColor getColour(QString name) const; Chris@376: int getColourIndex(QString name) const; // -1 -> not found Chris@376: int getColourIndex(QColor c) const; // returns first index of possibly many Chris@376: bool haveColour(QColor c) const; Chris@376: Chris@376: bool useDarkBackground(int c) const; Chris@376: void setUseDarkBackground(int c, bool dark); Chris@376: Chris@376: int addColour(QColor, QString); // returns index Chris@376: void removeColour(QString); Chris@376: Chris@376: // returned colour is not necessarily in database Chris@376: QColor getContrastingColour(int c) const; Chris@376: Chris@376: // for use in XML export Chris@376: void getStringValues(int index, Chris@376: QString &colourName, Chris@376: QString &colourSpec, Chris@376: QString &darkbg) const; Chris@376: Chris@376: // for use in XML import Chris@376: int putStringValues(QString colourName, Chris@376: QString colourSpec, Chris@376: QString darkbg); Chris@376: Chris@376: // for use by PropertyContainer getPropertyRangeAndValue methods Chris@376: void getColourPropertyRange(int *min, int *max) const; Chris@376: Chris@376: QPixmap getExamplePixmap(int index, QSize size) const; Chris@376: Chris@376: signals: Chris@376: void colourDatabaseChanged(); Chris@376: Chris@376: protected: Chris@376: ColourDatabase(); Chris@376: Chris@376: struct ColourRec { Chris@376: QColor colour; Chris@376: QString name; Chris@376: bool darkbg; Chris@376: }; Chris@376: Chris@376: typedef std::vector ColourList; Chris@376: ColourList m_colours; Chris@376: Chris@376: static ColourDatabase m_instance; Chris@376: }; Chris@376: Chris@376: #endif