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