Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Gdk::Color Class Reference

A GdkColor C++ wrapper class. More...

`#include <inti/gdk/color.h>`

Inheritance diagram for Inti::Gdk::Color:

List of all members.

## Public Member Functions

Constructors

- Color ()
    Construct the default color black.
- Color (const char *spec)
    Constructs a color object by parsing the textual specification of a color and filling in the red, green, and blue fields.
- Color (unsigned short value)
    Constructs a greyscale color by setting red, green and blue to value.
- Color (unsigned short r, unsigned short g, unsigned short b)
    Construct a color with the specified values.
- Color (GdkColor *color)
    Construct a new color from an existing GdkColor.
- Color (GdkColor *color, bool copy)
    Construct a new color from an existing GdkColor.
- Color (const Color &src)
    Copy constructor.
- ~Color ()
    Destructor.
- Color & operator= (const Color &src)
    Assignment operator.

Accessors

- GdkColor * gdk_color () const
    Get a pointer to the GdkColor structure.
- operator GdkColor * () const
    Conversion operator; safely converts a Color to a GdkColor pointer.
- unsigned short get_red () const
    Returns the red component of the color.
- unsigned short get_green () const
    Returns the green component of the color.
- unsigned short get_blue () const
    Returns the blue component of the color.
- unsigned long get_pixel () const
    For allocated colors, returns the value used to draw this color on the screen.
- void get (unsigned short &r, unsigned short &g, unsigned short &b) const
    Returns the red, green and blue component values.
- bool equal (const Color &other) const
    Compares this color with other.
- bool operator== (const Color &other)
    Equality operator; compares this color with other.
- bool operator!= (const Color &other)
    Inequality operator; compares this color with other.

Methods

- void set_red (unsigned short r)
    Sets the red component of the color.
- void set_green (unsigned short g)
    Sets the green component of the color.
- void set_blue (unsigned short b)
    Sets the blue component of the color.
- void set_pixel (unsigned long p)
    Sets the pixel value.
- void set_grey (unsigned short value)
    Sets a greyscale color by setting the red, green and blue components to value.
- void set (unsigned short r, unsigned short g, unsigned short b)
    Sets the red, green and blue components to the specified values.
- bool parse (const char *spec)
    Parses a textual specification of a color and fills in the red, green, and blue fields.
- unsigned int hash () const
    A hash function suitable for using for a hash table that stores Gdk::Color's.
- bool allocate (const Screen *screen=0)
    Allocates the color as read-only and best match, using the default system colormap for screen.
- void free (const Screen *screen=0)
    Frees a color previously allocated by allocate(), using the default system colormap for screen.

## Detailed Description

A GdkColor C++ wrapper class.

The Color object is used to describe an allocated or unallocated color.

## Constructor & Destructor Documentation

Inti::Gdk::Color::Color | ( | const char * | spec | ) | `[explicit]`

Constructs a color object by parsing the textual specification of a color and filling in the red, green, and blue fields.

Parameters:

  spec | The string specifying the color.

The color is not allocated, you must call allocate() or Gdk::Colormap::alloc_color() yourself. The text string can be in any of the forms accepted by XParseColor; these include the name for a color from rgb.txt, such as DarkSlateGray, or a hex specification such as 305050.

Inti::Gdk::Color::Color | ( | unsigned short | value | ) | `[explicit]`

Constructs a greyscale color by setting red, green and blue to value.

Parameters:

  value | A value between 0 and 65535.

Inti::Gdk::Color::Color | ( | unsigned short | r,
|  | unsigned short | g,
|  | unsigned short | b
| ) |

Construct a color with the specified values.

Parameters:

  r | The red component of the color, a value between 0 and 65535.
  g | The green component of the color.
  b | The blue component of the color.

Inti::Gdk::Color::Color | ( | GdkColor * | color | ) | `[explicit]`

Construct a new color from an existing GdkColor.

Parameters:

  color | A pointer to a GdkColor.

The color can be a newly created GdkColor or an existing GdkColor. The Color object created is a temporary object. It doesn't take over the ownership of GdkColor and GdkColor is not freed by the destructor.

Inti::Gdk::Color::Color | ( | GdkColor * | color,
|  | bool | copy
| ) |

Construct a new color from an existing GdkColor.

