;;; -*- mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (c) 2009 by the authors. ;;; ;;; See LICENCE for details. (in-package :hu.dwim.presentation) ;;;;;; ;;; Extended table (def (component e) extended-table/widget (standard/widget id/mixin) ((row-headers nil :type components) (row-headers-depth :type integer) (row-leaf-count :type integer) (column-headers nil :type components) (column-headers-depth :type integer) (column-leaf-count :type integer) (header-cell nil :type component) (cells nil :type components))) (def refresh-component extended-table/widget (bind (((:slots row-headers row-headers-depth row-leaf-count column-headers column-headers-depth column-leaf-count) -self-)) (flet ((setf-indices (headers) (iter (for index :from 0) (for leaf :in (collect-leaves headers)) (setf (index-of leaf) index)))) (setf row-headers-depth (count-depth row-headers)) (setf row-leaf-count (count-leaves row-headers)) (setf-indices row-headers) (setf column-headers-depth (count-depth column-headers)) (setf column-leaf-count (count-leaves column-headers)) (setf-indices column-headers)))) (def render-xhtml extended-table/widget (bind (((:read-only-slots header-cell row-headers row-headers-depth column-headers column-headers-depth column-leaf-count cells) -self-)) (labels ((cell-index (row-path column-path) (+ (* column-leaf-count (index-of (last-elt row-path))) (index-of (last-elt column-path)))) (map-headers-pathes (function headers) (foreach (lambda (header) (labels ((traverse (decdendant path) (aif (children-of decdendant) (foreach (lambda (child) (traverse child (append path (list child)))) it) (funcall function path)))) (traverse header (list header)))) headers)) (render-expanded-command (header) (render-component (make-toggle-expanded-command header))) (render-top-left-header ()