(U-00024182): Apply new conventions for glyph granularity.
[chise/xemacs-chise.git.1] / lisp / device.el
index 6d40d5f..2942e1d 100644 (file)
 
 ;;; Code:
 
+;;; Initialization
+
+; Specifier tag 'printer which matches printers
+(define-specifier-tag 'printer (function device-printer-p))
+
+; Specifier tag 'display which matches displays
+(define-specifier-tag 'display (function
+                               (lambda (device)
+                                 (not (device-printer-p device)))))
+
+;;; Functions
+
 (defun device-list ()
   "Return a list of all devices."
   (apply 'nconc (mapcar 'console-device-list (console-list))))
 This is equivalent to the type of the device's console.
 Value is `tty' for a tty device (a character-only terminal),
 `x' for a device that is a screen on an X display,
+`gtk' for a device that is a GTK connection.
 `ns' for a device that is a NeXTstep connection (not yet implemented),
-`mswindows' for a device that is a Windows or Windows NT connection,
-`pc' for a device that is a direct-write MS-DOS screen (not yet implemented),
+`mswindows' for a device that is a MS Windows workstation,
+`msprinter' for a device that is a MS Windows printer connection,
 `stream' for a stream device (which acts like a stdio stream), and
 `dead' for a deleted device."
   (or device (setq device (selected-device)))
@@ -91,6 +104,10 @@ it is nil, it is assumes to be the value returned by emacs-pid."
   "Return the number of color cells of DEVICE, or nil if unknown."
   (device-system-metric device 'num-color-cells))
 
+(defun make-gtk-device ()
+  "Create a new GTK device."
+  (make-device 'gtk nil))
+
 (defun make-x-device (&optional display)
   "Create a new device connected to DISPLAY."
   (make-device 'x display))
@@ -106,6 +123,29 @@ the toolbar, glyphs, etc."
   (or device (setq device (selected-device)))
   (console-on-window-system-p (device-console device)))
 
+(defun call-device-method (name device &rest args)
+  "Call a DEVICE-specific function with the generic name NAME.
+If DEVICE is not provided then the selected device is used."
+  (or device (setq device (selected-device)))
+  (or (symbolp name) (error "function name must be a symbol"))
+  (let ((devmeth (intern (concat (symbol-name 
+                                 (device-type device)) "-" (symbol-name name)))))
+    (if (functionp devmeth)
+       (if args
+           (apply devmeth args)
+         (funcall devmeth))
+      nil)))
+
+(defmacro define-device-method (name &optional docstring)
+  "Define NAME to be a device method."
+  `(defun ,name (&rest arglist) ,docstring
+     (apply 'call-device-method (quote ,name) nil arglist)))
+
+(defmacro define-device-method* (name &optional docstring)
+  "Define NAME to be a device method."
+  `(defun* ,name (&rest arglist) ,docstring
+     (apply 'call-device-method (quote ,name) nil arglist)))
+
 (defalias 'valid-device-type-p 'valid-console-type-p)
 (defalias 'device-type-list 'console-type-list)
 (defalias 'device-pixel-depth 'device-bitplanes)