]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/ColorCache.h
Extracted from r14281
[lyx.git] / src / frontends / qt4 / ColorCache.h
1 // -*- C++ -*-
2 /**
3  * \file ColorCache.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef COLORCACHE_H
13 #define COLORCACHE_H
14
15 #include "LColor.h"
16
17 #include <map>
18
19 #include <QColor>
20
21
22 namespace lyx {
23 struct RGBColor;
24 }
25
26
27 // FIXME: use a fixed-size array not a map ?
28
29 /**
30  * Cache from LColor to QColor.
31  */
32 class ColorCache {
33 public:
34         ColorCache();
35
36         /// get the given color
37         QColor const & get(LColor_color color) const;
38
39         /// clear all colors
40         void clear();
41
42 private:
43         typedef std::map<LColor_color, QColor> lcolor_map;
44
45         mutable lcolor_map colormap;
46 };
47
48 /// singleton instance
49 extern ColorCache lcolorcache;
50
51 ///
52 QColor const rgb2qcolor(lyx::RGBColor const &);
53 #endif // COLORCACHE_H