5 /* <groff_src_dir>/src/include/color.h
7 Last update: 14 Feb 2003
9 Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
10 Written by Gaius Mulley <gaius@glam.ac.uk>
12 This file is part of groff.
14 groff is free software; you can redistribute it and/or modify it under
15 the terms of the GNU General Public License as published by the Free
16 Software Foundation; either version 2, or (at your option) any later
19 groff is distributed in the hope that it will be useful, but WITHOUT ANY
20 WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 You should have received a copy of the GNU General Public License along
25 with groff; see the file COPYING. If not, write to the Free Software
26 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
31 enum color_scheme
{DEFAULT
, CMY
, CMYK
, RGB
, GRAY
};
36 unsigned int components
[4];
38 static color
*free_list
;
40 int read_encoding(const color_scheme
, const char * const,
45 enum {MAX_COLOR_VAL
= 0xffff};
46 color(symbol s
= default_symbol
) : scheme(DEFAULT
), nm(s
) {}
47 color(const color
* const);
49 void *operator new(size_t);
50 void operator delete(void *);
52 int operator==(const color
& c
) const;
53 int operator!=(const color
& c
) const;
55 int is_default() { return scheme
== DEFAULT
; }
57 // set color from given color component values
59 void set_rgb(const unsigned int r
, const unsigned int g
,
60 const unsigned int b
);
61 void set_cmy(const unsigned int c
, const unsigned int m
,
62 const unsigned int y
);
63 void set_cmyk(const unsigned int c
, const unsigned int m
,
64 const unsigned int y
, const unsigned int k
);
65 void set_gray(const unsigned int g
);
67 // set color from a color string
68 int read_rgb(const char * const s
);
69 int read_cmy(const char * const s
);
70 int read_cmyk(const char * const s
);
71 int read_gray(const char * const s
);
73 // Return the actual color scheme and retrieve the color components
74 // into a predefined vector (of length at least 4).
75 color_scheme
get_components(unsigned int *c
) const;
77 // retrieve the components of a color
78 void get_rgb(unsigned int *r
, unsigned int *g
, unsigned int *b
) const;
79 void get_cmy(unsigned int *c
, unsigned int *m
, unsigned int *y
) const;
80 void get_cmyk(unsigned int *c
, unsigned int *m
,
81 unsigned int *y
, unsigned int *k
) const;
82 void get_gray(unsigned int *g
) const;
87 #define Cyan components[0]
88 #define Magenta components[1]
89 #define Yellow components[2]
90 #define Black components[3]
92 #define Red components[0]
93 #define Green components[1]
94 #define Blue components[2]
96 #define Gray components[0]
98 extern color default_color
;