CLIM mail archive

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

Standalone Windows Resource?



    Date: Tue, 7 Jul 1992 19:30 EDT
    From: will taylor <taylor@charon.arc.nasa.gov>

    I am using CLIM 1.0 (27.5) under Genera 8.1.1

    I would like to pop-up a window over my application frame
    which has :scroll-bars :both and whose size I can determine.
    I can use OPEN-WINDOW-STREAM & WINDOW-EXPOSE to display the
    window.  But if I want it to appear under the cursor I need to 
    be able to move its location and re-size it OR be able to
    return the window to the "window-resource" and then create
    a new one with the size and location I desire.

    I guess what I am looking for is a window analog to WITH-MENU
    & MENU-CHOSE-FROM-DRAWER which has both scroll bars and gives
    me control over its size.  Anyone know how to do something 
    like this.

Here is what CLIM uses to define WITH-MENU resources:

 (defresource menu (associated-window root)
   :constructor (open-window-stream :parent root        ;"random" size
                                    :left 100 :top 100 :width 300 :height 200
                                    :scroll-bars ':vertical
                                    :window-class (menu-class-name root)
                                    :save-under T)
   :initializer (initialize-menu menu associated-window)
   :deinitializer (progn (setf (window-visibility menu) nil)
                         (window-clear menu)
                         (setf (window-label menu) nil))
   :matcher (eql (window-parent menu) root))
 
 (defmacro with-menu ((menu &optional (associated-window nil aw-p)) &body body)
   (let ((window '#:associated-window))
     `(let ((,window ,(if aw-p
                          associated-window
                          `(frame-top-level-window *application-frame*))))      ;once-only
        (using-resource (,menu menu (window-top-level-window ,window) (window-root ,window))
          (letf-globally (((stream-default-view ,menu) +menu-view+))
            ,@body)))))

You can call the two (internal) functions SIZE-MENU-APPROPRIATELY
(which computes the size based on what is in the output history) and
POSITION-WINDOW-NEAR-CAREFULLY to set the size and position of the
window once you have gooten it from the resource.  The typical thing
to do is (in this order):
 - allocate a window from the resource
 - compute its contents
 - call CLIM::SIZE-MENU-APPROPRIATELY
 - call CLIM::POSITION-WINDOW-NEAR-CAREFULLY
 - call WINDOW-EXPOSE


References:

Main Index | Thread Index