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