-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe.lisp
120 lines (92 loc) · 3.34 KB
/
frame.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
;; -*- 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)
;--- group geometry -----------------------------------------
(defmd inline-mixin (composite-widget widget)
(padx 0)
(pady 0)
(packing-side 'left)
(layout-anchor 'nw)
:kids-packing (c? (when (^kids)
(format nil "pack~{ ~a~} -side ~a -anchor ~a -padx ~a -pady ~a"
(mapcar 'path (^kids))
(down$ (^packing-side))
(down$ (^layout-anchor))
(^padx)(^pady)))))
(defobserver kids-packing ()
(when new-value
(tk-format `(:pack ,self kids-packing) new-value)))
(defmd row-mixin (inline-mixin)
:packing-side 'left)
(defmd stack-mixin (inline-mixin)
:packing-side 'top)
;--- g r i d s ----------------------------------------------
(defmd grid (grid-manager frame)
(rows)
(row-factory)
(kids (c? (the-kids
(loop for row in (^rows)
for row-num from 0
collect (funcall (^row-factory)
row
row-num))))))
(defobserver .kids ((self grid))
(when new-value
(loop for k in new-value
when (gridding k)
do (tk-format `(:grid ,k)
(format nil "grid ~a ~a"
(path k)
(gridding k))))))
(defmacro mk-grid (&rest initargs)
`(make-instance 'grid
,@initargs
:fm-parent *parent*))
;--- f r a m e --------------------------------------------------
(deftk frame (composite-widget widget)
()
(:tk-spec frame -borderwidth -cursor -highlightbackground -highlightcolor
-highlightthickness -padx -pady -relief
-takefocus -background (tk-class -class)
-colormap -container -height -visual -width)
(:default-initargs
:id (gentemp "F")))
(deftk frame-selector (tk-selector frame) ())
(deftk frame-row (row-mixin frame-selector)())
(deftk frame-stack (stack-mixin frame-selector)())
;--- l a b e l f r a m e ----------------------------------------------
(deftk labelframe (widget)
()
(:tk-spec labelframe -borderwidth -cursor -highlightbackground -highlightcolor
-highlightthickness -padx -pady -relief
-takefocus -background (tk-class -class) -colormap -container -height -visual -width
-text -labelanchor -labelwidget)
(:default-initargs
:id (gentemp "LF")))
(deftk labelframe-selector (tk-selector labelframe)())
(deftk labelframe-row (row-mixin labelframe-selector)())
(deftk labelframe-stack (stack-mixin labelframe-selector)())
;;; --- handy macros
(defmacro def-mk-inline (name (unlabelled labelled))
`(defmacro ,name ((&rest initargs) &rest kids)
(if (evenp (length initargs))
`(make-instance ',',unlabelled
:fm-parent *parent*
,@initargs
:kids (c? (the-kids ,@kids)))
`(make-instance ',',labelled
:fm-parent *parent*
:text ,(car initargs)
,@(cdr initargs)
:kids (c? (the-kids ,@kids))))))
(def-mk-inline mk-row (frame-row labelframe-row))
(def-mk-inline mk-stack (frame-stack labelframe-stack))