cd c:/drews-lisp-20/ diff -c "c:/emacs-21.3.50/lisp/toolbar/tool-bar.el" "c:/drews-lisp-20/tool-bar-w-popup-10-10.el" *** c:/emacs-21.3.50/lisp/toolbar/tool-bar.el Mon Jul 26 09:42:32 2004 --- c:/drews-lisp-20/tool-bar-w-popup-10-10.el Sun Oct 10 21:23:58 2004 *************** *** 40,45 **** --- 40,49 ---- ;;; Code: + + + ;;; Global Tool Bar Mode ------------------------ + ;;;###autoload (define-minor-mode tool-bar-mode "Toggle use of the tool bar. *************** *** 266,271 **** --- 270,367 ---- :help "Pop up the Help menu") ) + + + + ;;; Local Tool Bar Mode ------------------------- + + (define-minor-mode tool-bar-here-mode + "Toggle use of the tool bar on this frame only. + With numeric ARG, display the tool bar if and only if ARG is positive. + + See `tool-bar-add-item' and `tool-bar-add-item-from-menu' for + conveniently adding tool bar items." + :init-value nil :global t :group 'mouse :group 'frames + (and (display-images-p) + (let ((lines (if tool-bar-here-mode 1 0))) + ;; Alter existing frame... + (modify-frame-parameters (selected-frame) (list (cons 'tool-bar-lines lines)))) + (if (and tool-bar-here-mode + (display-graphic-p) + (= 1 (length (default-value 'tool-bar-map)))) ; not yet set up + (tool-bar-setup)))) + + (make-variable-frame-local 'tool-bar-here-mode) + + + + ;;; Pop-Up Tool Bar Mode ------------------------ + + ;; If either of the normal tool-bar modes is turned on, then + ;; `tool-bar-popup-mode' is not available. + (define-key global-map [menu-bar pop-up-tool-bar] + '(menu-item + "Buttons" show-tool-bar-for-one-command + :visible (and tool-bar-pop-up-mode (not tool-bar-mode) (not tool-bar-here-mode)) + :enable (and tool-bar-pop-up-mode (not tool-bar-mode) (not tool-bar-here-mode)) + :help "Use tool bar for one command")) + + (setq menu-bar-final-items (append menu-bar-final-items (list 'pop-up-tool-bar))) + + + + (define-minor-mode tool-bar-pop-up-mode + "Toggle tool-bar pop-up. + With numeric ARG, turn on tool-bar pop-up if and only if ARG is positive. + + Note: Command `tool-bar-pop-up-mode' functions as a toggle only + if neither `tool-bar-mode' nor `tool-bar-here-mode' is on. + + If either of those modes is on, then command + `tool-bar-pop-up-mode' turns them both off and turns + `tool-bar-pop-up-mode' on." + :init-value nil :global t :group 'mouse :group 'frames + (when (or tool-bar-mode tool-bar-here-mode) + (setq tool-bar-pop-up-mode t) + (tool-bar-mode -99) + (tool-bar-here-mode -99))) + + + ;; Note: This treats mouse events specially: it scrolls the buffer + ;; text (window) down to compensate for the disappearance of the + ;; tool-bar. That is, it replaces the tool-bar with an equivalent + ;; number of lines of buffer text. + ;; + ;; The reason for this is so that where you click the mouse when the + ;; tool-bar is visible corresponds to where the mouse is after the + ;; tool-bar disappears. Otherwise, the buffer text moves up, relative + ;; to the mouse, and a region is selected (without ever physically + ;; moving the mouse). + ;; + (defun show-tool-bar-for-one-command () + "Pop up the tool bar so you can click a button. + The tool bar stays visible until one command is executed + \(whether or not it was initiated by clicking a button)." + (interactive) + (unless tool-bar-pop-up-mode + (error "You must turn on `tool-bar-pop-up-mode' to use this command")) + (let (evnt tb-lines) + (unwind-protect + (progn + (tool-bar-here-mode 99) ; Show tool-bar + (setq evnt (read-event)) + (push evnt unread-command-events)) + (when (and (consp evnt) + (member (event-basic-type (car evnt)) '(mouse-1 mouse-2 mouse-3))) + (setq tb-lines (cdr (assq 'tool-bar-lines (frame-parameters (selected-frame))))) + (condition-case nil + (when tb-lines (scroll-down tb-lines)) + (error (tool-bar-here-mode -99)))) ; E.g. "Beginning of buffer" error + (tool-bar-here-mode -99)))) ; Hide tool-bar + + + ;;;;;;;;;;;;;;;;;; + (provide 'tool-bar) ;;; arch-tag: 15f30f0a-d0d7-4d50-bbb7-f48fd0c8582f Diff finished at Sun Oct 10 21:24:58