english
version "1.0"
identify "xyz"

#: Copyright (c) 1994, 1995, 1997 by Wayne C. Gramlich.
#, All rights reserved.
#,
#, Permission to use, copy, modify, distribute, and sell this software
#, for any purpose is hereby granted without fee provided that the above
#, copyright notice and this permission are retained.  The author makes
#, no representations about the suitability of this software for any purpose.
#, It is provided "as is" without express or implied warranty.

module xlib_color

#: This module implements an Xlib {XColor} object.

import
    address
    logical
    out_stream
    string
    unsigned
    xlib_color_map
    xlib_pixel
    xlib_screen


define xlib_color
    external



#: {xlib_color} routines:

procedure address_get@xlib_color
    takes
	color xlib_color
    returns address
    external xlib_color__address_get

    #: This procedure will return the address assocaiated with {color}.


procedure blue_get@xlib_color
    takes
	color xlib_color
    returns unsigned
    external xlib_color__blue_get

    #: This procedure will return blue intensity of {color} as a number
    #, between 0 and 2**16-1 (65535).


procedure blue_set@xlib_color
    takes
	color xlib_color
	value unsigned
    returns_nothing
    external xlib_color__blue_get

    #: This procedure will set the blue intensity of {color} to {value}
    #, (which must be between 0 and 2**16-1 (65535)).


procedure create@xlib_color
    takes
	color_map xlib_color_map
    returns xlib_color
    external xlib_color__create

    # This procedure will allocate and return a {color} object for
    # {color_map}.  No color slot is allocated from {color_map};
    # use {color_allocate}@{xlib_color_map}() for that purpose!


procedure green_get@xlib_color
    takes
	color xlib_color
    returns unsigned
    external xlib_color__green_get

    #: This procedure will return green intensity of {color} as a number
    #, between 0 and 2**16-1 (65535).


procedure green_set@xlib_color
    takes
	color xlib_color
	value unsigned
    returns_nothing
    external xlib_color__green_set

    #: This procedure will set the green intensity of {color} to {value}
    #, (which must be between 0 and 2**16-1 (65535)).


procedure identical@xlib_color
    takes
	color1 xlib_color
	color2 xlib_color
    returns logical

    #: This procedure will return {true} if {color1} is identical to
    #, {color2}.

    return color1.address = color2.address


procedure pixel_get@xlib_color
    takes
	color xlib_color
    returns xlib_pixel
    external xlib_color__pixel_get

    #: This procedure will return the pixel associated with {color}.


procedure print@xlib_color
    takes
	color xlib_color
	out_stream out_stream
    returns_nothing

    #: This procedure will print the contents of {color} to {out_stream}.

    put@('{address=', out_stream)
    print@(color.address, out_stream)
    put@(', red=', out_stream)
    print@(color.red, out_stream)
    put@(', green=', out_stream)
    print@(color.green, out_stream)
    put@(', blue=', out_stream)
    print@(color.blue, out_stream)
    put@("}", out_stream)


procedure red_get@xlib_color
    takes
	color xlib_color
    returns unsigned
    external xlib_color__red_get

    #: This procedure will return red intensity of {color} as a number
    #, between 0 and 2**16-1 (65535).


procedure red_set@xlib_color
    takes
	color xlib_color
	value unsigned
    returns_nothing
    external xlib_color__red_set

    #: This procedure will set the red intensity of {color} to {value}
    #, (which must be between 0 and 2**16-1 (65535).)


