## Documentation

Table of Contents
Class Inheritance Tree
Widget Screenshots
Package groups

## Index

Package: Color

- Goto spec source

# Description

    package Gdk.Color is

This package provides an interface to the color handling facilities in gtk+. It is able to handle any kind of visual (monochrome, greyscale, color with different depths, ...), but provides a common and easy interface for all of them.

Some of these functions expect a Colormap. There are two ways you can get such a colormap, either a system default colormap or a per-widget colormap. It is recommended, unless you are writing your own new widget, to always use the system default Colormap. All the functions to get these colormaps are found in Gtk.Widget.

Getting the Red/Green/Blue components can be done through Parse, and is actually recommended, since the exact color generally depends on the visual your application is running on.

Note for users transitioning from gtk+ 1.2: the Get_System call is now obsolete, and you should use Gtk.Widget.Get_Default_Colormap instead.

Binding from C File version 1.3.6

# Types

### Gdk_Color

- Goto declaration in source
- Goto full declaration in source

    type Gdk_Color is private;

A color to be displayed on the screen. Currently, GtkAda only supports the RGB standard, ie each color is set by its red, green and blue components. An extra field (Pixel) is the internal representation of the color, which is set once the color has been allocated.

### Gdk_Color_Array

- Goto declaration in source

    type Gdk_Color_Array is array (Natural range <>) of Gdk_Color;

An array of colors.

### Gdk_Colormap

- Goto declaration in source

    subtype Gdk_Colormap is Gdk.Gdk_Colormap;

The set of colors the can be displayed on the screen. When the screen is not a true-color screen (ie there is only a limited number of possible colors, like 256), the colors are in fact indexes into a colormap, which gives the components of the color. This is the same concept as a palette.

### Property_Gdk_Color

- Goto declaration in source

    type Property_Gdk_Color is new Glib.Property;

# Constants & Global variables

### Null_Color

- Goto declaration in source
- Goto full declaration in source

(Gdk_Color)

    Null_Color : constant Gdk_Color;

No color. For most functions, this will select the default color in the context, although this exact specification depends on the function you want to use.

### Null_Colormap

- Goto declaration in source

(Gdk_Colormap)

    Null_Colormap : constant Gdk_Colormap;

### Wrong_Color

- Goto declaration in source

    Wrong_Color : exception;

Exception raised when some functions below could not find or allocate a color on the user's system.

# Subprograms & Entries

### Gdk_Color_Type

- Goto spec in source
- Goto body in source

    function Gdk_Color_Type return Glib.GType;

Return the internal gtk+ types associated with a color

### Gdk_Colormap_Type

- Goto spec in source
- Goto body in source

    function Gdk_Colormap_Type return Glib.GType;

Return the internal gtk+ types associated with a colormap

### Set_Rgb

- Goto spec in source

    procedure Set_Rgb (Color: out Gdk_Color;Red, Green, Blue: Guint16);

Modify the fields of the color. You then have to allocate the color with one of the Alloc* functions above.

### Set_Pixel

- Goto spec in source

    procedure Set_Pixel (Color: in out Gdk_Color;Pixel: Guint32);

This function should almost never be used. Instead, use Alloc_Color.

### Red

- Goto spec in source

    function Red (Color: Gdk_Color) return Guint16;

Return the Red field of Color.

### Green

- Goto spec in source

    function Green (Color: Gdk_Color) return Guint16;

Return the Green field of Color.

### Blue

- Goto spec in source

    function Blue (Color: Gdk_Color) return Guint16;

Return the Blue field of Color.

### Pixel

- Goto spec in source

    function Pixel (Color: Gdk_Color) return Guint32;

Return the Pixel field of Color.

### Gdk_New

- Goto spec in source

    procedure Gdk_New (Colormap: out Gdk_Colormap;Visual: Gdk.Visual.Gdk_Visual;Private_Cmap: Boolean);

Create a new colormap for the visual. If Private_Cmap is true, then the colormap won't be modifiable outside this scope. This might result in some strange colors on the display...

### Ref

- Goto spec in source
- Goto body in source

    procedure Ref (Colormap: Gdk_Colormap);

Increment the ref-count for the color.

### Unref

- Goto spec in source
- Goto body in source

    procedure Unref (Colormap: Gdk_Colormap);

Unref is the only way to destroy a colormap once you no longer need it. Note that because gtk+ uses reference counts, the colormap will not be actually destroyed while at least one object is using it.

### Change

- Goto spec in source

    procedure Change (Colormap: Gdk_Colormap;Ncolors: Gint);

Change the first Ncolors defined in Colormap.

### Alloc_Colors

- Goto spec in source

    procedure Alloc_Colors (Colormap: Gdk_Colormap;Colors: in out Gdk_Color_Array;Writeable: Boolean := False;Best_Match: Boolean := True;Success: out Boolean_Array;Result: out Gint);

Allocate a set of colors. The parameters are the same as for Alloc_Color Result is the number of colors not successfully allocated. The size of the Boolean_Array is equal to the length of the Colors_Array. Usage of an array of a different size will probably lead to a Constraint_Error.

