]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/ColorHandler.h
Tiny clean-ups.
[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
16 #include "frontends/Painter.h"
17
18 #include <map>
19 #include <vector>
20 #include <boost/scoped_ptr.hpp>
21
22 // This is only included to provide stuff for the non-public sections
23 #include <X11/Xlib.h>
24
25 class LColor_color;
26 class LyXFont;
27
28 /**
29  * This is a factory class that can produce GCs with a specific
30  * color. It will cache GCs for performance.
31  */
32 class LyXColorHandler {
33 public:
34         ///
35         LyXColorHandler();
36         ///
37         ~LyXColorHandler();
38         ///
39         unsigned long colorPixel(LColor_color c);
40         ///
41         GC getGCForeground(LColor_color c);
42         ///
43         GC getGCLinepars(Painter::line_style,
44                          Painter::line_width, LColor_color c);
45         /// update the cache after a color definition change
46         void updateColor(LColor_color c);
47
48 private:
49         ///
50         Display * display;
51         ///
52         Colormap colormap;
53         ///
54         std::vector<GC> colorGCcache;
55         ///
56         GC getGCForeground(std::string const & s);
57         ///
58         typedef std::map<int, GC> LineGCCache;
59         ///
60         LineGCCache lineGCcache;
61         ///
62         Pixmap drawable;
63 };
64
65 ///
66 extern boost::scoped_ptr<LyXColorHandler> lyxColorHandler;
67
68 #endif