summaryrefslogtreecommitdiffstats
path: root/demo2
blob: 3e6ef61c52261eec2d2c97c9cc696a62c98e221f (plain)
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
#!/bin/bash
sbcl --script << 'EOF' 2> >(sed '/^Backtrace/,$d;/^; /d')

; Refer to the demostuff file for definitions and descriptions.

(load "demostuff")

(defun main ()
  (gapp demo2
    (window win demo2 "Numerals Demo" 250 250)
    (box h outerbox win)
    (box v mainbox outerbox)
    (box h numbox mainbox)
    (button but1 (bnt 1) mainbox (xnum (bn 1)))
    (button but2 (bnt 2) mainbox (xnum (bn 2)))
    (button but3 (bnt 3) mainbox (xnum (bn 3)))
    (button but4 (bnt 4) mainbox (xnum (bn 4)))
    (button but5 (bnt 5) mainbox (xnum (bn 5)))
    (button numeralbutton "Numerals" mainbox (togglenumar))
    (text thenum "zero" numbox)
    (gtk_widget_show_all win))
  (g_application_run demo2 0 nil)
  (g_object_unref demo2))

(defparameter numar 'a)  ;  'r = I II II IV V.  'a = 1 2 3 4 5.

; Button number (bn) and button number text (bnt):
(defun bn (n) (nth (1- n) '(11 22 33 44 55)))
(defun bnt (n) (format nil (if (eq numar 'a) "~d" "~@R") (bn n)))

(defun togglenumar ()
  (setq numar (if (eq numar 'a) 'r 'a))
  (loop as button in (list but1 but2 but3 but4 but5)
        as n from 1 to 5
        do (xlabel button (bnt n))))

(defun xnum (n) (xtext thenum (format nil "~R" n)))

(main)

EOF