- Timestamp:
- 11/05/2007 08:08:11 PM (19 years ago)
- branch-nick:
- tui-new
- revision id:
- dsowen@fugue88.ws-20071105200811-qxy33d8lrksbps4z
- File:
-
- 1 edited
-
main/panel.lisp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
main/panel.lisp
r16 r33 3 3 "Panels should be considered the fundamental division of a screen. 4 4 Doing so allows for overlapping regions to be painted correctly.") 5 (:use #:cl #:c ffi)5 (:use #:cl #:cdk #:cffi #:dso-util #:tui-window) 6 6 (:export #:create-panel #:update-panels #:do-update #:redraw-panels 7 7 #:client-window #:destroy-panel #:with-panel)) … … 39 39 40 40 41 (defclass panel () 42 ((panel-ptr :initarg :panel-ptr))) 41 (defclass panel (window) 42 ((panel-ptr :initarg :panel-ptr) 43 (client-window :initarg :client-window :reader client-window))) 43 44 44 45 45 46 46 (defun create-panel (height width y x) 47 (define-condition panel-construction-error (error) ()) 48 49 (define-condition panel-destruction-error (error) ()) 50 51 52 53 (defun create-panel (window) 47 54 "Creates a new panel. Associates a client window with it, covering 48 55 the entire panel." 49 (let* ((window (cdk::c-new-window height width y x)) 50 (panel-ptr (new-panel window))) 51 (make-instance 'panel :panel-ptr panel-ptr))) 52 53 (defmethod client-window ((panel panel)) 54 "Returns the client window associated with the panel." 55 (with-slots (panel-ptr) panel 56 (panel-window panel-ptr))) 56 (let ((panel-ptr (new-panel (window-pointer window)))) 57 (when (null-pointer-p panel-ptr) 58 (signal 'panel-construction-error)) 59 (make-instance 'panel :panel-ptr panel-ptr :client-window window))) 57 60 58 61 (defun redraw-panels () … … 67 70 68 71 (defun destroy-panel (panel) 69 "Destroys a panel and insures that the screen is correct." 70 (let ((window (client-window panel))) 71 (with-slots (panel-ptr) panel 72 (del-panel panel-ptr)) 73 (cdk::c-delete-window window)) 74 (redraw-panels)) 72 "Destroys a panel." 73 (with-slots (panel-ptr) panel 74 (unless (= (del-panel panel-ptr) +ok+) 75 (signal 'panel-destruction-error)))) 75 76 76 77 77 78 79 (defmethod tui-window::create-subwindow ((panel panel) height width y x) 80 (tui-window::create-subwindow (client-window panel) height width y x)) 81 82 (defmethod refresh ((panel panel)) 83 (update-panels) 84 #|(do-update)|#) 85 86 (defmethod tui-window:window-pointer ((panel panel)) 87 (tui-window:window-pointer (client-window panel))) 88 89 #| 90 (defmethod (setf tui-output:background) (pair (panel panel)) 91 (setf (tui-output:background (client-window panel)) pair)) 92 93 (defmethod tui-cursor:cursor-position ((panel panel)) 94 (tui-cursor:cursor-position (client-window panel))) 95 96 (defmethod (setf tui-cursor:cursor-position) (p (panel panel)) 97 (tui-cursor:cursor-position 98 |# 99 100 78 101 (defmacro with-panel ((var height width y x) &body body) 79 `(let ((,var (create-panel ,height ,width ,y ,x))) 80 (unwind-protect 81 (progn ,@body) 82 (destroy-panel ,var)))) 102 (with-gensyms (w) 103 `(with-screen-window (,w ,height ,width ,y ,x) 104 (let ((,var (create-panel ,w))) 105 (unwind-protect (progn ,@body) 106 (destroy-panel ,var) 107 (redraw-panels))))))
Note: See TracChangeset
for help on using the changeset viewer.
