Ignore:
Timestamp:
11/16/2007 04:52:26 PM (19 years ago)
Author:
David Owen <dsowen@…>
branch-nick:
tui
revision id:
dsowen@fugue88.ws-20071116165226-urvzht93m31b4n1t
Message:

Made column-widths part of the data model.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/grid/display.lisp

    r53 r55  
    55(defclass grid ()
    66  ((data :initarg :data)
    7    (column-widths :type (vector (integer 1)) :initarg :column-widths)
    87   (header-rows :type (integer 0) :initarg :header-rows)
    98   (header-columns :type (integer 0) :initarg :header-columns)
     
    1211   (column-scroll :type (integer 0) :initform 0 :accessor column-scroll)))
    1312
    14 (defun make-grid (window data column-widths
    15                   &key (header-rows 0) (header-columns 0))
     13(defun make-grid (window data &key (header-rows 0) (header-columns 0))
    1614  (make-instance 'grid
    1715                 :data data
    18                  :column-widths (coerce column-widths 'vector)
    1916                 :header-rows header-rows
    2017                 :header-columns header-columns
     
    4138
    4239(defun column-offset (grid column)
    43   (with-slots (column-widths header-columns column-scroll) grid
    44     (let ((base (+ header-columns column-scroll)))
     40  (with-slots (data header-columns column-scroll) grid
     41    (let ((base (+ header-columns column-scroll))
     42          (column-widths (mapcar (peval 'column-width data)
     43                                 (range header-columns))))
    4544      (multiple-value-bind (in-header in-data) (column-split grid column)
    4645        (let ((w1 (reduce '+ column-widths :end in-header))
     
    9998
    10099(defun draw (grid)
    101   (with-slots (data column-widths header-columns window column-scroll) grid
     100  (with-slots (data header-columns window column-scroll) grid
    102101    (erase window)
    103102    (let ((x 0))
    104103      (dotimes (i header-columns)
    105104        (draw-column grid i x)
    106         (incf x (svref column-widths i)))
     105        (incf x (column-width data i)))
    107106      (do ((i (+ header-columns column-scroll) (incf i)))
    108107          ((or (>= i (columns data))
    109108               (> x (nth-value 1 (size window)))))
    110109        (draw-column grid i x)
    111         (incf x (svref column-widths i))))))
     110        (incf x (column-width data i))))))
    112111
    113112
Note: See TracChangeset for help on using the changeset viewer.