UI/Model Parse - Textboxes
[clnl] / src / main / interface.lisp
index 6d2ae373572a8822f84ef90f0624a96363f87d74..6b2d85e5a5432eab6aff37f15a78f085ee7d4ed2 100644 (file)
@@ -496,7 +496,35 @@ keep apprised of any updates that may happen.")
     (list :switch (append switch-def (list :height clnl-gltk:*switch-height*)) switch nil)))
   switch-defs))
 
-(defun initialize (&key dims view buttons switches)
+(defun textbox-defs->textboxes (textbox-defs)
+ (mapcar
+  (lambda (textbox-def)
+   (let*
+    ; we adjust to make it match jvm netlogo more accurately because
+    ; of what we do with width/height (in terms of characters)
+    ((adjusted-top (+ (getf textbox-def :top) 3))
+     (adjusted-left (- (getf textbox-def :left) 3))
+     (textbox
+      (clnl-gltk:textbox
+       adjusted-left
+       (- *window-height* (* (getf textbox-def :height) clnl-gltk:*font-height*) adjusted-top)
+       (getf textbox-def :width)
+       (getf textbox-def :height)
+       :text (getf textbox-def :display)
+       :border nil
+       :word-wrap t)))
+    (list
+     :textbox
+     (append
+      (list
+       :left adjusted-left
+       :top adjusted-top
+       :height (* (getf textbox-def :height) clnl-gltk:*font-height*))
+      textbox-def)
+     textbox nil)))
+  textbox-defs))
+
+(defun initialize (&key dims view buttons switches textboxes)
  "INITIALIZE &key DIMS VIEW BUTTONS SWITCHES => RESULT
 
   DIMS: (:xmin XMIN :xmax XMAX :ymin YMIN :ymax YMAX :patch-size PATCH-SIZE)
@@ -534,6 +562,7 @@ DESCRIPTION:
  (setf *widgets*
   (append
    (button-defs->buttons buttons)
+   (textbox-defs->textboxes textboxes)
    (switch-defs->switches switches))))
 
 (defun run ()
@@ -578,7 +607,7 @@ DESCRIPTION:
    (clnl-gltk:textbox
     5 (+ clnl-gltk:*font-height* 14)
     10 12
-    (format nil *initial-banner* (asdf:component-version (asdf:find-system :clnl)))))
+    :text (format nil *initial-banner* (asdf:component-version (asdf:find-system :clnl)))))
   (setf *inputbox* (clnl-gltk:inputbox 5 5 10))
   (cl-glut:main-loop)))