Silas Vedder
2 years ago
6 changed files with 262 additions and 116 deletions
@ -1,56 +1,79 @@ |
|||||||
(in-package #:cl-bible.chapter) |
(in-package #:cl-bible.chapter) |
||||||
|
|
||||||
(defun book/chapter-window (canvas title) |
(defclass chapter () |
||||||
|
((%verses :initarg :verses |
||||||
|
:reader verses))) |
||||||
|
|
||||||
|
(defgeneric chapter-to-clog (chapter parent &key translation)) |
||||||
|
(defgeneric book/chapter-window (canvas title)) |
||||||
|
(defgeneric translations-drop-down (div display chapter drop-down)) |
||||||
|
(defgeneric display-chapter-or-book (canvas title chapter)) |
||||||
|
(defgeneric load-chapter (canvas book chapter)) |
||||||
|
(defgeneric load-book (canvas book)) |
||||||
|
|
||||||
|
(defmethod chapter-to-clog ((chapter chapter) (parent clog:clog-obj) &key (translation :mng)) |
||||||
|
(labels ((verse-to-clog (verse) |
||||||
|
;;; (clog:set-on-click |
||||||
|
(v:verse-to-clog verse parent :translation translation) |
||||||
|
;;; (lambda (obj) |
||||||
|
;;; (declare (ignore obj)) |
||||||
|
;;; (v::show-notes verse parent))) |
||||||
|
)) |
||||||
|
(mapcar #'verse-to-clog (verses chapter)))) |
||||||
|
|
||||||
|
(defmethod book/chapter-window (canvas (title string)) |
||||||
(let* ((win (window-content |
(let* ((win (window-content |
||||||
(create-gui-window canvas |
(create-gui-window canvas |
||||||
:title title |
:title title |
||||||
:height 400 |
:height 400 |
||||||
:width 650))) |
:width 500))) |
||||||
(mbar (create-gui-menu-bar win)) |
(mbar (create-gui-menu-bar win)) |
||||||
(drop-down (create-gui-menu-drop-down mbar :content "Translations"))) |
(drop-down (create-gui-menu-drop-down mbar :content "Translations"))) |
||||||
(values (create-div win) |
(values (create-div win) |
||||||
drop-down))) |
drop-down))) |
||||||
|
|
||||||
(defun translations-drop-down (div display verses drop-down) |
(defmethod translations-drop-down ((div clog:clog-div) display (chapter chapter) drop-down) |
||||||
(mapcar |
(mapcar |
||||||
(lambda (translation) |
(lambda (translation) |
||||||
(labels ((verse-to-clog (verse) |
(labels ((callback (obj) |
||||||
(v:verse-to-clog verse |
|
||||||
div |
|
||||||
:translation (second translation))) |
|
||||||
(hide-verse (verse) (setf (hiddenp verse) t)) |
|
||||||
(callback (obj) |
|
||||||
(declare (ignore obj)) |
(declare (ignore obj)) |
||||||
(mapc #'hide-verse display) |
(d:update-bible (third translation)))) |
||||||
(setf display (mapcar #'verse-to-clog verses)))) |
|
||||||
(create-gui-menu-item drop-down |
(create-gui-menu-item drop-down |
||||||
:content (first translation) |
:content (first translation) |
||||||
:on-click #'callback))) |
:on-click #'callback))) |
||||||
d:*translations*)) |
d:*translations*)) |
||||||
|
|
||||||
(defun display-chapter-or-book (canvas title verses) |
(defmethod display-chapter-or-book (canvas (title string) (chapter chapter)) |
||||||
(multiple-value-bind (div drop-down) |
(multiple-value-bind (div drop-down) |
||||||
(book/chapter-window canvas title) |
(book/chapter-window canvas title) |
||||||
(flet ((verse-to-clog (verse) |
(let ((display (chapter-to-clog chapter div :translation d:*translation*))) |
||||||
(v:verse-to-clog verse |
(translations-drop-down div display chapter drop-down)))) |
||||||
div |
|
||||||
:translation d:*translation*))) |
(defmethod load-chapter (canvas (book string) (chapter string)) |
||||||
(let ((display (mapcar #'verse-to-clog verses))) |
(let* ((bk (s:find-book d:*bible* book)) |
||||||
(translations-drop-down div display verses drop-down))))) |
(verses (if (find #\- chapter) |
||||||
|
(loop :for chap :in (uiop:split-string chapter :separator '(#\-)) |
||||||
(defun load-chapter (canvas book chapter) |
:append (s:find-chapter bk chap)) |
||||||
|
(s:find-chapter bk chapter)))) |
||||||
(display-chapter-or-book canvas |
(display-chapter-or-book canvas |
||||||
(format nil "~A: ~A ~A" |
(format nil "~A: ~A ~A" |
||||||
d:*translation* |
d:*translation* |
||||||
book |
book |
||||||
chapter) |
chapter) |
||||||
(s:find-chapter |
(make-instance 'chapter :verses verses)))) |
||||||
(s:find-book d:*bible* book) |
|
||||||
chapter))) |
|
||||||
|
|
||||||
(defun load-book (canvas book) |
(defmethod load-book ((canvas clog:clog-body) (book string)) |
||||||
(display-chapter-or-book canvas |
(display-chapter-or-book canvas |
||||||
(format nil "~A: ~A" |
(format nil "~A: ~A" |
||||||
d:*translation* |
d:*translation* |
||||||
book) |
book) |
||||||
(s:find-book d:*bible* book))) |
(make-instance 'chapter |
||||||
|
:verses (s:find-book d:*bible* book)))) |
||||||
|
|
||||||
|
(defmethod load-position ((canvas clog:clog-body) (pos string)) |
||||||
|
(display-chapter-or-book canvas |
||||||
|
(format nil "~A: ~A" |
||||||
|
d:*translation* |
||||||
|
pos) |
||||||
|
(make-instance 'chapter |
||||||
|
:verses (s:find-verse d:*bible* (s:parse-position pos))))) |
||||||
|
Loading…
Reference in new issue