cr-rgb

cr-rgb

Synopsis

struct              CRRgb;
enum CRStatus       cr_rgb_compute_from_percentage      (CRRgb *a_this);
enum CRStatus       cr_rgb_copy                         (CRRgb *a_dest,
                                                         CRRgb const *a_src);
void                cr_rgb_destroy                      (CRRgb *a_this);
void                cr_rgb_dump                         (CRRgb const *a_this,
                                                         FILE *a_fp);
gboolean            cr_rgb_is_set_to_inherit            (CRRgb const *a_this);
gboolean            cr_rgb_is_set_to_transparent        (CRRgb const *a_this);
CRRgb *             cr_rgb_new                          (void);
CRRgb *             cr_rgb_new_with_vals                (gulong a_red,
                                                         gulong a_green,
                                                         gulong a_blue,
                                                         gboolean a_is_percentage);
CRRgb *             cr_rgb_parse_from_buf               (const guchar *a_str,
                                                         enum CREncoding a_enc);
enum CRStatus       cr_rgb_set                          (CRRgb *a_this,
                                                         gulong a_red,
                                                         gulong a_green,
                                                         gulong a_blue,
                                                         gboolean a_is_percentage);
enum CRStatus       cr_rgb_set_from_hex_str             (CRRgb *a_this,
                                                         const guchar *a_hex_value);
enum CRStatus       cr_rgb_set_from_name                (CRRgb *a_this,
                                                         const guchar *a_color_name);
enum CRStatus       cr_rgb_set_from_rgb                 (CRRgb *a_this,
                                                         CRRgb const *a_rgb);
enum CRStatus       cr_rgb_set_from_term                (CRRgb *a_this,
                                                         const struct _CRTerm *a_value);
enum CRStatus       cr_rgb_set_to_inherit               (CRRgb *a_this,
                                                         gboolean a_inherit);
enum CRStatus       cr_rgb_set_to_transparent           (CRRgb *a_this,
                                                         gboolean a_is_transparent);
guchar *            cr_rgb_to_string                    (CRRgb const *a_this);

Description

Details

struct CRRgb

struct CRRgb {
        /*
         *the unit of the rgb.
         *Either NO_UNIT (integer) or 
         *UNIT_PERCENTAGE (percentage).
         */
        const guchar *name ;
        glong red ;
        glong green ;
        glong blue ;
        gboolean is_percentage ;
	gboolean inherit ;
        gboolean is_transparent ;
        CRParsingLocation location ;
};


cr_rgb_compute_from_percentage ()

enum CRStatus       cr_rgb_compute_from_percentage      (CRRgb *a_this);

If the rgb values are expressed in percentage, compute their real value.

a_this :

the current instance of CRRgb

Returns :

CR_OK upon successful completion, an error code otherwise.

cr_rgb_copy ()

enum CRStatus       cr_rgb_copy                         (CRRgb *a_dest,
                                                         CRRgb const *a_src);


cr_rgb_destroy ()

void                cr_rgb_destroy                      (CRRgb *a_this);

Destructor of CRRgb.

a_this :

the "this pointer" of the current instance of CRRgb.

cr_rgb_dump ()

void                cr_rgb_dump                         (CRRgb const *a_this,
                                                         FILE *a_fp);

Dumps the current instance of CRRgb to a file.

a_this :

the "this pointer" of the current instance of CRRgb.

a_fp :

the destination file pointer.

cr_rgb_is_set_to_inherit ()

gboolean            cr_rgb_is_set_to_inherit            (CRRgb const *a_this);

a_this: the current instance of CRRgb.

Returns :

TRUE if the rgb is set to the value "inherit", FALSE otherwise.

cr_rgb_is_set_to_transparent ()

gboolean            cr_rgb_is_set_to_transparent        (CRRgb const *a_this);

Tests if the the rgb is set to the value "transparent" or not.

a_this :

the current instance of CRRgb

Returns :

TRUE if the rgb has been set to transparent, FALSE otherwise.

cr_rgb_new ()

CRRgb *             cr_rgb_new                          (void);

The default constructor of CRRgb.

Returns :

the newly built instance of CRRgb

cr_rgb_new_with_vals ()

CRRgb *             cr_rgb_new_with_vals                (gulong a_red,
                                                         gulong a_green,
                                                         gulong a_blue,
                                                         gboolean a_is_percentage);

A constructor of CRRgb.

a_red :

the red component of the color.

a_green :

the green component of the color.

a_blue :

the blue component of the color.

Returns :

the newly built instance of CRRgb.

cr_rgb_parse_from_buf ()

CRRgb *             cr_rgb_parse_from_buf               (const guchar *a_str,
                                                         enum CREncoding a_enc);

Parses a text buffer that contains a rgb color

a_str :

a string that contains a color description

a_enc :

the encoding of a_str

Returns :

the parsed color, or NULL in case of error

cr_rgb_set ()

enum CRStatus       cr_rgb_set                          (CRRgb *a_this,
                                                         gulong a_red,
                                                         gulong a_green,
                                                         gulong a_blue,
                                                         gboolean a_is_percentage);

Sets rgb values to the RGB.

a_this :

the current instance of CRRgb.

a_red :

the red value.

a_green :

the green value.

a_blue :

the blue value.

Returns :

CR_OK upon successful completion, an error code otherwise.

cr_rgb_set_from_hex_str ()

enum CRStatus       cr_rgb_set_from_hex_str             (CRRgb *a_this,
                                                         const guchar *a_hex_value);

a_this :

the current instance of CRRgb

Returns :

CR_OK upon successful completion.

cr_rgb_set_from_name ()

enum CRStatus       cr_rgb_set_from_name                (CRRgb *a_this,
                                                         const guchar *a_color_name);

a_this :

the current instance of CRRgb

a_color_name :

the color name

Returns :

CR_OK upon successful completion, an error code otherwise.

cr_rgb_set_from_rgb ()

enum CRStatus       cr_rgb_set_from_rgb                 (CRRgb *a_this,
                                                         CRRgb const *a_rgb);

Sets the rgb from an other one.

a_this :

the current instance of CRRgb.

a_rgb :

the rgb to "copy"

Returns :

CR_OK upon successful completion, an error code otherwise.

cr_rgb_set_from_term ()

enum CRStatus       cr_rgb_set_from_term                (CRRgb *a_this,
                                                         const struct _CRTerm *a_value);

Set the rgb from a terminal symbol

a_this :

the instance of CRRgb to set

a_value :

the terminal from which to set

Returns :

CR_OK upon successful completion, an error code otherwise.

cr_rgb_set_to_inherit ()

enum CRStatus       cr_rgb_set_to_inherit               (CRRgb *a_this,
                                                         gboolean a_inherit);

sets the value of the rgb to inherit. Look at the css spec from chapter 6.1 to 6.2 to understand the meaning of "inherit".

a_this :

the current instance of CRRgb

Returns :

CR_OK upon succesful completion, an error code otherwise.

cr_rgb_set_to_transparent ()

enum CRStatus       cr_rgb_set_to_transparent           (CRRgb *a_this,
                                                         gboolean a_is_transparent);

Sets the rgb to the "transparent" value (or not)

a_this :

the current instance of CRRgb

a_is_transparent :

set to transparent or not.

Returns :

CR_OK upon successfull completion, an error code otherwise.

cr_rgb_to_string ()

guchar *            cr_rgb_to_string                    (CRRgb const *a_this);

Serializes the rgb into a zero terminated string.

a_this :

the instance of CRRgb to serialize.

Returns :

the zero terminated string containing the serialized rgb. MUST BE FREED by the caller using g_free().