1 /* -*- Mode: C; indent-tabs-mode:nil; c-basic-offset: 8-*- */
2 
3 /*
4  * This file is part of The Croco Library
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2.1 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA
19  *
20  * see COPYRIGHTS file for copyright information.
21  */
22 
23 #ifndef __CR_RGB_H__
24 #define __CR_RGB_H__
25 
26 #include <stdio.h>
27 #include <glib.h>
28 #include "cr-utils.h"
29 #include "cr-parsing-location.h"
30 
31 G_BEGIN_DECLS
32 
33 
34 typedef struct _CRRgb CRRgb ;
35 struct _CRRgb
36 {
37         /*
38          *the unit of the rgb.
39          *Either NO_UNIT (integer) or
40          *UNIT_PERCENTAGE (percentage).
41          */
42         const guchar *name ;
43         glong red ;
44         glong green ;
45         glong blue ;
46         gboolean is_percentage ;
47         CRParsingLocation location ;
48 } ;
49 
50 CRRgb * cr_rgb_new (void) ;
51 
52 CRRgb * cr_rgb_new_with_vals (gulong a_red, gulong a_green,
53                               gulong a_blue, gboolean a_is_percentage) ;
54 
55 CRRgb *cr_rgb_parse_from_buf(const guchar *a_str,
56                              enum CREncoding a_enc);
57 
58 enum CRStatus cr_rgb_compute_from_percentage (CRRgb *a_this) ;
59 
60 enum CRStatus cr_rgb_set (CRRgb *a_this, gulong a_red,
61                           gulong a_green, gulong a_blue,
62                           gboolean a_is_percentage) ;
63 
64 enum CRStatus cr_rgb_copy (CRRgb *a_dest, CRRgb const *a_src) ;
65 
66 enum CRStatus cr_rgb_set_from_rgb (CRRgb *a_this, CRRgb const *a_rgb) ;
67 
68 enum CRStatus cr_rgb_set_from_name (CRRgb *a_this, const guchar *a_color_name) ;
69 
70 enum CRStatus cr_rgb_set_from_hex_str (CRRgb *a_this, const guchar * a_hex_value) ;
71 
72 struct _CRTerm;
73 
74 enum CRStatus cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value);
75 
76 guchar * cr_rgb_to_string (CRRgb const *a_this) ;
77 
78 void cr_rgb_dump (CRRgb const *a_this, FILE *a_fp) ;
79 
80 void cr_rgb_destroy (CRRgb *a_this) ;
81 
82 G_END_DECLS
83 
84 #endif /*__CR_RGB_H__*/
85