3 /* <groff_src_dir>/src/include/color.h
5 Last update: 10 Apr 2002
7 Copyright (C) 2001, 2002 Free Software Foundation, Inc.
8 Written by Gaius Mulley <gaius@glam.ac.uk>
10 This file is part of groff.
12 groff is free software; you can redistribute it and/or modify it under
13 the terms of the GNU General Public License as published by the Free
14 Software Foundation; either version 2, or (at your option) any later
17 groff is distributed in the hope that it will be useful, but WITHOUT ANY
18 WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 You should have received a copy of the GNU General Public License along
23 with groff; see the file COPYING. If not, write to the Free Software
24 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
28 enum color_scheme {DEFAULT, CMY, CMYK, RGB, GRAY};
33 unsigned int components[4];
35 int read_encoding(const color_scheme, const char * const,
39 enum {MAX_COLOR_VAL = 0xffff};
40 color() : scheme(DEFAULT){}
41 color(const color * const);
43 int operator==(const color & c) const;
44 int operator!=(const color & c) const;
46 int is_default() { return scheme == DEFAULT; }
48 // set color from given color component values
50 void set_rgb(const unsigned int r, const unsigned int g,
51 const unsigned int b);
52 void set_cmy(const unsigned int c, const unsigned int m,
53 const unsigned int y);
54 void set_cmyk(const unsigned int c, const unsigned int m,
55 const unsigned int y, const unsigned int k);
56 void set_gray(const unsigned int g);
58 // set color from a color string
59 int read_rgb(const char * const s);
60 int read_cmy(const char * const s);
61 int read_cmyk(const char * const s);
62 int read_gray(const char * const s);
64 // Return the actual color scheme and retrieve the color components
65 // into a predefined vector (of length at least 4).
66 color_scheme get_components(unsigned int *c) const;
68 // retrieve the components of a color
69 void get_rgb(unsigned int *r, unsigned int *g, unsigned int *b) const;
70 void get_cmy(unsigned int *c, unsigned int *m, unsigned int *y) const;
71 void get_cmyk(unsigned int *c, unsigned int *m,
72 unsigned int *y, unsigned int *k) const;
73 void get_gray(unsigned int *g) const;
76 #define Cyan components[0]
77 #define Magenta components[1]
78 #define Yellow components[2]
79 #define Black components[3]
81 #define Red components[0]
82 #define Green components[1]
83 #define Blue components[2]
85 #define Gray components[0]
87 extern color default_color;