]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/ColorCache.C
Fix unreported bug related to 3246 by Richard Heck:
[lyx.git] / src / frontends / qt4 / ColorCache.C
1 /**
2  * \file ColorCache.C
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 "Color.h"
14 #include "ColorCache.h"
15
16 #include "LColor.h"
17
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
28 ColorCache::ColorCache()
29 {
30 }
31
32 QColor const & ColorCache::get(LColor_color col) const
33 {
34         lcolor_map::const_iterator cit = colormap.find(col);
35         if (cit != colormap.end())
36                 return cit->second;
37
38         if (lcolor.getX11Name(col) == "grey40")
39                 colormap[col] = grey40;
40         else if (lcolor.getX11Name(col) == "grey60")
41                 colormap[col] = grey60;
42         else if (lcolor.getX11Name(col) == "grey80")
43                 colormap[col] = grey80;
44         else if (lcolor.getX11Name(col) == "grey90")
45                 colormap[col] = grey90;
46         else if (lcolor.getX11Name(col) == "none")
47                 colormap[col] = none;
48         else
49                 colormap[col] = QColor(lcolor.getX11Name(col).c_str());
50
51         return colormap[col];
52 }
53
54
55 void ColorCache::clear()
56 {
57         colormap.clear();
58 }
59
60
61 QColor const rgb2qcolor(lyx::RGBColor const & rgb)
62 {
63         return QColor(rgb.r, rgb.g, rgb.b);
64 }
65
66
67 } // namespace lyx