All Manuals > CAPI User Guide > 14 The Color System

NextPrevUpTopContentsIndex

14.4 Color aliases

You can enter a color alias in the color database using the function define-color-alias . You can remove an entry in the color database using delete-color-translation .

define-color-alias makes an entry in the color database under a name, which should be a symbol. LispWorks by convention uses keyword symbols. The name points to either a color-spec or another color name (symbol):

(define-color-alias :wire-color :darkslategray)

Attempting to replace an existing color-spec in the color database results in an error. By default, replacement of existing aliases is allowed but there is an option to control this (see the LispWorks CAPI Reference Manual entry for define-color-alias).

delete-color-translation removes an entry from the color-database. Both original entries and aliases can be removed:

(delete-color-translation :wire-color)

As described in Color specs, the function get-color-spec returns the color-spec associated with a color alias. The function get-color-alias-translation returns the ultimate color name for an alias:

(define-color-alias :lispworks-blue 
            (make-rgb 0.70s0 0.90s0 0.99s0))
(define-color-alias :color-background 
                   :lispworks-blue)
(define-color-alias :listener-background 
                   :color-background)
(get-color-alias-translation :listener-background)
         => :lispworks-blue
(get-color-alias-translation :color-background)
         => :lispworks-blue

There is a system-defined color alias :transparent which is useful when specified as the background of a pane. It is currently supported only on Cocoa. For example:

(capi:popup-confirmer
 (make-instance 'capi:display-pane
                :text
                (format nil "The background of this pane~%is transparent")
                :background :transparent)  
 "")

CAPI User Guide (Unix version) - 30 Aug 2011

NextPrevUpTopContentsIndex