]> git.lyx.org Git - features.git/blob - src/frontends/xforms/ColorHandler.h
a402f22f3e0853b62ff5c7a345699be9a4120a5a
[features.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
16 #include "frontends/Painter.h"
17
18 #include <map>
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 LyXFont;
25
26 /**
27  * This is a factory class that can produce GCs with a specific
28  * color. It will cache GCs for performance.
29  */
30 class LyXColorHandler {
31 public:
32         ///
33         LyXColorHandler();
34         ///
35         ~LyXColorHandler();
36         ///
37         unsigned long colorPixel(LColor::color c);
38         ///
39         GC getGCForeground(LColor::color c);
40         ///
41         GC getGCLinepars(Painter::line_style,
42                          Painter::line_width, LColor::color c);
43         /// update the cache after a color definition change
44         void updateColor(LColor::color c);
45
46 private:
47         ///
48         Display * display;
49         ///
50         Colormap colormap;
51         ///
52         GC colorGCcache[LColor::ignore + 1];
53         ///
54         typedef std::map<int, GC> LineGCCache;
55         ///
56         LineGCCache lineGCcache;
57         ///
58         Pixmap drawable;
59 };
60
61 ///
62 extern boost::scoped_ptr<LyXColorHandler> lyxColorHandler;
63
64 #endif