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.
Types |
---|
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.
| |
type Gdk_Color_Array is array (Natural range <>) of Gdk_Color; | |
An array of colors.
| |
type Gdk_Colormap is new C_Proxy; | |
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.
|
Subprograms |
---|
Creating and Destroying colors | ||
function Parse (Spec : in String) return Gdk_Color; | ||
Parse the string Spec, and get its Red/Green/Blue components.
| ||
procedure Alloc_Color (Colormap : in Gdk_Colormap; Color : in out Gdk_Color; Writeable : in Boolean; Best_Match : in Boolean; Success : out Boolean); | ||
Allocate a new color. | ||
procedure Alloc_Colors (Colormap : in Gdk_Colormap; Colors : in out Gdk_Color_Array; Writeable : in Boolean; Best_Match : in Boolean; Success : out Boolean_Array; Result : out Gint); | ||
Allocate a set of colors.
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.
| ||
procedure Alloc (Colormap : in Gdk_Colormap; Color : in out Gdk_Color); | ||
Same function as Alloc_Colors above, but for a single color. | ||
function White (Colormap : in Gdk_Colormap) return Gdk_Color; | ||
Return the default white color for the colormap. | ||
function Black (Colormap : in Gdk_Colormap) return Gdk_Color; | ||
Return the default black colors for the colormap. | ||
function Get_System return Gdk_Colormap; | ||
Get the default colormap for the system. | ||
procedure Get_Visual (Colormap : in Gdk_Colormap; Visual : out Gdk.Visual.Gdk_Visual); | ||
Get the visual associated with a colormap. | ||
procedure Gdk_New (Colormap : out Gdk_Colormap; Visual : in Gdk.Visual.Gdk_Visual; Private_Cmap : in Boolean); | ||
Create a new colormap for the visual. | ||
procedure Unref (Colormap : in Gdk_Colormap); | ||
Unref is the only way to destroy a colormap once you no longer need it. | ||
procedure Ref (Colormap : in Gdk_Colormap); | ||
Increment the ref-count for the color. | ||
function Get_System_Size return Gint; | ||
Return the number of entries in the default colormap on the system.
| ||
procedure Free_Colors (Colormap : in Gdk_Colormap; Colors : in Gdk_Color_Array); | ||
Free Colors, assuming they are allocated in Colormap.
| ||
procedure Store (Colormap : in Gdk_Colormap; Colors : in Gdk_Color_Array); | ||
Store the Colors in the Colormap
| ||
procedure Alloc (Colormap : in Gdk_Colormap; Contiguous : in Boolean; Planes : in Gulong_Array; Pixels : in Gulong_Array; Succeeded : out Boolean); | ||
Allocate some Read/Write color cells. | ||
procedure Free (Colormap : in Gdk_Colormap; Pixels : in Gulong_Array; Planes : in Gulong); | ||
Free some colors in the colormap. | ||
procedure Change (Colormap : in Gdk_Colormap; Color : in out Gdk_Color; Succeeded : out Boolean); | ||
Change the Read/Write colormap cell corresponding to Color. | ||
procedure Change (Colormap : in Gdk_Colormap; Ncolors : in Gint); | ||
Changes the first Ncolors defined in Colormap.
| ||
procedure Copy (Source : in Gdk_Color; Destination : out Gdk_Color); | ||
Copy the Source color to Destination.
| ||
function Equal (Colora, Colorb : in Gdk_Color) return Boolean; | ||
True if the Red, Green and Blue components of both colors are equal.
| ||
Setting/Getting the fields of Gdk_Color | ||
procedure Set_Rgb (Color : out Gdk_Color; Red, Green, Blue : in Gushort); | ||
Modify the fields of the color. | ||
procedure Set_Pixel (Color : in out Gdk_Color; Pixel : Gulong); | ||
This function should almost never be used. Instead, use Alloc_Color
| ||
function Red (Color : in Gdk_Color) return Gushort; | ||
Return the Red field of Color.
| ||
function Green (Color : in Gdk_Color) return Gushort; | ||
Return the Green field of Color.
| ||
function Blue (Color : in Gdk_Color) return Gushort; | ||
Return the Blue field of Color.
| ||
function Pixel (Color : in Gdk_Color) return Gulong; | ||
Return the Pixel field of Color.
|
Example |
---|
-- Here is an example how you can allocate a new color, when you know -- its red/green/blue components: Color : Gdk_Color; Success : Boolean; Set_Rbg (Color, 255, 255, 255); Alloc_Color (Colormap => Gtk.Widget.Get_Default_Colormap, Color => Color, Writeable => False, Best_Match => True, Success => Success); if not Success then ...; -- allocation failed end if;