kpalette.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1999 Waldo Bastian (bastian@kde.org) 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; version 00007 2 of the License. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 //----------------------------------------------------------------------------- 00020 // KDE color palette. 00021 00022 #ifndef __KPALETTE_H__ 00023 #define __KPALETTE_H__ 00024 00025 #include <qcolor.h> 00026 #include <qptrlist.h> 00027 #include <qstring.h> 00028 #include <qstringlist.h> 00029 #include "kdelibs_export.h" 00030 00031 class KPalettePrivate; 00032 00047 class KDECORE_EXPORT KPalette 00048 { 00049 public: 00055 static QStringList getPaletteList(); 00056 00062 KPalette(const QString &name=QString::null); 00063 00067 KPalette(const KPalette &); 00068 00072 virtual ~KPalette(); 00073 00077 KPalette& operator=( const KPalette &); 00078 00084 bool save(); 00085 00090 QString description() const 00091 { return mDesc; } 00092 00097 void setDescription(const QString &desc) 00098 { mDesc = desc; } 00099 00104 QString name() const 00105 { return mName; } 00106 00111 void setName(const QString &name) 00112 { mName = name; } 00113 00119 enum Editable { Yes, 00120 No, 00121 Ask 00122 }; 00123 00128 Editable editable() const 00129 { return mEditable; } 00130 00135 void setEditable(Editable editable) 00136 { mEditable = editable; } 00137 00142 int nrColors() const 00143 { return (int) mKolorList.count(); } 00144 00150 QColor color(int index); 00151 00158 int findColor(const QColor &color) const; 00159 00167 QString colorName(int index); 00168 00176 QString colorName(const QColor &color) 00177 { return colorName( findColor(color)); } 00178 00186 int addColor(const QColor &newColor, 00187 const QString &newColorName = QString::null); 00188 00198 int changeColor(int index, 00199 const QColor &newColor, 00200 const QString &newColorName = QString::null); 00201 00211 int changeColor(const QColor &oldColor, 00212 const QColor &newColor, 00213 const QString &newColorName = QString::null) 00214 { return changeColor( findColor(oldColor), newColor, newColorName); } 00215 00216 private: 00217 typedef struct { QColor color; QString name; } kolor; 00218 QPtrList<kolor> mKolorList; 00219 00220 QString mName; 00221 QString mDesc; 00222 Editable mEditable; 00223 00224 KPalettePrivate *d; 00225 }; 00226 00227 00228 #endif // __KPALETTE_H__ 00229