Libcroco
cr-rgb.h
Go to the documentation of this file.
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  gboolean inherit ;
48  gboolean is_transparent ;
50 } ;
51 
52 CRRgb * cr_rgb_new (void) ;
53 
54 CRRgb * cr_rgb_new_with_vals (gulong a_red, gulong a_green,
55  gulong a_blue, gboolean a_is_percentage) ;
56 
57 CRRgb *cr_rgb_parse_from_buf(const guchar *a_str,
58  enum CREncoding a_enc);
59 
61 
62 enum CRStatus cr_rgb_set (CRRgb *a_this, gulong a_red,
63  gulong a_green, gulong a_blue,
64  gboolean a_is_percentage) ;
65 
66 enum CRStatus cr_rgb_copy (CRRgb *a_dest, CRRgb const *a_src) ;
67 
68 enum CRStatus cr_rgb_set_to_inherit (CRRgb *a_this, gboolean a_inherit) ;
69 
70 gboolean cr_rgb_is_set_to_inherit (CRRgb const *a_this) ;
71 
72 gboolean cr_rgb_is_set_to_transparent (CRRgb const *a_this) ;
73 
75  gboolean a_is_transparent) ;
76 enum CRStatus cr_rgb_set_from_rgb (CRRgb *a_this, CRRgb const *a_rgb) ;
77 
78 enum CRStatus cr_rgb_set_from_name (CRRgb *a_this, const guchar *a_color_name) ;
79 
80 enum CRStatus cr_rgb_set_from_hex_str (CRRgb *a_this, const guchar * a_hex_value) ;
81 
82 struct _CRTerm;
83 
84 enum CRStatus cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value);
85 
86 guchar * cr_rgb_to_string (CRRgb const *a_this) ;
87 
88 void cr_rgb_dump (CRRgb const *a_this, FILE *a_fp) ;
89 
90 void cr_rgb_destroy (CRRgb *a_this) ;
91 
92 G_END_DECLS
93 
94 #endif /*__CR_RGB_H__*/
_CRRgb::is_percentage
gboolean is_percentage
Definition: cr-rgb.h:46
cr_rgb_dump
void cr_rgb_dump(CRRgb const *a_this, FILE *a_fp)
cr_rgb_dump: @a_this: the "this pointer" of the current instance of CRRgb.
Definition: cr-rgb.c:294
cr_rgb_set_from_hex_str
enum CRStatus cr_rgb_set_from_hex_str(CRRgb *a_this, const guchar *a_hex_value)
cr_rgb_set_from_hex_str: @a_this: the current instance of CRRgb @a_hex: the hexadecimal value to set.
Definition: cr-rgb.c:501
cr_rgb_destroy
void cr_rgb_destroy(CRRgb *a_this)
cr_rgb_destroy: @a_this: the "this pointer" of the current instance of CRRgb.
Definition: cr-rgb.c:632
cr_rgb_copy
enum CRStatus cr_rgb_copy(CRRgb *a_dest, CRRgb const *a_src)
Definition: cr-rgb.c:615
cr_rgb_set_from_term
enum CRStatus cr_rgb_set_from_term(CRRgb *a_this, const struct _CRTerm *a_value)
cr_rgb_set_from_term: @a_this: the instance of CRRgb to set @a_value: the terminal from which to set
Definition: cr-rgb.c:564
_CRRgb::name
const guchar * name
Definition: cr-rgb.h:42
cr_rgb_set_from_rgb
enum CRStatus cr_rgb_set_from_rgb(CRRgb *a_this, CRRgb const *a_rgb)
cr_rgb_set_from_rgb: @a_this: the current instance of CRRgb.
Definition: cr-rgb.c:446
_CRRgb
Definition: cr-rgb.h:35
cr_rgb_compute_from_percentage
enum CRStatus cr_rgb_compute_from_percentage(CRRgb *a_this)
cr_rgb_compute_from_percentage: @a_this: the current instance of CRRgb
Definition: cr-rgb.c:319
cr_rgb_set
enum CRStatus cr_rgb_set(CRRgb *a_this, gulong a_red, gulong a_green, gulong a_blue, gboolean a_is_percentage)
cr_rgb_set: @a_this: the current instance of CRRgb.
Definition: cr-rgb.c:345
cr_rgb_is_set_to_inherit
gboolean cr_rgb_is_set_to_inherit(CRRgb const *a_this)
cr_rgb_is_set_to_inherit:
Definition: cr-rgb.c:393
cr_rgb_to_string
guchar * cr_rgb_to_string(CRRgb const *a_this)
cr_rgb_to_string: @a_this: the instance of CRRgb to serialize.
Definition: cr-rgb.c:248
_CRRgb::blue
glong blue
Definition: cr-rgb.h:45
_CRParsingLocation
Definition: cr-parsing-location.h:39
cr_rgb_new_with_vals
CRRgb * cr_rgb_new_with_vals(gulong a_red, gulong a_green, gulong a_blue, gboolean a_is_percentage)
cr_rgb_new_with_vals: @a_red: the red component of the color.
Definition: cr-rgb.c:221
cr_rgb_set_to_inherit
enum CRStatus cr_rgb_set_to_inherit(CRRgb *a_this, gboolean a_inherit)
cr_rgb_set_to_inherit: @a_this: the current instance of CRRgb
Definition: cr-rgb.c:376
CRRgb
typedefG_BEGIN_DECLS struct _CRRgb CRRgb
Definition: cr-rgb.h:34
cr_rgb_parse_from_buf
CRRgb * cr_rgb_parse_from_buf(const guchar *a_str, enum CREncoding a_enc)
cr_rgb_parse_from_buf: @a_str: a string that contains a color description @a_enc: the encoding of a_s...
Definition: cr-rgb.c:648
cr-parsing-location.h
cr_rgb_set_from_name
enum CRStatus cr_rgb_set_from_name(CRRgb *a_this, const guchar *a_color_name)
cr_rgb_set_from_name: @a_this: the current instance of CRRgb @a_color_name: the color name
Definition: cr-rgb.c:473
CREncoding
CREncoding
Encoding values.
Definition: cr-utils.h:84
_CRRgb::is_transparent
gboolean is_transparent
Definition: cr-rgb.h:48
_CRTerm
An abstraction of a css2 term as defined in the CSS2 spec in appendix D.1: term ::= [ NUMBER S* | PER...
Definition: cr-term.h:82
CRStatus
CRStatus
The status type returned by the methods of the croco library.
Definition: cr-utils.h:43
_CRRgb::red
glong red
Definition: cr-rgb.h:43
_CRRgb::green
glong green
Definition: cr-rgb.h:44
cr-utils.h
cr_rgb_set_to_transparent
enum CRStatus cr_rgb_set_to_transparent(CRRgb *a_this, gboolean a_is_transparent)
cr_rgb_set_to_transparent: @a_this: the current instance of CRRgb @a_is_transparent: set to transpare...
Definition: cr-rgb.c:428
_CRRgb::location
CRParsingLocation location
Definition: cr-rgb.h:49
cr_rgb_is_set_to_transparent
gboolean cr_rgb_is_set_to_transparent(CRRgb const *a_this)
cr_rgb_is_set_to_transparent: @a_this: the current instance of CRRgb
Definition: cr-rgb.c:412
cr_rgb_new
CRRgb * cr_rgb_new(void)
cr_rgb_new:
Definition: cr-rgb.c:192
_CRRgb::inherit
gboolean inherit
Definition: cr-rgb.h:47