CLIM mail archive

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

multiple command menu panes in one application



    Date: Tue, 14 Jul 1992 13:32 EDT
    From: Meir Laker <meir@watson.ibm.com>

    Normally, I would like one command menu pane for my users to interact
    with my application.  However, for debugging purposes, it would be
    nice to add a second menu pane on demand with debugging commands.  How
    do I do this?  CLIM:DEFINE-PROGRAM-FRAMEWORK seems to allow multiple
    command menu panes, but they all show the same set of commands; there
    doesn't seem to be any way to specify the commands-table.
    On the other hand, if I use CLIM:DISPLAY-COMMAND-MENU to display to an
    :application pane, the commands are not mouse-sensitive.

;;; -*- Mode: LISP; Syntax: Common-Lisp; Base: 10; Package: CLIM-USER -*-

;;;>*********************************************************************
;;;>
;;;>       Symbolics hereby grants permission to customer to incorporate
;;;>       the examples in this file in any work belonging to customer.
;;;>
;;;>*********************************************************************

;;; Simple example of how to use command-table inheritance to get
;;; multiple menus in a frame.

(define-command-table primary)

(define-command (com-red :command-table primary :menu t) ()
  (echo-command *application-frame* "Red"))

(define-command (com-blue :command-table primary :menu t) ()
  (echo-command *application-frame* "Blue"))

(define-command (com-green :command-table primary :menu t) ()
  (echo-command *application-frame* "Green"))

(define-command-table secondary)

(define-command (com-yellow :command-table secondary :menu t) ()
  (echo-command *application-frame* "Yellow"))

(define-command (com-cyan :command-table secondary :menu t) ()
  (echo-command *application-frame* "Cyan"))

(define-command (com-magenta :command-table secondary :menu t) ()
  (echo-command *application-frame* "Magenta"))


;;; first version with one layout

(clim:define-application-frame multi-menu ()
    ()
  (:command-table (t :inherit-from (primary secondary)))
  (:panes ((display :application)
	   (own-menu :command-menu)
	   (primary-menu :command-menu
			 :display-function '(clim:display-command-menu :command-table primary))
	   (secondary-menu :command-menu
			   :display-function '(clim:display-command-menu :command-table secondary))))
  (:layout ((regular
	      (:column 1
	       (display :rest)
	       (:row 1/6 (primary-menu :compute) (secondary-menu :compute) (own-menu :rest)))))))

(define-multi-menu-command (com-exit-multi-menu :menu "Exit") ()
  (frame-exit *application-frame*))

(defmethod echo-command ((frame multi-menu) string)
  (let ((stream (get-frame-pane frame 'display)))
    (format stream "~%The ~A command." string)))


;;; second version with multiple configurations

(clim:define-application-frame multi-menu ()
    ()
  (:command-table (t :inherit-from (primary secondary)))
  (:panes ((display :application)
	   (own-menu :command-menu)
	   (primary-menu :command-menu
			 :display-function '(clim:display-command-menu :command-table primary))
	   (secondary-menu :command-menu
			   :display-function '(clim:display-command-menu :command-table secondary))))
  (:layout ((primary
	     (:column 1
	      (display :rest)
	      (:row 1/6 (primary-menu :compute) (own-menu :rest))))
	    (secondary
	      (:column 1
	       (display :rest)
	       (:row 1/6 (secondary-menu :compute) (own-menu :rest)))))))

(define-multi-menu-command (com-exit-multi-menu :menu "Exit") ()
  (frame-exit *application-frame*))

(defmethod echo-command ((frame multi-menu) string)
  (let ((stream (get-frame-pane frame 'display)))
    (format stream "~%The ~A command." string)))

(define-multi-menu-command (switch-configurations :menu "Switch") ()
  (let ((new-config (case (frame-current-layout *application-frame*)
		      (primary 'secondary)
		      (secondary 'primary))))
    (set-frame-layout *application-frame* new-config)))


#||
() ;standalone testing
(defvar *clim-root* (open-root-window :sheet))
(setq mm (clim:make-application-frame 'multi-menu :parent *clim-root* :width 600 :height 500 :left 100 :top 100))
(clim:run-frame-top-level mm)
||#


References:

Main Index | Thread Index