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 |
|
49
|
80 |
selectionChanged
|
|
81 |
"selection has changed
|
|
82 |
"
|
|
83 |
|sel|
|
43
|
84 |
|
49
|
85 |
selection notNil ifTrue:[
|
|
86 |
selection size == 1 ifTrue:[
|
58
|
87 |
sel := (list at:(selection first)) string withoutSeparators
|
49
|
88 |
] ifFalse:[
|
|
89 |
sel := OrderedCollection new.
|
|
90 |
selection do:[:aNumber|
|
|
91 |
aNumber ~~ 1 ifTrue:[
|
58
|
92 |
sel add:((list at:aNumber) string withoutSeparators)
|
49
|
93 |
]
|
|
94 |
]
|
43
|
95 |
]
|
49
|
96 |
].
|
54
|
97 |
builderView selectNames:sel
|
43
|
98 |
|
|
99 |
!
|
|
100 |
|
58
|
101 |
selectionChangedFrom:oldSelection
|
|
102 |
"redraw master
|
|
103 |
"
|
|
104 |
self disableMaster:oldSelection.
|
|
105 |
super selectionChangedFrom:oldSelection
|
|
106 |
|
|
107 |
!
|
|
108 |
|
43
|
109 |
update:something
|
|
110 |
|
49
|
111 |
(something == #tree or:[something == #widgetName]) ifTrue:[
|
43
|
112 |
self updateTree
|
|
113 |
] ifFalse:[
|
58
|
114 |
something ~~ #selection ifTrue:[
|
43
|
115 |
^ self
|
49
|
116 |
].
|
58
|
117 |
self disableMaster:selection.
|
49
|
118 |
self setSelection:nil.
|
43
|
119 |
].
|
|
120 |
|
49
|
121 |
"update selection
|
|
122 |
"
|
|
123 |
builderView selectionDo:[:aView||idx|
|
|
124 |
idx := self indexOf:(builderView variableNameOf:aView).
|
43
|
125 |
|
49
|
126 |
idx ~~ 0 ifTrue:[
|
58
|
127 |
selection isNil ifTrue:[
|
|
128 |
|m i|
|
|
129 |
|
|
130 |
m := list at:idx.
|
|
131 |
i := m indexOfNonSeparatorStartingAt:1.
|
|
132 |
i == 0 ifTrue:[ i := 1 ].
|
|
133 |
m := Text string:m.
|
|
134 |
m emphasizeFrom:i with:#(#bold #underline).
|
|
135 |
list at:idx put:m
|
|
136 |
].
|
49
|
137 |
self addToSelection:idx
|
|
138 |
]
|
54
|
139 |
].
|
|
140 |
selection isNil ifTrue:[
|
|
141 |
self setSelection:1
|
43
|
142 |
]
|
|
143 |
! !
|
|
144 |
|
|
145 |
!UIPainterTreeView methodsFor:'initialization'!
|
|
146 |
|
|
147 |
initialize
|
|
148 |
super initialize.
|
|
149 |
|
49
|
150 |
list := OrderedCollection new.
|
43
|
151 |
|
49
|
152 |
self multipleSelectOk:true.
|
|
153 |
self action:[:aSelection| self selectionChanged ].
|
43
|
154 |
|
49
|
155 |
|
43
|
156 |
! !
|
|
157 |
|
49
|
158 |
!UIPainterTreeView methodsFor:'menu & actions'!
|
43
|
159 |
|
58
|
160 |
inspectProps
|
|
161 |
builderView inspectAttributes
|
|
162 |
!
|
|
163 |
|
|
164 |
inspectSpec
|
|
165 |
builderView inspectSpec
|
|
166 |
!
|
|
167 |
|
|
168 |
inspectView
|
|
169 |
builderView inspectSelection
|
|
170 |
!
|
|
171 |
|
|
172 |
menu
|
|
173 |
|menu noSel|
|
|
174 |
|
|
175 |
noSel := builderView numberOfSelections.
|
|
176 |
|
|
177 |
menu := PopUpMenu labels:(
|
|
178 |
resources array:#(
|
|
179 |
'cut'
|
|
180 |
'undo'
|
|
181 |
'-'
|
|
182 |
'misc'
|
|
183 |
)
|
|
184 |
)
|
|
185 |
selectors:#(
|
|
186 |
#cut
|
|
187 |
#undo
|
|
188 |
nil
|
|
189 |
#misc
|
|
190 |
)
|
|
191 |
receiver:self.
|
|
192 |
|
|
193 |
noSel == 1 ifTrue:[ menu subMenuAt:#misc put:(self menuMisc)]
|
|
194 |
ifFalse:[ menu disable:#misc].
|
|
195 |
|
|
196 |
noSel == 0 ifTrue:[ menu disable:#cut]
|
|
197 |
ifFalse:[ menu actionAt:#cut put:[builderView deleteSelection]].
|
|
198 |
|
|
199 |
builderView hasUndos ifFalse:[ menu disable:#undo]
|
|
200 |
ifTrue:[ menu actionAt:#undo put:[builderView undoLast]].
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
^ menu
|
|
205 |
|
|
206 |
|
|
207 |
!
|
|
208 |
|
|
209 |
menuMisc
|
|
210 |
|
49
|
211 |
|menu ispMenu|
|
43
|
212 |
|
58
|
213 |
menu := PopUpMenu labels:( resources array:#('inspect' 'ordering' 'remove layout' ) )
|
|
214 |
selectors:#( #inspect #ordering #removeLayout )
|
49
|
215 |
receiver:self.
|
43
|
216 |
|
58
|
217 |
ispMenu := PopUpMenu labels:( resources array:#('view' 'spec' 'property') )
|
|
218 |
selectors:#( #inspectView #inspectSpec #inspectProps )
|
49
|
219 |
receiver:self.
|
43
|
220 |
|
49
|
221 |
menu subMenuAt:#inspect put:ispMenu.
|
|
222 |
^ menu
|
43
|
223 |
|
|
224 |
|
|
225 |
!
|
|
226 |
|
58
|
227 |
ordering
|
|
228 |
"change selected view to an index in its subview subviews collection
|
|
229 |
"
|
|
230 |
|myIdx view spView index names values|
|
|
231 |
|
|
232 |
view := builderView singleSelection.
|
|
233 |
view isNil ifTrue:[^ self].
|
|
234 |
|
|
235 |
spView := view superView.
|
|
236 |
names := OrderedCollection new.
|
|
237 |
values := OrderedCollection new.
|
|
238 |
index := 1.
|
|
239 |
|
|
240 |
spView allSubViewsDo:[:aView||props|
|
|
241 |
aView ~~ view ifTrue:[
|
|
242 |
props := builderView propertyOfView:aView.
|
|
243 |
|
|
244 |
props notNil ifTrue:[
|
|
245 |
names add:(props name).
|
|
246 |
values add:index
|
|
247 |
]
|
|
248 |
] ifFalse:[
|
|
249 |
myIdx := index
|
|
250 |
].
|
|
251 |
index := index + 1
|
|
252 |
].
|
|
253 |
|
|
254 |
names isEmpty ifTrue:[
|
|
255 |
^ self
|
|
256 |
].
|
|
257 |
|
|
258 |
index := Dialog choose:'before name:'
|
|
259 |
fromList:names
|
|
260 |
values:values
|
|
261 |
lines:20
|
|
262 |
cancel:[nil].
|
|
263 |
|
|
264 |
index isNil ifTrue:[
|
|
265 |
^ self
|
|
266 |
].
|
|
267 |
myIdx < index ifTrue:[
|
|
268 |
index := index - 1
|
|
269 |
].
|
|
270 |
(spView changeSequenceOrderFor:view to:index) ifTrue:[
|
|
271 |
self update:#tree
|
|
272 |
]
|
43
|
273 |
!
|
|
274 |
|
58
|
275 |
removeLayout
|
|
276 |
builderView selectionHiddenDo:[
|
|
277 |
builderView selectionDo:[:aView|
|
|
278 |
aView geometryLayout:nil.
|
|
279 |
aView superView sizeChanged:nil
|
|
280 |
]
|
|
281 |
].
|
|
282 |
! !
|
|
283 |
|
|
284 |
!UIPainterTreeView methodsFor:'redrawing'!
|
|
285 |
|
|
286 |
disableMaster:aLineNrOrCollection
|
|
287 |
"find and redraw line from master as no master
|
|
288 |
"
|
|
289 |
|line|
|
|
290 |
|
|
291 |
aLineNrOrCollection notNil ifTrue:[
|
|
292 |
aLineNrOrCollection isCollection ifFalse:[
|
|
293 |
(line := list at:aLineNrOrCollection) isText ifTrue:[
|
|
294 |
list at:aLineNrOrCollection put:(line string).
|
|
295 |
self redrawLine:aLineNrOrCollection.
|
|
296 |
]
|
|
297 |
] ifTrue:[
|
|
298 |
aLineNrOrCollection do:[:aNumber|
|
|
299 |
(line := list at:aNumber) isText ifTrue:[
|
|
300 |
list at:aNumber put:(line string).
|
|
301 |
^ self redrawLine:aNumber.
|
|
302 |
]
|
|
303 |
]
|
|
304 |
]
|
|
305 |
]
|
49
|
306 |
! !
|
|
307 |
|
|
308 |
!UIPainterTreeView methodsFor:'update'!
|
43
|
309 |
|
49
|
310 |
updateSubTree:aView indent:anIndent
|
|
311 |
|name indent|
|
43
|
312 |
|
49
|
313 |
name := builderView variableNameOf:aView.
|
43
|
314 |
|
49
|
315 |
anIndent ~~ 0 ifTrue:[
|
|
316 |
name := (String new:anIndent), name
|
|
317 |
].
|
|
318 |
list add:name.
|
|
319 |
|
|
320 |
indent := anIndent + self class indent.
|
|
321 |
|
|
322 |
builderView subviewsOf:aView do:[:subview|
|
|
323 |
self updateSubTree:subview indent:indent
|
43
|
324 |
]
|
|
325 |
|
|
326 |
|
49
|
327 |
!
|
43
|
328 |
|
49
|
329 |
updateTree
|
43
|
330 |
|
49
|
331 |
selection := nil.
|
|
332 |
list := OrderedCollection new.
|
|
333 |
self updateSubTree:builderView indent:0.
|
|
334 |
super list:list.
|
43
|
335 |
|
|
336 |
! !
|
|
337 |
|
|
338 |
!UIPainterTreeView class methodsFor:'documentation'!
|
|
339 |
|
|
340 |
version
|
|
341 |
^ '$Header$'
|
|
342 |
! !
|