60
|
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 |
|
|
13 |
ApplicationModel subclass:#UIPainter
|
|
14 |
instanceVariableNames:'topView workView propertyView treeView elementMenu fileName
|
|
15 |
specClass specSelector specSuperclass aspects'
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'Interface-UIPainter'
|
|
19 |
!
|
|
20 |
|
58
|
21 |
HorizontalPanelView subclass:#ButtonPanel
|
|
22 |
instanceVariableNames:'receiver argumentToSelector'
|
|
23 |
classVariableNames:''
|
|
24 |
poolDictionaries:''
|
|
25 |
privateIn:UIPainter
|
|
26 |
!
|
|
27 |
|
60
|
28 |
!UIPainter class methodsFor:'documentation'!
|
|
29 |
|
|
30 |
copyright
|
|
31 |
"
|
|
32 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
33 |
All Rights Reserved
|
|
34 |
|
|
35 |
This software is furnished under a license and may be used
|
|
36 |
only in accordance with the terms of that license and with the
|
|
37 |
inclusion of the above copyright notice. This software may not
|
|
38 |
be provided or otherwise made available to, or used by, any
|
|
39 |
other person. No title to or ownership of the software is
|
|
40 |
hereby transferred.
|
|
41 |
"
|
|
42 |
!
|
|
43 |
|
|
44 |
documentation
|
|
45 |
"
|
|
46 |
not yet finished, not yet published, not yet released.
|
|
47 |
|
|
48 |
[start with:]
|
|
49 |
UIPainter open
|
|
50 |
"
|
|
51 |
! !
|
|
52 |
|
|
53 |
!UIPainter class methodsFor:'interface specs'!
|
|
54 |
|
|
55 |
nameAndSelectorSpec
|
|
56 |
"this window spec was automatically generated by the ST/X UIPainter"
|
|
57 |
|
|
58 |
"do not manually edit this - the painter/builder may not be able to
|
|
59 |
handle the specification if its corrupted."
|
|
60 |
|
|
61 |
"
|
|
62 |
UIPainter new openOnClass:UIPainter andSelector:#nameAndSelectorSpec
|
|
63 |
UIPainter new openInterface:#nameAndSelectorSpec
|
|
64 |
"
|
|
65 |
|
|
66 |
<resource: #canvas>
|
|
67 |
|
|
68 |
^
|
|
69 |
|
|
70 |
#(#FullSpec
|
|
71 |
#'isOpaque:' true
|
|
72 |
#'window:'
|
|
73 |
#(#WindowSpec
|
|
74 |
#'name:' 'uIPainterView'
|
|
75 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
|
|
76 |
#'isOpaque:' true
|
|
77 |
#'label:' 'unnamed'
|
|
78 |
#'bounds:' #(#Rectangle 0 0 300 300)
|
|
79 |
)
|
|
80 |
#'component:'
|
|
81 |
#(#SpecCollection
|
|
82 |
#'collection:'
|
|
83 |
#(
|
|
84 |
#(#LabelSpec
|
|
85 |
#'name:' 'label1'
|
|
86 |
#'layout:' #(#LayoutFrame 10 0 50 0 110 0 70 0)
|
|
87 |
#'isOpaque:' true
|
|
88 |
#'label:' 'class:'
|
|
89 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
90 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
91 |
#'initiallyInvisible:' false
|
|
92 |
#'level:' 0
|
|
93 |
#'adjust:' #right
|
|
94 |
#'hasCharacterOrientedLabel:' true
|
|
95 |
)
|
|
96 |
#(#LabelSpec
|
|
97 |
#'name:' 'label2'
|
|
98 |
#'layout:' #(#LayoutFrame 10 0 90 0 110 0 110 0)
|
|
99 |
#'isOpaque:' true
|
|
100 |
#'label:' 'superclass:'
|
|
101 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
102 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
103 |
#'initiallyInvisible:' false
|
|
104 |
#'level:' 0
|
|
105 |
#'adjust:' #right
|
|
106 |
#'hasCharacterOrientedLabel:' true
|
|
107 |
)
|
|
108 |
#(#LabelSpec
|
|
109 |
#'name:' 'label3'
|
|
110 |
#'layout:' #(#LayoutFrame 10 0 130 0 110 0 150 0)
|
|
111 |
#'isOpaque:' true
|
|
112 |
#'label:' 'selector:'
|
|
113 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
114 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
115 |
#'initiallyInvisible:' false
|
|
116 |
#'level:' 0
|
|
117 |
#'adjust:' #right
|
|
118 |
#'hasCharacterOrientedLabel:' true
|
|
119 |
)
|
|
120 |
#(#InputFieldSpec
|
|
121 |
#'name:' 'classNameField'
|
|
122 |
#'layout:' #(#LayoutFrame 120 0 50 0 289 0 69 0)
|
|
123 |
#'isOpaque:' true
|
|
124 |
#'initiallyDisabled:' false
|
|
125 |
#'initiallyInvisible:' false
|
|
126 |
#'model:' #classNameChannel
|
|
127 |
#'isReadOnly:' false
|
|
128 |
#'tabable:' true
|
|
129 |
#'immediateAccept:' false
|
|
130 |
#'acceptOnLeave:' true
|
|
131 |
#'acceptOnReturn:' true
|
|
132 |
#'acceptOnTab:' true
|
|
133 |
#'acceptOnLostFocus:' true
|
|
134 |
#'hasBorder:' false
|
|
135 |
)
|
|
136 |
#(#InputFieldSpec
|
|
137 |
#'name:' 'superclassNameField'
|
|
138 |
#'layout:' #(#LayoutFrame 120 0 90 0 289 0 109 0)
|
|
139 |
#'isOpaque:' true
|
|
140 |
#'initiallyDisabled:' false
|
|
141 |
#'initiallyInvisible:' false
|
|
142 |
#'model:' #superclassNameChannel
|
|
143 |
#'isReadOnly:' false
|
|
144 |
#'tabable:' true
|
|
145 |
#'immediateAccept:' false
|
|
146 |
#'acceptOnLeave:' true
|
|
147 |
#'acceptOnReturn:' true
|
|
148 |
#'acceptOnTab:' true
|
|
149 |
#'acceptOnLostFocus:' true
|
|
150 |
#'hasBorder:' false
|
|
151 |
)
|
|
152 |
#(#InputFieldSpec
|
|
153 |
#'name:' 'methodNameField'
|
|
154 |
#'layout:' #(#LayoutFrame 120 0 130 0 289 0 149 0)
|
|
155 |
#'isOpaque:' true
|
|
156 |
#'initiallyDisabled:' false
|
|
157 |
#'initiallyInvisible:' false
|
|
158 |
#'model:' #methodNameChannel
|
|
159 |
#'isReadOnly:' false
|
|
160 |
#'tabable:' true
|
|
161 |
#'immediateAccept:' false
|
|
162 |
#'acceptOnLeave:' true
|
|
163 |
#'acceptOnReturn:' true
|
|
164 |
#'acceptOnTab:' true
|
|
165 |
#'acceptOnLostFocus:' true
|
|
166 |
#'hasBorder:' false
|
|
167 |
)
|
|
168 |
#(#ActionButtonSpec
|
|
169 |
#'name:' 'button1'
|
|
170 |
#'layout:' #(#LayoutFrame 30 0 250 0 129 0 279 0)
|
|
171 |
#'isOpaque:' true
|
|
172 |
#'label:' 'cancel'
|
|
173 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
174 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
175 |
#'initiallyInvisible:' false
|
|
176 |
#'tabable:' true
|
|
177 |
#'isDefault:' false
|
|
178 |
#'defaultable:' false
|
|
179 |
#'model:' #cancel
|
|
180 |
#'hasCharacterOrientedLabel:' true
|
|
181 |
#'isDecorated:' false
|
|
182 |
#'initiallyDisabled:' false
|
|
183 |
)
|
|
184 |
#(#ActionButtonSpec
|
|
185 |
#'name:' 'button2'
|
|
186 |
#'layout:' #(#LayoutFrame 160 0 250 0 259 0 279 0)
|
|
187 |
#'isOpaque:' true
|
|
188 |
#'label:' 'ok'
|
|
189 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
190 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
191 |
#'initiallyInvisible:' false
|
|
192 |
#'tabable:' true
|
|
193 |
#'isDefault:' true
|
|
194 |
#'defaultable:' false
|
|
195 |
#'model:' #accept
|
|
196 |
#'hasCharacterOrientedLabel:' true
|
|
197 |
#'isDecorated:' false
|
|
198 |
#'initiallyDisabled:' false
|
|
199 |
)
|
|
200 |
#(#LabelSpec
|
|
201 |
#'name:' 'boxLabel'
|
|
202 |
#'layout:' #(#LayoutOrigin 78 0 11 0)
|
|
203 |
#'isOpaque:' true
|
|
204 |
#'label:' 'class & selector for code'
|
|
205 |
#'foregroundColor:' #(#Color 0.0 0.0 0.0)
|
|
206 |
#'backgroundColor:' #(#Color 66.9993 66.9993 66.9993)
|
|
207 |
#'initiallyInvisible:' false
|
|
208 |
#'level:' 0
|
|
209 |
#'adjust:' #center
|
|
210 |
#'hasCharacterOrientedLabel:' true
|
|
211 |
)
|
|
212 |
)
|
|
213 |
)
|
|
214 |
)
|
|
215 |
! !
|
|
216 |
|
|
217 |
!UIPainter methodsFor:'BuilderView interface'!
|
|
218 |
|
61
|
219 |
update:what
|
60
|
220 |
|
|
221 |
elementMenu deselect.
|
61
|
222 |
treeView builderViewChanged:what.
|
|
223 |
propertyView builderViewChanged:what.
|
60
|
224 |
! !
|
|
225 |
|
|
226 |
!UIPainter methodsFor:'aspects'!
|
|
227 |
|
|
228 |
aspectFor:aKey
|
|
229 |
^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
|
|
230 |
|
|
231 |
! !
|
|
232 |
|
|
233 |
!UIPainter methodsFor:'filein & fileout'!
|
|
234 |
|
|
235 |
openFile:aFileName
|
|
236 |
|aStream |
|
|
237 |
|
|
238 |
aStream := FileStream readonlyFileNamed:aFileName.
|
|
239 |
|
|
240 |
aStream notNil ifTrue:[
|
|
241 |
workView fileInContentsFrom:aStream.
|
|
242 |
aStream close.
|
|
243 |
fileName := aFileName
|
|
244 |
]
|
|
245 |
|
|
246 |
!
|
|
247 |
|
|
248 |
saveAs:aFileName
|
|
249 |
|aStream|
|
|
250 |
|
|
251 |
aStream := FileStream newFileNamed:aFileName.
|
|
252 |
|
|
253 |
aStream notNil ifTrue:[
|
|
254 |
workView storeContentsOn:aStream.
|
|
255 |
aStream close.
|
|
256 |
fileName := aFileName
|
|
257 |
].
|
|
258 |
|
|
259 |
! !
|
|
260 |
|
|
261 |
!UIPainter methodsFor:'help'!
|
|
262 |
|
|
263 |
helpTextFor:aComponent
|
|
264 |
|sel|
|
|
265 |
|
|
266 |
(aComponent isKindOf:Button) ifTrue:[
|
|
267 |
(sel := aComponent changeMessage) notNil ifTrue:[
|
|
268 |
"/ take the buttons change symbol as resource-key
|
|
269 |
^ resources string:(sel asString)
|
|
270 |
]
|
|
271 |
].
|
|
272 |
^ nil
|
|
273 |
|
|
274 |
"Modified: 31.8.1995 / 20:49:58 / claus"
|
|
275 |
! !
|
|
276 |
|
|
277 |
!UIPainter methodsFor:'initialization'!
|
|
278 |
|
|
279 |
createCanvas
|
|
280 |
|topView|
|
|
281 |
|
|
282 |
super initialize.
|
|
283 |
|
|
284 |
topView := StandardSystemView new.
|
|
285 |
topView label:'unnamed'.
|
|
286 |
topView extent:300@300.
|
|
287 |
topView application:self.
|
|
288 |
|
|
289 |
workView := UIPainterView in:topView.
|
|
290 |
workView layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
|
|
291 |
|
|
292 |
^ workView.
|
|
293 |
|
|
294 |
"Builder new createCanvas open"
|
|
295 |
!
|
|
296 |
|
|
297 |
initChannels
|
|
298 |
|cls|
|
|
299 |
|
|
300 |
aspects := IdentityDictionary new.
|
|
301 |
|
|
302 |
aspects at:#classNameChannel put:(
|
|
303 |
(specClass notNil ifTrue:[specClass]
|
|
304 |
ifFalse:['NewApplication']) asValue
|
|
305 |
).
|
|
306 |
specSuperclass isNil ifTrue:[
|
|
307 |
specClass notNil ifTrue:[
|
|
308 |
(cls := Smalltalk at:specClass asSymbol) notNil ifTrue:[
|
|
309 |
specSuperclass := cls superclass name.
|
|
310 |
]
|
|
311 |
]
|
|
312 |
].
|
|
313 |
aspects at:#superclassNameChannel put:(
|
|
314 |
(specSuperclass notNil ifTrue:[specSuperclass]
|
|
315 |
ifFalse:['ApplicationModel']) asValue
|
|
316 |
).
|
|
317 |
aspects at:#methodNameChannel put:(
|
|
318 |
(specSelector notNil ifTrue:[specSelector]
|
|
319 |
ifFalse:[#windowSpec]) asValue
|
|
320 |
).
|
|
321 |
!
|
|
322 |
|
|
323 |
initPullDownMenu:aMenu
|
|
324 |
aMenu labels:(resources array:#(
|
|
325 |
'file'
|
|
326 |
'font'
|
|
327 |
'type'
|
|
328 |
'align'
|
|
329 |
'dimension'
|
|
330 |
'special'
|
|
331 |
'misc'
|
|
332 |
'code'
|
|
333 |
'test'
|
|
334 |
)).
|
|
335 |
|
|
336 |
aMenu selectors:#(#file
|
|
337 |
#font
|
|
338 |
#type
|
|
339 |
#align
|
|
340 |
#dimension
|
|
341 |
#special
|
|
342 |
#misc
|
|
343 |
#code
|
|
344 |
#test
|
|
345 |
).
|
|
346 |
|
|
347 |
aMenu at:#file
|
|
348 |
putLabels:(resources array:
|
|
349 |
#('new'
|
|
350 |
'from class ...'
|
|
351 |
'pick a view '
|
|
352 |
'-'
|
|
353 |
'load'
|
|
354 |
'save'
|
|
355 |
'save as ...'
|
|
356 |
'-'
|
|
357 |
'install spec'
|
|
358 |
'install aspects'
|
|
359 |
'-'
|
|
360 |
"/ 'source'
|
|
361 |
'windowSpec'
|
|
362 |
'inspect me'
|
|
363 |
'raise'
|
|
364 |
'-'
|
|
365 |
'print'
|
|
366 |
'-'
|
|
367 |
'quit'
|
|
368 |
))
|
|
369 |
selectors:#(doNew
|
|
370 |
doFromClass
|
|
371 |
doPickAView
|
|
372 |
nil
|
|
373 |
doOpen
|
|
374 |
doSave
|
|
375 |
doSaveAs
|
|
376 |
nil
|
|
377 |
doInstallSpec
|
|
378 |
doInstallAspects
|
|
379 |
nil
|
|
380 |
"/ doSource
|
|
381 |
doWindowSpec
|
|
382 |
inspect
|
|
383 |
doRaise
|
|
384 |
nil
|
|
385 |
doPrint
|
|
386 |
nil
|
|
387 |
doFinish
|
|
388 |
)
|
|
389 |
receiver:self.
|
|
390 |
|
|
391 |
aMenu at:#font putMenu:(workView subMenuFont menuView).
|
|
392 |
|
|
393 |
aMenu at:#type
|
|
394 |
putLabels:(resources array:#(
|
|
395 |
'basic widgets'
|
|
396 |
'layout'
|
|
397 |
'text'
|
|
398 |
'interactors'
|
|
399 |
'modal'
|
|
400 |
'other'
|
|
401 |
'-'
|
|
402 |
'all'
|
|
403 |
) )
|
|
404 |
selectors:#(showBasicWidgets
|
|
405 |
showLayoutWidgets
|
|
406 |
showTextWidgets
|
|
407 |
showInteractorWidgets
|
|
408 |
showModalWidgets
|
|
409 |
showOtherWidgets
|
|
410 |
nil
|
|
411 |
showAllWidgets
|
|
412 |
)
|
|
413 |
receiver:self.
|
|
414 |
|
|
415 |
aMenu at:#align putMenu:(workView subMenuAlign menuView).
|
|
416 |
aMenu at:#dimension putMenu:(workView subMenuDimension menuView).
|
|
417 |
|
|
418 |
aMenu at:#special
|
|
419 |
putLabels:(resources array:#(
|
|
420 |
'group radioButtons'
|
|
421 |
'group enterFields'
|
|
422 |
) )
|
|
423 |
selectors:#(
|
|
424 |
groupRadioButtons
|
|
425 |
groupEnterFields
|
|
426 |
)
|
|
427 |
receiver:workView.
|
|
428 |
|
|
429 |
aMenu at:#code
|
|
430 |
putLabels:(resources array:#(
|
|
431 |
'class & method'
|
|
432 |
) )
|
|
433 |
selectors:#(
|
|
434 |
defineClassAndSelector
|
|
435 |
)
|
|
436 |
receiver:self.
|
|
437 |
|
|
438 |
aMenu at:#misc putMenu:(self menuMisc).
|
|
439 |
|
|
440 |
aMenu at:#test
|
|
441 |
putLabels:(resources array:#(
|
|
442 |
'\c test mode'
|
|
443 |
) )
|
|
444 |
selectors:#(doToggleTest
|
|
445 |
)
|
|
446 |
receiver:self.
|
|
447 |
|
|
448 |
(aMenu menuAt:#test) checkToggleAt:#doToggleTest put:(workView testMode).
|
|
449 |
!
|
|
450 |
|
|
451 |
openInterface
|
|
452 |
|inset panel menu|
|
|
453 |
|
|
454 |
self initChannels.
|
|
455 |
workView := self createCanvas.
|
|
456 |
|
|
457 |
topView := StandardSystemView new.
|
|
458 |
topView label:'Interface Builder'.
|
|
459 |
topView icon:(Image fromFile:'bitmaps/Builder.xbm' resolution:100).
|
|
460 |
topView extent:(600 @ 400).
|
|
461 |
|
|
462 |
menu := PullDownMenu in:topView.
|
|
463 |
panel := ButtonPanel in:topView.
|
|
464 |
inset := menu preferredExtent y + panel preferredExtent y.
|
|
465 |
|
|
466 |
panel origin:0.0@(menu preferredExtent y) corner:1.0@inset .
|
|
467 |
panel receiver:workView.
|
|
468 |
|
|
469 |
elementMenu := HVScrollableView for:SelectionInListView miniScrollerH:true in:topView.
|
|
470 |
elementMenu origin:0.0@0.0 corner:0.3 @ 1.0.
|
|
471 |
elementMenu topInset:inset .
|
|
472 |
elementMenu := elementMenu scrolledView.
|
|
473 |
|
|
474 |
elementMenu action:[:selection |
|
|
475 |
workView testMode ifTrue:[
|
|
476 |
elementMenu deselect
|
|
477 |
] ifFalse:[
|
|
478 |
selection notNil ifTrue:[
|
|
479 |
workView createWidgetWithClass:
|
|
480 |
(Smalltalk at:(elementMenu selectionValue asSymbol))
|
|
481 |
]
|
|
482 |
]
|
|
483 |
].
|
|
484 |
|
|
485 |
treeView := HVScrollableView for:UIPainterTreeView miniScrollerH:true in:topView.
|
|
486 |
treeView origin:0.3 @ 0.0 corner:0.6@1.0.
|
|
487 |
treeView topInset:inset .
|
|
488 |
treeView := treeView scrolledView.
|
|
489 |
treeView builderView:workView.
|
|
490 |
|
|
491 |
propertyView := View origin:(0.6 @ 0.0) corner:1.0@1.0 in:topView.
|
|
492 |
propertyView topInset:inset .
|
61
|
493 |
propertyView := UIPropertyView in:propertyView builder:workView.
|
60
|
494 |
|
|
495 |
workView addDependent:self.
|
|
496 |
self initPullDownMenu:menu.
|
|
497 |
topView application:self.
|
|
498 |
builder window:topView.
|
|
499 |
topView beMaster.
|
|
500 |
workView topView beSlave.
|
|
501 |
topView open.
|
|
502 |
workView topView openInGroup:(topView windowGroup).
|
77
|
503 |
|
60
|
504 |
!
|
|
505 |
|
|
506 |
openNewWindowCanvas
|
|
507 |
self open.
|
|
508 |
|
|
509 |
|
|
510 |
!
|
|
511 |
|
|
512 |
openOnClass:aClass andSelector:aSelector
|
|
513 |
"open up an interface builder, fetching a spec from someClass
|
|
514 |
via some selector"
|
|
515 |
|
|
516 |
|specArray|
|
|
517 |
|
|
518 |
specClass := aClass name.
|
|
519 |
specSuperclass := aClass superclass name.
|
|
520 |
specSelector := aSelector.
|
|
521 |
|
|
522 |
self openInterface.
|
|
523 |
workView className:aClass name.
|
|
524 |
workView methodName:aSelector.
|
|
525 |
workView setupFromSpec:(aClass perform:aSelector).
|
|
526 |
!
|
|
527 |
|
|
528 |
openOnSpec:aSpecOrSpecArray
|
|
529 |
"open up an interface builder, given some specArray"
|
|
530 |
|
|
531 |
|newBuilder|
|
|
532 |
|
|
533 |
newBuilder := self new.
|
|
534 |
! !
|
|
535 |
|
|
536 |
!UIPainter methodsFor:'menus'!
|
|
537 |
|
|
538 |
menuMisc
|
|
539 |
|
|
540 |
|menuView menuGrid menuUndo|
|
|
541 |
|
|
542 |
menuView := MenuView labels:
|
|
543 |
(resources array:#(
|
|
544 |
'grid'
|
|
545 |
'undo'
|
|
546 |
)
|
|
547 |
)
|
|
548 |
selectors:#(
|
|
549 |
#grid
|
|
550 |
#undo
|
|
551 |
)
|
|
552 |
receiver:self.
|
|
553 |
|
|
554 |
|
|
555 |
menuGrid := PopUpMenu labels:(
|
|
556 |
resources array:#(
|
|
557 |
'\c show'
|
|
558 |
'\c align'
|
|
559 |
)
|
|
560 |
)
|
|
561 |
selectors:#(
|
|
562 |
#gridShown:
|
|
563 |
#gridAlign:
|
|
564 |
)
|
|
565 |
receiver:workView.
|
|
566 |
|
|
567 |
menuGrid checkToggleAt:#gridShown: put:(workView gridShown).
|
|
568 |
menuGrid checkToggleAt:#gridAlign: put:(workView gridAlign).
|
|
569 |
menuView subMenuAt:#grid put:menuGrid.
|
|
570 |
|
|
571 |
menuUndo := PopUpMenu labels:(
|
|
572 |
resources array:#(
|
|
573 |
'last'
|
|
574 |
'menu'
|
|
575 |
'-'
|
|
576 |
'delete'
|
|
577 |
)
|
|
578 |
)
|
|
579 |
selectors:#(
|
|
580 |
#undoLast
|
|
581 |
#openUndoMenu
|
|
582 |
nil
|
|
583 |
#removeUndoHistory
|
|
584 |
)
|
|
585 |
receiver:workView.
|
|
586 |
|
|
587 |
menuView subMenuAt:#undo put:menuUndo.
|
|
588 |
^ menuView
|
|
589 |
! !
|
|
590 |
|
|
591 |
!UIPainter methodsFor:'setup choices'!
|
|
592 |
|
|
593 |
showAllWidgets
|
|
594 |
"create list of basic widgets"
|
|
595 |
|
|
596 |
self showWidgetsWhere:[:class | true]
|
|
597 |
!
|
|
598 |
|
|
599 |
showBasicWidgets
|
|
600 |
"create list of basic widgets"
|
|
601 |
|
|
602 |
self showWidgetsInCategory:'Views-Basic'
|
|
603 |
butNot:[:class | class isKindOf:ModalBox class]
|
|
604 |
!
|
|
605 |
|
|
606 |
showInteractorWidgets
|
|
607 |
"create list of interactor widgets"
|
|
608 |
|
|
609 |
self showWidgetsInCategory:'Views-Interactors'
|
|
610 |
butNot:[:class | class isKindOf:ModalBox class]
|
|
611 |
!
|
|
612 |
|
|
613 |
showLayoutWidgets
|
|
614 |
"create list of basic widgets"
|
|
615 |
|
|
616 |
self showWidgetsInCategory:'Views-Layout'
|
|
617 |
butNot:[:class | class isKindOf:ModalBox class]
|
|
618 |
!
|
|
619 |
|
|
620 |
showModalWidgets
|
|
621 |
"create list of modal widgets"
|
|
622 |
|
|
623 |
self showWidgetsWhere:[:class | class isKindOf:ModalBox class]
|
|
624 |
!
|
|
625 |
|
|
626 |
showOtherWidgets
|
|
627 |
"create list of other widgets"
|
|
628 |
|
|
629 |
|check cat|
|
|
630 |
|
|
631 |
check := [:class |
|
|
632 |
(#('Views-Basic'
|
|
633 |
'Views-Interactors'
|
|
634 |
'Views-Layout'
|
|
635 |
'Views-Text') includes:class category) not].
|
|
636 |
self showWidgetsWhere:check
|
|
637 |
butNot:[:class | class isKindOf:ModalBox class]
|
|
638 |
!
|
|
639 |
|
|
640 |
showTextWidgets
|
|
641 |
"create list of basic widgets"
|
|
642 |
|
|
643 |
self showWidgetsInCategory:'Views-Text'
|
|
644 |
butNot:[:class | class isKindOf:ModalBox class]
|
|
645 |
!
|
|
646 |
|
|
647 |
showWidgetsInCategory:aCategory
|
|
648 |
"create list of basic widgets"
|
|
649 |
|
|
650 |
self showWidgetsWhere:[:class | class category = aCategory]
|
|
651 |
!
|
|
652 |
|
|
653 |
showWidgetsInCategory:aCategory butNot:excludeBlock
|
|
654 |
"create list of basic widgets"
|
|
655 |
|
|
656 |
self showWidgetsWhere:[:class | class category = aCategory]
|
|
657 |
butNot:excludeBlock
|
|
658 |
!
|
|
659 |
|
|
660 |
showWidgetsWhere:aBlock
|
|
661 |
"create list of widgets where aBlock avaluates to true"
|
|
662 |
|
|
663 |
self showWidgetsWhere:aBlock butNot:[:class | false]
|
|
664 |
!
|
|
665 |
|
|
666 |
showWidgetsWhere:aBlock butNot:excludeBlock
|
|
667 |
"create list of widgets where aBlock evaluates to true and excludeBlock
|
|
668 |
evaluates to false"
|
|
669 |
|
|
670 |
|list|
|
|
671 |
|
|
672 |
list := OrderedCollection new:0.
|
|
673 |
SimpleView allSubclassesDo:[:aSubclass |
|
|
674 |
(aBlock value:aSubclass) ifTrue:[
|
|
675 |
(excludeBlock value:aSubclass) ifFalse:[
|
|
676 |
list add:(aSubclass name)
|
|
677 |
]
|
|
678 |
]
|
|
679 |
].
|
|
680 |
(aBlock value:View) ifTrue:[
|
|
681 |
(excludeBlock value:View) ifFalse:[
|
|
682 |
list add:'View'
|
|
683 |
]
|
|
684 |
].
|
|
685 |
(list size == 0) ifFalse:[
|
|
686 |
list sort
|
|
687 |
].
|
|
688 |
elementMenu list:list
|
|
689 |
! !
|
|
690 |
|
|
691 |
!UIPainter methodsFor:'user interaction'!
|
|
692 |
|
|
693 |
closeRequest
|
|
694 |
workView notNil ifTrue:[workView release. workView := nil].
|
|
695 |
super closeRequest
|
|
696 |
!
|
|
697 |
|
|
698 |
closeRequestFor:aTopView
|
|
699 |
aTopView == topView ifTrue:[
|
|
700 |
super closeRequestFor:aTopView
|
|
701 |
] ifFalse:[
|
|
702 |
topView device beep
|
|
703 |
]
|
|
704 |
! !
|
|
705 |
|
|
706 |
!UIPainter methodsFor:'user interaction - dialogs'!
|
|
707 |
|
|
708 |
checkClassAndSelector
|
|
709 |
"check for class & superclass"
|
|
710 |
|
|
711 |
|superclass cls|
|
|
712 |
|
|
713 |
specClass isNil ifTrue:[^ false].
|
|
714 |
|
|
715 |
specClass isBehavior ifFalse:[
|
|
716 |
cls := Smalltalk at:specClass asSymbol
|
|
717 |
] ifTrue:[
|
|
718 |
cls := specClass
|
|
719 |
].
|
|
720 |
cls isNil ifTrue:[
|
|
721 |
(superclass := Smalltalk at:specSuperclass asSymbol) isNil ifTrue:[
|
|
722 |
self warn:'no class named ' , specSuperclass , ' exists.'.
|
|
723 |
^ false.
|
|
724 |
].
|
|
725 |
(self confirm:'create ' , specClass , ' ?') ifTrue:[
|
|
726 |
superclass subclass:(specClass asSymbol)
|
|
727 |
instanceVariableNames:''
|
|
728 |
classVariableNames:''
|
|
729 |
poolDictionaries:''
|
|
730 |
category:'New-Applications'.
|
|
731 |
^ true.
|
|
732 |
].
|
|
733 |
^ false.
|
|
734 |
].
|
|
735 |
cls isBehavior ifFalse:[
|
|
736 |
self warn:'a global named ' , specClass , ' exists, but is no class.'.
|
|
737 |
^ false.
|
|
738 |
].
|
|
739 |
|
|
740 |
specSuperclass isBehavior ifFalse:[
|
|
741 |
superclass := Smalltalk at:specSuperclass asSymbol
|
|
742 |
] ifTrue:[
|
|
743 |
superclass := specSuperclass
|
|
744 |
].
|
|
745 |
specSuperclass notNil ifTrue:[
|
|
746 |
superclass isNil ifTrue:[
|
|
747 |
self warn:'no class named ' , specSuperclass , ' exists.'.
|
|
748 |
^ false.
|
|
749 |
].
|
|
750 |
|
|
751 |
(cls isSubclassOf:superclass) ifFalse:[
|
|
752 |
self warn:'a global named ' , specClass , ' exists, but is not a subclass of ' , superclass name , '.'.
|
|
753 |
^ false.
|
|
754 |
]
|
|
755 |
].
|
|
756 |
^ true
|
|
757 |
!
|
|
758 |
|
|
759 |
defineClassAndSelector
|
|
760 |
"launch a dialog to define class, superclass and method"
|
|
761 |
|
|
762 |
|again|
|
|
763 |
|
|
764 |
[
|
|
765 |
again := false.
|
|
766 |
(self openDialogInterface:#nameAndSelectorSpec) ifTrue:[
|
|
767 |
|
|
768 |
specClass := (self aspectFor:#classNameChannel) value.
|
|
769 |
specSelector := (self aspectFor:#methodNameChannel) value.
|
|
770 |
specSuperclass := (self aspectFor:#superclassNameChannel) value.
|
|
771 |
|
|
772 |
again := self checkClassAndSelector not.
|
|
773 |
again ifFalse:[
|
|
774 |
workView className:specClass superclassName:specSuperclass selector:specSelector.
|
|
775 |
].
|
|
776 |
]
|
|
777 |
] doWhile:[again]
|
|
778 |
|
|
779 |
! !
|
|
780 |
|
|
781 |
!UIPainter methodsFor:'user interaction - menu'!
|
|
782 |
|
|
783 |
doFinish
|
|
784 |
self closeRequest
|
|
785 |
!
|
|
786 |
|
|
787 |
doFromClass
|
|
788 |
|className methodName cls sel accepted failed spec s|
|
|
789 |
|
|
790 |
className := '' asValue.
|
|
791 |
methodName := '' asValue.
|
|
792 |
(s := workView className) notNil ifTrue:[
|
|
793 |
className value:s
|
|
794 |
].
|
|
795 |
(s := workView methodName) notNil ifTrue:[
|
|
796 |
methodName value:s
|
|
797 |
].
|
|
798 |
|
|
799 |
failed := false.
|
|
800 |
[
|
|
801 |
accepted :=
|
|
802 |
(DialogBox new
|
|
803 |
addTextLabel:'Classes name:';
|
|
804 |
addInputFieldOn:className;
|
|
805 |
addVerticalSpace;
|
|
806 |
addTextLabel:'methods name:';
|
|
807 |
addInputFieldOn:methodName;
|
|
808 |
addAbortButton;
|
|
809 |
addOkButton;
|
|
810 |
open
|
|
811 |
) accepted.
|
|
812 |
|
|
813 |
accepted ifTrue:[
|
|
814 |
cls := Smalltalk classNamed:className value.
|
|
815 |
cls isNil ifTrue:[
|
|
816 |
failed := true.
|
|
817 |
self warn:'no such class'.
|
|
818 |
] ifFalse:[
|
|
819 |
sel := methodName value asSymbol.
|
|
820 |
(cls respondsTo:sel ) ifFalse:[
|
|
821 |
failed := true.
|
|
822 |
self warn:'no such method'
|
|
823 |
] ifTrue:[
|
|
824 |
spec := cls perform:sel.
|
|
825 |
spec isArray ifFalse:[
|
|
826 |
failed := true.
|
|
827 |
self warn:'not a windowSpec method'
|
|
828 |
].
|
|
829 |
"/ ok, got it
|
|
830 |
workView className:className value.
|
|
831 |
workView methodName:methodName value.
|
|
832 |
workView setupFromSpec:spec.
|
|
833 |
^ self
|
|
834 |
]
|
|
835 |
]
|
|
836 |
]
|
|
837 |
] doWhile:[accepted and:[failed]].
|
|
838 |
|
|
839 |
"Modified: 5.9.1995 / 18:47:57 / claus"
|
|
840 |
!
|
|
841 |
|
|
842 |
doInstallAspects
|
|
843 |
|code|
|
|
844 |
|
|
845 |
(specClass isNil or:[specSelector isNil]) ifTrue:[
|
|
846 |
self defineClassAndSelector
|
|
847 |
].
|
|
848 |
|
|
849 |
self checkClassAndSelector ifFalse:[
|
|
850 |
^ self
|
|
851 |
].
|
|
852 |
|
|
853 |
workView className:specClass superclassName:specSuperclass selector:specSelector.
|
|
854 |
|
|
855 |
code := workView generateAspectMethods.
|
|
856 |
(ReadStream on:code) fileIn.
|
|
857 |
|
|
858 |
"Modified: 4.9.1995 / 17:06:10 / claus"
|
|
859 |
!
|
|
860 |
|
|
861 |
doInstallSpec
|
|
862 |
|code|
|
|
863 |
|
|
864 |
(specClass isNil or:[specSelector isNil]) ifTrue:[
|
|
865 |
self defineClassAndSelector
|
|
866 |
].
|
|
867 |
|
|
868 |
self checkClassAndSelector ifFalse:[
|
|
869 |
^ self
|
|
870 |
].
|
|
871 |
|
|
872 |
workView className:specClass superclassName:specSuperclass selector:specSelector.
|
|
873 |
|
|
874 |
code := workView generateCode.
|
|
875 |
(ReadStream on:code) fileIn.
|
|
876 |
|
|
877 |
"Modified: 4.9.1995 / 17:06:10 / claus"
|
|
878 |
!
|
|
879 |
|
|
880 |
doNew
|
|
881 |
workView removeAll.
|
|
882 |
!
|
|
883 |
|
|
884 |
doOpen
|
|
885 |
|box|
|
|
886 |
|
|
887 |
box := FileSelectionBox new.
|
|
888 |
box title:(resources string:'Which file ?').
|
|
889 |
box selectingDirectory:false.
|
|
890 |
box pattern:'*.*'.
|
|
891 |
box action:[:aFile| self openFile:aFile ].
|
|
892 |
box open
|
|
893 |
!
|
|
894 |
|
|
895 |
doPickAView
|
|
896 |
|view className methodName cls sel accepted spec s|
|
|
897 |
|
|
898 |
view := Display viewFromUser.
|
|
899 |
view isNil ifTrue:[^ self].
|
|
900 |
|
|
901 |
spec := UISpecification fromView:view topView.
|
|
902 |
|
|
903 |
"/ ok, got it
|
|
904 |
workView setupFromSpec:spec.
|
|
905 |
workView className:view class name.
|
|
906 |
workView methodName:#newSpec.
|
|
907 |
^ self
|
|
908 |
|
|
909 |
"Modified: 5.9.1995 / 23:25:53 / claus"
|
|
910 |
!
|
|
911 |
|
|
912 |
doPrint
|
|
913 |
^ self
|
|
914 |
!
|
|
915 |
|
|
916 |
doRaise
|
|
917 |
workView topView raise
|
|
918 |
!
|
|
919 |
|
|
920 |
doSave
|
|
921 |
fileName notNil ifTrue:[
|
|
922 |
self saveAs:fileName
|
|
923 |
] ifFalse:[
|
|
924 |
self doSaveAs
|
|
925 |
]
|
|
926 |
!
|
|
927 |
|
|
928 |
doSaveAs
|
|
929 |
|box|
|
|
930 |
|
|
931 |
box := FileSelectionBox new.
|
|
932 |
box title:(resources string:'Which file ?').
|
|
933 |
box selectingDirectory:false.
|
|
934 |
box pattern:'*.*'.
|
|
935 |
box action:[:aFile| self saveAs:aFile ].
|
|
936 |
box open
|
|
937 |
! !
|
|
938 |
|
|
939 |
!UIPainter ignoredMethodsFor:'user interaction - menu'!
|
|
940 |
|
|
941 |
doSource
|
|
942 |
|code v|
|
|
943 |
|
|
944 |
code := workView generateCode.
|
|
945 |
v := CodeView open.
|
|
946 |
v contents:code.
|
|
947 |
v label:(workView applicationName).
|
|
948 |
^ self
|
|
949 |
|
|
950 |
"Modified: 5.9.1995 / 21:02:05 / claus"
|
|
951 |
! !
|
|
952 |
|
|
953 |
!UIPainter methodsFor:'user interaction - menu'!
|
|
954 |
|
|
955 |
doToggleTest
|
|
956 |
workView testMode:(workView testMode not)
|
|
957 |
!
|
|
958 |
|
|
959 |
doWindowSpec
|
68
|
960 |
|code code2 v|
|
60
|
961 |
|
|
962 |
code := workView generateWindowSpecMethodSource.
|
68
|
963 |
"/ code2 := workView generateAspectMethods.
|
|
964 |
code2 notNil ifTrue:[
|
|
965 |
code := code , code2.
|
|
966 |
].
|
|
967 |
|
60
|
968 |
v := CodeView open.
|
|
969 |
v contents:code.
|
|
970 |
v label:'windowSpec'.
|
|
971 |
^ self
|
|
972 |
|
|
973 |
"Modified: 5.9.1995 / 21:04:14 / claus"
|
|
974 |
! !
|
|
975 |
|
|
976 |
!UIPainter::ButtonPanel class methodsFor:'documentation'!
|
|
977 |
|
|
978 |
version
|
|
979 |
^ '$Header$'
|
|
980 |
! !
|
|
981 |
|
58
|
982 |
!UIPainter::ButtonPanel methodsFor:'accessing'!
|
|
983 |
|
|
984 |
receiver
|
|
985 |
^ receiver
|
|
986 |
!
|
|
987 |
|
|
988 |
receiver:aReceiver
|
|
989 |
receiver := aReceiver
|
|
990 |
! !
|
|
991 |
|
|
992 |
!UIPainter::ButtonPanel methodsFor:'initialization'!
|
|
993 |
|
|
994 |
initialize
|
|
995 |
"initialize and setup buttons
|
|
996 |
"
|
|
997 |
super initialize.
|
|
998 |
|
|
999 |
self level:-1.
|
|
1000 |
self borderWidth:0.
|
|
1001 |
self horizontalLayout:#leftSpace.
|
|
1002 |
argumentToSelector := 1.
|
|
1003 |
|
|
1004 |
self specification do:[:anArray|
|
|
1005 |
|selector image button seperator|
|
|
1006 |
|
|
1007 |
selector := anArray at:1.
|
|
1008 |
|
|
1009 |
selector notNil ifTrue:[
|
|
1010 |
image := Image fromFile:( anArray at:2 ).
|
|
1011 |
button := Button label:image in:self.
|
|
1012 |
|
|
1013 |
selector last == $: ifFalse:[
|
|
1014 |
button action:[
|
|
1015 |
receiver notNil ifTrue:[
|
|
1016 |
receiver perform:selector
|
|
1017 |
]
|
|
1018 |
]
|
|
1019 |
] ifTrue:[
|
|
1020 |
button pressAction:[
|
|
1021 |
receiver notNil ifTrue:[
|
|
1022 |
receiver perform:selector with:argumentToSelector
|
72
|
1023 |
].
|
|
1024 |
receiver enableUndoHistory:false.
|
58
|
1025 |
].
|
72
|
1026 |
button releaseAction:[ receiver enableUndoHistory:true ].
|
58
|
1027 |
button autoRepeat:true.
|
|
1028 |
button menuHolder:self; menuMessage:#editMenu; menuPerformer:self.
|
|
1029 |
]
|
|
1030 |
] ifFalse:[
|
|
1031 |
seperator := View in:self.
|
|
1032 |
seperator extent:20@1.
|
|
1033 |
seperator borderWidth:0.
|
|
1034 |
]
|
|
1035 |
].
|
|
1036 |
|
|
1037 |
!
|
|
1038 |
|
|
1039 |
specification
|
|
1040 |
"return a spec for the buttons in the panel;
|
|
1041 |
entries consists of selector and bitmap-filename.
|
|
1042 |
nil selectors are taken as separators (see setupButtonPanel)"
|
|
1043 |
|
|
1044 |
^ #(
|
|
1045 |
#( alignSelectionLeft 'b_alignL.xbm' )
|
|
1046 |
#( alignSelectionRight 'b_alignR.xbm' )
|
|
1047 |
#( alignSelectionLeftAndRight 'b_alignLR.xbm' )
|
|
1048 |
#( nil )
|
|
1049 |
#( alignSelectionTop 'b_alignT.xbm' )
|
|
1050 |
#( alignSelectionBottom 'b_alignB.xbm' )
|
|
1051 |
#( alignSelectionTopAndBottom 'b_alignTB.xbm' )
|
|
1052 |
#( nil )
|
|
1053 |
#( alignSelectionCenterHor 'b_alignCH.xbm' )
|
|
1054 |
#( alignSelectionCenterVer 'b_alignCV.xbm' )
|
|
1055 |
#( nil )
|
|
1056 |
#( moveSelectionLeft: 'b_moveLeft.xbm' )
|
|
1057 |
#( moveSelectionRight: 'b_moveRight.xbm' )
|
|
1058 |
#( moveSelectionUp: 'b_moveUp.xbm' )
|
|
1059 |
#( moveSelectionDown: 'b_moveDown.xbm' )
|
|
1060 |
)
|
|
1061 |
|
|
1062 |
|
|
1063 |
! !
|
|
1064 |
|
|
1065 |
!UIPainter::ButtonPanel methodsFor:'menu'!
|
|
1066 |
|
|
1067 |
editMenu
|
|
1068 |
"edit menu used by buttons using an argument for the receiver; the argumentToSelector
|
|
1069 |
"
|
|
1070 |
|menu|
|
|
1071 |
|
|
1072 |
menu := PopUpMenu labels:#( '1' '2' '4' '10' '20' '..' )
|
|
1073 |
args:#( 1 2 4 10 20 nil ).
|
|
1074 |
|
|
1075 |
menu action:[:anArg||no|
|
|
1076 |
(no := anArg) isNil ifTrue:[
|
|
1077 |
no := EnterBox request:'number'.
|
|
1078 |
no := SmallInteger readFrom:no onError:0.
|
|
1079 |
].
|
|
1080 |
no ~~ 0 ifTrue:[
|
|
1081 |
|index view|
|
|
1082 |
|
|
1083 |
view := (WindowGroup lastEventQuerySignal raise) view.
|
|
1084 |
view := view menuPerformer.
|
|
1085 |
argumentToSelector := no.
|
|
1086 |
view pressAction value.
|
|
1087 |
argumentToSelector := 1.
|
|
1088 |
]
|
|
1089 |
].
|
|
1090 |
^ menu
|
|
1091 |
! !
|
|
1092 |
|
60
|
1093 |
!UIPainter class methodsFor:'documentation'!
|
|
1094 |
|
|
1095 |
version
|
|
1096 |
^ '$Header$'
|
|
1097 |
! !
|