Main Page | Alphabetical List | Data Structures | 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_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.

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 CR_BAD_PARAM_ERROR, and CR_OK.

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 480 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().

CRRgb* cr_rgb_new void   ) 
 

The default constructor of CRRgb.

Returns:
the newly built instance of CRRgb

Definition at line 185 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 211 of file cr-rgb.c.

References cr_rgb_new(), and CRRgb.

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 494 of file cr-rgb.c.

References CR_OK, 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 CR_BAD_PARAM_ERROR, and CR_OK.

Referenced by cr_rgb_set_from_hex_str(), cr_rgb_set_from_rgb(), and cr_style_set_props_to_defaults().

enum CRStatus cr_rgb_set_from_hex_str CRRgb a_this,
const guchar *  a_hex
 

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

References CR_BAD_PARAM_ERROR, CR_OK, cr_rgb_set(), CR_UNKNOWN_TYPE_ERROR, 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 363 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, CR_OK, cr_rgb_set_from_rgb(), CR_UNKNOWN_TYPE_ERROR, 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 352 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, CR_OK, and cr_rgb_set().

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 444 of file cr-rgb.c.

References CR_BAD_PARAM_ERROR, CR_OK, cr_rgb_set_from_hex_str(), cr_rgb_set_from_name(), cr_rgb_set_from_rgb(), CR_UNKNOWN_TYPE_ERROR, CRStatus, TERM_HASH, TERM_IDENT, and TERM_RGB.

Referenced by cr_rgb_parse_from_buf().

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 235 of file cr-rgb.c.

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


Generated on Sat Mar 20 02:38:50 2004 for Libcroco by doxygen 1.3.5