60
|
1 |
ApplicationModel subclass:#UIPainter
|
109
|
2 |
instanceVariableNames:'objectList currentView selectionPanel tabSelection lastSlice
|
121
|
3 |
specView layoutTool fileName specClass specSelector
|
109
|
4 |
specSuperclass aspects'
|
60
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Interface-UIPainter'
|
|
8 |
!
|
|
9 |
|
|
10 |
!UIPainter class methodsFor:'documentation'!
|
|
11 |
|
|
12 |
documentation
|
|
13 |
"
|
127
|
14 |
GUI-Builder:
|
|
15 |
this class allows the user to build its own applications providing a graphical
|
|
16 |
user interface to buildin components and to define the behavior of the components
|
|
17 |
during runtime. The resulting specifications can be installed as methods on
|
|
18 |
classes, typically subclasses of an ApplicationModel. These specifications
|
|
19 |
are used by the UIBuilder to generate the application window and its component
|
|
20 |
structues when open the application.
|
60
|
21 |
|
|
22 |
[start with:]
|
|
23 |
UIPainter open
|
127
|
24 |
|
|
25 |
[see also:]
|
|
26 |
UIBuilder
|
|
27 |
ApplicationModel
|
|
28 |
UISpecification
|
60
|
29 |
"
|
109
|
30 |
|
|
31 |
! !
|
|
32 |
|
|
33 |
!UIPainter class methodsFor:'instance creation'!
|
|
34 |
|
|
35 |
listHolder:aListHolder
|
|
36 |
|application|
|
|
37 |
|
|
38 |
application := self new.
|
|
39 |
application objectList:aListHolder.
|
|
40 |
^ application open
|
|
41 |
!
|
|
42 |
|
|
43 |
painter:aBuilderView
|
|
44 |
|application|
|
|
45 |
|
|
46 |
application := self new.
|
|
47 |
application painter:aBuilderView.
|
|
48 |
^ application open
|
60
|
49 |
! !
|
|
50 |
|
87
|
51 |
!UIPainter class methodsFor:'ST-80 queries'!
|
|
52 |
|
|
53 |
preferenceFor:aSymbol
|
|
54 |
^ false
|
109
|
55 |
|
|
56 |
|
|
57 |
! !
|
|
58 |
|
|
59 |
!UIPainter class methodsFor:'constants'!
|
|
60 |
|
|
61 |
titleOfLayoutMenu
|
|
62 |
^ 'Dimension'
|
87
|
63 |
! !
|
|
64 |
|
118
|
65 |
!UIPainter class methodsFor:'icons'!
|
|
66 |
|
|
67 |
iconAlignB
|
|
68 |
^ Image fromFile:'b_alignB.xbm'
|
|
69 |
|
|
70 |
!
|
|
71 |
|
|
72 |
iconAlignCenterH
|
|
73 |
^ Image fromFile:'b_alignCH.xbm'
|
|
74 |
|
|
75 |
!
|
|
76 |
|
|
77 |
iconAlignCenterV
|
|
78 |
^ Image fromFile:'b_alignCV.xbm'
|
|
79 |
|
|
80 |
!
|
|
81 |
|
|
82 |
iconAlignL
|
|
83 |
^ Image fromFile:'b_alignL.xbm'
|
|
84 |
!
|
|
85 |
|
|
86 |
iconAlignLR
|
|
87 |
^ Image fromFile:'b_alignLR.xbm'
|
|
88 |
|
|
89 |
!
|
|
90 |
|
|
91 |
iconAlignR
|
|
92 |
^ Image fromFile:'b_alignR.xbm'
|
|
93 |
|
|
94 |
!
|
|
95 |
|
|
96 |
iconAlignT
|
|
97 |
^ Image fromFile:'b_alignT.xbm'
|
|
98 |
|
|
99 |
!
|
|
100 |
|
|
101 |
iconAlignTB
|
|
102 |
^ Image fromFile:'b_alignTB.xbm'
|
|
103 |
|
|
104 |
! !
|
|
105 |
|
60
|
106 |
!UIPainter class methodsFor:'interface specs'!
|
|
107 |
|
118
|
108 |
menuAlignment
|
|
109 |
^ #(#Menu #(
|
|
110 |
#(#MenuItem
|
|
111 |
#'label:' 'align left'
|
|
112 |
#'value:' #alignSelectionLeft
|
130
|
113 |
#'labelImage:' #( ResourceRetriever nil iconAlignL )
|
118
|
114 |
)
|
|
115 |
#(#MenuItem
|
|
116 |
#'label:' 'align right'
|
|
117 |
#'value:' #alignSelectionRight
|
130
|
118 |
#'labelImage:' #( ResourceRetriever nil iconAlignR )
|
118
|
119 |
)
|
|
120 |
#(#MenuItem
|
|
121 |
#'label:' 'align left & right'
|
|
122 |
#'value:' #alignSelectionLeftAndRight
|
130
|
123 |
#'labelImage:' #( ResourceRetriever nil iconAlignLR )
|
118
|
124 |
)
|
|
125 |
#(#MenuItem
|
|
126 |
#'label:' 'align top'
|
|
127 |
#'value:' #alignSelectionTop
|
130
|
128 |
#'labelImage:' #( ResourceRetriever nil iconAlignT )
|
118
|
129 |
)
|
|
130 |
#(#MenuItem
|
|
131 |
#'label:' 'align bottom'
|
|
132 |
#'value:' #alignSelectionBottom
|
130
|
133 |
#'labelImage:' #( ResourceRetriever nil iconAlignB )
|
118
|
134 |
)
|
|
135 |
#(#MenuItem
|
|
136 |
#'label:' 'align top & bottom'
|
|
137 |
#'value:' #alignSelectionTopAndBottom
|
130
|
138 |
#'labelImage:' #( ResourceRetriever nil iconAlignTB )
|
118
|
139 |
)
|
|
140 |
#(#MenuItem
|
|
141 |
#'label:' 'align centered horizontal'
|
|
142 |
#'value:' #alignSelectionCenterHor
|
130
|
143 |
#'labelImage:' #( ResourceRetriever nil iconAlignCenterH )
|
118
|
144 |
)
|
|
145 |
#(#MenuItem
|
|
146 |
#'label:' 'align centered vertical'
|
|
147 |
#'value:' #alignSelectionCenterVer
|
130
|
148 |
#'labelImage:' #( ResourceRetriever nil iconAlignCenterV )
|
118
|
149 |
)
|
|
150 |
)
|
|
151 |
#( 4 2 )
|
|
152 |
nil
|
|
153 |
)
|
|
154 |
|
|
155 |
!
|
|
156 |
|
|
157 |
menuPullDown
|
109
|
158 |
^ #(#Menu #(
|
|
159 |
#(#MenuItem
|
|
160 |
#'label:' 'file'
|
114
|
161 |
#'value:' #file
|
109
|
162 |
#'submenu:'
|
|
163 |
#(#Menu #(
|
|
164 |
#(#MenuItem
|
|
165 |
#'label:' 'new'
|
114
|
166 |
#'value:' #removeAll
|
109
|
167 |
)
|
|
168 |
#(#MenuItem
|
|
169 |
#'label:' 'from class ...'
|
114
|
170 |
#'value:' #doFromClass
|
109
|
171 |
)
|
|
172 |
#(#MenuItem
|
|
173 |
#'label:' 'pick a view '
|
114
|
174 |
#'value:' #doPickAView
|
109
|
175 |
)
|
|
176 |
#(#MenuItem
|
|
177 |
#'label:' 'raise'
|
114
|
178 |
#'value:' #doRaise
|
109
|
179 |
)
|
|
180 |
#(#MenuItem
|
|
181 |
#'label:' 'quit'
|
114
|
182 |
#'value:' #closeRequest
|
109
|
183 |
)
|
|
184 |
)
|
133
|
185 |
#(3 1)
|
109
|
186 |
nil
|
|
187 |
)
|
|
188 |
)
|
|
189 |
#(#MenuItem
|
|
190 |
#'label:' 'special'
|
114
|
191 |
#'value:' #special
|
109
|
192 |
#'submenu:'
|
|
193 |
#(#Menu #(
|
|
194 |
#(#MenuItem
|
|
195 |
#'label:' 'group radioButtons'
|
114
|
196 |
#'value:' #groupRadioButtons
|
109
|
197 |
)
|
|
198 |
#(#MenuItem
|
|
199 |
#'label:' 'group enterFields'
|
114
|
200 |
#'value:' #groupEnterFields
|
109
|
201 |
)
|
|
202 |
)
|
|
203 |
nil
|
|
204 |
nil
|
|
205 |
)
|
|
206 |
)
|
|
207 |
#(#MenuItem
|
|
208 |
#'label:' 'misc'
|
114
|
209 |
#'value:' #misc
|
109
|
210 |
#'submenu:'
|
|
211 |
#(#Menu #(
|
|
212 |
#(#MenuItem
|
|
213 |
#'label:' 'grid'
|
114
|
214 |
#'value:' #grid
|
109
|
215 |
#'submenu:'
|
|
216 |
#(#Menu #(
|
|
217 |
#(#MenuItem
|
137
|
218 |
#'label:' 'show'
|
|
219 |
#'indication:' #gridShown:
|
109
|
220 |
)
|
|
221 |
#(#MenuItem
|
137
|
222 |
#'label:' 'align'
|
|
223 |
#'indication:' #gridAlign:
|
109
|
224 |
)
|
|
225 |
)
|
|
226 |
nil
|
|
227 |
nil
|
|
228 |
)
|
|
229 |
)
|
|
230 |
#(#MenuItem
|
|
231 |
#'label:' 'undo'
|
114
|
232 |
#'value:' #undo
|
109
|
233 |
#'submenu:'
|
|
234 |
#(#Menu #(
|
|
235 |
#(#MenuItem
|
|
236 |
#'label:' 'last'
|
114
|
237 |
#'value:' #undoLast
|
109
|
238 |
)
|
|
239 |
#(#MenuItem
|
|
240 |
#'label:' 'menu'
|
114
|
241 |
#'value:' #openUndoMenu
|
109
|
242 |
)
|
|
243 |
#(#MenuItem
|
|
244 |
#'label:' 'delete'
|
114
|
245 |
#'value:' #removeUndoHistory
|
109
|
246 |
)
|
|
247 |
)
|
|
248 |
#(2)
|
|
249 |
nil
|
|
250 |
)
|
|
251 |
)
|
|
252 |
)
|
|
253 |
nil
|
|
254 |
nil
|
|
255 |
)
|
|
256 |
)
|
|
257 |
#(#MenuItem
|
|
258 |
#'label:' 'code'
|
114
|
259 |
#'value:' #code
|
109
|
260 |
#'submenu:'
|
|
261 |
#(#Menu #(
|
|
262 |
#(#MenuItem
|
133
|
263 |
#'label:' 'class && method'
|
114
|
264 |
#'value:' #defineClassAndSelector
|
109
|
265 |
)
|
|
266 |
#(#MenuItem
|
|
267 |
#'label:' 'install spec'
|
114
|
268 |
#'value:' #doInstallSpec
|
109
|
269 |
)
|
|
270 |
#(#MenuItem
|
|
271 |
#'label:' 'install aspects'
|
114
|
272 |
#'value:' #doInstallAspects
|
109
|
273 |
)
|
|
274 |
#(#MenuItem
|
|
275 |
#'label:' 'windowSpec'
|
114
|
276 |
#'value:' #doWindowSpec
|
109
|
277 |
)
|
133
|
278 |
#(#MenuItem
|
|
279 |
#'label:' 'browse'
|
|
280 |
#'value:' #browseAppClass
|
|
281 |
)
|
109
|
282 |
)
|
133
|
283 |
#( 1 2 1)
|
109
|
284 |
nil
|
|
285 |
)
|
|
286 |
)
|
|
287 |
#(#MenuItem
|
|
288 |
#'label:' 'test'
|
118
|
289 |
#'nameKey:' #test
|
114
|
290 |
#'value:' #test
|
109
|
291 |
#'submenu:'
|
|
292 |
#(#Menu #(
|
|
293 |
#(#MenuItem
|
137
|
294 |
#'label:' 'test mode'
|
|
295 |
#'indication:' #testMode:
|
109
|
296 |
)
|
|
297 |
)
|
|
298 |
nil
|
|
299 |
nil
|
|
300 |
)
|
|
301 |
)
|
|
302 |
)
|
|
303 |
nil
|
|
304 |
nil
|
|
305 |
)
|
|
306 |
|
|
307 |
!
|
|
308 |
|
60
|
309 |
nameAndSelectorSpec
|
|
310 |
"this window spec was automatically generated by the ST/X UIPainter"
|
|
311 |
|
|
312 |
"do not manually edit this - the painter/builder may not be able to
|
|
313 |
handle the specification if its corrupted."
|
|
314 |
|
|
315 |
"
|
|
316 |
UIPainter new openOnClass:UIPainter andSelector:#nameAndSelectorSpec
|
|
317 |
UIPainter new openInterface:#nameAndSelectorSpec
|
|
318 |
"
|
|
319 |
|
|
320 |
<resource: #canvas>
|
|
321 |
|
|
322 |
^
|
109
|
323 |
|
60
|
324 |
#(#FullSpec
|
|
325 |
#'window:'
|
|
326 |
#(#WindowSpec
|
|
327 |
#'name:' 'uIPainterView'
|
|
328 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
127
|
329 |
#'label:' 'unnamed canvas'
|
92
|
330 |
#'bounds:' #(#Rectangle 0 0 300 223)
|
60
|
331 |
)
|
|
332 |
#'component:'
|
|
333 |
#(#SpecCollection
|
|
334 |
#'collection:'
|
|
335 |
#(
|
|
336 |
#(#LabelSpec
|
|
337 |
#'name:' 'label1'
|
|
338 |
#'layout:' #(#LayoutFrame 10 0 50 0 110 0 70 0)
|
|
339 |
#'label:' 'class:'
|
|
340 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
341 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
342 |
#'initiallyInvisible:' false
|
81
|
343 |
#'translateLabel:' false
|
60
|
344 |
#'level:' 0
|
|
345 |
#'adjust:' #right
|
|
346 |
#'hasCharacterOrientedLabel:' true
|
|
347 |
)
|
|
348 |
#(#LabelSpec
|
|
349 |
#'name:' 'label2'
|
|
350 |
#'layout:' #(#LayoutFrame 10 0 90 0 110 0 110 0)
|
|
351 |
#'label:' 'superclass:'
|
|
352 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
353 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
354 |
#'initiallyInvisible:' false
|
81
|
355 |
#'translateLabel:' false
|
60
|
356 |
#'level:' 0
|
|
357 |
#'adjust:' #right
|
|
358 |
#'hasCharacterOrientedLabel:' true
|
|
359 |
)
|
|
360 |
#(#LabelSpec
|
|
361 |
#'name:' 'label3'
|
|
362 |
#'layout:' #(#LayoutFrame 10 0 130 0 110 0 150 0)
|
|
363 |
#'label:' 'selector:'
|
|
364 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
365 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
366 |
#'initiallyInvisible:' false
|
81
|
367 |
#'translateLabel:' false
|
60
|
368 |
#'level:' 0
|
|
369 |
#'adjust:' #right
|
|
370 |
#'hasCharacterOrientedLabel:' true
|
|
371 |
)
|
|
372 |
#(#InputFieldSpec
|
|
373 |
#'name:' 'classNameField'
|
92
|
374 |
#'layout:' #(#LayoutFrame 120 0 50 0 289 0 72 0)
|
60
|
375 |
#'model:' #classNameChannel
|
|
376 |
#'tabable:' true
|
129
|
377 |
#'immediateAccept:' true
|
60
|
378 |
#'hasBorder:' false
|
|
379 |
)
|
|
380 |
#(#InputFieldSpec
|
|
381 |
#'name:' 'superclassNameField'
|
92
|
382 |
#'layout:' #(#LayoutFrame 120 0 90 0 289 0 112 0)
|
60
|
383 |
#'model:' #superclassNameChannel
|
|
384 |
#'tabable:' true
|
129
|
385 |
#'immediateAccept:' true
|
60
|
386 |
#'hasBorder:' false
|
|
387 |
)
|
|
388 |
#(#InputFieldSpec
|
|
389 |
#'name:' 'methodNameField'
|
92
|
390 |
#'layout:' #(#LayoutFrame 120 0 130 0 289 0 152 0)
|
60
|
391 |
#'model:' #methodNameChannel
|
|
392 |
#'tabable:' true
|
129
|
393 |
#'immediateAccept:' true
|
60
|
394 |
#'hasBorder:' false
|
|
395 |
)
|
|
396 |
#(#ActionButtonSpec
|
|
397 |
#'name:' 'button1'
|
92
|
398 |
#'layout:' #(#LayoutFrame 30 0 180 0 129 0 209 0)
|
60
|
399 |
#'label:' 'cancel'
|
|
400 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
401 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
81
|
402 |
#'translateLabel:' false
|
60
|
403 |
#'tabable:' true
|
|
404 |
#'model:' #cancel
|
81
|
405 |
#'isTriggerOnDown:' false
|
60
|
406 |
)
|
|
407 |
#(#ActionButtonSpec
|
|
408 |
#'name:' 'button2'
|
92
|
409 |
#'layout:' #(#LayoutFrame 160 0 180 0 259 0 209 0)
|
60
|
410 |
#'label:' 'ok'
|
|
411 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
412 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
81
|
413 |
#'translateLabel:' false
|
60
|
414 |
#'tabable:' true
|
|
415 |
#'isDefault:' true
|
|
416 |
#'model:' #accept
|
81
|
417 |
#'isTriggerOnDown:' false
|
60
|
418 |
)
|
|
419 |
#(#LabelSpec
|
|
420 |
#'name:' 'boxLabel'
|
92
|
421 |
#'layout:' #(#LayoutFrame 0 0.0 11 0 0 1.0 32 0)
|
|
422 |
#'label:' 'class & selector for code:'
|
60
|
423 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
424 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
425 |
#'initiallyInvisible:' false
|
81
|
426 |
#'translateLabel:' false
|
60
|
427 |
#'level:' 0
|
92
|
428 |
#'adjust:' #left
|
60
|
429 |
#'hasCharacterOrientedLabel:' true
|
|
430 |
)
|
|
431 |
)
|
|
432 |
)
|
|
433 |
)
|
92
|
434 |
|
109
|
435 |
!
|
|
436 |
|
|
437 |
windowSpec
|
|
438 |
"this window spec was automatically generated by the ST/X UIPainter"
|
|
439 |
|
|
440 |
"do not manually edit this - the painter/builder may not be able to
|
|
441 |
handle the specification if its corrupted."
|
|
442 |
|
|
443 |
"
|
|
444 |
UIPainter new openOnClass:UIPainter andSelector:#windowSpec
|
|
445 |
UIPainter new openInterface:#windowSpec
|
|
446 |
"
|
|
447 |
"UIPainter open"
|
|
448 |
|
|
449 |
<resource: #canvas>
|
|
450 |
|
|
451 |
^
|
|
452 |
|
|
453 |
#(#FullSpec
|
|
454 |
#'window:'
|
|
455 |
#(#WindowSpec
|
|
456 |
#'name:' 'uIPainterView'
|
|
457 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
458 |
#'label:' 'Tree-View'
|
137
|
459 |
#'bounds:' #(#Rectangle 0 0 478 429)
|
109
|
460 |
)
|
|
461 |
#'component:'
|
|
462 |
#(#SpecCollection
|
|
463 |
#'collection:'
|
|
464 |
#(
|
|
465 |
#(#MenuPanelSpec
|
137
|
466 |
#'name:' 'menuPullDown'
|
114
|
467 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 24 0)
|
118
|
468 |
#'menu:' #menuPullDown
|
|
469 |
#'showSeparatingLines:' false
|
|
470 |
#'verticalLayout:' false
|
|
471 |
#'fitFirstPanel:' true
|
109
|
472 |
)
|
137
|
473 |
#(#MenuPanelSpec
|
|
474 |
#'name:' 'menuAlignment'
|
|
475 |
#'layout:' #(#LayoutFrame 0 0.0 29 0 233 0 54 0)
|
|
476 |
#'menu:' #menuAlignment
|
|
477 |
#'showSeparatingLines:' true
|
|
478 |
#'verticalLayout:' false
|
|
479 |
#'fitFirstPanel:' true
|
|
480 |
)
|
|
481 |
#(#PanelViewSpec
|
|
482 |
#'name:' 'panelViewButtons'
|
|
483 |
#'layout:' #(#LayoutFrame -125 1.0 25 0.0 0 1.0 58 0.0)
|
|
484 |
#'component:'
|
|
485 |
#(#SpecCollection
|
|
486 |
#'collection:'
|
|
487 |
#(
|
|
488 |
#(#ActionButtonSpec
|
|
489 |
#'name:' 'moveLeft'
|
|
490 |
#'label:' ''
|
|
491 |
#'translateLabel:' true
|
|
492 |
#'labelChannel:' #'LABELb_moveLeft.xbm'
|
|
493 |
#'defaultable:' true
|
|
494 |
#'model:' #moveSelectionLeft
|
|
495 |
#'isTriggerOnDown:' true
|
|
496 |
#'enableChannel:' #enableChannel
|
|
497 |
#'autoRepeat:' false
|
|
498 |
#'extent:' #(#Point 26 24)
|
|
499 |
)
|
|
500 |
#(#ActionButtonSpec
|
|
501 |
#'name:' 'moveRight'
|
|
502 |
#'label:' ''
|
|
503 |
#'translateLabel:' true
|
|
504 |
#'labelChannel:' #'LABELb_moveRight.xbm'
|
|
505 |
#'defaultable:' true
|
|
506 |
#'model:' #moveSelectionRight
|
|
507 |
#'isTriggerOnDown:' true
|
|
508 |
#'enableChannel:' #enableChannel
|
|
509 |
#'autoRepeat:' false
|
|
510 |
#'extent:' #(#Point 26 24)
|
|
511 |
)
|
|
512 |
#(#ActionButtonSpec
|
|
513 |
#'name:' 'moveUp'
|
|
514 |
#'label:' ''
|
|
515 |
#'translateLabel:' true
|
|
516 |
#'labelChannel:' #'LABELb_moveUp.xbm'
|
|
517 |
#'defaultable:' true
|
|
518 |
#'model:' #moveSelectionUp
|
|
519 |
#'isTriggerOnDown:' true
|
|
520 |
#'enableChannel:' #enableChannel
|
|
521 |
#'autoRepeat:' false
|
|
522 |
#'extent:' #(#Point 26 24)
|
|
523 |
)
|
|
524 |
#(#ActionButtonSpec
|
|
525 |
#'name:' 'moveDown'
|
|
526 |
#'label:' ''
|
|
527 |
#'translateLabel:' true
|
|
528 |
#'labelChannel:' #'LABELb_moveDown.xbm'
|
|
529 |
#'defaultable:' true
|
|
530 |
#'model:' #moveSelectionDown
|
|
531 |
#'isTriggerOnDown:' true
|
|
532 |
#'enableChannel:' #enableChannel
|
|
533 |
#'autoRepeat:' false
|
|
534 |
#'extent:' #(#Point 26 24)
|
|
535 |
)
|
|
536 |
)
|
|
537 |
)
|
|
538 |
#'level:' 1
|
|
539 |
#'horizontalLayout:' #fitSpace
|
|
540 |
#'verticalLayout:' #fitSpace
|
|
541 |
#'horizontalSpace:' 4
|
|
542 |
#'verticalSpace:' 4
|
|
543 |
)
|
|
544 |
#(#SequenceViewSpec
|
|
545 |
#'name:' 'objectTree'
|
|
546 |
#'layout:' #(#LayoutFrame 0 0.0 59 0.0 0 0.35 0 1.0)
|
|
547 |
#'enableChannel:' #enableChannel
|
|
548 |
#'menu:' #objectListMenu
|
|
549 |
#'tabable:' false
|
|
550 |
#'model:' #objectList
|
|
551 |
#'hasHorizontalScrollBar:' true
|
|
552 |
#'hasVerticalScrollBar:' true
|
|
553 |
#'miniScrollerHorizontal:' true
|
|
554 |
#'miniScrollerVertical:' false
|
|
555 |
#'isMultiSelect:' true
|
|
556 |
#'doubleClickSelector:' #doubleClick
|
|
557 |
#'useIndex:' true
|
|
558 |
)
|
|
559 |
#(#NoteBookViewSpec
|
|
560 |
#'name:' 'noteBook'
|
|
561 |
#'layout:' #(#LayoutFrame 0 0.35 59 0.0 0 1.0 -30 1.0)
|
|
562 |
#'enableChannel:' #enableChannel
|
|
563 |
#'menu:' #tabList
|
|
564 |
#'style:'
|
|
565 |
#(#FontDescription
|
|
566 |
#fixed #medium
|
|
567 |
#roman #'10'
|
|
568 |
)
|
|
569 |
#'model:' #tabModel
|
|
570 |
#'tabWidget:' #Window
|
|
571 |
#'useIndex:' false
|
|
572 |
#'level:' 0
|
|
573 |
#'canvas:' #noteBookView
|
|
574 |
)
|
|
575 |
#(#HorizontalPanelViewSpec
|
|
576 |
#'name:' 'modifyPanel'
|
|
577 |
#'layout:' #(#LayoutFrame 0 0.35 -30 1.0 0 1.0 0 1.0)
|
|
578 |
#'component:'
|
|
579 |
#(#SpecCollection
|
|
580 |
#'collection:'
|
|
581 |
#(
|
|
582 |
#(#ActionButtonSpec
|
|
583 |
#'name:' 'cancelButton'
|
|
584 |
#'label:' 'cancel'
|
|
585 |
#'model:' #cancel
|
|
586 |
#'isTriggerOnDown:' false
|
|
587 |
#'enableChannel:' #modifiedChannel
|
|
588 |
#'autoRepeat:' false
|
|
589 |
#'extent:' #(#Point 151 24)
|
|
590 |
)
|
|
591 |
#(#ActionButtonSpec
|
|
592 |
#'name:' 'acceptButton'
|
|
593 |
#'label:' 'ok'
|
|
594 |
#'model:' #accept
|
|
595 |
#'isTriggerOnDown:' false
|
|
596 |
#'enableChannel:' #modifiedChannel
|
|
597 |
#'autoRepeat:' false
|
|
598 |
#'extent:' #(#Point 151 24)
|
|
599 |
)
|
|
600 |
)
|
|
601 |
)
|
|
602 |
#'level:' 0
|
|
603 |
#'horizontalLayout:' #fitSpace
|
|
604 |
#'verticalLayout:' #fitSpace
|
|
605 |
#'horizontalSpace:' 3
|
|
606 |
#'verticalSpace:' 3
|
|
607 |
)
|
109
|
608 |
)
|
|
609 |
)
|
|
610 |
)
|
60
|
611 |
! !
|
|
612 |
|
109
|
613 |
!UIPainter methodsFor:'actions'!
|
60
|
614 |
|
109
|
615 |
accept
|
|
616 |
"automatically generated by UIPainter ..."
|
|
617 |
|layout|
|
60
|
618 |
|
109
|
619 |
currentView notNil ifTrue:[
|
|
620 |
tabSelection = 'Dimension' ifTrue:[
|
|
621 |
(layout := layoutTool layout) notNil ifTrue:[
|
|
622 |
layoutTool layoutType == #Extent ifTrue:[
|
|
623 |
self painter setExtent:layout
|
|
624 |
] ifFalse:[
|
|
625 |
self painter setDimension:layout
|
|
626 |
]
|
|
627 |
]
|
|
628 |
] ifFalse:[
|
|
629 |
self painter updateFromSpec:(specView specEdited).
|
|
630 |
].
|
|
631 |
self cancel
|
|
632 |
]
|
|
633 |
|
|
634 |
!
|
|
635 |
|
|
636 |
cancel
|
|
637 |
"cancel all changes and read back attributes from current view
|
|
638 |
"
|
|
639 |
specView specEdited:(self painter specFor:currentView).
|
|
640 |
layoutTool forView:currentView.
|
|
641 |
self modifiedChannel value:false.
|
137
|
642 |
!
|
|
643 |
|
|
644 |
doubleClick
|
|
645 |
objectList selectGroup
|
60
|
646 |
! !
|
|
647 |
|
|
648 |
!UIPainter methodsFor:'aspects'!
|
|
649 |
|
118
|
650 |
enableChannel
|
|
651 |
"true if modifications are allowed otherwise running test
|
|
652 |
"
|
|
653 |
^ self painter enableChannel
|
109
|
654 |
!
|
|
655 |
|
118
|
656 |
menuAlignment
|
|
657 |
|menu channel|
|
|
658 |
|
|
659 |
channel := self enableChannel.
|
|
660 |
|
|
661 |
menu := Menu new.
|
|
662 |
menu fromLiteralArrayEncoding:(self class menuAlignment).
|
|
663 |
menu receiver:self.
|
|
664 |
menu menuItems do:[:anItem| anItem enabled:channel].
|
|
665 |
^ menu
|
|
666 |
!
|
|
667 |
|
|
668 |
menuPullDown
|
|
669 |
|menu channel|
|
|
670 |
|
|
671 |
channel := self enableChannel.
|
|
672 |
|
|
673 |
menu := Menu new.
|
|
674 |
menu fromLiteralArrayEncoding:(self class menuPullDown).
|
|
675 |
menu receiver:self.
|
|
676 |
|
|
677 |
menu menuItems do:[:anItem|
|
|
678 |
anItem nameKey ~~ #test ifTrue:[anItem enabled:channel]
|
133
|
679 |
ifFalse:[anItem value:channel].
|
118
|
680 |
].
|
|
681 |
^ menu
|
109
|
682 |
!
|
|
683 |
|
|
684 |
modifiedChannel
|
|
685 |
|
|
686 |
|holder|
|
|
687 |
|
|
688 |
(holder := builder bindingAt:#modifiedChannel) isNil ifTrue:[
|
|
689 |
builder aspectAt:#modifiedChannel put:(holder := false asValue).
|
|
690 |
].
|
|
691 |
^ holder
|
|
692 |
!
|
|
693 |
|
|
694 |
noteBookView
|
|
695 |
"automatically generated by UIPainter ..."
|
|
696 |
|
|
697 |
|noteBook channel|
|
|
698 |
|
|
699 |
(noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
|
|
700 |
noteBook := View origin:0.0 @0.0 corner:1.0@1.0.
|
|
701 |
layoutTool := UIPropertyView for:#Dimension in:noteBook.
|
|
702 |
specView := UIPropertyView for:#Specification in:noteBook.
|
60
|
703 |
|
109
|
704 |
channel := self modifiedChannel.
|
|
705 |
layoutTool modifiedHolder:channel.
|
|
706 |
specView modifiedHolder:channel.
|
|
707 |
specView viewBackground:(layoutTool viewBackground).
|
|
708 |
builder aspectAt:#noteBookView put:noteBook.
|
|
709 |
].
|
|
710 |
^ noteBook
|
|
711 |
!
|
|
712 |
|
|
713 |
objectList
|
|
714 |
^ objectList
|
|
715 |
!
|
|
716 |
|
|
717 |
objectListMenu
|
|
718 |
"returns a block which returns the menu
|
114
|
719 |
!!hack!!
|
109
|
720 |
"
|
121
|
721 |
^ [ self painter showMiddleButtonMenu ].
|
109
|
722 |
|
|
723 |
|
|
724 |
|
|
725 |
!
|
|
726 |
|
|
727 |
tabList
|
|
728 |
"automatically generated by UIPainter ..."
|
|
729 |
|
|
730 |
|holder|
|
|
731 |
|
|
732 |
(holder := builder bindingAt:#tabList) isNil ifTrue:[
|
|
733 |
builder aspectAt:#tabList put:(holder := ValueHolder new).
|
137
|
734 |
holder value:#( ' ' ' ' ).
|
109
|
735 |
].
|
|
736 |
^ holder
|
|
737 |
!
|
|
738 |
|
|
739 |
tabModel
|
|
740 |
"automatically generated by UIPainter ..."
|
|
741 |
|
|
742 |
|holder|
|
|
743 |
|
|
744 |
(holder := builder bindingAt:#tabModel) isNil ifTrue:[
|
|
745 |
lastSlice := 'Basics'.
|
|
746 |
holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
|
|
747 |
builder aspectAt:#tabModel put:holder.
|
|
748 |
].
|
|
749 |
^ holder
|
60
|
750 |
! !
|
|
751 |
|
109
|
752 |
!UIPainter methodsFor:'binding access'!
|
|
753 |
|
|
754 |
aspectFor:aKey
|
|
755 |
"check wether aspect is assigned to a label icon
|
|
756 |
"
|
|
757 |
(aKey startsWith:'LABEL') ifFalse:[
|
|
758 |
^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
|
|
759 |
].
|
|
760 |
^ Image fromFile:(aKey copyFrom:(('LABEL' size) + 1))
|
|
761 |
! !
|
|
762 |
|
|
763 |
!UIPainter methodsFor:'change & update'!
|
|
764 |
|
|
765 |
update:something with:aParameter from:someObject
|
|
766 |
|
|
767 |
(someObject == objectList and:[something ~~ #list]) ifTrue:[
|
|
768 |
something ~~ #layout ifTrue:[
|
|
769 |
self objectListChanged
|
|
770 |
] ifFalse:[
|
|
771 |
(self modifiedChannel value) ifFalse:[
|
|
772 |
layoutTool forView:currentView
|
|
773 |
]
|
|
774 |
]
|
|
775 |
]
|
|
776 |
! !
|
|
777 |
|
|
778 |
!UIPainter methodsFor:'event handling'!
|
|
779 |
|
|
780 |
doesNotUnderstand:aMessage
|
|
781 |
|painter|
|
|
782 |
|
|
783 |
painter := self painter.
|
|
784 |
|
|
785 |
(painter respondsTo:(aMessage selector)) ifTrue:[
|
|
786 |
^ aMessage sendTo:painter
|
|
787 |
].
|
|
788 |
self error
|
|
789 |
|
|
790 |
!
|
|
791 |
|
|
792 |
objectListChanged
|
|
793 |
"something changed in the painter view
|
|
794 |
"
|
|
795 |
|setSel slices list spec props|
|
|
796 |
|
|
797 |
props := objectList selectedProperty.
|
|
798 |
tabSelection := nil.
|
|
799 |
|
|
800 |
props isNil ifFalse:[
|
|
801 |
currentView := props view.
|
|
802 |
layoutTool forView:currentView.
|
|
803 |
|
|
804 |
spec := props spec copy.
|
|
805 |
slices := spec class slices.
|
|
806 |
list := slices collect:[:slice| slice first asString ].
|
|
807 |
list add:'Dimension'.
|
|
808 |
(self tabList) value:list.
|
|
809 |
|
|
810 |
(list findFirst:[:aName| aName = lastSlice]) ~~ 0 ifTrue:[
|
|
811 |
setSel := lastSlice
|
|
812 |
]
|
121
|
813 |
] ifTrue:[
|
|
814 |
layoutTool forView:nil
|
109
|
815 |
].
|
|
816 |
|
|
817 |
specView specEdited:spec.
|
|
818 |
self tabModel value:setSel.
|
|
819 |
! !
|
|
820 |
|
|
821 |
!UIPainter methodsFor:'file access'!
|
60
|
822 |
|
|
823 |
openFile:aFileName
|
|
824 |
|aStream |
|
|
825 |
|
|
826 |
aStream := FileStream readonlyFileNamed:aFileName.
|
|
827 |
|
|
828 |
aStream notNil ifTrue:[
|
109
|
829 |
self painter fileInContentsFrom:aStream.
|
60
|
830 |
aStream close.
|
|
831 |
fileName := aFileName
|
|
832 |
]
|
|
833 |
|
109
|
834 |
|
60
|
835 |
!
|
|
836 |
|
|
837 |
saveAs:aFileName
|
|
838 |
|aStream|
|
|
839 |
|
|
840 |
aStream := FileStream newFileNamed:aFileName.
|
|
841 |
|
|
842 |
aStream notNil ifTrue:[
|
109
|
843 |
self painter storeContentsOn:aStream.
|
60
|
844 |
aStream close.
|
|
845 |
fileName := aFileName
|
|
846 |
].
|
|
847 |
|
|
848 |
! !
|
|
849 |
|
109
|
850 |
!UIPainter methodsFor:'private'!
|
|
851 |
|
|
852 |
painter
|
|
853 |
^ objectList painter
|
|
854 |
! !
|
|
855 |
|
|
856 |
!UIPainter methodsFor:'selection'!
|
|
857 |
|
|
858 |
tabSelection
|
|
859 |
^ tabSelection
|
|
860 |
!
|
|
861 |
|
|
862 |
tabSelection:something
|
|
863 |
|specEdited slices spec idx|
|
60
|
864 |
|
121
|
865 |
something isNil ifTrue:[^ self].
|
|
866 |
|
|
867 |
tabSelection := something.
|
|
868 |
|
|
869 |
(specEdited := specView specEdited) notNil ifTrue:[
|
|
870 |
slices := specEdited class slices.
|
|
871 |
lastSlice := tabSelection.
|
109
|
872 |
|
121
|
873 |
idx:= slices findFirst:[:aSlice| aSlice first = tabSelection ].
|
|
874 |
idx == 0 ifTrue:[
|
|
875 |
layoutTool forView:currentView.
|
|
876 |
^ layoutTool raise.
|
|
877 |
].
|
|
878 |
spec := specEdited class perform:((slices at:idx) last).
|
60
|
879 |
].
|
121
|
880 |
specView raise.
|
|
881 |
|
109
|
882 |
specEdited isNil ifTrue:[
|
121
|
883 |
specView buildFromSpec:nil
|
109
|
884 |
] ifFalse:[
|
|
885 |
specView buildFromSpec:spec
|
|
886 |
]
|
60
|
887 |
! !
|
|
888 |
|
109
|
889 |
!UIPainter methodsFor:'startup / release'!
|
|
890 |
|
|
891 |
closeRequest
|
|
892 |
"close all windows open by builder
|
|
893 |
"
|
133
|
894 |
|anyUnsavedChanges|
|
|
895 |
|
|
896 |
objectList painter isModified ifTrue:[
|
|
897 |
(self confirm:'quit without saving ?') ifFalse:[
|
|
898 |
^ self
|
|
899 |
]
|
|
900 |
].
|
|
901 |
|
109
|
902 |
objectList removeDependent:self.
|
|
903 |
objectList painter release.
|
|
904 |
objectList := nil.
|
60
|
905 |
|
109
|
906 |
selectionPanel notNil ifTrue:[
|
|
907 |
selectionPanel closeRequest
|
|
908 |
].
|
|
909 |
super closeRequest.
|
|
910 |
|
|
911 |
!
|
|
912 |
|
|
913 |
closeRequestFor:aTopView
|
|
914 |
"handle a close request for a specific view
|
|
915 |
"
|
60
|
916 |
|topView|
|
|
917 |
|
109
|
918 |
topView := self window.
|
60
|
919 |
|
109
|
920 |
topView == aTopView ifTrue:[
|
|
921 |
super closeRequestFor:aTopView
|
|
922 |
] ifFalse:[
|
133
|
923 |
topView raise.
|
|
924 |
topView device beep
|
109
|
925 |
].
|
60
|
926 |
!
|
|
927 |
|
109
|
928 |
openInterface
|
|
929 |
"open interfaces
|
|
930 |
"
|
136
|
931 |
|painterView painter cls topView|
|
60
|
932 |
|
|
933 |
aspects := IdentityDictionary new.
|
|
934 |
|
|
935 |
aspects at:#classNameChannel put:(
|
|
936 |
(specClass notNil ifTrue:[specClass]
|
|
937 |
ifFalse:['NewApplication']) asValue
|
|
938 |
).
|
|
939 |
specSuperclass isNil ifTrue:[
|
|
940 |
specClass notNil ifTrue:[
|
|
941 |
(cls := Smalltalk at:specClass asSymbol) notNil ifTrue:[
|
|
942 |
specSuperclass := cls superclass name.
|
|
943 |
]
|
|
944 |
]
|
|
945 |
].
|
|
946 |
aspects at:#superclassNameChannel put:(
|
|
947 |
(specSuperclass notNil ifTrue:[specSuperclass]
|
|
948 |
ifFalse:['ApplicationModel']) asValue
|
|
949 |
).
|
|
950 |
aspects at:#methodNameChannel put:(
|
|
951 |
(specSelector notNil ifTrue:[specSelector]
|
|
952 |
ifFalse:[#windowSpec]) asValue
|
|
953 |
).
|
136
|
954 |
|
|
955 |
painterView := StandardSystemView new.
|
|
956 |
painterView label:'unnamed canvas'.
|
|
957 |
painterView extent:300@300.
|
|
958 |
|
|
959 |
painter := UIPainterView in:painterView.
|
109
|
960 |
painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
|
136
|
961 |
|
109
|
962 |
objectList := painter listHolder.
|
|
963 |
objectList addDependent:self.
|
136
|
964 |
|
109
|
965 |
super openInterface.
|
60
|
966 |
|
136
|
967 |
topView := self window.
|
|
968 |
topView bePartner.
|
|
969 |
topView label:'Interface Builder'.
|
|
970 |
topView icon:(Image fromFile:'bitmaps/Builder.xbm' resolution:100).
|
|
971 |
|
|
972 |
painterView openInGroup:(topView windowGroup).
|
|
973 |
painterView bePartner.
|
|
974 |
painterView application:self.
|
|
975 |
painterView open.
|
|
976 |
|
|
977 |
painterView application:self.
|
|
978 |
selectionPanel := UISelectionPanel newDefault.
|
|
979 |
selectionPanel allButOpenInterface:#windowSpec.
|
|
980 |
selectionPanel window openInGroup:(topView windowGroup).
|
|
981 |
selectionPanel window bePartner.
|
|
982 |
selectionPanel openWindow.
|
|
983 |
selectionPanel window application:self.
|
|
984 |
|
60
|
985 |
!
|
|
986 |
|
|
987 |
openNewWindowCanvas
|
109
|
988 |
"open new
|
|
989 |
"
|
60
|
990 |
self open.
|
|
991 |
|
|
992 |
|
|
993 |
!
|
|
994 |
|
109
|
995 |
openOnClass:aClass
|
|
996 |
"open up an interface builder
|
|
997 |
"
|
|
998 |
self openOnClass:aClass andSelector:#windowSpec
|
|
999 |
!
|
|
1000 |
|
60
|
1001 |
openOnClass:aClass andSelector:aSelector
|
|
1002 |
"open up an interface builder, fetching a spec from someClass
|
109
|
1003 |
via some selector
|
|
1004 |
"
|
|
1005 |
|painter|
|
60
|
1006 |
|
109
|
1007 |
self openInterface.
|
60
|
1008 |
|
109
|
1009 |
painter := self painter.
|
60
|
1010 |
specClass := aClass name.
|
|
1011 |
specSuperclass := aClass superclass name.
|
|
1012 |
specSelector := aSelector.
|
|
1013 |
|
109
|
1014 |
painter className:aClass name.
|
|
1015 |
painter methodName:aSelector.
|
|
1016 |
painter setupFromSpec:(aClass perform:aSelector).
|
60
|
1017 |
|
|
1018 |
! !
|
|
1019 |
|
109
|
1020 |
!UIPainter methodsFor:'user interaction - dialog'!
|
60
|
1021 |
|
133
|
1022 |
browseAppClass
|
|
1023 |
"open a browser on the class"
|
|
1024 |
|
|
1025 |
|cls|
|
|
1026 |
|
|
1027 |
specClass isNil ifTrue:[
|
|
1028 |
self information:'no class yet'.
|
|
1029 |
^ self
|
|
1030 |
].
|
|
1031 |
|
|
1032 |
specClass isBehavior ifFalse:[
|
|
1033 |
cls := Smalltalk at:specClass asSymbol
|
|
1034 |
] ifTrue:[
|
|
1035 |
cls := specClass
|
|
1036 |
].
|
|
1037 |
|
|
1038 |
cls isNil ifTrue:[
|
|
1039 |
self information:'no class yet'.
|
|
1040 |
^ self
|
|
1041 |
].
|
|
1042 |
|
|
1043 |
SystemBrowser openInClass:cls
|
|
1044 |
|
|
1045 |
|
|
1046 |
!
|
|
1047 |
|
60
|
1048 |
checkClassAndSelector
|
|
1049 |
"check for class & superclass"
|
|
1050 |
|
|
1051 |
|superclass cls|
|
|
1052 |
|
|
1053 |
specClass isNil ifTrue:[^ false].
|
|
1054 |
|
|
1055 |
specClass isBehavior ifFalse:[
|
|
1056 |
cls := Smalltalk at:specClass asSymbol
|
|
1057 |
] ifTrue:[
|
|
1058 |
cls := specClass
|
|
1059 |
].
|
|
1060 |
cls isNil ifTrue:[
|
|
1061 |
(superclass := Smalltalk at:specSuperclass asSymbol) isNil ifTrue:[
|
|
1062 |
self warn:'no class named ' , specSuperclass , ' exists.'.
|
|
1063 |
^ false.
|
|
1064 |
].
|
|
1065 |
(self confirm:'create ' , specClass , ' ?') ifTrue:[
|
|
1066 |
superclass subclass:(specClass asSymbol)
|
|
1067 |
instanceVariableNames:''
|
|
1068 |
classVariableNames:''
|
|
1069 |
poolDictionaries:''
|
|
1070 |
category:'New-Applications'.
|
|
1071 |
^ true.
|
|
1072 |
].
|
|
1073 |
^ false.
|
|
1074 |
].
|
|
1075 |
cls isBehavior ifFalse:[
|
|
1076 |
self warn:'a global named ' , specClass , ' exists, but is no class.'.
|
|
1077 |
^ false.
|
|
1078 |
].
|
|
1079 |
|
|
1080 |
specSuperclass isBehavior ifFalse:[
|
|
1081 |
superclass := Smalltalk at:specSuperclass asSymbol
|
|
1082 |
] ifTrue:[
|
|
1083 |
superclass := specSuperclass
|
|
1084 |
].
|
|
1085 |
specSuperclass notNil ifTrue:[
|
|
1086 |
superclass isNil ifTrue:[
|
|
1087 |
self warn:'no class named ' , specSuperclass , ' exists.'.
|
|
1088 |
^ false.
|
|
1089 |
].
|
|
1090 |
|
|
1091 |
(cls isSubclassOf:superclass) ifFalse:[
|
|
1092 |
self warn:'a global named ' , specClass , ' exists, but is not a subclass of ' , superclass name , '.'.
|
|
1093 |
^ false.
|
|
1094 |
]
|
|
1095 |
].
|
|
1096 |
^ true
|
109
|
1097 |
|
|
1098 |
|
60
|
1099 |
!
|
|
1100 |
|
|
1101 |
defineClassAndSelector
|
|
1102 |
"launch a dialog to define class, superclass and method"
|
|
1103 |
|
|
1104 |
|again|
|
|
1105 |
|
|
1106 |
[
|
|
1107 |
again := false.
|
109
|
1108 |
|
60
|
1109 |
(self openDialogInterface:#nameAndSelectorSpec) ifTrue:[
|
|
1110 |
|
|
1111 |
specClass := (self aspectFor:#classNameChannel) value.
|
|
1112 |
specSelector := (self aspectFor:#methodNameChannel) value.
|
|
1113 |
specSuperclass := (self aspectFor:#superclassNameChannel) value.
|
|
1114 |
|
109
|
1115 |
(again := self checkClassAndSelector not) ifFalse:[
|
|
1116 |
self painter className:specClass
|
|
1117 |
superclassName:specSuperclass
|
|
1118 |
selector:specSelector.
|
|
1119 |
]
|
60
|
1120 |
]
|
109
|
1121 |
|
60
|
1122 |
] doWhile:[again]
|
|
1123 |
|
109
|
1124 |
|
60
|
1125 |
! !
|
|
1126 |
|
109
|
1127 |
!UIPainter methodsFor:'user interaction - pullDown'!
|
60
|
1128 |
|
|
1129 |
doFromClass
|
109
|
1130 |
|className methodName cls sel accepted failed spec s painter|
|
60
|
1131 |
|
109
|
1132 |
className := '' asValue.
|
60
|
1133 |
methodName := '' asValue.
|
109
|
1134 |
painter := self painter.
|
|
1135 |
|
|
1136 |
(s := painter className) notNil ifTrue:[
|
60
|
1137 |
className value:s
|
|
1138 |
].
|
109
|
1139 |
(s := painter methodName) notNil ifTrue:[
|
60
|
1140 |
methodName value:s
|
|
1141 |
].
|
|
1142 |
|
|
1143 |
failed := false.
|
|
1144 |
[
|
|
1145 |
accepted :=
|
|
1146 |
(DialogBox new
|
|
1147 |
addTextLabel:'Classes name:';
|
|
1148 |
addInputFieldOn:className;
|
|
1149 |
addVerticalSpace;
|
|
1150 |
addTextLabel:'methods name:';
|
|
1151 |
addInputFieldOn:methodName;
|
|
1152 |
addAbortButton;
|
|
1153 |
addOkButton;
|
|
1154 |
open
|
|
1155 |
) accepted.
|
|
1156 |
|
|
1157 |
accepted ifTrue:[
|
|
1158 |
cls := Smalltalk classNamed:className value.
|
|
1159 |
cls isNil ifTrue:[
|
|
1160 |
failed := true.
|
|
1161 |
self warn:'no such class'.
|
|
1162 |
] ifFalse:[
|
|
1163 |
sel := methodName value asSymbol.
|
|
1164 |
(cls respondsTo:sel ) ifFalse:[
|
|
1165 |
failed := true.
|
|
1166 |
self warn:'no such method'
|
|
1167 |
] ifTrue:[
|
|
1168 |
spec := cls perform:sel.
|
|
1169 |
spec isArray ifFalse:[
|
|
1170 |
failed := true.
|
|
1171 |
self warn:'not a windowSpec method'
|
|
1172 |
].
|
|
1173 |
"/ ok, got it
|
109
|
1174 |
painter className:className value.
|
|
1175 |
painter methodName:methodName value.
|
|
1176 |
painter setupFromSpec:spec.
|
|
1177 |
^ self
|
60
|
1178 |
]
|
|
1179 |
]
|
|
1180 |
]
|
|
1181 |
] doWhile:[accepted and:[failed]].
|
|
1182 |
|
|
1183 |
!
|
|
1184 |
|
|
1185 |
doInstallAspects
|
|
1186 |
|code|
|
|
1187 |
|
|
1188 |
(specClass isNil or:[specSelector isNil]) ifTrue:[
|
|
1189 |
self defineClassAndSelector
|
|
1190 |
].
|
|
1191 |
|
|
1192 |
self checkClassAndSelector ifFalse:[
|
|
1193 |
^ self
|
|
1194 |
].
|
|
1195 |
|
109
|
1196 |
self painter className:specClass
|
|
1197 |
superclassName:specSuperclass
|
|
1198 |
selector:specSelector.
|
60
|
1199 |
|
109
|
1200 |
code := self painter generateAspectMethods.
|
60
|
1201 |
(ReadStream on:code) fileIn.
|
|
1202 |
|
|
1203 |
!
|
|
1204 |
|
|
1205 |
doInstallSpec
|
|
1206 |
|code|
|
|
1207 |
|
|
1208 |
(specClass isNil or:[specSelector isNil]) ifTrue:[
|
|
1209 |
self defineClassAndSelector
|
|
1210 |
].
|
|
1211 |
|
|
1212 |
self checkClassAndSelector ifFalse:[
|
|
1213 |
^ self
|
|
1214 |
].
|
|
1215 |
|
109
|
1216 |
self painter className:specClass
|
|
1217 |
superclassName:specSuperclass
|
|
1218 |
selector:specSelector.
|
60
|
1219 |
|
109
|
1220 |
code := self painter generateCode.
|
60
|
1221 |
(ReadStream on:code) fileIn.
|
|
1222 |
|
|
1223 |
!
|
|
1224 |
|
|
1225 |
doOpen
|
|
1226 |
|box|
|
|
1227 |
|
|
1228 |
box := FileSelectionBox new.
|
|
1229 |
box title:(resources string:'Which file ?').
|
|
1230 |
box selectingDirectory:false.
|
|
1231 |
box pattern:'*.*'.
|
|
1232 |
box action:[:aFile| self openFile:aFile ].
|
|
1233 |
box open
|
109
|
1234 |
|
60
|
1235 |
!
|
|
1236 |
|
|
1237 |
doPickAView
|
109
|
1238 |
|painter view className methodName cls sel accepted spec s|
|
60
|
1239 |
|
109
|
1240 |
(view := Display viewFromUser) notNil ifTrue:[
|
|
1241 |
painter := self painter.
|
60
|
1242 |
|
109
|
1243 |
spec := UISpecification fromView:view topView.
|
60
|
1244 |
|
109
|
1245 |
"/ ok, got it
|
|
1246 |
painter setupFromSpec:spec.
|
|
1247 |
painter className:view class name.
|
|
1248 |
painter methodName:#newSpec.
|
|
1249 |
]
|
60
|
1250 |
!
|
|
1251 |
|
|
1252 |
doRaise
|
109
|
1253 |
self painter topView raise.
|
|
1254 |
|
|
1255 |
selectionPanel notNil ifTrue:[
|
|
1256 |
selectionPanel window raise
|
|
1257 |
]
|
|
1258 |
|
60
|
1259 |
!
|
|
1260 |
|
|
1261 |
doSave
|
|
1262 |
fileName notNil ifTrue:[
|
|
1263 |
self saveAs:fileName
|
|
1264 |
] ifFalse:[
|
|
1265 |
self doSaveAs
|
|
1266 |
]
|
109
|
1267 |
|
60
|
1268 |
!
|
|
1269 |
|
|
1270 |
doSaveAs
|
|
1271 |
|box|
|
|
1272 |
|
|
1273 |
box := FileSelectionBox new.
|
|
1274 |
box title:(resources string:'Which file ?').
|
|
1275 |
box selectingDirectory:false.
|
|
1276 |
box pattern:'*.*'.
|
|
1277 |
box action:[:aFile| self saveAs:aFile ].
|
|
1278 |
box open
|
|
1279 |
|
|
1280 |
!
|
|
1281 |
|
|
1282 |
doWindowSpec
|
68
|
1283 |
|code code2 v|
|
60
|
1284 |
|
109
|
1285 |
code := self painter generateWindowSpecMethodSource.
|
68
|
1286 |
|
60
|
1287 |
v := CodeView open.
|
|
1288 |
v contents:code.
|
|
1289 |
v label:'windowSpec'.
|
|
1290 |
|
81
|
1291 |
! !
|
|
1292 |
|
60
|
1293 |
!UIPainter class methodsFor:'documentation'!
|
|
1294 |
|
|
1295 |
version
|
|
1296 |
^ '$Header$'
|
|
1297 |
! !
|