-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbox.lisp
122 lines (92 loc) · 2.98 KB
/
box.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
(in-package #:jupyter/widgets)
(defwidget box (dom-widget)
((box-style
:initarg :box-style
:initform ""
:accessor widget-box-style
:documentation "Use a predefined styling for the box."
:trait :string)
(children
:initarg :children
:initform nil
:accessor widget-children
:documentation "List of widget children."
:trait :widget-list))
(:default-initargs
:%model-name "BoxModel"
:%view-name "BoxView")
(:documentation
"Displays multiple widgets in a group. The widgets are laid out horizontally.
### Example
```common-lisp
(use-package :jupyter-widgets)
(defvar title-widget (make-instance 'html :value \"<em>Box Example</em>\"))
(defvar slider (make-instance 'int-slider))
(make-instance 'box :children (list title-widget slider))
```"))
(defwidget accordion (box)
((%titles
:initarg :%titles
:initform nil
:accessor widget-%titles
:documentation "Titles of the pages."
:trait :string-list)
(selected-index
:initarg :selected-index
:accessor widget-selected-index
:initform nil
:documentation "The index of the selected page. This is either an integer selecting a particular sub-widget, or nil to have no widgets selected."
:trait :int))
(:default-initargs
:%model-name "AccordionModel"
:%view-name "AccordionView")
(:documentation "Displays children each on a separate accordion page."))
(defmethod validate-trait ((w accordion) (type (eql :int)) name value)
(if (and (integerp value)
(equal name 'selected-index)
(outside-left-closed-interval value
0
(if (slot-boundp w 'children)
(length (widget-children w))
0)))
(error 'trait-error :format-control "Invalid selection: selected-index out of bounds")
(call-next-method)))
(defwidget grid-box (box)
()
(:default-initargs
:%model-name "GridBoxModel"
:%view-name "GridBoxView"))
(defwidget h-box (box)
()
(:default-initargs
:%model-name "HBoxModel"
:%view-name "HBoxView")
(:documentation
"Displays multiple widgets horizontally using the flexible box model.
### Example
```common-lisp
(use-package :jupyter-widgets)
(defvar title-widget (make-instance 'html :value \"<em>Box Example</em>\"))
(defvar slider (make-instance 'int-slider))
(make-instance 'h-box :children (list title-widget slider))
```"))
(defwidget tab (accordion)
()
(:default-initargs
:%model-name "TabModel"
:%view-name "TabView")
(:documentation "Displays children each on a separate accordion tab."))
(defwidget v-box (box)
()
(:default-initargs
:%model-name "VBoxModel"
:%view-name "VBoxView")
(:documentation
"Displays multiple widgets vertically using the flexible box model.
### Example
```common-lisp
(use-package :jupyter-widgets)
(defvar title-widget (make-instance 'html :value \"<em>Box Example</em>\"))
(defvar slider (make-instance 'int-slider))
(make-instance 'v-box :children (list title-widget slider))
```"))