Changeset main,33 for main


Ignore:
Timestamp:
11/05/2007 08:08:11 PM (19 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
tui-new
revision id:
dsowen@fugue88.ws-20071105200811-qxy33d8lrksbps4z
Message:

Panels are now like windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/panel.lisp

    r16 r33  
    33   "Panels should be considered the fundamental division of a screen.
    44Doing so allows for overlapping regions to be painted correctly.")
    5   (:use #:cl #:cffi)
     5  (:use #:cl #:cdk #:cffi #:dso-util #:tui-window)
    66  (:export #:create-panel #:update-panels #:do-update #:redraw-panels
    77           #:client-window #:destroy-panel #:with-panel))
     
    3939
    4040
    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)))
    4344
    4445
    4546
    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)
    4754  "Creates a new panel.  Associates a client window with it, covering
    4855the 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)))
    5760
    5861(defun redraw-panels ()
     
    6770
    6871(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))))
    7576
    7677
    7778
     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
    78101(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.