]> git.lyx.org Git - lyx.git/blob - src/ColorHandler.h
selection using the mouse should work now. Note: an x is not a y, nor is
[lyx.git] / src / ColorHandler.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1995-2001 The LyX Team
8  *
9  * ======================================================*/
10
11 #ifndef COLOR_HANDLER_H
12 #define COLOR_HANDLER_H
13
14 #ifdef __GNUG__
15 #pragma interface
16 #endif
17
18 #include <boost/smart_ptr.hpp>
19
20 // This is only included to provide stuff for the non-public sections
21 #include <X11/Xlib.h>
22
23 #include "PainterBase.h"
24
25 class LyXFont;
26 class WorkArea;
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(PainterBase::line_style,
44                          PainterBase::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         GC colorGCcache[LColor::ignore + 1];
55         ///
56         typedef std::map<int, GC> LineGCCache;
57         ///
58         LineGCCache lineGCcache;
59         ///
60         Pixmap drawable;
61 };
62
63 ///
64 extern boost::scoped_ptr<LyXColorHandler> lyxColorHandler;
65
66 #endif