### Alloc_Color

- Goto spec in source

    procedure Alloc_Color (Colormap: Gdk_Colormap;Color: in out Gdk_Color;Writeable: Boolean := False;Best_Match: Boolean := True;Success: out Boolean);

Allocate a new color. The fields RGB should have been set before calling this function. If Writeable is True, the color will be allocated read/write, that can be changed at any time. Not all visuals support this. On modern systems this usage has become less useful than before, since redrawing the screen with a new color is about as fast. If Best_Match is True, and the exact color can not be allocated, GtkAda will find the closest possible match, and modify the fields Red, Green and Blue of Color. Note that the allocation has more chances to succeed if Writeable is False and Best_Match is True. When you no longer use a color, you should call Free.

### Free_Colors

- Goto spec in source

    procedure Free_Colors (Colormap: Gdk_Colormap;Colors: Gdk_Color_Array);

Free Colors, assuming they are allocated in Colormap.

### Get_Visual

- Goto spec in source

    procedure Get_Visual (Colormap: Gdk_Colormap;Visual: out Gdk.Visual.Gdk_Visual);

Get the visual associated with a colormap. The main information you can get from there is the depth of the display.

### Copy

- Goto spec in source

    procedure Copy (Source: Gdk_Color;Destination: out Gdk_Color);

Copy the Source color to Destination.

### Parse

- Goto spec in source

    function Parse (Spec: String) return Gdk_Color;

Parse the string Spec, and get its Red/Green/Blue components. The color is not allocated, and you need to call Alloc_Color. If the string could not be parsed to an existing color, Wrong_Color is raised. The string can be one of : - "RGB:FF/FF/FF" where the "FF" substrings are respectively the value of the red, green and blue components. Some other prefixes than RGB are defined in the X11 definition, please see some X11 documentation (or the man page XParseColor on unix systems). - "color_name" which can be any color name defined in the file rgb.txt of the user's system. You should always check that Wrong_Color was not raised, in case the color was not known on the user's system. This string is case insensitive. Color names are not supported on Windows systems.

### Equal

- Goto spec in source

    function Equal (Colora, Colorb: Gdk_Color) return Boolean;

True if the Red, Green and Blue components of both colors are equal.

### Store

- Goto spec in source

    procedure Store (Colormap: Gdk_Colormap;Colors: Gdk_Color_Array);

Store the Colors in the Colormap.

### Alloc

- Goto spec in source

    procedure Alloc (Colormap: Gdk_Colormap;Contiguous: Boolean;Planes: Gulong_Array;Pixels: Gulong_Array;Succeeded: out Boolean);

Allocate some Read/Write color cells. Color cells' values can be changed dynamically. The pixels allocated are returned in Pixels. See XAllocColorCells(3) on Unix systems. The Planes parameter can be used to nondestructively overlay one set of graphics over another. See the X11 manual for more info. Note that this is a low-level function which you should rarely have to use.

### Free

- Goto spec in source

    procedure Free (Colormap: Gdk_Colormap;Pixels: Gulong_Array;Planes: Gulong);

Free some colors in the colormap. See XFreeColors(3) on Unix systems.

### White

- Goto spec in source

    function White (Colormap: Gdk_Colormap) return Gdk_Color;

Return the default white color for the colormap. If this color was not found or could not be allocated, Wrong_Color is raised.

### Black

- Goto spec in source

    function Black (Colormap: Gdk_Colormap) return Gdk_Color;

Return the default black colors for the colormap. If this color is not found or could not be allocated, Wrong_Color is raised.

### Alloc

- Goto spec in source

    procedure Alloc (Colormap: Gdk_Colormap;Color: in out Gdk_Color);

Same function as Alloc_Colors above, but for a single color. The color is allocated non-writeable, and the best-match is taken. Raises Wrong_Color if the color could not be allocated

### Change

- Goto spec in source

    procedure Change (Colormap: Gdk_Colormap;Color: in out Gdk_Color;Succeeded: out Boolean);

Change the Read/Write colormap cell corresponding to Color. The new value is the one contained in the Red, Green and Blue fields of Color.

### To_String

- Goto spec in source

    function To_String (Color: Gdk_Color) return String;

Return the RGB values of Color under the form "#RRGGBB". Directly usable by Parse, see above.

### Set_Property

- Goto spec in source

    procedure Set_Property (Object: access Glib.Object.GObject_Record'Class;Name: Property_Gdk_Color;Value: Gdk_Color);

### Get_Property

- Goto spec in source

    function Get_Property (Object: access Glib.Object.GObject_Record'Class;Name: Property_Gdk_Color) return Gdk_Color;

### Set_Value

- Goto spec in source

    procedure Set_Value (Value: out Glib.Values.GValue;Val: Gdk_Color);

### Get_Value

- Goto spec in source

    function  Get_Value (Value: Glib.Values.GValue) return Gdk_Color;

Store or retrieve a color from a value