home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.freefriends.org
/
ftp.freefriends.org.tar
/
ftp.freefriends.org
/
arnold
/
Source
/
gwm-dist.tar.gz
/
gwm-dist.tar
/
home-gwm
/
pop-menu.gwm
< prev
next >
Wrap
Lisp/Scheme
|
1993-07-07
|
3KB
|
87 lines
; My version of pop-menu. Uses a property to remember what the last
; selection was, and pops the menu at that position.
;
; NOTE WELL -- must be loaded AFTER `std-popups.gwm' since it supersedes
; the definition of `item-make' in that file, but BEFORE `item-make' is
; actually used (currently, only in `def-menus.gwm'). This means it
; goes fine in `.profile.gwm'.
(if (not (boundp 'primitive-pop-menu))
(: primitive-pop-menu pop-menu))
(de pop-err (s)
(? "ERROR: " s "\n" (+ '(pop-menu) arglist) "\n")
(exit my-pop-menu-tag nil))
(df pop-menu arglist
(with (m wob-menu pos nil)
(tag my-pop-menu-tag
(if arglist
(if (> (length arglist) 2)
(pop-err "pop-menu takes 0 to 2 arguments:")
(if (error-occurred (: m (eval (# 0 arglist))))
(pop-err "error in evaluation of first argument:")
(not (eq (type m) 'menu))
(pop-err "first argument isn't a menu:")
(= (length arglist) 2)
(if (error-occurred (: pos (eval (# 1 arglist))))
(pop-err "error in evaluation of second argument:")
(not (eq (type pos) 'number))
(pop-err "second argument isn't a number:")))))
(if (null pos)
(: pos (with (wob (menu-wob m)) (# 'last-menu-position wob-property))))
(if (null pos)
(: pos 0))
(primitive-pop-menu m pos))))
(if (not (boundp 'primitive-menu-make))
(: primitive-menu-make menu-make))
(df menu-make items
(with (menu-make-item-position 0)
(eval (+ '(primitive-menu-make) items))))
(setq std-popups.fsm (fsm-make
(: closed
(state-make
(on enter-window (std-popups.enter) opened)))
(: opened
(state-make
(on (buttonrelease any any)
(progn
(setq std-popups.action
(# 'action wob-property))
(wob wob-parent)
(unpop-menu wob)
(wob wob-parent)
(eval std-popups.action)
)
closed)
(on enter-window (std-popups.enter))
(on leave-window (wob-invert))))))
(de std-popups.enter nil
(wob-invert)
(with (pos (# 'position wob-property))
(with (wob wob-parent)
(wob-property (# 'last-menu-position wob-property pos)))))
(df item-make (label action)
(with (borderwidth 0 ; was 1
inner-borderwidth 0
borderpixel white
fsm std-popups.fsm
label-vertical-margin 0
property
(+ (list
'action action
'position menu-make-item-position)
property))
(: menu-make-item-position (+ 1 menu-make-item-position))
(bar-make
nil
(with (borderwidth 0 fsm nil font pop-item-font
bar-min-width pop-item-height)
(plug-make (label-make label)))
nil)))