-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemos.lisp
222 lines (193 loc) · 9.1 KB
/
demos.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
;; -*- mode: Lisp; Syntax: Common-Lisp; Package: cells; -*-
#|
Celtk -- Cells, Tcl, and Tk
Copyright (C) 2006 by Kenneth Tilton
This library is free software; you can redistribute it and/or
modify it under the terms of the Lisp Lesser GNU Public License
(http://opensource.franz.com/preamble.html), known as the LLGPL.
This library is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the Lisp Lesser GNU Public License for more details.
|#
(in-package :celtk-user)
(defmodel my-test (window)
((my-mode :accessor my-mode :initform (c? (evenp (selection (fm! :my-selector))))))
(:default-initargs
:id :my-test-id
:kids (c? (the-kids
(mk-stack ("stack" :packing (c?pack-self "-side bottom") :relief 'ridge)
(mk-entry :id :my-entry
:value (c-in "abc"))
(mk-row ( "row" #| :packing (c?pack-self "-side bottom") |# :relief 'ridge)
(mk-label :text (c? (format nil "selection: ~a" (selection (fm^ :my-selector)))))
(mk-label :text "Labeltext")
(mk-button-ex ("Reset" (setf (selection (fm^ :my-selector)) 1)))
(mk-stack ((c? (format nil "current selection: ~a" (^selection))) :id :my-selector :selection (c-in 1) :relief 'ridge)
(mk-radiobutton-ex ("selection 1" 1))
(mk-radiobutton-ex ("selection 2" 2))
(mk-radiobutton-ex ("selection 3" 3))
(mk-radiobutton-ex ("selection 4" 4)))
(mk-label :text (c? (format nil "selection: ~a" (selection (fm^ :my-selector)))))
))))))
(defobserver my-mode ((self my-test) new-value old-value old-value-bound-p)
(format t "~% mode changed from ~a to ~a" old-value new-value))
(defun ctk::franks-test ()
(run-window 'my-test))
#+test
(ctk::franks-test)
(defun ctk::tk-test () ;; ACL project manager needs a zero-argument function, in project package
(test-window
;;'place-test
'font-view-2
;; 'one-button-window
;; 'ltktest-cells-inside
;;'menu-button-test
;;'spinbox-test
;;'one-button-window
;;'lotsa-widgets
;; Now in Gears project 'gears-demo
))
(defmodel place-test (window)
()
(:default-initargs
:kids (c? (the-kids
(mk-label :text "hi, Mom"
:parent-x 100
:py 20)))))
(defmodel one-button-window (window)
()
(:default-initargs
:kids (c? (the-kids
#+shhhh (mk-menubar
:kids (c? (the-kids
(mk-menu-entry-cascade-ex (:label "File")
(mk-menu-entry-command-ex () "Load" (format t "~&Load pressed"))
(mk-menu-entry-command-ex () "Save" (format t "~&Save pressed"))))))
(mk-frame-stack
:packing (c?pack-self)
:kids (c? (the-kids
(mk-text-widget
:id :my-text
:value (c?n "[bzbzbzbz]")
:height 8
:width 25)
(make-instance 'entry
:id :entree
:fm-parent *parent*
:value (c-in "Boots")))))))))
(defun one-deep-menubar ()
(mk-menubar
:id 'mbar
:kids (c? (the-kids
(mk-menu-entry-cascade-ex (:label "File")
(mk-menu-entry-command-ex () "Load" (format t "~&Load pressed"))
(mk-menu-entry-command-ex () "Save" (format t "~&Save pressed")))
(mk-menu-entry-cascade
:id 'editcascade
:label "Edit"
:kids (c? (the-kids
(mk-menu
:id 'editmenu
:kids (c? (the-kids
(mk-menu-radio-group :id :app-font-face
:selection (c-in "courier")
:kids (c? (the-kids
(mk-menu-entry-radiobutton :label "Times" :value "times")
(mk-menu-entry-radiobutton :label "Courier" :value "courier")
(mk-menu-entry-radiobutton :label "Helvetica" :value "helvetica"))))))))))))))
(defmodel spinbox-test (window)
()
(:default-initargs
:kids (c? (the-kids
(mk-stack (:packing (c?pack-self))
(mk-spinbox
:id :spin-pkg
:value (c-in "cells") ;;(cells::c?n "cells")
:tk-values (mapcar 'down$
(sort (mapcar 'package-name
(list-all-packages))
'string>)))
(mk-scrolled-list
:id :spinpkg-sym-list
:list-height 6
:list-item-keys (c? (trc "enter item keys" self (fm^ :spin-pkg))
(let* ((spinner (fm^ :spin-pkg))
(item (when spinner (value spinner)))
(pkg (find-package (string-upcase item))))
(when pkg
(loop for sym being the symbols in pkg
for n below 5
counting sym into symct
collecting sym into syms
finally (return syms)))))
:list-item-factory (lambda (sym)
(make-instance 'listbox-item
:fm-parent *parent*
:value sym
:item-text (down$ (symbol-name sym)))))
(mk-label :text (c? (selection (fm^ :spinpkg-sym-list)))))))))
(defmodel menu-button-test (window)
()
(:default-initargs
:kids (c? (the-kids
(mk-stack ("Style by Widgets" :id :widstyle :packing (c?pack-self))
(mk-popup-menubutton
:id :font-face
:initial-value (c? (second (^entry-values)))
:entry-values (c? (subseq (tk-eval-list "font families") 4 10)))
(mk-label :text "Four score and seven years ago today, our fathers broguht forth on this continent a new nation..."
:wraplength 200
:tk-justify 'left
:tkfont (c? (list
(selection (fm^ :font-face))
14))))))))
(defmodel font-view-2 (window)
()
(:default-initargs
:kids (c? (the-kids
(mk-panedwindow
:packing (c?pack-self)
:orient 'vertical
:kids (c? (the-kids
(loop repeat 2
collecting (make-instance 'font-view :fm-parent *parent*)))))))))
(defun mk-font-view ()
(make-instance 'font-view))
(defmodel font-view (frame-stack)
()
(:default-initargs
:value (c? (tk-eval-list "font families"))
:pady 10 :padx 4
:packing-side 'left
:layout-anchor 'nw
:kids (c? (the-kids
(mk-spinbox :id :font-face
:value (c-in (car (^value)))
:tk-values (c? (value .parent)))
(mk-scale :id :font-size
:value (c-in 14)
:tk-label "Font Size"
:from 7 :to 24
:orient 'horizontal)
(mk-label :id :txt
:text "Four score seven years ago today"
:wraplength 600
:tkfont (c? (list ;; format nil "{{~{~a~^ ~}} ~a}" ;; eg, {{wp greek century} 24}
(value (fm^ :font-face))
(value (fm^ :font-size)))))))))
#| 06-02-14 following stuff not resurrected after latest revisions to Celtk
;;; ---- toplevel --------------------------------
(defmodel file-open (toplevel)
()
(:default-initargs
:value (c? (directory "\\windows\\fonts\\*.ttf"))
:pady 2 :padx 4
:kids (c? (the-kids
(mk-spinbox :id :font-face
:value (c-in (car (^value)))
:tk-values (c? (mapcar 'pathname-name (value .parent))))
(mk-button-ex ("Open" (progn
(tk-format `(:destroy ,self) "destroy ~a" (path (upper self toplevel)))
(not-to-be (upper self toplevel))))
:underline 0)))))
|#