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