# Gdk::Color Class Reference

Gdk::Color is used to describe an allocated or unallocated color. More...

List of all members.

## Public Member Functions

| Color (GdkColor* gobject, bool make_a_copy=true)
| Color (const Color& other)
Color& | operator= (const Color& other)
| ~Color ()
void | swap (Color& other)
GdkColor* | gobj ()
| Provides access to the underlying C instance.
const GdkColor* | gobj () const
| Provides access to the underlying C instance.
GdkColor* | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
| Color ()
| Instantiate a new Gdk::Color.
| Color (const Glib::ustring&value)
| Instantiate a new Gdk::Color.
void | set_grey (gushort value)
| Set a grey color, by using the same value for all color components.
void | set_grey_p (double g)
void | set_rgb (gushort red_, gushort green_, gushort blue_)
| Set the color, by specifying red, green, and blue color component values.
void | set_rgb_p (double red_, double green_, double blue_)
| Set the color, by specifying red, green, and blue color component values, as percentages.
void | set_hsv (double h, double s, double v)
void | set_hsl (double h, double s, double l)
bool | set (const Glib::ustring&value)
| Parses a textual specification of a color and fills in the red, green, and blue values.
gushort | get_red () const
| Get the red component of the color.
gushort | get_green () const
| Get the green component of the color.
gushort | get_blue () const
| Get the blue component of the color.
void | set_red (gushort value)
| Set the red component of the color.
void | set_green (gushort value)
| Set the green component of the color.
void | set_blue (gushort value)
| Set the blue component of the color.
guint | get_pixel () const
| Get the pixel value, for allocated colors.
double | get_red_p () const
| Get the red component of the color, as a percentage.
double | get_green_p () const
| Get the green component of the color, as a percentage.
double | get_blue_p () const
| Get the blue component of the color, as a percentage.
Glib::ustring | to_string () const
| Get a textual specification of color in the hexadecimal form #rrrrggggbbbb, where r, g and b are hex digits representing the red, green and blue components respectively.

## Protected Attributes

GdkColor* | gobject_

## Related Functions

(Note that these are not member functions.)
bool | operator== (const Color& lhs, const Color& rhs)
bool | operator!= (const Color& lhs, const Color& rhs)
void | swap (Color& lhs, Color& rhs)
Gdk::Color | wrap (GdkColor* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Gdk::Color is used to describe an allocated or unallocated color.

It contains the following data: pixel: For allocated colors, the value used to draw this color on the screen. red: The red component of the color. This is a value between 0 and 65535, with 65535 indicating full intensitiy. green: The green component of the color. blue: The blue component of the color.

## Constructor & Destructor Documentation

Gdk::Color::Color | ( | GdkColor * | gobject,
|  | bool | make_a_copy = `true`
| ) |  | `[explicit]`

Gdk::Color::Color | ( | const Color& | other | ) |

Gdk::Color::~Color | ( |  | ) |

Gdk::Color::Color | ( |  | ) |

Instantiate a new Gdk::Color.

You should then use the set methods.

Gdk::Color::Color | ( | const Glib::ustring & | value | ) | `[explicit]`

Instantiate a new Gdk::Color.

The text string can be in any of the forms accepted by XParseColor; these include names for a color from rgb.txt, such as DarkSlateGray, or a hex specification such as 305050.

Parameters:

  value | the string specifying the color..

## Member Function Documentation

gushort Gdk::Color::get_blue | ( |  | ) | const

Get the blue component of the color.

Returns:
  The blue component of the color.

double Gdk::Color::get_blue_p | ( |  | ) | const

Get the blue component of the color, as a percentage.

Returns:
  The blue component of the color, as a percentage.

gushort Gdk::Color::get_green | ( |  | ) | const

Get the green component of the color.

Returns:
  The green component of the color.

double Gdk::Color::get_green_p | ( |  | ) | const

Get the green component of the color, as a percentage.

Returns:
  The green component of the color, as a percentage.

guint Gdk::Color::get_pixel | ( |  | ) | const

Get the pixel value, for allocated colors.

Returns:
  For allocated colors, the value used to draw this color on the screen.

gushort Gdk::Color::get_red | ( |  | ) | const

Get the red component of the color.

Returns:
  The red component of the color.

double Gdk::Color::get_red_p | ( |  | ) | const

Get the red component of the color, as a percentage.

Returns:
  The red component of the color, as a percentage.

const GdkColor* Gdk::Color::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C instance.

GdkColor* Gdk::Color::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C instance.

GdkColor* Gdk::Color::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.

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

bool Gdk::Color::set | ( | const Glib::ustring & | value | ) |

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

The text string can be in any of the forms accepted by XParseColor; these include names for a color from rgb.txt, such as DarkSlateGray, or a hex specification such as 305050.

Parameters:

  value | the string specifying the color.

Returns:
  true if the parsing succeeded.

void Gdk::Color::set_blue | ( | gushort | value | ) |

Set the blue component of the color.

Parameters:

  value | The blue component of the color.

void Gdk::Color::set_green | ( | gushort | value | ) |

Set the green component of the color.

Parameters:

  value | The green component of the color.

void Gdk::Color::set_grey | ( | gushort | value | ) |

Set a grey color, by using the same value for all color components.

Parameters:

  value | The value to be used for the red, green, and blue components.

void Gdk::Color::set_grey_p | ( | double | g | ) |

void Gdk::Color::set_hsl | ( | double | h,
|  | double | s,
|  | double | l
| ) |  |

void Gdk::Color::set_hsv | ( | double | h,
|  | double | s,
|  | double | v
| ) |  |

void Gdk::Color::set_red | ( | gushort | value | ) |

Set the red component of the color.

Parameters:

  value | The red component of the color.

void Gdk::Color::set_rgb | ( | gushort | red_,
|  | gushort | green_,
|  | gushort | blue_
| ) |  |

Set the color, by specifying red, green, and blue color component values.

Parameters:

  red_ | The red component of the color.
  green_ | The green component of the color.
  blue_ | The blue component of the color.

void Gdk::Color::set_rgb_p | ( | double | red_,
|  | double | green_,
|  | double | blue_
| ) |  |

Set the color, by specifying red, green, and blue color component values, as percentages.

Parameters:

  red_ | The red component of the color, as a percentage.
  green_ | The green component of the color, as a percentage.
  blue_ | The blue component of the color, as a percentage.

void Gdk::Color::swap | ( | Color& | other | ) |

Glib::ustring Gdk::Color::to_string | ( |  | ) | const

Get a textual specification of color in the hexadecimal form #rrrrggggbbbb, where r, g and b are hex digits representing the red, green and blue components respectively.

Returns:
  The string representation.

Since gtkmm 2.14:

## Friends And Related Function Documentation

bool operator!= | ( | const Color& | lhs,
|  | const Color& | rhs
| ) |  | `[related]`

Parameters:

  lhs | The left-hand side
  rhs | The right-hand side

Returns:
  The result

bool operator== | ( | const Color& | lhs,
|  | const Color& | rhs
| ) |  | `[related]`

Parameters:

  lhs | The left-hand side
  rhs | The right-hand side

Returns:
  The result

void swap | ( | Color& | lhs,
|  | Color& | rhs
| ) |  | `[related]`

Parameters:

  lhs | The left-hand side
  rhs | The right-hand side

Gdk::Color wrap | ( | GdkColor * | object,
|  | bool | take_copy = `false`
| ) |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

## Member Data Documentation

GdkColor* Gdk::Color::gobject_`[protected]`

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

- gdkmm/color.h