Parameters:

  color | A pointer to a GdkColor.
  copy | Whether the Color object should make a copy of GdkColor or not.

The color can be a newly created GdkColor or an existing GdkColor. If copy is true Color will make a copy of GdkColor. If copy is false Color wont make a copy but instead takes over the ownership of GdkColor. Either way, the destructor will free GdkColor when the Color object is destroyed. This constructor is used by G::Boxed::wrap() to wrap GdkColor objects in a C++ wrapper.

Inti::Gdk::Color::Color | ( | const Color & | src | ) |

Copy constructor.

Parameters:

  src | The source color.

## Member Function Documentation

bool Inti::Gdk::Color::allocate | ( | const Screen * | screen = 0 | ) |

Allocates the color as read-only and best match, using the default system colormap for screen.

Parameters:

  screen | The Screen to use, or null for the default screen.

bool Inti::Gdk::Color::equal | ( | const Color & | other | ) | const

Compares this color with other.

Parameters:

  other | The color to compare.

Returns:
  true if the two colors compare equal.

void Inti::Gdk::Color::free | ( | const Screen * | screen = 0 | ) |

Frees a color previously allocated by allocate(), using the default system colormap for screen.

Parameters:

  screen | The Screen to use, or null for the default screen.

void Inti::Gdk::Color::get | ( | unsigned short & | r,
|  | unsigned short & | g,
|  | unsigned short & | b
| ) | const

Returns the red, green and blue component values.

Parameters:

  r | The location to store the red component, a value between 0 and 65535.
  g | The location to store the green component.
  b | The location to store the blue component.

unsigned short Inti::Gdk::Color::get_red | ( |  | ) | const

| Returns the red component of the color. This is a value between 0 and 65535, with 65535 indicating full intensitiy.

unsigned int Inti::Gdk::Color::hash | ( |  | ) | const

A hash function suitable for using for a hash table that stores Gdk::Color's.

Returns:
  The hash function applied to this color.

bool Inti::Gdk::Color::operator!= | ( | const Color & | other | ) |

Inequality operator; compares this color with other.

Parameters:

  other | The color to compare.

Returns:
  true if the two colors compare unequal.

Color& Inti::Gdk::Color::operator= | ( | const Color & | src | ) |

Assignment operator.

Parameters:

  src | The source color.

bool Inti::Gdk::Color::operator== | ( | const Color & | other | ) |

Equality operator; compares this color with other.

Parameters:

  other | The color to compare.

Returns:
  true if the two colors compare equal.

bool Inti::Gdk::Color::parse | ( | const char * | spec | ) |

Parses a textual specification of a color and fills in the red, green, and blue fields.

Parameters:

  spec | The string specifying the color.

Returns:
  true if the parsing succeeded.

The color is not allocated, you must call allocate() or Gdk::Colormap::alloc_color() yourself. The text string can be in any of the forms accepted by XParseColor; these include the name for a color from rgb.txt, such as DarkSlateGray, or a hex specification such as 305050.

void Inti::Gdk::Color::set | ( | unsigned short | r,
|  | unsigned short | g,
|  | unsigned short | b
| ) |

Sets the red, green and blue components to the specified values.

Parameters:

  r | The red component of the color, a value between 0 and 65535.
  g | The green component of the color.
  b | The blue component of the color.

void Inti::Gdk::Color::set_blue | ( | unsigned short | b | ) |

Sets the blue component of the color.

Parameters:

  b | The blue component, a value between 0 and 65535,

void Inti::Gdk::Color::set_green | ( | unsigned short | g | ) |

Sets the green component of the color.

Parameters:

  g | The green component, a value between 0 and 65535,

void Inti::Gdk::Color::set_grey | ( | unsigned short | value | ) |

Sets a greyscale color by setting the red, green and blue components to value.

Parameters:

  value | A value between 0 and 65535.

void Inti::Gdk::Color::set_pixel | ( | unsigned long | p | ) |

Sets the pixel value.

Parameters:

  p | The pixel value.

void Inti::Gdk::Color::set_red | ( | unsigned short | r | ) |

Sets the red component of the color.

Parameters:

  r | The red component, a value between 0 and 65535,

The documentation for this class was generated from the following file:

- color.h

Main Page - Footer