]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/ColorCache.cpp
header cleanup
[lyx.git] / src / frontends / qt4 / ColorCache.cpp
1 /**
2  * \file ColorCache.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "ColorCache.h"
14
15 #include "Color.h"
16
17 #include <string>
18
19 namespace lyx {
20
21 const QColor grey40(0x66, 0x66, 0x66);
22 const QColor grey60(0x99, 0x99, 0x99);
23 const QColor grey80(0xcc, 0xcc, 0xcc);
24 const QColor grey90(0xe5, 0xe5, 0xe5);
25 const QColor none = Qt::black;
26
27 QColor const & ColorCache::get(ColorCode col) const
28 {
29         lcolor_map::const_iterator cit = colormap.find(col);
30         if (cit != colormap.end())
31                 return cit->second;
32
33         if (lcolor.getX11Name(col) == "grey40")
34                 colormap[col] = grey40;
35         else if (lcolor.getX11Name(col) == "grey60")
36                 colormap[col] = grey60;
37         else if (lcolor.getX11Name(col) == "grey80")
38                 colormap[col] = grey80;
39         else if (lcolor.getX11Name(col) == "grey90")
40                 colormap[col] = grey90;
41         else if (lcolor.getX11Name(col) == "none")
42                 colormap[col] = none;
43         else
44                 colormap[col] = QColor(lcolor.getX11Name(col).c_str());
45
46         return colormap[col];
47 }
48
49
50 void ColorCache::clear()
51 {
52         colormap.clear();
53 }
54
55
56 QColor const rgb2qcolor(RGBColor const & rgb)
57 {
58         return QColor(rgb.r, rgb.g, rgb.b);
59 }
60
61
62 } // namespace lyx