]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/ColorCache.h
Make string-widget combination more l7n friendly
[lyx.git] / src / frontends / qt / ColorCache.h
1 // -*- C++ -*-
2 /**
3  * \file ColorCache.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef COLORCACHE_H
13 #define COLORCACHE_H
14
15 #include "ColorCode.h"
16
17 #include <QColor>
18 #include <QPalette>
19
20 namespace lyx {
21
22 class Color;
23
24 /**
25  * Cache from Color to QColor.
26  */
27 class ColorCache
28 {
29 public:
30         ///
31         ColorCache() : initialized_(false) {}
32
33         /// get the given color (depends on LyXRC::use_system_color)
34         QColor get(Color const & color) const;
35
36         /// get the given color
37         QColor get(Color const & color, bool use_system_colors) const;
38
39         /// is this color replaced when LyXRC::use_system_color is true?
40         bool isSystem(ColorCode color) const;
41
42         /// guess whether we are in dark mode
43         bool isDarkMode() const;
44
45         /// change the undelying palette
46         void setPalette(QPalette const pal) { pal_ = pal; clear(); }
47
48         /// clear all colors
49         void clear() { initialized_ = false; }
50
51 private:
52         ///
53         void init();
54         ///
55         QColor lcolors_[Color_ignore + 1];
56         ///
57         bool initialized_;
58         ///
59         QPalette pal_;
60 };
61
62 ///
63 QColor const rgb2qcolor(RGBColor const &);
64
65 } // namespace lyx
66
67 #endif // COLORCACHE_H