summaryrefslogtreecommitdiffstats
path: root/demo2.tl
blob: e982c05955a394c7b93c4ff370b492cd680d3e55 (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
; Refer to the gtkffi.tl file for definitions and descriptions.

(defun demo2 ()
  (window demo2 demos "Numerals Demo" 250 250)
  (box h outerbox2 demo2)
  (box v mainbox2 outerbox2)
  (box h numbox2 mainbox2)
  (button b21 (bnt 1) mainbox2 (xnum (bn 1)))
  (button b22 (bnt 2) mainbox2 (xnum (bn 2)))
  (button b23 (bnt 3) mainbox2 (xnum (bn 3)))
  (button b24 (bnt 4) mainbox2 (xnum (bn 4)))
  (button b25 (bnt 5) mainbox2 (xnum (bn 5)))
  (button numeralbutton2 "Dec/Hex" mainbox2 (togglenumar))
  (text num2 "zero" numbox2)
  (gtk_widget_show_all demo2))

(defparm numar 'dec) ;; dec or hex

(defparm toggle (relate '(dec hex) '(hex dec)))

; Button number (bn) and button number text (bnt):
(defun bn (n) (nth (pred n) '(11 22 33 44 55)))

(defun bnt (n)
  (let ((h-or-d (relate '(dec hex) '("~d" "~x"))))
    (fmt [h-or-d numar] (bn n))))

(defun togglenumar ()
  (upd numar toggle)
  (each ((button (list b21 b22 b23 b24 b25))
         (n (range 1 5)))
    (xlabel button (bnt n))))

(defun xnum (n) (xtext num2 (format nil "~d" n)))