]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Color.h
Converter patch from Dekel, Preference patch from Angus, menu patch from Rob
[lyx.git] / src / frontends / xforms / Color.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *          Copyright 1995 Matthias Ettrich
8  *          Copyright 1995-2000 The LyX Team.
9  *
10  *======================================================*/
11
12 #ifndef COLOR_H
13 #define COLOR_H
14
15 #include <utility> // for pair
16
17 #ifdef __GNUG_
18 #pragma interface
19 #endif
20
21 #include "LString.h"
22
23 class HSVColor;
24 class RGBColor;
25
26 struct HSVColor {
27         double h;
28         double s;
29         double v;
30         HSVColor() : h(0.0), s(0.0), v(0.0) {}
31         HSVColor(double hue, double sat, double val) : h(hue), s(sat), v(val) {}
32         HSVColor( RGBColor const & );
33 };
34
35 struct RGBColor {
36         int r;
37         int g;
38         int b;
39         RGBColor() : r(0), g(0), b(0) {}
40         RGBColor(int red, int green, int blue) : r(red), g(green), b(blue) {}
41         RGBColor( HSVColor const & );
42 };
43
44 typedef std::pair<string, RGBColor> X11Color;
45
46 /// struct holding xform-specific colors
47 struct XformColor {
48         string name;
49         int colorID;
50         RGBColor col;
51         XformColor() : colorID(0) {}
52         string const getname() { return name; }
53         static bool read( string const & );
54         static bool write( string const & );
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