annotate lisp/dialog.el @ 406:b8cc9ab3f761 r21-2-33

Import from CVS: tag r21-2-33
author cvs
date Mon, 13 Aug 2007 11:17:09 +0200
parents 2f8bb876ab1d
children 697ef44129c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; dialog.el --- Dialog-box support for XEmacs
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1991-4, 1997 Free Software Foundation, Inc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5 ;; Maintainer: XEmacs Development Team
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
6 ;; Keywords: extensions, internal, dumped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; Free Software Foundation, 59 Temple Place - Suite 330,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29 ;; This file is dumped with XEmacs (when dialog boxes are compiled in).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
31 ;; Dialog boxes are non-modal at the C level, but made modal at the
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
32 ;; Lisp level via hacks in functions such as yes-or-no-p-dialog-box
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
33 ;; below. Perhaps there should be truly modal dialog boxes
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
34 ;; implemented at the C level for safety. All code using dialog boxes
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
35 ;; should be careful to assume that the environment, for example the
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
36 ;; current buffer, might be completely different after returning from
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
37 ;; yes-or-no-p-dialog-box, but such code is difficult to write and test.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
38
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 (defun yes-or-no-p-dialog-box (prompt)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
41 "Ask user a yes-or-no question with a popup dialog box.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
42 Return t if the answer is \"yes\".
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
43 Takes one argument, which is the string to display to ask the question."
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
44 (save-selected-frame
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 361
diff changeset
45 (popup-dialog-box
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
46 (list prompt ["Yes" yes t] ["No" no t] nil ["Cancel" cancel t]))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
47 (let (event)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
48 (catch 'ynp-done
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
49 (while t
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
50 (setq event (next-command-event event))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
51 (when (misc-user-event-p event)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
52 (message "%s" (event-object event))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
53 (case (event-object event)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
54 ((yes) (throw 'ynp-done t))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
55 ((no) (throw 'ynp-done nil))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
56 ((cancel menu-no-selection-hook) (signal 'quit nil))))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
57 (unless (button-release-event-p event) ; don't beep twice
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
58 (beep)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
59 (message "please answer the dialog box")))))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 (defun yes-or-no-p-maybe-dialog-box (prompt)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 "Ask user a yes-or-no question. Return t if answer is yes.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63 The question is asked with a dialog box or the minibuffer, as appropriate.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 Takes one argument, which is the string to display to ask the question.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65 It should end in a space; `yes-or-no-p' adds `(yes or no) ' to it.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 The user must confirm the answer with RET,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
67 and can edit it until it as been confirmed."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
68 (if (should-use-dialog-box-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
69 (yes-or-no-p-dialog-box prompt)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
70 (yes-or-no-p-minibuf prompt)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
71
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
72 (defun y-or-n-p-maybe-dialog-box (prompt)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
73 "Ask user a \"y or n\" question. Return t if answer is \"y\".
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
74 Takes one argument, which is the string to display to ask the question.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
75 The question is asked with a dialog box or the minibuffer, as appropriate.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
76 It should end in a space; `y-or-n-p' adds `(y or n) ' to it.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
77 No confirmation of the answer is requested; a single character is enough.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
78 Also accepts Space to mean yes, or Delete to mean no."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
79 (if (should-use-dialog-box-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
80 (yes-or-no-p-dialog-box prompt)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
81 (y-or-n-p-minibuf prompt)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
82
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
83 (when (fboundp 'popup-dialog-box)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
84 (fset 'yes-or-no-p 'yes-or-no-p-maybe-dialog-box)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
85 (fset 'y-or-n-p 'y-or-n-p-maybe-dialog-box))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
86
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
87 ;; this is call-compatible with the horribly-named FSF Emacs function
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
88 ;; `x-popup-dialog'. I refuse to use that name.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
89 (defun get-dialog-box-response (position contents)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
90 ;; by Stig@hackvan.com
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
91 ;; modified by pez@atlantic2.sbi.com
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
92 "Pop up a dialog box and return user's selection.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
93 POSITION specifies which frame to use.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 This is normally an event or a window or frame.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95 If POSITION is t or nil, it means to use the frame the mouse is on.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
96 The dialog box appears in the middle of the specified frame.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
97
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
98 CONTENTS specifies the alternatives to display in the dialog box.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
99 It is a list of the form (TITLE ITEM1 ITEM2...).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
100 Each ITEM is a cons cell (STRING . VALUE).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101 The return value is VALUE from the chosen item.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
102
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103 An ITEM may also be just a string--that makes a nonselectable item.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
104 An ITEM may also be nil--that means to put all preceding items
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
105 on the left of the dialog box and all following items on the right."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106 (cond
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 ((eventp position)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108 (select-frame (event-frame position)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
109 ((framep position)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
110 (select-frame position))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
111 ((windowp position)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
112 (select-window position)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113 (let ((dbox (cons (car contents)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
114 (mapcar #'(lambda (x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
115 (cond
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
116 ((null x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
117 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
118 ((stringp x)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119 `[,x 'ignore nil]) ;this will never get
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
120 ;selected
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
121 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
122 `[,(car x) (throw 'result ',(cdr x)) t])))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
123 (cdr contents))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124 )))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
125 (catch 'result
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126 (popup-dialog-box dbox)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127 (dispatch-event (next-command-event)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129 (defun message-box (fmt &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 "Display a message, in a dialog box if possible.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
131 If the selected device has no dialog-box support, use the echo area.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
132 The arguments are the same as to `format'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
133
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
134 If the only argument is nil, clear any existing message; let the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 minibuffer contents show."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
136 (if (and (null fmt) (null args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137 (progn
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 (clear-message nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 nil)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
140 (let ((str (apply 'format fmt args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
141 (if (device-on-window-system-p)
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 371
diff changeset
142 (get-dialog-box-response nil (list str (cons "%_OK" t)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
143 (display-message 'message str))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
144 str)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 (defun message-or-box (fmt &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
147 "Display a message in a dialog box or in the echo area.\n\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
148 If this command was invoked with the mouse, use a dialog box.\n\
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
149 Otherwise, use the echo area.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 The arguments are the same as to `format'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152 If the only argument is nil, clear any existing message; let the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153 minibuffer contents show."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
154 (if (should-use-dialog-box-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155 (apply 'message-box fmt args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156 (apply 'message fmt args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
158 (defun make-dialog-box (&optional spec props parent)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
159 "Create a frame suitable for use as a general dialog box.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
160 The frame is made a child of PARENT (defaults to the selected frame),
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
161 and has additional properties PROPS, as well as `dialog-frame-plist'.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
162 SPEC is a string or glyph to be placed in the gutter. If INVISIBLE is
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
163 non-nil then the frame is initially unmapped.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
164 Normally the created frame has no modelines, menubars, scrollbars,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
165 minibuffer or toolbars and is entirely covered by its gutter."
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
166 (or parent (setq parent (selected-frame)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
167 (let* ((ftop (frame-property parent 'top))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
168 (fleft (frame-property parent 'left))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
169 (fwidth (frame-pixel-width parent))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
170 (fheight (frame-pixel-height parent))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
171 (fonth (font-height (face-font 'default)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
172 (fontw (font-width (face-font 'default)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
173 (props (append props dialog-frame-plist))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
174 (dfheight (plist-get props 'height))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
175 (dfwidth (plist-get props 'width))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
176 (unmapped (plist-get props 'initially-unmapped))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
177 (gutter-spec spec)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
178 (name (or (plist-get props 'name) "XEmacs"))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
179 (frame nil))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
180 (plist-remprop props 'initially-unmapped)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
181 ;; allow the user to just provide a glyph
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
182 (when (glyphp spec)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
183 (setq gutter-spec (copy-sequence "\n"))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
184 (set-extent-begin-glyph (make-extent 0 1 gutter-spec) spec))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
185 ;; under FVWM at least, if I don't specify the initial position,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
186 ;; it ends up always at (0, 0). xwininfo doesn't tell me
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
187 ;; that there are any program-specified position hints, so
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
188 ;; it must be an FVWM bug. So just be smashing and position
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
189 ;; in the center of the selected frame.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
190 (setq frame (make-frame
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
191 (append props
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
192 `(popup ,parent initially-unmapped t
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
193 menubar-visible-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
194 has-modeline-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
195 default-toolbar-visible-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
196 top-gutter-visible-p t
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
197 top-gutter-height ,(* dfheight fonth)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
198 top-gutter ,gutter-spec
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
199 minibuffer none
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
200 name ,name
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
201 modeline-shadow-thickness 0
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
202 vertical-scrollbar-visible-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
203 horizontal-scrollbar-visible-p nil
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
204 unsplittable t
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
205 left ,(+ fleft (- (/ fwidth 2)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
206 (/ (* dfwidth fontw)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
207 2)))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
208 top ,(+ ftop (- (/ fheight 2)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
209 (/ (* dfheight fonth)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
210 2)))))))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
211 (set-face-foreground 'modeline [default foreground] frame)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
212 (set-face-background 'modeline [default background] frame)
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
213 (unless unmapped (make-frame-visible frame))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
214 frame))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
215
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
216
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
217 ;;; dialog.el ends here