-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.lisp
96 lines (76 loc) · 2.87 KB
/
button.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
;; -*- 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)
;--- button ----------------------------------------------
(deftk button (commander widget)
()
(:tk-spec button
-activebackground -activeforeground -anchor
-background -bitmap -borderwidth -cursor
-disabledforeground (tkfont -font) -foreground
-highlightbackground -highlightcolor -highlightthickness -image
(tk-justify -justify)
-padx -pady -relief -repeatdelay
-repeatinterval -takefocus -text -textvariable
-underline -wraplength
-command -compound -default -height -overrelief -state -width)
(:default-initargs
:id (gentemp "B")))
(defmacro mk-button-ex ((text command) &rest initargs)
`(make-instance 'button
:fm-parent *parent*
:text ,text
:on-command (c? (lambda (self)
(declare (ignorable self))
,command))
,@initargs))
; --- checkbutton ---------------------------------------------
(deftk radiocheck (commander widget)
()
(:tk-spec radiocheck
-activebackground -activeforeground -anchor
-background -bitmap -borderwidth -compound -cursor
-disabledforeground (tkfont -font) -foreground
-highlightbackground -highlightcolor -highlightthickness -image
(tk-justify -justify) -padx -pady -relief -takefocus -text -textvariable
-underline -wraplength
-command -height -indicatoron -offrelief
-overrelief -selectcolor -selectimage -state -tristateimage
-tristatevalue (tk-variable -variable) -width))
(deftk checkbutton (radiocheck)
()
(:tk-spec checkbutton
-offvalue -onvalue)
(:default-initargs
:id (gentemp "CK")
:value (c-in nil)
:tk-variable (c? (^path))
:on-command (lambda (self)
(setf (^value) (not (^value))))))
(defobserver .value ((self checkbutton))
(tk-format `(:variable ,self) "set ~(~a~) ~a" (path self) (if new-value 1 0)))
; --- radiobutton -------------------------------------
(deftk radiobutton (radiocheck)
()
(:tk-spec radiobutton
-value)
(:default-initargs
:id (gentemp "RB")
:tk-variable (c? (path (upper self tk-selector)))
:on-command (lambda (self)
(setf (selection (upper self tk-selector)) (value self)))))
(defmacro mk-radiobutton-ex ((text value) &rest initargs)
`(make-instance 'radiobutton
:fm-parent *parent*
:text ,text
:value ,value
,@initargs))