;;; Code:
(defun yes-or-no-p-dialog-box (prompt)
"Ask user a yes-or-no question with a popup dialog box.
-Return t if the answer is \"yes\".
-Takes one argument, which is the string to display to ask the question."
+Return t if the answer is \"yes\", nil if \"no\". Takes one argument,
+the question string to display."
(save-selected-frame
(make-dialog-box 'question
:question prompt
:spec
The widget spec -- anything that can be passed to `make-glyph'.
-
:title
The title of the frame.
:parent
The frame is made a child of this frame (defaults to the selected frame).
-
:properties
Additional properties of the frame, as well as `dialog-frame-plist'.
+:autosize
+ If t the frame is sized to exactly fit the widgets given by :spec.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
+For type `directory':
+
+The keywords allowed are
+
+:initial-directory
+ The initial directory to be selected in the dialog box (defaults to the
+ current buffer's `default-directory).
+:title
+ The title of the dialog box (defaults to \"Open\").
+
+---------------------------------------------------------------------------
+
For type `print':
This invokes the Windows standard Print dialog.
An 'msprinter device.
:print-settings
A printer settings object.
+:allow-selection
+ t or nil -- whether the \"Selection\" button is enabled (defaults to nil).
+:allow-pages
+ t or nil -- whether the \"Pages\" button and associated edit controls
+ are enabled (defaults to t).
+:selected-page-button
+ `all', `selection', or `pages' -- which page button is initially
+ selected.
-Exactly one of these keywords must be given.
+Exactly one of :device and :print-settings must be given.
The function brings up the Print dialog, where the user can
-select a different printer and/or change printer options. Connection
+select a different printer and/or change printer options. Connection
name can change as a result of selecting a different printer device. If
-a printer is specified, then changes are stored into the settings object
+a device is specified, then changes are stored into the settings object
currently selected into that printer. If a settings object is supplied,
-then changes are recorded into it, and, it it is selected into a
+then changes are recorded into it, and, it is selected into a
printer, then changes are propagated to that printer
too.
Return value is nil if the user has canceled the dialog. Otherwise, it
is a new plist, with the following properties:
- name Printer device name, even if unchanged by the user.
- from-page First page to print, 1-based. If not specified by the user,
- then this value is not included in the plist.
- to-page Last page to print, inclusive, 1-based. If not specified by
- the user, then this value is not included in the plist.
- copies Number of copies to print. Always returned.
+ name Printer device name, even if unchanged by the user.
+ from-page First page to print, 1-based. Returned if
+ `selected-page-button' is `pages'.
+ user, then this value is not included in the plist.
+ to-page Last page to print, inclusive, 1-based. Returned if
+ `selected-page-button' is `pages'.
+ copies Number of copies to print. Always returned.
+ selected-page-button Which page button was selected (`all', `selection',
+ or `pages').
The DEVICE is destroyed and an error is signaled in case of
initialization problem with the new printer.
-See also the `page-setup' and `print-setup' dialog boxes.
+See also the `page-setup' dialog box type.
---------------------------------------------------------------------------
For type `page-setup':
This invokes the Windows standard Page Setup dialog.
-This dialog is usually invoked in response to the Page Setup command, and
-used to choose such parameters as page orientation, print margins etc.
-Note that this dialog contains the \"Printer\" button, which invokes
-the Printer Setup dialog (see `msprinter-print-setup-dialog') so that the
-user can update the printer options or even select a different printer
-as well.
+This dialog is usually invoked in response to the Page Setup command,
+and used to choose such parameters as page orientation, print margins
+etc. Note that this dialog contains the \"Printer\" button, which
+invokes the Printer Setup dialog so that the user can update the
+printer options or even select a different printer as well.
The keywords allowed are
The function brings up the Page Setup dialog, where the user
can select a different printer and/or change printer options.
Connection name can change as a result of selecting a different printer
-device. If a printer is specified, then changes are stored into the
+device. If a device is specified, then changes are stored into the
settings object currently selected into that printer. If a settings
-object is supplied, then changes are recorded into it, and, it it is
+object is supplied, then changes are recorded into it, and, it is
selected into a printer, then changes are propagated to that printer
too.
Return value is nil if the user has canceled the dialog. Otherwise,
it is a new plist, containing the new list of properties.
+NOTE: The margin properties (returned by this function) are *NOT* stored
+into the print-settings or device object.
+
The DEVICE is destroyed and an error is signaled in case of
initialization problem with the new printer.
-See also the `print' and `print-setup' dialogs.
-
----------------------------------------------------------------------------
-
-For type `print-setup':
-
-This invokes the Windows standard Print Setup dialog.
-This dialog is usually invoked when the user selects the Printer Setup
-command.
-
-The keywords allowed are
-
-:device
- An 'msprinter device.
-:print-settings
- A printer settings object.
-
-Exactly one of these keywords must be given.
-
-The function brings up the Print Setup dialog, where the user
-can select a different printer and/or change printer options.
-Connection name can change as a result of selecting a different printer
-device. If a printer is specified, then changes are stored into the
-settings object currently selected into that printer. If a settings
-object is supplied, then changes are recorded into it, and, it it is
-selected into a printer, then changes are propagated to that printer
-too.
-
-Return value is nil if the user has canceled the dialog. Otherwise, it
-is a new plist, with the following properties:
- name Printer device name, even if unchanged by the user.
-
-The printer device is destroyed and an error is signaled if new printer
-is selected by the user, but cannot be initialized.
-
-See also the `print' and `page-setup' dialogs.
+See also the `print' dialog box type.
---------------------------------------------------------------------------
'internal-make-dialog-box-exit did)
(remove-hook 'delete-dialog-box-hook
',sym))))
- (add-hook 'delete-dialog-box-hook sym)
+ (if (framep id)
+ (add-hook 'delete-frame-hook sym)
+ (add-hook 'delete-dialog-box-hook sym))
(mapc 'disable-frame frames)
(block nil
(while t
(:parent (selected-frame))
:modal
:properties
+ :autosize
:spec)
()
(flet ((create-dialog-box-frame ()
vertical-scrollbar-visible-p nil
horizontal-scrollbar-visible-p nil
unsplittable t
+ internal-border-width 8
left ,(+ fleft (- (/ fwidth 2)
(/ (* dfwidth
fontw)
2)))))))
(set-face-foreground 'modeline [default foreground] frame)
(set-face-background 'modeline [default background] frame)
+ ;; resize before mapping
+ (when cl-autosize
+ (set-frame-pixel-size
+ frame
+ (image-instance-width
+ (glyph-image-instance cl-spec
+ (frame-selected-window frame)))
+ (image-instance-height
+ (glyph-image-instance cl-spec
+ (frame-selected-window frame)))))
+ ;; somehow, even though the resizing is supposed
+ ;; to be while the frame is not visible, a
+ ;; visible resize is perceptible
(unless unmapped (make-frame-visible frame))
(let ((newbuf (generate-new-buffer " *dialog box*")))
(set-buffer-dedicated-frame newbuf frame)
(set-frame-property frame 'dialog-box-buffer newbuf)
+ (set-window-buffer (frame-root-window frame) newbuf)
(with-current-buffer newbuf
- (setq frame-title-format cl-title)
- (make-local-hook 'delete-frame-hook)
- (add-hook 'delete-frame-hook
- #'(lambda (frame)
- (kill-buffer
- (frame-property
- frame
- 'dialog-box-buffer))))))
+ (set (make-local-variable 'frame-title-format)
+ cl-title)
+ (add-local-hook 'delete-frame-hook
+ #'(lambda (frame)
+ (kill-buffer
+ (frame-property
+ frame
+ 'dialog-box-buffer))))))
frame)))
(if cl-modal
(dialog-box-modal-loop '(create-dialog-box-frame))