author | Claus Gittinger <cg@exept.de> |
Wed, 13 Mar 2019 22:17:11 +0100 | |
changeset 3655 | 194726a985db |
parent 3613 | 5b03d091c507 |
permissions | -rw-r--r-- |
809
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
1 |
" |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
2621 | 3 |
All Rights Reserved |
809
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
4 |
|
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
5 |
This software is furnished under a license and may be used |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
10 |
hereby transferred. |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
11 |
" |
3613 | 12 |
"{ Package: 'stx:libtool2' }" |
809
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
13 |
|
2621 | 14 |
"{ NameSpace: Tools }" |
34 | 15 |
|
1213 | 16 |
SelectionInListView subclass:#NewInspectorListView |
39 | 17 |
instanceVariableNames:'actionHolder inspectorList includesSelf' |
34 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
1213 | 20 |
category:'Interface-NewInspector' |
34 | 21 |
! |
22 |
||
1213 | 23 |
!NewInspectorListView class methodsFor:'documentation'! |
34 | 24 |
|
809
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
25 |
copyright |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
26 |
" |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
27 |
COPYRIGHT (c) 1997 by eXept Software AG |
2621 | 28 |
All Rights Reserved |
809
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
29 |
|
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
30 |
This software is furnished under a license and may be used |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
31 |
only in accordance with the terms of that license and with the |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
32 |
inclusion of the above copyright notice. This software may not |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
33 |
be provided or otherwise made available to, or used by, any |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
34 |
other person. No title to or ownership of the software is |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
35 |
hereby transferred. |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
36 |
" |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
37 |
|
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
38 |
|
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
39 |
! |
6f127dd5e578
added copyright & documentation
Claus Gittinger <cg@exept.de>
parents:
327
diff
changeset
|
40 |
|
34 | 41 |
examples |
42 |
" |
|
2621 | 43 |
open a list view on an instance |
44 |
[exBegin] |
|
45 |
|top slv a| |
|
34 | 46 |
|
2621 | 47 |
a := OrderedCollection new. |
48 |
a add:1. |
|
34 | 49 |
|
2621 | 50 |
top := StandardSystemView new |
51 |
label:'select'; |
|
52 |
extent:200@200. |
|
34 | 53 |
|
2621 | 54 |
slv := ScrollableView for:self in:top. |
55 |
slv origin:0.0@0.0 corner:1.0@1.0. |
|
56 |
slv := slv scrolledView. |
|
57 |
slv inspect:top. |
|
58 |
slv action:[:el|Transcript showCR:(el printString)]. |
|
59 |
top open |
|
60 |
[exEnd] |
|
34 | 61 |
" |
62 |
! ! |
|
63 |
||
1213 | 64 |
!NewInspectorListView methodsFor:'accessing'! |
34 | 65 |
|
66 |
includesSelf:aBool |
|
67 |
includesSelf := aBool |
|
68 |
! |
|
69 |
||
39 | 70 |
list |
71 |
^ inspectorList |
|
34 | 72 |
! |
73 |
||
39 | 74 |
list:aList |
75 |
"set the lists contents from another list |
|
34 | 76 |
" |
39 | 77 |
aList notNil ifTrue:[inspectorList := aList list] |
2621 | 78 |
ifFalse:[inspectorList := NewInspectorList new]. |
34 | 79 |
|
39 | 80 |
inspectorList includesSelf:includesSelf. |
81 |
super list:(inspectorList instanceNames). |
|
34 | 82 |
! |
83 |
||
39 | 84 |
update |
85 |
"update the current list |
|
34 | 86 |
" |
39 | 87 |
inspectorList update. |
88 |
super list:(inspectorList instanceNames). |
|
34 | 89 |
|
90 |
! ! |
|
91 |
||
1213 | 92 |
!NewInspectorListView methodsFor:'accessing actions'! |
34 | 93 |
|
39 | 94 |
action:aOneArgAction |
95 |
"set the single click action block. If non-nil, that one is evaluated on single |
|
96 |
click, passing the selected instance as argument |
|
34 | 97 |
" |
39 | 98 |
actionHolder := aOneArgAction |
34 | 99 |
! ! |
100 |
||
1213 | 101 |
!NewInspectorListView methodsFor:'drawing'! |
34 | 102 |
|
103 |
drawVisibleLineSelected:visLineNr with:fg and:bg |
|
39 | 104 |
"redraw a single line as selected. |
105 |
" |
|
2621 | 106 |
|nr| |
34 | 107 |
|
108 |
(nr := self visibleLineToListLine:visLineNr) notNil ifTrue:[ |
|
2621 | 109 |
^ self drawVisibleLine:visLineNr with:fg and:bg. |
34 | 110 |
]. |
111 |
^ super drawVisibleLine:visLineNr with:fg and:bg |
|
112 |
||
113 |
! |
|
114 |
||
115 |
redrawArrowVisibleLine:visLineNr |
|
39 | 116 |
"draw a right arrow for visible line |
117 |
" |
|
34 | 118 |
|nr| |
119 |
||
120 |
nr := self visibleLineToListLine:visLineNr. |
|
121 |
||
39 | 122 |
(inspectorList instanceTypeAt:nr) == #directory ifTrue:[ |
2621 | 123 |
self drawRightArrowInVisibleLine:visLineNr |
34 | 124 |
] |
125 |
||
126 |
||
127 |
! |
|
128 |
||
129 |
redrawFromVisibleLine:startVisLineNr to:endVisLineNr |
|
130 |
"redefined to look for directory in every line |
|
131 |
" |
|
132 |
super redrawFromVisibleLine:startVisLineNr to:endVisLineNr. |
|
133 |
||
134 |
startVisLineNr to:endVisLineNr do:[:visLineNr| |
|
2621 | 135 |
self redrawArrowVisibleLine:visLineNr |
34 | 136 |
] |
137 |
! |
|
138 |
||
139 |
redrawVisibleLine:visLineNr |
|
140 |
"if the line is one for a directory, draw a right arrow |
|
141 |
" |
|
142 |
super redrawVisibleLine:visLineNr. |
|
143 |
self redrawArrowVisibleLine:visLineNr. |
|
144 |
! |
|
145 |
||
146 |
visibleLineNeedsSpecialCare:visLineNr |
|
39 | 147 |
"returns true if the visible line needs special care |
148 |
" |
|
34 | 149 |
|nr| |
150 |
||
327
0040d47658c6
check - warnings eliminated. Fix in InspectorList.st
Claus Gittinger <cg@exept.de>
parents:
39
diff
changeset
|
151 |
nr := self visibleLineToListLine:visLineNr. |
0040d47658c6
check - warnings eliminated. Fix in InspectorList.st
Claus Gittinger <cg@exept.de>
parents:
39
diff
changeset
|
152 |
|
39 | 153 |
(inspectorList instanceTypeAt:nr) == #directory ifTrue:[ |
2621 | 154 |
^ true |
34 | 155 |
]. |
156 |
^ super visibleLineNeedsSpecialCare:visLineNr |
|
157 |
||
158 |
! |
|
159 |
||
160 |
widthForScrollBetween:firstLine and:lastLine |
|
161 |
"return the width in pixels for a scroll between firstLine and lastLine |
|
162 |
- return full width here since there might be directory marks |
|
163 |
" |
|
164 |
^ (width - margin - margin) |
|
165 |
||
166 |
||
167 |
! ! |
|
168 |
||
1213 | 169 |
!NewInspectorListView methodsFor:'event handling'! |
34 | 170 |
|
171 |
sizeChanged:how |
|
39 | 172 |
"redraw marks |
173 |
" |
|
34 | 174 |
super sizeChanged:how. |
175 |
shown ifTrue:[self invalidate] |
|
176 |
||
177 |
! ! |
|
178 |
||
1213 | 179 |
!NewInspectorListView methodsFor:'initialization'! |
34 | 180 |
|
181 |
initialize |
|
182 |
"initialization |
|
183 |
" |
|
184 |
super initialize. |
|
185 |
||
186 |
ignoreReselect := false. |
|
187 |
includesSelf := false. |
|
188 |
actionHolder := [:el|]. |
|
1213 | 189 |
inspectorList := NewInspectorList new. |
34 | 190 |
|
191 |
actionBlock := [:dummy| |
|
2621 | 192 |
self setSelection:selection. |
193 |
actionHolder value:(self selectedInstanceVar) |
|
34 | 194 |
]. |
195 |
! ! |
|
196 |
||
1213 | 197 |
!NewInspectorListView methodsFor:'private'! |
34 | 198 |
|
39 | 199 |
doesNotUnderstand:aMessage |
200 |
"forward a message to the inspectorList |
|
34 | 201 |
" |
39 | 202 |
(inspectorList respondsTo:(aMessage selector)) ifTrue:[ |
2621 | 203 |
^ aMessage sendTo:inspectorList |
39 | 204 |
]. |
205 |
^ super doesNotUnderstand:aMessage |
|
206 |
||
207 |
||
208 |
! |
|
209 |
||
210 |
list:aCollection keepSelection:aBoolean |
|
211 |
"set the list - redefined, since setting the list implies unselecting |
|
212 |
and clearing attributes." |
|
213 |
||
214 |
"somewhat of a kludge: if selection is first line, |
|
215 |
we have to remove the highlight frame by hand here" |
|
216 |
||
217 |
(shown and:[hilightLevel ~~ 0]) ifTrue:[ |
|
2621 | 218 |
selection == firstLineShown ifTrue:[ |
219 |
self paint:bgColor. |
|
220 |
self fillRectangleX:margin y:margin |
|
221 |
width:(width - (margin * 2)) |
|
222 |
height:(hilightLevel abs). |
|
223 |
]. |
|
39 | 224 |
]. |
225 |
listAttributes := nil. |
|
226 |
super list:aCollection expandTabs:false. |
|
227 |
super setSelection:(inspectorList selection). |
|
228 |
||
229 |
||
230 |
||
231 |
||
34 | 232 |
! ! |
233 |
||
1213 | 234 |
!NewInspectorListView methodsFor:'selections'! |
34 | 235 |
|
39 | 236 |
setSelection:aNumberOrNil |
237 |
"select line, aNumber or deselect if argument is nil |
|
238 |
" |
|
239 |
|oldSize| |
|
240 |
||
241 |
oldSize := inspectorList size. |
|
242 |
inspectorList setSelection:aNumberOrNil. |
|
243 |
oldSize == inspectorList size ifTrue:[super setSelection:(inspectorList selection)] |
|
2621 | 244 |
ifFalse:[super list:(inspectorList instanceNames)]. |
39 | 245 |
! ! |
246 |
||
1213 | 247 |
!NewInspectorListView methodsFor:'user interaction'! |
39 | 248 |
|
249 |
accept:aText notifying:aView |
|
250 |
"evaluating aText on the selected instance var; if an error occurs #Error |
|
251 |
is returned otherwise the inspected object instance. On success the list |
|
252 |
will be updated. |
|
34 | 253 |
" |
39 | 254 |
|res| |
255 |
||
256 |
res := inspectorList accept:aText notifying:aView. |
|
257 |
||
258 |
res ~~ #Error ifTrue:[ |
|
2621 | 259 |
super list:(inspectorList instanceNames) |
39 | 260 |
]. |
261 |
^ res |
|
262 |
! |
|
263 |
||
264 |
doIt:aCode notifying:aView |
|
265 |
"evaluating aCode on the selected instance var; if an error occurs #Error |
|
266 |
is returned otherwise the result returned from the evaluator. On success |
|
267 |
the list will be updated. |
|
268 |
" |
|
269 |
|res| |
|
270 |
||
271 |
res := inspectorList doIt:aCode notifying:aView. |
|
272 |
||
273 |
res ~~ #Error ifTrue:[ |
|
2621 | 274 |
super list:(inspectorList instanceNames) |
39 | 275 |
]. |
276 |
^ res |
|
34 | 277 |
|
278 |
! |
|
279 |
||
39 | 280 |
inspect:anObject |
281 |
"inspect a new instance; update contents |
|
34 | 282 |
" |
39 | 283 |
(inspectorList inspectedObject) == anObject ifTrue:[ |
2621 | 284 |
^ self update |
39 | 285 |
]. |
1286 | 286 |
inspectorList := NewInspectorList for:anObject. |
39 | 287 |
inspectorList includesSelf:includesSelf. |
34 | 288 |
|
39 | 289 |
super list:(inspectorList instanceNames). |
34 | 290 |
! ! |
291 |
||
1213 | 292 |
!NewInspectorListView class methodsFor:'documentation'! |
34 | 293 |
|
294 |
version |
|
295 |
^ '$Header$' |
|
296 |
! ! |
|
3613 | 297 |