]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/ColorCache.cpp
4ae3d065bb7304a8a85a419f818df425861e4f47
[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 void ColorCache::init()
22 {
23         for (int col = 0; col <= Color_ignore; ++col)
24                 lcolors_[col] = QColor(lcolor.getX11Name(ColorCode(col)).c_str());
25         initialized_ = true;
26 }
27
28
29 /// get the given color
30 QColor const & ColorCache::get(ColorCode color) const
31 {
32         if (!initialized_)
33                 const_cast<ColorCache *>(this)->init();
34         return lcolors_[color];
35 }
36
37
38 QColor const rgb2qcolor(RGBColor const & rgb)
39 {
40         return QColor(rgb.r, rgb.g, rgb.b);
41 }
42
43
44 } // namespace lyx