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