Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

cr-rgb.c File Reference

#include <stdio.h>
#include <string.h>
#include "cr-rgb.h"
#include "cr-term.h"
#include "cr-parser.h"

Go to the source code of this file.

Functions

CRRgbcr_rgb_new (void)
 The default constructor of CRRgb.
CRRgbcr_rgb_new_with_vals (gulong a_red, gulong a_green, gulong a_blue, gboolean a_is_percentage)
 A constructor of CRRgb.
guchar * cr_rgb_to_string (CRRgb *a_this)
 Serializes the rgb into a zero terminated string.
void cr_rgb_dump (CRRgb *a_this, FILE *a_fp)
 Dumps the current instance of CRRgb to a file.
enum CRStatus cr_rgb_compute_from_percentage (CRRgb *a_this)
 If the rgb values are expressed in percentage, compute their real value.
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.
enum CRStatus cr_rgb_set_to_inherit (CRRgb *a_this, gboolean a_inherit)
 sets the value of the rgb to inherit.
gboolean cr_rgb_is_set_to_inherit (CRRgb *a_this)
gboolean cr_rgb_is_set_to_transparent (CRRgb *a_this)
 Tests if the the rgb is set to the value "transparent" or not.
enum CRStatus cr_rgb_set_to_transparent (CRRgb *a_this, gboolean a_is_transparent)
 Sets the rgb to the "transparent" value (or not).
enum CRStatus cr_rgb_set_from_rgb (CRRgb *a_this, CRRgb *a_rgb)
 Sets the rgb from an other one.
enum CRStatus cr_rgb_set_from_name (CRRgb *a_this, const guchar *a_color_name)
enum CRStatus cr_rgb_set_from_hex_str (CRRgb *a_this, const guchar *a_hex)
enum CRStatus cr_rgb_set_from_term (CRRgb *a_this, const struct _CRTerm *a_value)
 Set the rgb from a terminal symbol.
enum CRStatus cr_rgb_copy (CRRgb *a_dest, CRRgb *a_src)
void cr_rgb_destroy (CRRgb *a_this)
 Destructor of CRRgb.
CRRgbcr_rgb_parse_from_buf (const guchar *a_str, enum CREncoding a_enc)
 Parses a text buffer that contains a rgb color.


Function Documentation

enum CRStatus cr_rgb_compute_from_percentage CRRgb a_this  ) 
 

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

Parameters:
a_this the current instance of CRRgb
Returns:

Definition at line 303 of file cr-rgb.c.

References _CRRgb::blue, CR_BAD_PARAM_ERROR, _CRRgb::green, _CRRgb::is_percentage, and _CRRgb::red.

enum CRStatus cr_rgb_copy CRRgb a_dest,
CRRgb a_src
 

Definition at line 551 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, and CRRgb.

Referenced by cr_rgb_set_from_rgb(), and cr_style_resolve_inherited_properties().

void cr_rgb_destroy CRRgb a_this  ) 
 

Destructor of CRRgb.

Parameters:
a_this the "this pointer" of the current instance of CRRgb.

Definition at line 566 of file cr-rgb.c.

void cr_rgb_dump CRRgb a_this,
FILE *  a_fp
 

Dumps the current instance of CRRgb to a file.

Parameters:
a_this the "this pointer" of the current instance of CRRgb.
a_fp the destination file pointer.

Definition at line 281 of file cr-rgb.c.

References cr_rgb_to_string().

gboolean cr_rgb_is_set_to_inherit CRRgb a_this  ) 
 

Definition at line 364 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, and _CRRgb::inherit.

Referenced by cr_style_resolve_inherited_properties().

gboolean cr_rgb_is_set_to_transparent CRRgb a_this  ) 
 

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

Parameters:
a_this the current instance of CRRgb
Returns:
TRUE if the rgb has been set to transparent, FALSE otherwise.

Definition at line 380 of file cr-rgb.c.

References _CRRgb::is_transparent.

CRRgb* cr_rgb_new void   ) 
 

The default constructor of CRRgb.

Returns:
the newly built instance of CRRgb

Definition at line 187 of file cr-rgb.c.

