]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/ColorHandler.h
d4086ae9a6f1e80ffe87e54b7e8f9d915845a0cc
[lyx.git] / src / frontends / xforms / ColorHandler.h
1 // -*- C++ -*-
2 /**
3  * \file ColorHandler.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef COLOR_HANDLER_H
13 #define COLOR_HANDLER_H
14
15 #include "frontends/Painter.h"
16
17 #include <map>
18 #include <vector>
19 #include <boost/scoped_ptr.hpp>
20
21 // This is only included to provide stuff for the non-public sections
22 #include <X11/Xlib.h>
23
24 class LColor_color;
25 class LyXFont;
26
27 namespace lyx {
28 namespace frontend {
29
30 /**
31  * This is a factory class that can produce GCs with a specific
32  * color. It will cache GCs for performance.
33  */
34 class LyXColorHandler {
35 public:
36         ///
37         LyXColorHandler();
38         ///
39         ~LyXColorHandler();
40         ///
41         unsigned long colorPixel(LColor_color c);
42         ///
43         GC getGCForeground(LColor_color c);
44         ///
45         GC getGCLinepars(Painter::line_style,
46                          Painter::line_width, LColor_color c);
47         /// update the cache after a color definition change
48         void updateColor(LColor_color c);
49
50 private:
51         ///
52         Display * display;
53         ///
54         Colormap colormap;
55         ///
56         std::vector<GC> colorGCcache;
57         ///
58         GC getGCForeground(std::string const & s);
59         ///
60         typedef std::map<int, GC> LineGCCache;
61         ///
62         LineGCCache lineGCcache;
63         ///
64         Pixmap drawable;
65 };
66
67 ///
68 extern boost::scoped_ptr<LyXColorHandler> lyxColorHandler;
69
70 } // namespace frontend
71 } // namespace lyx
72
73 #endif