Ardour  8.7-14-g57a6773833
Gdk::Color Class Reference

#include <color.h>

Public Member Functions

 Color (GdkColor *gobject, bool make_a_copy=true)
 
 Color (const Color &other)
 
Coloroperator= (const Color &other)
 
 ~Color ()
 
void swap (Color &other)
 
GdkColorgobj ()
 Provides access to the underlying C instance. More...
 
const GdkColorgobj () const
 Provides access to the underlying C instance. More...
 
GdkColorgobj_copy () const
 Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. More...
 
 Color ()
 
 Color (const Glib::ustring &value)
 
void set_grey (gushort value)
 
void set_grey_p (double g)
 
void set_rgb (gushort red_, gushort green_, gushort blue_)
 
void set_rgb_p (double red_, double green_, double blue_)
 
void set_hsv (double h, double s, double v)
 
void set_hsl (double h, double s, double l)
 
bool set (const Glib::ustring &value)
 
bool parse (const Glib::ustring &spec)
 
gushort get_red () const
 
gushort get_green () const
 
gushort get_blue () const
 
void set_red (gushort value)
 
void set_green (gushort value)
 
void set_blue (gushort value)
 
void rgb_find_color (const Glib::RefPtr< Gdk::Colormap > &map)
 
guint get_pixel () const
 
double get_red_p () const
 
double get_green_p () const
 
double get_blue_p () const
 
Glib::ustring to_string () const
 

Static Public Member Functions

static GType get_type () G_GNUC_CONST
 

Protected Attributes

GdkColorgobject_
 

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)
 

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.

Definition at line 54 of file color.h.

Constructor & Destructor Documentation

◆ Color() [1/4]

Gdk::Color::Color ( GdkColor gobject,
bool  make_a_copy = true 
)
explicit

◆ Color() [2/4]

Gdk::Color::Color ( const Color other)

◆ ~Color()

Gdk::Color::~Color ( )

◆ Color() [3/4]

Gdk::Color::Color ( )

Instantiate a new Gdk::Color. You should then use the set methods and call Gdk::Colormap::alloc_color().

◆ Color() [4/4]

Gdk::Color::Color ( const Glib::ustring &  value)
explicit

Instantiate a new Gdk::Color. The color is not allocated - you must call Gdk::Colormap::alloc_color() yourself. 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
valuethe string specifying the color..

Member Function Documentation

◆ get_blue()

gushort Gdk::Color::get_blue ( ) const

Get the blue component of the color.

Returns
The blue component of the color.

◆ get_blue_p()

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.

◆ get_green()

gushort Gdk::Color::get_green ( ) const

Get the green component of the color.

Returns
The green component of the color.

◆ get_green_p()

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.

◆ get_pixel()

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.

◆ get_red()

gushort Gdk::Color::get_red ( ) const

Get the red component of the color.

Returns
The red component of the color.

◆ get_red_p()

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.

◆ get_type()

static GType Gdk::Color::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GdkColor* Gdk::Color::gobj ( )
inline

Provides access to the underlying C instance.

Definition at line 77 of file color.h.

◆ gobj() [2/2]

const GdkColor* Gdk::Color::gobj ( ) const
inline

Provides access to the underlying C instance.

Definition at line 80 of file color.h.

◆ gobj_copy()

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.

◆ operator=()

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

◆ parse()

bool Gdk::Color::parse ( const Glib::ustring &  spec)

◆ rgb_find_color()

void Gdk::Color::rgb_find_color ( const Glib::RefPtr< Gdk::Colormap > &  map)

This will fill in the pixel field with the best matching pixel from a color cube. The color is then ready to be used for drawing, e.g. you can call Gdk::GC::set_foreground() which expects pixel to be initialized. Call this after setting the red, green, and blue fields.

In many cases, you can avoid this whole issue by calling Gdk::GC::set_rgb_fg_color() or Gdk::GC::set_rgb_bg_color(), which do not expect pixels to be initialized in advance. If you use those methods, there's no need for this method().

Parameters
mapThe colormap for the graphics context and drawable you're using to draw. If you're drawing to a Gtk::Widget, call Gtk::Widget::get_colormap().

◆ set()

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 color is not allocated - you must call Gdk::Colormap::alloc_color() yourself. 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
valuethe string specifying the color.
Returns
true if the parsing succeeded.

◆ set_blue()

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

Set the blue component of the color.

Parameters
valueThe blue component of the color.

◆ set_green()

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

Set the green component of the color.

Parameters
valueThe green component of the color.

◆ set_grey()

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

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

Parameters
valueThe value to be used for the red, green, and blue components.

◆ set_grey_p()

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

◆ set_hsl()

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

◆ set_hsv()

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

◆ set_red()

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

Set the red component of the color.

Parameters
valueThe red component of the color.

◆ set_rgb()

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.

◆ set_rgb_p()

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.

◆ swap()

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

◆ to_string()

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.

Friends And Related Function Documentation

◆ operator!=()

bool operator!= ( const Color lhs,
const Color rhs 
)
related
Parameters
lhsThe left-hand side
rhsThe right-hand side
Returns
The result

◆ operator==()

bool operator== ( const Color lhs,
const Color rhs 
)
related
Parameters
lhsThe left-hand side
rhsThe right-hand side
Returns
The result

◆ swap()

void swap ( Color lhs,
Color rhs 
)
related
Parameters
lhsThe left-hand side
rhsThe right-hand side

Definition at line 275 of file color.h.

◆ wrap()

Gdk::Color wrap ( GdkColor object,
bool  take_copy = false 
)
related

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

Parameters
objectThe C instance.
take_copyFalse 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

◆ gobject_

GdkColor* Gdk::Color::gobject_
protected

Definition at line 86 of file color.h.


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