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) Why can't I get the :scroll-bar option to the list-pane gadget to work?


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 (especially when patched with ACL 4.2 patch3344, but that simply brought an existing problem to the fore), 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 1.2 to work properly. The problem often first shows up after loading ACL 4.2 patch3344. However, the problem is not with the patch because even without that patch there are potential problems - for example doing a cut-and-paste between Motif text-fields will cause a segmentation violation.

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. When the associated colormap overflows, the PALETTE-FULL condition is signaled. The default palette (i.e., the palette returned by PORT-DEFAULT-PALETTE) is associated with the screen's default colormap - This is usually shared with other applications. 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.

In order to determine if you need a new palette you should try and allocate all of your colors in the default palette prior to creating any frames. You can do this with...

(apply #'add-colors-to-palette
  (port-default-palette (find-port)) list-of-colors)

This will either successfully allocate all the colors in the associated colormap or fail (with a palette-full condition) and not allocate any colors. In the latter case you should create a frame-manager with a new palette and use this to create any frames e.g.,

(let ((port (find-port)))
  (make-application-frame
   'clim-demo::puzzle
   :frame-manager (find-frame-manager :palette (make-palette port)
                                      :port port)))

In the next release of ACL CLIM the default behavior will be to use the closest available color when the palette fills up. Alternatively an application can choose to have an error signaled and then via a handler programmatically invoke a restart to use a particular alternative color.


Q 4.3-4) Why can't I get the :scroll-bar option to the list-pane gadget to work?

A 4.3-4) The documentation is in error. The list-pane gadget class doesn't take a :scroll-bars initarg. (On the other hand the list-pane-view class does take a :scroll-bar initarg)

If you want your list-pane to have scroll-bars you should wrap it in a scroller pane. You can do this either in the panes specification or in the layout specification. e.g., using

(scrolling ()
  (make-pane 'list-pane ...)

Moreover there is a bug in Motif 1.2.2 involving scroll-bars. Also CLIM 2.0 final doesn't handle the :vertical case properly - it produces both horizontal and vertical scroll-bars.

You shouldn't use :dynamic or :horizontal as this exposes the toolkit bug.

The toolkit bug appears to be fixed in Motif 1.2.4. Along with changes to the CLIM backend this is now fixed so that all cases work except for the :horizontal case which behaves as :both. This appears to be an unavoidable consequence of the Motif XmList widget interface.

In the meantime you should use either :both, :vertical or t - all of which will have the effect of always adding both scroll-bars.


© Copyright 1998, Franz Inc., Berkeley, CA.  All rights reserved.
$Revision: 1.1.2.7 $