summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/colorscheme.h
blob: b7c17b2bbd1708b90a0b284e1a2cd2d91a7144c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/***************************************************************************
                          colorscheme.h  -  description
                             -------------------
    begin                : Wed May 8 2002
    copyright            : (C) 2002 by Jason Harris
    email                : kstars@30doradus.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef COLORSCHEME_H
#define COLORSCHEME_H

#include <qmap.h>
#include <qstringlist.h>

class KConfig;

/**
	*@class ColorScheme
	*This class stores all of the adjustable colors in KStars, in 
	*a QMap object keyed by the names of the colors.  It also stores
	*information on how stars are to be rendered in the map
	*(with realistic colors, or as solid red/whit/black circles).
	*In addition to the brief "Key names" used to index the colors in 
	*the QMap, each color has a "long name" description that is a bit 
	*more verbose, and suitable for UI display.
	*@author Jason Harris
	*@version 1.0
	*/

class ColorScheme {

	public:

	/**Constructor.  Enter all adjustable colors and their default 
		*values into the QMap.  Also assign the corresponding long names.
		*/
		ColorScheme();

	/**Copy constructor
		*/
		ColorScheme( const ColorScheme &cs );

	/**Destructor
		*/
		~ColorScheme();

	/**@return true if the Palette contains the given key name
		*/
		bool hasColorNamed( const QString &name ) const { return ( ! Palette[ name ].isEmpty() ); }
		
	/**
		*@short Retrieve a color by name.  
		*@p name the key name of the color to be retrieved.
		*@return the requested color, or "#FFFFFF" (white) if color name not found. 
		*/
		QString colorNamed( const QString &name ) const;
		
	/**@p i the index of the color to retrieve
		*@return a color by its index in the QMap
		*/
		QString colorAt( int i ) const;
		
	/**@p i the index of the long name to retrieve
		*@return the name of the color at index i
		*/
		QString nameAt( int i ) const;
		
	/**@p i the index of the key name to retrieve
		*@return the key name of the color at index i
		*/
		QString keyAt( int i ) const;
		
	/**
		*@return the long name of the color whose key name is given
		*@p key the key name identifying the color.
		*/
		QString nameFromKey( const QString &key ) const;
		
	/**Change the color with the given key to the given value
		*@p key the key-name of the color to be changed
		*@p color the new color value
		*/
		void setColor( const QString &key, const QString &color );

	/**Load a color scheme from a *.colors file
		*@p filename the filename of the color scheme to be loaded.
		*@return TRUE if the scheme was successfully loaded
		*/
		bool load( const QString &filename );
		
	/**Save the current color scheme to a *.colors file.
		*@p name the filename to create
		*@return TRUE if the color scheme is successfully writeen to a file
		*/
		bool save( const QString &name );
		
	/**@return the Filename associated with the color scheme.
		*/
		QString fileName() const { return FileName; }
		
	/**Copy a color scheme
		*@p cs the color scheme to be copied into this object
		*/
		void copy( const ColorScheme &cs );

	/**Read color-scheme data from the Config object.
		*/
		void loadFromConfig( KConfig* );
		
	/**Save color-scheme data to the Config object.
		*/
		void saveToConfig( KConfig* );

	/**@return the number of colors in the color scheme.*/
		unsigned int numberOfColors() const { return (int)Palette.size(); }

	/**@return the star color mode used by the color scheme*/
		int starColorMode() const { return StarColorMode; }
		
	/**@return the star color intensity value used by the color scheme*/
		int starColorIntensity() const { return StarColorIntensity; }
		
	/**Set the star color mode used by the color scheme*/
		void setStarColorMode( int mode ) { StarColorMode = mode; }
		
	/**Set the star color intensity value used by the color scheme*/
		void setStarColorIntensity( int intens) { StarColorIntensity = intens; }

	private:
		int StarColorMode, StarColorIntensity;
		QString FileName;
		QStringList KeyName, Name, Default;
		QMap<QString,QString> Palette;

};

#endif