;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; CLOG - The Common Lisp Omnificent GUI ;;;;
;;;; (c) 2020-2021 David Botton ;;;;
;;;; License BSD 3 Clause ;;;;
;;;; ;;;;
;;;; clog-element-commont.lisp ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(cl:in-package :clog)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - clog-a
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defclass clog-a (clog-element)()
(:documentation "CLOG A, anchor, Objects."))
;;;;;;;;;;;;;;
;; create-a ;;
;;;;;;;;;;;;;;
(defgeneric create-a (clog-obj &key link content target auto-place)
(:documentation "Create a new CLOG-A as child of CLOG-OBJ with :LINK and
:CONTENT (default \"\") and :TARGET (\"_self\") and if :AUTO-PLACE (default t)
place-inside-bottom-of CLOG-OBJ.
Target of link, name of a frame or:
_blank = new window
_top = top most frame (full browser window)
_parent = parent frame or window
_self = current frame or window"))
(defmethod create-a ((obj clog-obj)
&key (link "")
(content "")
(target "_self")
(auto-place t))
(create-child obj (format nil "~A"
(escape-string target)
(escape-string link)
(escape-string content))
:clog-type 'clog-a
:auto-place auto-place))
;;;;;;;;;;
;; link ;;
;;;;;;;;;;
(defgeneric link (clog-a)
(:documentation "Get/Setf the HREF link of the anchor."))
(defmethod link ((obj clog-a))
(property obj "href"))
(defgeneric set-link (clog-a value)
(:documentation "Set link VALUE for CLOG-A"))
(defmethod set-link ((obj clog-a) value)
(setf (property obj "href") value))
(defsetf link set-link)
;;;;;;;;;;;;
;; target ;;
;;;;;;;;;;;;
(defgeneric target (clog-a)
(:documentation "Get/Setf the link target of the anchor."))
(defmethod target ((obj clog-a))
(property obj "target"))
(defgeneric set-target (clog-a value)
(:documentation "Set target VALUE for CLOG-A"))
(defmethod set-target ((obj clog-a) value)
(setf (property obj "target") value))
(defsetf target set-target)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - clog-br
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defclass clog-br (clog-element)()
(:documentation "CLOG BR Objects for line breaks."))
;;;;;;;;;;;;;;;
;; create-br ;;
;;;;;;;;;;;;;;;
(defgeneric create-br (clog-obj &key auto-place)
(:documentation "Create a new CLOG-BR as child of CLOG-OBJ that creates a
line break and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ"))
(defmethod create-br ((obj clog-obj) &key (auto-place t))
(create-child obj "
" :clog-type 'clog-br :auto-place auto-place))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - clog-button
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defclass clog-button (clog-element)()
(:documentation "CLOG Button Objects."))
;;;;;;;;;;;;;;;;;;;
;; create-button ;;
;;;;;;;;;;;;;;;;;;;
(defgeneric create-button (clog-obj &key content auto-place)
(:documentation "Create a new CLOG-Button as child of CLOG-OBJ with :CONTENT
(default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of
CLOG-OBJ"))
(defmethod create-button ((obj clog-obj) &key (content "") (auto-place t))
(create-child obj (format nil "" (escape-string content))
:clog-type 'clog-button :auto-place auto-place))
;;;;;;;;;;;;;;;
;; disabledp ;;
;;;;;;;;;;;;;;;
(defgeneric disabledp (clog-button)
(:documentation "Get/Setf disabled status of button."))
(defmethod disabledp ((obj clog-button))
(js-true-p (property obj "disabled")))
(defgeneric set-disabledp (clog-button value)
(:documentation "Set editable VALUE for CLOG-BUTTON"))
(defmethod set-disabledp ((obj clog-button) value)
(setf (property obj "disabled") (p-true-js value)))
(defsetf disabledp set-editable)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Implementation - clog-div
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defclass clog-div (clog-element)()
(:documentation "CLOG Div Objects."))
;;;;;;;;;;;;;;;;
;; create-div ;;
;;;;;;;;;;;;;;;;
(defgeneric create-div (clog-obj &key content auto-place)
(:documentation "Create a new CLOG-Div as child of CLOG-OBJ with :CONTENT
(default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of
CLOG-OBJ"))
(defmethod create-div ((obj clog-obj) &key (content "") (auto-place t))
(create-child obj (format nil "
~A
" (escape-string content)) :clog-type 'clog-p :auto-place auto-place)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-span ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass clog-span (clog-element)() (:documentation "CLOG Span Objects.")) ;;;;;;;;;;;;;;;;; ;; create-span ;; ;;;;;;;;;;;;;;;;; (defgeneric create-span (clog-obj &key content auto-place) (:documentation "Create a new CLOG-Span as child of CLOG-OBJ with CONTENT and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-span ((obj clog-obj) &key (content "") (auto-place t)) (create-child obj (format nil "~A" (escape-string content)) :clog-type 'clog-span :auto-place auto-place)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-section ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass clog-section (clog-element)() (:documentation "CLOG Section Objects.")) ;;;;;;;;;;;;;;;;;;;; ;; create-section ;; ;;;;;;;;;;;;;;;;;;;; (deftype section-type () '(member :address :article :aside :header :main :nav :p :pre :section :blockquote :h1 :h2 :h3 :h4 :h5 :h6 :hgroup)) (defgeneric create-section (clog-obj section &key content auto-place) (:documentation "Create a new CLOG-Section of section type as child of CLOG-OBJ with CONTENT and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-section ((obj clog-obj) section &key (content "") (auto-place t)) (create-child obj (format nil "<~A>~A~A>" section (escape-string content) section) :clog-type 'clog-section :auto-place auto-place)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-phrase ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass clog-phrase (clog-element)() (:documentation "CLOG Phrase Objects.")) ;;;;;;;;;;;;;;;;;;; ;; create-phrase ;; ;;;;;;;;;;;;;;;;;;; (deftype phrase-type () '(member :abbr :code :strong :em :dfn :samp :kbd :var :marked :del :ins :s :q :big :small :time :tt :cite :i :b :u :sub :su)) (defgeneric create-phrase (clog-obj phrase &key content auto-place) (:documentation "Create a new CLOG-Phrase of phrase type as child of CLOG-OBJ with CONTENT and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) (defmethod create-phrase ((obj clog-obj) phrase &key (content "") (auto-place t)) (create-child obj (format nil "<~A>~A~A>" phrase (escape-string content) phrase) :clog-type 'clog-phrase :auto-place auto-place))