home *** CD-ROM | disk | FTP | other *** search
- (in-package :oou)
- (oou-provide :window-ce)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; window-ce.Lisp
- ;;
- ;; Copyright ⌐ 1992 Northwestern University Institute for the Learning Sciences
- ;; All Rights Reserved
- ;;
- ;; author: Michael S. Engber
- ;;
- ;; methods for the window class
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (oou-dependencies
- :GDevice-u)
-
- (export '(window-center-on-screen
- ))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defmethod window-center-on-screen ((w window) which-screen
- &key
- (upper-3rd-p t)
- (move-now-p t)
- (GDevice nil)
- (point nil))
- (with-macptrs ((gd (ecase which-screen
- (:specified-GD (if (handlep GDevice) GDevice (error "bad GDevice")))
- (:deepest (get-max-device))
- (:main (#_GetMainDevice))
- (:containing-mouse (find-GDevice-containing-point))
- (:containing-point (find-GDevice-containing-point point)))))
- (let ((struct-topLeft)
- (struct-botRight)
- (content-topLeft))
- (let ((shown-p (window-shown-p w))
- (old-w-pos (view-position w)))
- (with-macptrs ((struct-rgn (pref (wptr w) :WindowRecord.strucRgn))
- (content-rgn (pref (wptr w) :WindowRecord.contRgn)))
- (unless shown-p
- ;hidden windows have empty struct/content regions
- ;so we temporarily show them (way the hell off screen)
- (set-view-position w #@(16383 16383))
- (#_ShowWindow (wptr w)))
-
- (setf struct-topLeft (href struct-rgn :Region.rgnBBox.topLeft)
- struct-botRight (href struct-rgn :Region.rgnBBox.botRight)
- content-topLeft (href content-rgn :Region.rgnBBox.topLeft))
-
- (unless shown-p
- (#_HideWindow (wptr w))
- (set-view-position w old-w-pos))))
-
-
- (let* ((mbar-hgt (if (eql gd (#_GetMainDevice)) (#_GetMBarHeight) 0))
- (wind-hgt (- (point-v struct-botRight) (point-v struct-topLeft)))
- (wind-wid (- (point-h struct-botRight) (point-h struct-topLeft)))
- (scrn-hgt (- (href gd :GDevice.gdRect.bottom) (href gd :GDevice.gdRect.top) mbar-hgt))
- (scrn-wid (- (href gd :GDevice.gdRect.right) (href gd :GDevice.gdRect.left)))
- (v-off (max (+ mbar-hgt (floor (- scrn-hgt wind-hgt) (if upper-3rd-p 3 2))) mbar-hgt))
- (h-off (max (floor (- scrn-wid wind-wid) 2) 0))
- (pos (add-points
- (add-points (href gd :GDevice.gdRect.topLeft) (make-point h-off v-off))
- (subtract-points content-topLeft struct-topLeft))))
-
- (when move-now-p (set-view-position w pos))
- pos))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- #|
-
- (setf *test-w* (make-instance 'window))
-
- (window-center-on-screen *test-w* :main)
- (window-center-on-screen *test-w* :deepest)
-
- |#