### 4.3: CLIM

Q 4.3-1) How do I provide scrollable popup menus in Allegro CLIM 2.x?
Q 4.3-2) Why do I need an XNLSPATH environment variable?
Q 4.3-3) What should I do to avoid getting palette-full error messages?
Q 4.3-4) CLIM does not work on RedHat 9 with OpenMotif 2.2.2. Why not?

Go to main FAQ page.

Q 4.3-1) How do I provide scrollable popup menus in Allegro CLIM 2.x?

A 4.3-1) Motif doesn't support scrollable popup menus. CLIM 2.2 supports :scroll-bars t but by using an old CLIM 1 presentation style menu rather than a native Motif widget based menu.

However, a better solution may be to use a a popup dialog with a scrollable list-pane. This can be done with the following code. In a real application you might want to avoid recreating a new application frame for each popup. However, this code is presented here to be as simple as possible.

    (in-package :clim-user)

    (define-application-frame selection-frame ()
      ((items :initarg :items)
       (select-callback :initarg :select-callback))
      (:panes
       (menu
        (with-slots (items select-callback) *application-frame*
            (make-pane 'list-pane
                       :items items
                       :visible-items (min 10 (length items))
                       :value-changed-callback select-callback))))
      (:layouts
       (default
           (scrolling (:scroll-bars :dynamic)
             menu)))
      (:menu-bar nil))

    (defun popup-selection-frame (items)
      (flet ((select-callback (gadget value)
               (declare (ignore gadget))
               (return-from popup-selection-frame value)))
        (run-frame-top-level
         (make-application-frame 'selection-frame
                                 :items items
                                 :select-callback #'select-callback))))

Q 4.3-2) Why do I need an XNLSPATH environment variable?

A 4.3-2) In order for CLIM to work, it must be able to find the xnls directory and it tries to do so via the XNLSPATH environment variable. See 3 paragraphs below for the standard location.

You need to supply an nls directory for Motif to work properly.

The error mode is unfortunate since the toolkit calls exit() directly rather than signaling an Xlib error. In post-CLIM2.0 versions CLIM will test for the Locale Database directly and will give a Lisp (hence recoverable) error message prior to startup.

If you have a standard X11R5 distribution you should find the nls directory in /usr/lib/X11 and you should set XNLSPATH to point to it. If you don't have a standard X11R5 distribution we can mail you a tar file of the directory which you should install and set XNLSPATH to point to. You can distribute the directory freely as it's part of the standard X11R5 distribution. Let us know if you would like us to send you this tar file.

Q 4.3-3) What should I do to avoid getting palette-full error messages?

A 4.3-3) CLIM's palettes are associated with X colormaps. The size of X colormaps is small, often 256 colors. To make matters worse, the default colormap is shared by all applications on your desktop. Applications such as Netscape may use up most of the colormap and leave CLIM with little to work with.

If you encounter problems, you should consider allocating your own private colormap for CLIM. CLIM allows you to create a new palette associated with a new colormap so that your application gets exclusive use of that colormap. The downside of this is that because typical display servers only have one hardware colormap, all windows of other applications will appear in "technicolor" while your CLIM app has the focus.

Here is how you change CLIM's default color palette.

    (setq port (clim:find-port))
    (setq framem (clim:find-frame-manager :port port))
    (setq palette (clim:make-palette port))
    (setf (clim:frame-manager-palette framem) palette)
    (setf (slot-value port 'silica::default-palette) palette)

Nevertheless, if the palette becomes full, CLIM normally does not signal an error but instead uses the "nearest" color that already exists in the colormap. It may not look quite right, but execution will continue.

This is not true for "dynamic" colors. Dynamic colors have special properties and should only be used when those special properties are required. You can change the rgb values of a dynamic color and cause all renderings of that color to change dynamically without redrawing. Attempting to allocate a dynamic color when the palette is full will signal an error because the "nearest" color will not be a dynamic color.

Q 4.3-4) CLIM does not work on RedHat 9 with OpenMotif 2.2.2. Why not?

A 4.3-4) You need to install runtime support for it. Install the package (on the RedHat 9 CD's) openmotif21-2.1.3--8.i386.rpm.

Next FAQ topic: 4.4. Common Graphics and the Integrated Development Environment

Previous FAQ topic: 4.2. Lisp-Editor Protocol (LEP)

© Copyright 1999, 2002, 2004, Franz Inc., Berkeley, CA. All rights reserved.
$Revision: 1.1.1.1 $