3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "ColorCache.h"
22 void ColorCache::init()
24 for (int col = 0; col <= Color_ignore; ++col)
25 lcolors_[col] = QColor(lcolor.getX11Name(ColorCode(col)).c_str());
30 /// get the given color
31 QColor ColorCache::get(Color color) const
34 const_cast<ColorCache *>(this)->init();
35 if (color <= Color_ignore && color.mergeColor == Color_ignore)
36 return lcolors_[color.baseColor];
37 if (color.mergeColor != Color_ignore) {
38 QColor base_color = get(color.baseColor).toRgb();
39 QColor merge_color = get(color.mergeColor).toRgb();
41 (base_color.red() + merge_color.red())/2,
42 (base_color.green() + merge_color.green())/2,
43 (base_color.blue() + merge_color.blue())/2);
46 return QColor(lcolor.getX11Name(color.baseColor).c_str());
50 QColor const rgb2qcolor(RGBColor const & rgb)
52 return QColor(rgb.r, rgb.g, rgb.b);