References cr_utils_trace_info, and CRRgb.

Referenced by cr_rgb_new_with_vals(), and cr_rgb_parse_from_buf().

CRRgb* cr_rgb_new_with_vals gulong  a_red,
gulong  a_green,
gulong  a_blue,
gboolean  a_is_percentage
 

A constructor of CRRgb.

Parameters:
a_red the red component of the color.
a_green the green component of the color.
a_blue the blue component of the color.
a_unit the unit of the rgb values. (either percentage or integer values)
Returns:
the newly built instance of CRRgb.

Definition at line 213 of file cr-rgb.c.

References _CRRgb::blue, cr_rgb_new(), CRRgb, _CRRgb::green, _CRRgb::is_percentage, and _CRRgb::red.

CRRgb* cr_rgb_parse_from_buf const guchar *  a_str,
enum CREncoding  a_enc
 

Parses a text buffer that contains a rgb color.

Parameters:
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

Definition at line 579 of file cr-rgb.c.

References cr_parser_destroy(), cr_parser_new_from_buf(), cr_parser_parse_term(), cr_parser_try_to_skip_spaces_and_comments(), cr_rgb_new(), cr_rgb_set_from_term(), cr_term_destroy(), CRParser, CRRgb, CRStatus, and CRTerm.

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.

Parameters:
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.

Definition at line 326 of file cr-rgb.c.

References _CRRgb::blue, CR_BAD_PARAM_ERROR, _CRRgb::green, _CRRgb::inherit, _CRRgb::is_percentage, _CRRgb::is_transparent, and _CRRgb::red.

Referenced by cr_rgb_set_from_hex_str(), cr_style_set_props_to_default_values(), and cr_style_set_props_to_initial_values().

enum CRStatus cr_rgb_set_from_hex_str CRRgb a_this,
const guchar *  a_hex
 

Definition at line 441 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, cr_rgb_set(), cr_rgb_set_to_transparent(), and CRStatus.

Referenced by cr_rgb_set_from_term().

enum CRStatus cr_rgb_set_from_name CRRgb a_this,
const guchar *  a_color_name
 

Definition at line 418 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, cr_rgb_set_from_rgb(), CRStatus, and name.

Referenced by cr_rgb_set_from_term().

enum CRStatus cr_rgb_set_from_rgb CRRgb a_this,
CRRgb a_rgb
 

Sets the rgb from an other one.

Parameters:
a_this the current instance of CRRgb.
a_rgb the rgb to "copy"
Returns:
CR_OK upon successful completion, an error code otherwise.

Definition at line 408 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, and cr_rgb_copy().

Referenced by cr_rgb_set_from_name(), and 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.

Parameters:
a_this the instance of CRRgb to set
a_value the terminal from which to set

Definition at line 500 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, cr_rgb_set_from_hex_str(), cr_rgb_set_from_name(), cr_rgb_set_from_rgb(), cr_utils_trace_info, CRStatus, _CRRgb::inherit, _CRRgb::is_transparent, TERM_HASH, TERM_IDENT, and TERM_RGB.

Referenced by cr_rgb_parse_from_buf().

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".

Parameters:
a_this the current instance of CRRgb

Definition at line 354 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, and _CRRgb::inherit.

Referenced by cr_style_set_props_to_default_values().

enum CRStatus cr_rgb_set_to_transparent CRRgb a_this,
gboolean  a_is_transparent
 

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

Parameters:
a_this the current instance of CRRgb
a_is_transparent set to transparent or not.

Definition at line 393 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, and _CRRgb::is_transparent.

Referenced by cr_rgb_set_from_hex_str(), cr_style_set_props_to_default_values(), and cr_style_set_props_to_initial_values().

guchar* cr_rgb_to_string CRRgb a_this  ) 
 

Serializes the rgb into a zero terminated string.

Parameters:
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().

Definition at line 237 of file cr-rgb.c.

Referenced by cr_rgb_dump(), cr_style_rgb_prop_val_to_string(), cr_term_one_to_string(), and cr_term_to_string().


Generated on Fri Oct 29 08:29:13 2004 for Libcroco by  doxygen 1.3.9.1