43
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
49
|
13 |
SelectionInListView subclass:#UIPainterTreeView
|
|
14 |
instanceVariableNames:'builderView'
|
43
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Interface-UIPainter'
|
|
18 |
!
|
|
19 |
|
|
20 |
!UIPainterTreeView class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
25 |
All Rights Reserved
|
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
documentation
|
|
37 |
"
|
|
38 |
not yet finished, not yet published, not yet released.
|
|
39 |
"
|
|
40 |
! !
|
|
41 |
|
49
|
42 |
!UIPainterTreeView class methodsFor:'constants'!
|
43
|
43 |
|
49
|
44 |
indent
|
|
45 |
"indent for contained element
|
|
46 |
"
|
|
47 |
^ 2
|
|
48 |
|
43
|
49 |
|
49
|
50 |
! !
|
|
51 |
|
|
52 |
!UIPainterTreeView class methodsFor:'defaults'!
|
43
|
53 |
|
49
|
54 |
defaultMenuMessage
|
|
55 |
"This message is the default yo be sent to the menuHolder to get a menu
|
|
56 |
"
|
58
|
57 |
^ #menu
|
43
|
58 |
|
|
59 |
|
|
60 |
! !
|
|
61 |
|
49
|
62 |
!UIPainterTreeView methodsFor:'accessing'!
|
43
|
63 |
|
|
64 |
builderView:aBuilderView
|
|
65 |
builderView := aBuilderView.
|
49
|
66 |
self updateTree.
|
43
|
67 |
|
|
68 |
!
|
|
69 |
|
49
|
70 |
indexOf:aString
|
|
71 |
"returns the index of the string entry into my list
|
|
72 |
"
|
58
|
73 |
^ list findFirst:[:aName| aName string withoutSeparators = aString ]
|
49
|
74 |
|
|
75 |
|
|
76 |
! !
|
|
77 |
|
|
78 |
!UIPainterTreeView methodsFor:'event handling'!
|
43
|
79 |
|
62
|
80 |
builderViewChanged:what
|
|
81 |
"something changed in the builder view
|
49
|
82 |
"
|
62
|
83 |
(what == #tree or:[what == #widgetName]) ifTrue:[
|
43
|
84 |
self updateTree
|
|
85 |
] ifFalse:[
|
62
|
86 |
what ~~ #selection ifTrue:[
|
43
|
87 |
^ self
|
49
|
88 |
].
|
58
|
89 |
self disableMaster:selection.
|
49
|
90 |
self setSelection:nil.
|
43
|
91 |
].
|
|
92 |
|
49
|
93 |
"update selection
|
|
94 |
"
|
|
95 |
builderView selectionDo:[:aView||idx|
|
|
96 |
idx := self indexOf:(builderView variableNameOf:aView).
|
43
|
97 |
|
49
|
98 |
idx ~~ 0 ifTrue:[
|
58
|
99 |
selection isNil ifTrue:[
|
|
100 |
|m i|
|
|
101 |
|
|
102 |
m := list at:idx.
|
|
103 |
i := m indexOfNonSeparatorStartingAt:1.
|
|
104 |
i == 0 ifTrue:[ i := 1 ].
|
|
105 |
m := Text string:m.
|
|
106 |
m emphasizeFrom:i with:#(#bold #underline).
|
|
107 |
list at:idx put:m
|
|
108 |
].
|
49
|
109 |
self addToSelection:idx
|
|
110 |
]
|
54
|
111 |
].
|
|
112 |
selection isNil ifTrue:[
|
|
113 |
self setSelection:1
|
43
|
114 |
]
|
62
|
115 |
!
|
|
116 |
|
|
117 |
selectionChanged
|
|
118 |
"selection has changed
|
|
119 |
"
|
|
120 |
|sel|
|
|
121 |
|
|
122 |
selection notNil ifTrue:[
|
|
123 |
selection size == 1 ifTrue:[
|
|
124 |
sel := (list at:(selection first)) string withoutSeparators
|
|
125 |
] ifFalse:[
|
|
126 |
sel := OrderedCollection new.
|
|
127 |
selection do:[:aNumber|
|
|
128 |
aNumber ~~ 1 ifTrue:[
|
|
129 |
sel add:((list at:aNumber) string withoutSeparators)
|
|
130 |
]
|
|
131 |
]
|
|
132 |
]
|
|
133 |
].
|
|
134 |
builderView selectNames:sel
|
|
135 |
|
|
136 |
!
|
|
137 |
|
|
138 |
selectionChangedFrom:oldSelection
|
|
139 |
"redraw master
|
|
140 |
"
|
|
141 |
self disableMaster:oldSelection.
|
|
142 |
super selectionChangedFrom:oldSelection
|
|
143 |
|
43
|
144 |
! !
|
|
145 |
|
|
146 |
!UIPainterTreeView methodsFor:'initialization'!
|
|
147 |
|
|
148 |
initialize
|
|
149 |
super initialize.
|
|
150 |
|
49
|
151 |
list := OrderedCollection new.
|
43
|
152 |
|
49
|
153 |
self multipleSelectOk:true.
|
|
154 |
self action:[:aSelection| self selectionChanged ].
|
43
|
155 |
|
49
|
156 |
|
43
|
157 |
! !
|
|
158 |
|
49
|
159 |
!UIPainterTreeView methodsFor:'menu & actions'!
|
43
|
160 |
|
58
|
161 |
inspectProps
|
|
162 |
builderView inspectAttributes
|
|
163 |
!
|
|
164 |
|
|
165 |
inspectSpec
|
|
166 |
builderView inspectSpec
|
|
167 |
!
|
|
168 |
|
|
169 |
inspectView
|
|
170 |
builderView inspectSelection
|
|
171 |
!
|
|
172 |
|
|
173 |
menu
|
62
|
174 |
|menu|
|
58
|
175 |
|
62
|
176 |
(menu := builderView menu) notNil ifTrue:[
|
|
177 |
menu addLabels:(
|
|
178 |
resources array:#(
|
58
|
179 |
'-'
|
62
|
180 |
'treeMisc'
|
|
181 |
)
|
|
182 |
)
|
|
183 |
selectors:#(
|
58
|
184 |
nil
|
62
|
185 |
#treeMisc
|
|
186 |
).
|
58
|
187 |
|
62
|
188 |
(builderView numberOfSelections) == 1 ifTrue:[
|
|
189 |
menu subMenuAt:#treeMisc put:(self menuMisc)
|
|
190 |
] ifFalse:[
|
|
191 |
menu disable:#treeMisc
|
|
192 |
]
|
|
193 |
].
|
|
194 |
^ menu
|
58
|
195 |
!
|
|
196 |
|
|
197 |
menuMisc
|
|
198 |
|
49
|
199 |
|menu ispMenu|
|
43
|
200 |
|
58
|
201 |
menu := PopUpMenu labels:( resources array:#('inspect' 'ordering' 'remove layout' ) )
|
|
202 |
selectors:#( #inspect #ordering #removeLayout )
|
49
|
203 |
receiver:self.
|
43
|
204 |
|
58
|
205 |
ispMenu := PopUpMenu labels:( resources array:#('view' 'spec' 'property') )
|
|
206 |
selectors:#( #inspectView #inspectSpec #inspectProps )
|
49
|
207 |
receiver:self.
|
43
|
208 |
|
49
|
209 |
menu subMenuAt:#inspect put:ispMenu.
|
|
210 |
^ menu
|
43
|
211 |
|
|
212 |
|
|
213 |
!
|
|
214 |
|
58
|
215 |
ordering
|
|
216 |
"change selected view to an index in its subview subviews collection
|
|
217 |
"
|
|
218 |
|myIdx view spView index names values|
|
|
219 |
|
|
220 |
view := builderView singleSelection.
|
|
221 |
view isNil ifTrue:[^ self].
|
|
222 |
|
|
223 |
spView := view superView.
|
|
224 |
names := OrderedCollection new.
|
|
225 |
values := OrderedCollection new.
|
|
226 |
index := 1.
|
|
227 |
|
|
228 |
spView allSubViewsDo:[:aView||props|
|
|
229 |
aView ~~ view ifTrue:[
|
|
230 |
props := builderView propertyOfView:aView.
|
|
231 |
|
|
232 |
props notNil ifTrue:[
|
|
233 |
names add:(props name).
|
|
234 |
values add:index
|
|
235 |
]
|
|
236 |
] ifFalse:[
|
|
237 |
myIdx := index
|
|
238 |
].
|
|
239 |
index := index + 1
|
|
240 |
].
|
|
241 |
|
|
242 |
names isEmpty ifTrue:[
|
|
243 |
^ self
|
|
244 |
].
|
|
245 |
|
|
246 |
index := Dialog choose:'before name:'
|
|
247 |
fromList:names
|
|
248 |
values:values
|
|
249 |
lines:20
|
|
250 |
cancel:[nil].
|
|
251 |
|
|
252 |
index isNil ifTrue:[
|
|
253 |
^ self
|
|
254 |
].
|
|
255 |
myIdx < index ifTrue:[
|
|
256 |
index := index - 1
|
|
257 |
].
|
|
258 |
(spView changeSequenceOrderFor:view to:index) ifTrue:[
|
62
|
259 |
self builderViewChanged:#tree
|
58
|
260 |
]
|
43
|
261 |
!
|
|
262 |
|
58
|
263 |
removeLayout
|
62
|
264 |
builderView withSelectionHiddenDo:[
|
58
|
265 |
builderView selectionDo:[:aView|
|
|
266 |
aView geometryLayout:nil.
|
62
|
267 |
builderView elementChangedSize:aView.
|
58
|
268 |
]
|
|
269 |
].
|
|
270 |
! !
|
|
271 |
|
|
272 |
!UIPainterTreeView methodsFor:'redrawing'!
|
|
273 |
|
|
274 |
disableMaster:aLineNrOrCollection
|
|
275 |
"find and redraw line from master as no master
|
|
276 |
"
|
|
277 |
|line|
|
|
278 |
|
|
279 |
aLineNrOrCollection notNil ifTrue:[
|
|
280 |
aLineNrOrCollection isCollection ifFalse:[
|
|
281 |
(line := list at:aLineNrOrCollection) isText ifTrue:[
|
|
282 |
list at:aLineNrOrCollection put:(line string).
|
|
283 |
self redrawLine:aLineNrOrCollection.
|
|
284 |
]
|
|
285 |
] ifTrue:[
|
|
286 |
aLineNrOrCollection do:[:aNumber|
|
|
287 |
(line := list at:aNumber) isText ifTrue:[
|
|
288 |
list at:aNumber put:(line string).
|
|
289 |
^ self redrawLine:aNumber.
|
|
290 |
]
|
|
291 |
]
|
|
292 |
]
|
|
293 |
]
|
49
|
294 |
! !
|
|
295 |
|
|
296 |
!UIPainterTreeView methodsFor:'update'!
|
43
|
297 |
|
49
|
298 |
updateSubTree:aView indent:anIndent
|
|
299 |
|name indent|
|
43
|
300 |
|
49
|
301 |
name := builderView variableNameOf:aView.
|
43
|
302 |
|
49
|
303 |
anIndent ~~ 0 ifTrue:[
|
|
304 |
name := (String new:anIndent), name
|
|
305 |
].
|
|
306 |
list add:name.
|
|
307 |
|
|
308 |
indent := anIndent + self class indent.
|
|
309 |
|
|
310 |
builderView subviewsOf:aView do:[:subview|
|
|
311 |
self updateSubTree:subview indent:indent
|
43
|
312 |
]
|
|
313 |
|
|
314 |
|
49
|
315 |
!
|
43
|
316 |
|
49
|
317 |
updateTree
|
43
|
318 |
|
49
|
319 |
selection := nil.
|
|
320 |
list := OrderedCollection new.
|
|
321 |
self updateSubTree:builderView indent:0.
|
|
322 |
super list:list.
|
43
|
323 |
|
|
324 |
! !
|
|
325 |
|
|
326 |
!UIPainterTreeView class methodsFor:'documentation'!
|
|
327 |
|
|
328 |
version
|
|
329 |
^ '$Header$'
|
|
330 |
! !
|