CLIM mail archive

[Prev][Next][Index][Thread]

CLIM problem



    Date: Mon, 11 Nov 1991 10:52 EST
    From: Jean-Pascal Baechler <baech_jp@liasun3.epfl.ch>

    I am currently writing an user interface using CLIM and I am trying
    to deal with a problem : I need two (this is a DeLuxe user interface
    ...) graphical representation for an object in two separate windows.
    I think that this is possible by specializing the present method on
    the view argument, but I don't know how to create my own views and
    how to manipule them. This is a very disturbing feeling.

As you know, the ACCEPT and PRESENT methods both take view arguments
that can be specialized on.  All you need to do is define a view class,
and then write a presentation method that class specializes it.

 (in-package :clim-user)
 
 (defclass mc-text-view (view))
 (defclass mc-folder-view (view))
 
 (define-presentation-type mc-pathname ())
 
 (define-presentation-method present (object (type mc-pathname) stream (view mc-text-view) &key)
   ;;--- Present the object as a pathname, textually
   )
 
 (define-presentation-method present (object (type mc-pathname) stream (view mc-folder-view) &key)
   ;;--- Present the object as a file folder
   )

Then you just call PRESENT:

 (present a-pathname 'mc-pathname :stream s :view (make-instance 'mc-folder-view))

If the views will never be parameterized (that is, have no slots), you
can create a single instance of a view so that you don't have to cons it
constantly.  However, you could parameterize the view (to indicate the
size and color of the file folder, perhaps), and then the PRESENT method
can look at the slots of the view to figure out what to do.

Exercise for the interested would-be CLIM designer: how would you use
views to implement an interface to toolkit gadgets, presuming that the
gadgets are already implemented for you?  For example, suppose I want to
do this inside of ACCEPTING-VALUES:

 (accept '(real 0 10) :view (make-instance 'slider :orientation :horizontal))

0,,

References:

Main Index | Thread Index