]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/ColorCache.cpp
4a77f0ff63eb3a1be43d48e3328ab3dab6374ac3
[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 #include "Color.h"
15
16
17 namespace lyx {
18
19 const QColor grey40(0x66, 0x66, 0x66);
20 const QColor grey60(0x99, 0x99, 0x99);
21 const QColor grey80(0xcc, 0xcc, 0xcc);
22 const QColor grey90(0xe5, 0xe5, 0xe5);
23 const QColor none = Qt::black;
24
25 QColor const & ColorCache::get(Color_color col) const
26 {
27         lcolor_map::const_iterator cit = colormap.find(col);
28         if (cit != colormap.end())
29                 return cit->second;
30
31         if (lcolor.getX11Name(col) == "grey40")
32                 colormap[col] = grey40;
33         else if (lcolor.getX11Name(col) == "grey60")
34                 colormap[col] = grey60;
35         else if (lcolor.getX11Name(col) == "grey80")
36                 colormap[col] = grey80;
37         else if (lcolor.getX11Name(col) == "grey90")
38                 colormap[col] = grey90;
39         else if (lcolor.getX11Name(col) == "none")
40                 colormap[col] = none;
41         else
42                 colormap[col] = QColor(lcolor.getX11Name(col).c_str());
43
44         return colormap[col];
45 }
46
47
48 void ColorCache::clear()
49 {
50         colormap.clear();
51 }
52
53
54 QColor const rgb2qcolor(RGBColor const & rgb)
55 {
56         return QColor(rgb.r, rgb.g, rgb.b);
57 }
58
59
60 } // namespace lyx