]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/lcolorcache.C
rename LFUN enum values according to their command (as used in th minibuffer/bind...
[lyx.git] / src / frontends / qt4 / lcolorcache.C
1 /**
2  * \file lcolorcache.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 "lcolorcache.h"
15
16 #include "LColor.h"
17
18 LColorCache lcolorcache;
19
20 const QColor grey40(0x66, 0x66, 0x66);
21 const QColor grey60(0x99, 0x99, 0x99);
22 const QColor grey80(0xcc, 0xcc, 0xcc);
23 const QColor grey90(0xe5, 0xe5, 0xe5);
24 const QColor none = Qt::black;
25
26
27 LColorCache::LColorCache()
28 {
29 }
30
31 QColor const & LColorCache::get(LColor_color col) const
32 {
33         lcolor_map::const_iterator cit = colormap.find(col);
34         if (cit != colormap.end())
35                 return cit->second;
36
37         if (lcolor.getX11Name(col) == "grey40")
38                 colormap[col] = grey40;
39         else if (lcolor.getX11Name(col) == "grey60")
40                 colormap[col] = grey60;
41         else if (lcolor.getX11Name(col) == "grey80")
42                 colormap[col] = grey80;
43         else if (lcolor.getX11Name(col) == "grey90")
44                 colormap[col] = grey90;
45         else if (lcolor.getX11Name(col) == "none")
46                 colormap[col] = none;
47         else
48                 colormap[col] = QColor(lcolor.getX11Name(col).c_str());
49
50         return colormap[col];
51 }
52
53
54 void LColorCache::clear()
55 {
56         colormap.clear();
57 }
58
59
60 QColor const rgb2qcolor(lyx::RGBColor const & rgb)
61 {
62         return QColor(rgb.r, rgb.g, rgb.b);
63 }