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_map

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

import
    address
    logical
    out_stream
    string
    unsigned
    xlib_color
    xlib_screen
    xlib_visual


define xlib_color_map	#: The color map object
    external


#: {xlib_color_map} routines:


procedure address_get@xlib_color_map
    takes
	color_map xlib_color_map
    returns address
    external xlib_color_map__address_get

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


procedure color_allocate@xlib_color_map
    takes
	color_map xlib_color_map
	color xlib_color
    returns logical
    external xlib_color_map__color_allocate

    #: This procedure will allocate the closest color to {color} in
    #, {color_map}.  If a color is successfully allocated, the color
    #, values are stored and color id are stored into {color} and
    #, {false} is returned.  If no color is allocated, {false} is
    #, returned.


procedure create@xlib_color_map
    takes
	screen xlib_screen
	visual xlib_visual
	allocate_color_map logical
    returns xlib_color_map
    external xlib_color_map__create

    #: This procedure will create and return an {xlib_color_map} object.
    #, The returned color map will will be
    #, associated with {screen} and {visual}.  If {allocate_color_map}
    #, is {true}, all of the color map entries are allocated as read/write
    #, color map cells; otherwise, none are allocated.


procedure lookup@xlib_color_map
    takes
	color_map xlib_color_map
	color_name string
    returns xlib_color
    external xlib_color_map__lookup

    #: This procedure will lookup the color associated with {name} for
    #, use with {color_map}.


procedure print@xlib_color_map
    takes
	color_map xlib_color_map
	out_stream out_stream
    returns_nothing

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

    put@('{address=', out_stream)
    print@(color_map.address, out_stream)
    put@("}", out_stream)


#: {xlib_screen} routines:


procedure color_map_default_get@xlib_screen
    takes
	screen xlib_screen
    returns xlib_color_map
    external xlib_screen__color_map_default_get

    #: This procedure will return the default color_map associated with
    #, {screen}.


