]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Color.h
fix crash with "save as"
[lyx.git] / src / frontends / xforms / Color.h
1 // -*- C++ -*-
2 /**
3  * \file Color.h
4  * Copyright 1995 Matthias Ettrich
5  * This file is part of LyX, the document processor.
6  * Licence details can be found in the file COPYING.
7  *
8  * \author Angus Leeming 
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 /* structs RGBColor and HSVColor to enable simple conversion between
14  * color spaces.
15  */
16
17 #ifndef COLOR_H
18 #define COLOR_H
19
20 #ifdef __GNUG__
21 #pragma interface
22 #endif
23
24 #include "LString.h"
25
26 struct RGBColor;
27
28 struct HSVColor {
29         double h;
30         double s;
31         double v;
32         HSVColor() : h(0.0), s(0.0), v(0.0) {}
33         HSVColor(double hue, double sat, double val)
34                 : h(hue), s(sat), v(val) {}
35         HSVColor(RGBColor const &);
36 };
37
38 struct RGBColor {
39         int r;
40         int g;
41         int b;
42         RGBColor() : r(0), g(0), b(0) {}
43         RGBColor(int red, int green, int blue)
44                 : r(red), g(green), b(blue) {}
45         RGBColor(HSVColor const &);
46 };
47
48 struct NamedColor : public RGBColor {
49         string name;
50         NamedColor() : RGBColor() {}
51         NamedColor(string const & n, RGBColor const & c)
52                 : RGBColor(c), name(n) {}
53         RGBColor const & color() const { return *this; }
54         string const & getname() const { return name; }
55 };
56
57 inline
58 bool operator==(RGBColor const & c1, RGBColor const & c2)
59 {
60         return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
61 }
62
63
64 inline
65 bool operator!=(RGBColor const & c1, RGBColor const & c2)
66 {
67         return !(c1 == c2);
68 }
69
70 #endif