1 ;; -*- mode: Lisp; Syntax: Common-Lisp; Package: cells; -*-
4 Celtk -- Cells
, Tcl
, and Tk
6 Copyright
(C) 2006 by Kenneth Tilton
8 This library is free software
; you can redistribute it and/or
9 modify it under the terms of the Lisp Lesser GNU Public License
10 (http://opensource.franz.com
/preamble.html
), known as the LLGPL.
12 This library is distributed WITHOUT ANY WARRANTY
; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the Lisp Lesser GNU Public License for more details.
19 (in-package :celtk-user
)
22 (defmodel my-test
(window)
23 ((my-mode :accessor my-mode
:initform
(c?
(evenp (selection (fm! :my-selector
))))))
27 (mk-stack ("stack" :packing
(c?pack-self
"-side bottom") :relief
'ridge
)
28 (mk-entry :id
:my-entry
30 (mk-row ( "row" #|
:packing
(c?pack-self
"-side bottom") |
# :relief
'ridge
)
31 (mk-label :text
(c?
(format nil
"selection: ~a" (selection (fm^
:my-selector
)))))
32 (mk-label :text
"Labeltext")
33 (mk-button-ex ("Reset" (setf (selection (fm^
:my-selector
)) 1)))
34 (mk-stack ((c?
(format nil
"current selection: ~a" (^selection
))) :id
:my-selector
:selection
(c-in 1) :relief
'ridge
)
35 (mk-radiobutton-ex ("selection 1" 1))
36 (mk-radiobutton-ex ("selection 2" 2))
37 (mk-radiobutton-ex ("selection 3" 3))
38 (mk-radiobutton-ex ("selection 4" 4)))
39 (mk-label :text
(c?
(format nil
"selection: ~a" (selection (fm^
:my-selector
)))))
42 (defobserver my-mode
((self my-test
) new-value old-value old-value-bound-p
)
43 (format t
"~% mode changed from ~a to ~a" old-value new-value
))
45 (defun ctk::franks-test
()
46 (run-window 'my-test
))
51 (defun ctk::tk-test
() ;; ACL project manager needs a zero-argument function, in project package
55 ;;'ltktest-cells-inside
59 ;; Now in Gears project 'gears-demo
62 (defmodel place-test
(window)
66 (mk-label :text
"hi, Mom"
70 (defmodel one-button-window
(window)
76 (mk-menu-entry-cascade-ex (:label
"File")
77 (mk-menu-entry-command-ex () "Load" (format t
"~&Load pressed"))
78 (mk-menu-entry-command-ex () "Save" (format t
"~&Save pressed"))))))
80 :packing
(c?pack-self
)
84 :value
(c?n
"[bzbzbzbz]")
90 :value
(c-in "Boots")))))))))
92 (defun one-deep-menubar ()
96 (mk-menu-entry-cascade-ex (:label
"File")
97 (mk-menu-entry-command-ex () "Load" (format t
"~&Load pressed"))
98 (mk-menu-entry-command-ex () "Save" (format t
"~&Save pressed")))
99 (mk-menu-entry-cascade
106 (mk-menu-radio-group :id
:app-font-face
107 :selection
(c-in "courier")
109 (mk-menu-entry-radiobutton :label
"Times" :value
"times")
110 (mk-menu-entry-radiobutton :label
"Courier" :value
"courier")
111 (mk-menu-entry-radiobutton :label
"Helvetica" :value
"helvetica"))))))))))))))
113 (defmodel spinbox-test
(window)
117 (mk-stack (:packing
(c?pack-self
))
120 :value
(c-in "cells") ;;(cells::c?n "cells")
121 :tk-values
(mapcar 'down$
122 (sort (mapcar 'package-name
126 :id
:spinpkg-sym-list
128 :list-item-keys
(c?
(trc "enter item keys" self
(fm^
:spin-pkg
))
129 (let* ((spinner (fm^
:spin-pkg
))
130 (item (when spinner
(value spinner
)))
131 (pkg (find-package (string-upcase item
))))
133 (loop for sym being the symbols in pkg
135 counting sym into symct
136 collecting sym into syms
137 finally
(return syms
)))))
138 :list-item-factory
(lambda (sym)
139 (make-instance 'listbox-item
142 :item-text
(down$
(symbol-name sym
)))))
143 (mk-label :text
(c?
(selection (fm^
:spinpkg-sym-list
)))))))))
146 (defmodel menu-button-test
(window)
150 (mk-stack ("Style by Widgets" :id
:widstyle
:packing
(c?pack-self
))
153 :initial-value
(c?
(second (^entry-values
)))
154 :entry-values
(c?
(subseq (tk-eval-list "font families") 4 10)))
155 (mk-label :text
"Four score and seven years ago today, our fathers broguht forth on this continent a new nation..."
159 (selection (fm^
:font-face
))
162 (defmodel font-view-2
(window)
167 :packing
(c?pack-self
)
171 collecting
(make-instance 'font-view
:fm-parent
*parent
*)))))))))
173 (defun mk-font-view ()
174 (make-instance 'font-view
))
176 (defmodel font-view
(frame-stack)
179 :value
(c?
(tk-eval-list "font families"))
184 (mk-spinbox :id
:font-face
185 :value
(c-in (car (^value
)))
186 :tk-values
(c?
(value .parent
)))
187 (mk-scale :id
:font-size
189 :tk-label
"Font Size"
193 :text
"Four score seven years ago today"
195 :tkfont
(c?
(list ;; format nil "{{~{~a~^ ~}} ~a}" ;; eg, {{wp greek century} 24}
196 (value (fm^
:font-face
))
197 (value (fm^
:font-size
)))))))))
199 #|
06-
02-
14 following stuff not resurrected after latest revisions to Celtk
201 ;;; ---- toplevel --------------------------------
206 (defmodel file-open
(toplevel)
209 :value
(c?
(directory "\\windows\\fonts\\*.ttf"))
212 (mk-spinbox :id
:font-face
213 :value
(c-in (car (^value
)))
214 :tk-values
(c?
(mapcar 'pathname-name
(value .parent
))))
215 (mk-button-ex ("Open" (progn
216 (tk-format `(:destroy
,self
) "destroy ~a" (path (upper self toplevel
)))
217 (not-to-be (upper self toplevel
))))