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