Re: Adding gadgets to frames at run time

Paolo Amoroso <[email protected]> Mon, 21 Jun 2004 17:48:49 +0200
Newsgroups gmane.lisp.clim
Organization Paolo Amoroso - Milano, ITALY
Message-ID <[email protected]>
Paolo Amoroso <[email protected]> writes:

> Is it possible to add gadgets at run time to a frame layout,
> i.e. gadgets that are not yet known when the frame is defined?  Is

Andy Hefner suggested to create the pane with MAKE-PANE, and use
SHEET-ADOPT-CHILD to parent it into an existing layout pane.  Here is
an example I have put together:

(in-package :clim-user)

(define-application-frame dynamic-panes ()
  ()
  (:panes
   (interactor :interactor)
   (hbox-layout (make-pane 'hbox-pane)))
  (:layouts
   (default (vertically () interactor hbox-layout))))

(define-dynamic-panes-command (com-dynamic :menu t :name t) ()
  (with-look-and-feel-realization (*default-frame-manager* *application-frame*)
    (let ((button (make-pane 'push-button :label "Dynamically Generated"))
          (layout-pane (find-pane-named *application-frame* 'hbox-layout)))
      (sheet-adopt-child layout-pane button))))

(define-dynamic-panes-command (com-quit :menu t :name t) ()
  (frame-exit *application-frame*))

In order to run it with McCLIM, you need CVS sources later than 21
June 2004, with a fix by Andy to a named panes problem that prevented
the above code to work.


Paolo
-- 
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
--
[To unsubscribe to this list send an email to "[email protected]"
with the following text in the BODY of the message "unsubscribe clim"]