update.
[chise/xemacs-chise.git.1] / lisp / dialog.el
index aae2d92..235d135 100644 (file)
@@ -40,8 +40,8 @@
 ;;; Code:
 (defun yes-or-no-p-dialog-box (prompt)
   "Ask user a yes-or-no question with a popup dialog box.
 ;;; 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
   (save-selected-frame
     (make-dialog-box 'question
                     :question prompt
@@ -189,14 +189,14 @@ The keywords allowed for `general' are
 
 :spec
   The widget spec -- anything that can be passed to `make-glyph'.
 
 :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).
 :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'.
 :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.
 
 ---------------------------------------------------------------------------
 
 
 ---------------------------------------------------------------------------
 
@@ -264,6 +264,18 @@ The keywords allowed are
 
 ---------------------------------------------------------------------------
 
 
 ---------------------------------------------------------------------------
 
+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.
 For type `print':
 
 This invokes the Windows standard Print dialog.
@@ -276,31 +288,42 @@ The keywords allowed are
   An 'msprinter device.
 :print-settings
   A printer settings object.
   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
 name can change as a result of selecting a different printer 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,
 
 The function brings up the Print 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 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:
 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.
 
 
 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.
 
 ---------------------------------------------------------------------------
 
 
 ---------------------------------------------------------------------------
 
@@ -329,7 +352,7 @@ 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 device is specified, then changes are stored into the
 settings object currently selected into that printer.  If a settings
 Connection name can change as a result of selecting a different printer
 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.
 
 selected into a printer, then changes are propagated to that printer
 too.
 
@@ -346,42 +369,7 @@ 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.
 
 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.
 
 ---------------------------------------------------------------------------
 
 
 ---------------------------------------------------------------------------
 
@@ -561,7 +549,9 @@ The keywords allowed are
                                   'internal-make-dialog-box-exit did)
                                  (remove-hook 'delete-dialog-box-hook
                                               ',sym))))
                                   '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
                       (mapc 'disable-frame frames)
                       (block nil
                         (while t
@@ -582,6 +572,7 @@ The keywords allowed are
             (:parent (selected-frame))
             :modal
             :properties
             (:parent (selected-frame))
             :modal
             :properties
+            :autosize
             :spec)
            ()
          (flet ((create-dialog-box-frame ()
             :spec)
            ()
          (flet ((create-dialog-box-frame ()
@@ -629,6 +620,7 @@ The keywords allowed are
                                            vertical-scrollbar-visible-p nil
                                            horizontal-scrollbar-visible-p nil
                                            unsplittable t
                                            vertical-scrollbar-visible-p nil
                                            horizontal-scrollbar-visible-p nil
                                            unsplittable t
+                                           internal-border-width 8
                                            left ,(+ fleft (- (/ fwidth 2)
                                                              (/ (* dfwidth
                                                                    fontw)
                                            left ,(+ fleft (- (/ fwidth 2)
                                                              (/ (* dfwidth
                                                                    fontw)
@@ -639,6 +631,19 @@ The keywords allowed are
                                                               2)))))))
                     (set-face-foreground 'modeline [default foreground] frame)
                     (set-face-background 'modeline [default background] frame)
                                                               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)
                     (unless unmapped (make-frame-visible frame))
                     (let ((newbuf (generate-new-buffer " *dialog box*")))
                       (set-buffer-dedicated-frame newbuf frame)