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