moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / colorscheme.h
blob04543ebe20c85507c606249ffb4f09bae5e8568f
1 /***************************************************************************
2 colorscheme.h - description
3 -------------------
4 begin : Wed May 8 2002
5 copyright : (C) 2002 by Jason Harris
6 email : kstars@30doradus.org
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef COLORSCHEME_H
19 #define COLORSCHEME_H
21 #include <qmap.h>
22 #include <qstringlist.h>
24 class KConfig;
26 /**@class ColorScheme
27 *This class stores all of the adjustable colors in KStars, in
28 *a QMap object keyed by the names of the colors. It also stores
29 *information on how stars are to be rendered in the map
30 *(with realistic colors, or as solid red/whit/black circles).
31 *In addition to the brief "Key names" used to index the colors in
32 *the QMap, each color has a "long name" description that is a bit
33 *more verbose, and suitable for UI display.
34 *@author Jason Harris
35 *@version 1.0
38 class ColorScheme {
40 public:
42 /**Constructor. Enter all adjustable colors and their default
43 *values into the QMap. Also assign the corresponding long names.
45 ColorScheme();
47 /**Copy constructor
49 ColorScheme( const ColorScheme &cs );
51 /**Destructor
53 ~ColorScheme();
55 /**@return true if the Palette contains the given key name
57 bool hasColorNamed( const QString &name ) const { return ( ! Palette[ name ].isEmpty() ); }
59 /**Retrieve a color by name.
60 *@name the key name of the color to be retrieved.
61 *@return the requested color, or "#FFFFFF" (white) if color name not found.
63 QString colorNamed( const QString &name ) const;
65 /**@p i the index of the color to retrieve
66 *@return a color by its index in the QMap
68 QString colorAt( int i ) const;
70 /**@p i the index of the key name to retrieve
71 *@return the name of the color at index i
73 QString nameAt( int i ) const;
75 /**@p i the index of the key name to retrieve
76 *@return the key name of the color at index i
78 QString keyAt( int i ) const;
80 QString nameFromKey( const QString &key ) const;
82 /**Change the color with the given key to the given value
83 *@p key the key-name of the color to be changed
84 *@p color the new color value
86 void setColor( const QString &key, const QString &color );
88 /**Load a color scheme from a *.colors file
89 *@p filename the filename of the color scheme to be loaded.
90 *@return TRUE if the scheme was successfully loaded
92 bool load( const QString &filename );
94 /**Save the current color scheme to a *.colors file.
95 *@p name the filename to create
96 *@return TRUE if the color scheme is successfully writeen to a file
98 bool save( const QString &name );
100 /**@return the Filename associated with the color scheme.
102 QString fileName() const { return FileName; }
104 /**Copy a color scheme
105 *@p cs the color scheme to be copied into this object
107 void copy( const ColorScheme &cs );
109 /**Read color-scheme data from the Config object.
111 void loadFromConfig( KConfig* );
113 /**Save color-scheme data to the Config object.
115 void saveToConfig( KConfig* );
117 /**@return the number of colors in the color scheme.*/
118 unsigned int numberOfColors() const { return (int)Palette.size(); }
120 /**@return the star color mode used by the color scheme*/
121 int starColorMode() const { return StarColorMode; }
123 /**@return the star color intensity value used by the color scheme*/
124 int starColorIntensity() const { return StarColorIntensity; }
126 /**Set the star color mode used by the color scheme*/
127 void setStarColorMode( int mode ) { StarColorMode = mode; }
129 /**Set the star color intensity value used by the color scheme*/
130 void setStarColorIntensity( int intens) { StarColorIntensity = intens; }
132 private:
133 int StarColorMode, StarColorIntensity;
134 QString FileName;
135 QStringList KeyName, Name, Default;
136 QMap<QString,QString> Palette;
140 #endif