37 " |
37 " |
38 not yet finished, not yet published, not yet released. |
38 not yet finished, not yet published, not yet released. |
39 " |
39 " |
40 ! ! |
40 ! ! |
41 |
41 |
42 !UIPainterTreeView class methodsFor:'startup'! |
42 !UIPainterTreeView class methodsFor:'constants'! |
43 |
43 |
44 start |
44 indent |
45 |topView v| |
45 "indent for contained element |
46 |
46 " |
47 topView := StandardSystemView |
47 ^ 2 |
48 label:'View hierarchy' |
|
49 icon:(Form fromFile:'BuildTreeV.icon' resolution:100). |
|
50 v := HVScrollableView for:self in:topView. |
|
51 v origin:(0 @ 0) extent:(1.0 @ 1.0). |
|
52 |
|
53 topView realize. |
|
54 ^ v scrolledView |
|
55 |
|
56 "BuilderTreeView start" |
|
57 |
48 |
58 |
49 |
59 ! ! |
50 ! ! |
60 |
51 |
61 !UIPainterTreeView methodsFor:'BuilderView interface'! |
52 !UIPainterTreeView class methodsFor:'defaults'! |
|
53 |
|
54 defaultMenuMessage |
|
55 "This message is the default yo be sent to the menuHolder to get a menu |
|
56 " |
|
57 ^ #editMenu |
|
58 |
|
59 |
|
60 ! ! |
|
61 |
|
62 !UIPainterTreeView methodsFor:'accessing'! |
62 |
63 |
63 builderView:aBuilderView |
64 builderView:aBuilderView |
64 builderView := aBuilderView. |
65 builderView := aBuilderView. |
65 |
66 self updateTree. |
66 |
67 |
67 ! |
68 ! |
68 |
69 |
69 selectName:aString |
70 indexOf:aString |
70 contents do:[:obj | |
71 "returns the index of the string entry into my list |
71 (obj text asString withoutSeparators = aString) ifTrue:[ |
72 " |
72 ^ self select:obj. |
73 ^ list findFirst:[:aName| aName withoutSeparators = aString ] |
|
74 |
|
75 |
|
76 ! ! |
|
77 |
|
78 !UIPainterTreeView methodsFor:'event handling'! |
|
79 |
|
80 selectionChanged |
|
81 "selection has changed |
|
82 " |
|
83 |sel| |
|
84 |
|
85 selection notNil ifTrue:[ |
|
86 selection size == 1 ifTrue:[ |
|
87 sel := (list at:(selection first)) withoutSeparators |
|
88 ] ifFalse:[ |
|
89 sel := OrderedCollection new. |
|
90 selection do:[:aNumber| |
|
91 aNumber ~~ 1 ifTrue:[ |
|
92 sel add:((list at:aNumber) withoutSeparators) |
|
93 ] |
|
94 ] |
73 ] |
95 ] |
74 ] |
96 ]. |
75 |
97 builderView selectName:sel |
76 ! |
|
77 |
|
78 selectNameAdd:aString |
|
79 contents do:[:obj | |
|
80 (obj text asString withoutSeparators = aString) ifTrue:[ |
|
81 ^ self addToSelection:obj. |
|
82 ] |
|
83 ] |
|
84 |
|
85 |
98 |
86 ! |
99 ! |
87 |
100 |
88 update:something |
101 update:something |
89 |sel| |
|
90 |
102 |
91 something == #tree ifTrue:[ |
103 (something == #tree or:[something == #widgetName]) ifTrue:[ |
92 ^ self updateTree. |
|
93 ]. |
|
94 |
|
95 something == #widgetName ifTrue:[ |
|
96 self updateTree |
104 self updateTree |
97 ] ifFalse:[ |
105 ] ifFalse:[ |
98 something == #selection ifFalse:[ |
106 something == #selection ifFalse:[ |
99 ^ self |
107 ^ self |
100 ] |
108 ]. |
|
109 self setSelection:nil. |
101 ]. |
110 ]. |
102 |
111 |
103 sel := builderView selection. |
112 "update selection |
|
113 " |
|
114 builderView selectionDo:[:aView||idx| |
|
115 idx := self indexOf:(builderView variableNameOf:aView). |
104 |
116 |
105 (sel isKindOf:Collection) ifTrue:[ |
117 idx ~~ 0 ifTrue:[ |
106 sel do:[:v | self selectNameAdd:(builderView variableNameOf:v)] |
118 self addToSelection:idx |
107 ] ifFalse:[ |
119 ] |
108 self selectName:(builderView variableNameOf:sel) |
|
109 ] |
120 ] |
110 |
|
111 ! ! |
|
112 |
|
113 !UIPainterTreeView methodsFor:'drawing'! |
|
114 |
|
115 showSelected:anObject |
|
116 "show an object as selected" |
|
117 |
|
118 |oldFg oldBg| |
|
119 |
|
120 oldFg := anObject foreground. |
|
121 oldBg := anObject background. |
|
122 anObject foreground:oldBg. |
|
123 anObject background:oldFg. |
|
124 anObject drawIn:self. |
|
125 anObject foreground:oldFg. |
|
126 anObject background:oldBg |
|
127 |
|
128 "Modified: 31.8.1995 / 13:52:02 / claus" |
|
129 ! ! |
|
130 |
|
131 !UIPainterTreeView methodsFor:'generating the class-tree picture'! |
|
132 |
|
133 addToTree:name indent:indent |
|
134 |newObject| |
|
135 |
|
136 newObject := DrawText new. |
|
137 "newObject font:font. " |
|
138 newObject text:name. |
|
139 newObject origin:((indent asInteger + margin) @ yPos). |
|
140 newObject foreground:Color black. "/ foreground. |
|
141 newObject background:Color white. "/background. |
|
142 newObject linePattern:1; fillPattern:1. "/ opaque |
|
143 yPos := yPos + newObject frame height. |
|
144 self add:newObject. |
|
145 maxX := maxX max:(newObject frame corner x). |
|
146 |
|
147 "Modified: 5.9.1995 / 23:54:26 / claus" |
|
148 ! |
|
149 |
|
150 addViewsToTreeFrom:aView indent:currentIndent |
|
151 |name| |
|
152 |
|
153 name := builderView variableNameOf:aView. |
|
154 self addToTree:name indent:currentIndent. |
|
155 |
|
156 builderView subviewsOf:aView do:[:subview | |
|
157 self addViewsToTreeFrom:subview |
|
158 indent:(currentIndent + indent) |
|
159 ] |
|
160 ! |
|
161 |
|
162 updateTree |
|
163 self removeAll. |
|
164 maxX := 0. |
|
165 yPos := (self verticalPixelPerMillimeter:1) rounded asInteger. |
|
166 self addViewsToTreeFrom:builderView indent:(self horizontalPixelPerMillimeter:1). |
|
167 self contentsChanged |
|
168 |
|
169 "Modified: 5.9.1995 / 23:54:35 / claus" |
|
170 ! ! |
121 ! ! |
171 |
122 |
172 !UIPainterTreeView methodsFor:'initialization'! |
123 !UIPainterTreeView methodsFor:'initialization'! |
173 |
124 |
174 initialize |
125 initialize |
175 super initialize. |
126 super initialize. |
176 |
127 |
177 maxX := 0. |
128 list := OrderedCollection new. |
178 yPos := (self verticalPixelPerMillimeter:1) rounded asInteger. |
|
179 indent := (self horizontalPixelPerMillimeter:5) rounded asInteger. |
|
180 sorted := true. |
|
181 pressAction := [:aPoint | self click:aPoint]. |
|
182 shiftPressAction := [:aPoint | self shiftClick:aPoint] |
|
183 |
129 |
184 "Modified: 6.9.1995 / 00:11:48 / claus" |
130 self multipleSelectOk:true. |
185 ! |
131 self action:[:aSelection| self selectionChanged ]. |
186 |
132 |
187 initializeMiddleButtonMenu |
|
188 |labels| |
|
189 |
133 |
190 labels := resources array:#( |
|
191 'inspect view' |
|
192 'inspect properties' |
|
193 ). |
|
194 |
|
195 self middleButtonMenu:(PopUpMenu |
|
196 labels:labels |
|
197 selectors:#( |
|
198 inspectView |
|
199 inspectProps |
|
200 ) |
|
201 receiver:self |
|
202 for:self) |
|
203 ! ! |
134 ! ! |
204 |
135 |
205 !UIPainterTreeView methodsFor:'private'! |
136 !UIPainterTreeView methodsFor:'menu & actions'! |
206 |
137 |
207 selectedName |
138 editMenu |
208 selection isNil ifTrue:[^ nil]. |
139 |menu ispMenu| |
209 ^ selection text asString withoutSeparators |
|
210 ! |
|
211 |
140 |
212 withSelectedNameDo:aBlock |
141 menu := PopUpMenu labels:#( 'inspect' ) |
213 |name| |
142 selectors:#( #inspect ) |
|
143 receiver:self. |
214 |
144 |
215 name := self selectedName. |
145 ispMenu := PopUpMenu labels:#( 'view' 'property' ) |
216 name notNil ifTrue:[aBlock value:name] |
146 selectors:#( #inspectView #inspectProps ) |
217 ! ! |
147 receiver:self. |
218 |
148 |
219 !UIPainterTreeView methodsFor:'queries'! |
149 menu subMenuAt:#inspect put:ispMenu. |
220 |
150 ^ menu |
221 heightOfContents |
|
222 ^ yPos + (self verticalPixelPerMillimeter:1) rounded |
|
223 |
|
224 "Modified: 6.9.1995 / 12:56:24 / claus" |
|
225 ! |
|
226 |
|
227 widthOfContents |
|
228 ^ maxX + (self horizontalPixelPerMillimeter:1) rounded |
|
229 |
|
230 "Modified: 6.9.1995 / 12:56:28 / claus" |
|
231 ! ! |
|
232 |
|
233 !UIPainterTreeView methodsFor:'user interaction'! |
|
234 |
|
235 click:aPoint |
|
236 |anObject| |
|
237 |
|
238 anObject := self findObjectAtVisible:aPoint. |
|
239 (anObject ~~ selection) ifTrue:[ |
|
240 self unselect. |
|
241 anObject notNil ifTrue:[ |
|
242 self select:anObject. |
|
243 builderView selectName:(self selectedName) |
|
244 ] ifFalse:[ |
|
245 builderView selectName:'self' |
|
246 ] |
|
247 ] |
|
248 |
|
249 |
|
250 |
151 |
251 |
152 |
252 ! |
153 ! |
253 |
154 |
254 inspectProps |
155 inspectProps |
255 builderView inspectAttributes |
156 builderView inspectAttributes |
256 ! |
157 ! |
257 |
158 |
258 inspectView |
159 inspectView |
259 builderView inspectSelection |
160 builderView inspectSelection |
260 ! |
161 ! ! |
261 |
162 |
262 shiftClick:aPoint |
163 !UIPainterTreeView methodsFor:'update'! |
263 |anObject| |
|
264 |
164 |
265 anObject := self findObjectAtVisible:aPoint. |
165 updateSubTree:aView indent:anIndent |
|
166 |name indent| |
266 |
167 |
267 anObject notNil ifTrue:[ |
168 name := builderView variableNameOf:aView. |
268 (self isSelected:anObject) ifTrue:[ |
169 |
269 builderView removeNameFromSelection:anObject text asString withoutSeparators |
170 anIndent ~~ 0 ifTrue:[ |
270 ] ifFalse:[ |
171 name := (String new:anIndent), name |
271 builderView addNameToSelection:anObject text asString withoutSeparators |
172 ]. |
272 ] |
173 list add:name. |
|
174 |
|
175 indent := anIndent + self class indent. |
|
176 |
|
177 builderView subviewsOf:aView do:[:subview| |
|
178 self updateSubTree:subview indent:indent |
273 ] |
179 ] |
274 |
180 |
275 |
181 |
|
182 ! |
276 |
183 |
|
184 updateTree |
277 |
185 |
278 |
186 selection := nil. |
|
187 list := OrderedCollection new. |
|
188 self updateSubTree:builderView indent:0. |
|
189 super list:list. |
279 |
190 |
280 ! ! |
191 ! ! |
281 |
192 |
282 !UIPainterTreeView class methodsFor:'documentation'! |
193 !UIPainterTreeView class methodsFor:'documentation'! |
283 |
194 |