forked from Jariel208/Scratch-Archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlock Element Editor.txt
5363 lines (4238 loc) · 164 KB
/
Block Element Editor.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 11 July 2015 at 9:11:30 am'!
"Change Set: Jens Elements
Date: 13 February 2009
Author: Jens Moenig
a graphical Smalltalk"!
Morph subclass: #ClassChooserMorph
instanceVariableNames: 'class label button frame '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
Morph subclass: #ElementPaletteMorph
instanceVariableNames: 'elements variables '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
ElementPaletteMorph class
instanceVariableNames: ''!
Morph subclass: #ElementsButtonMorph
instanceVariableNames: 'target selector '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
Morph subclass: #ElementsMethodEditorMorph
instanceVariableNames: 'classChooser methodChooser sideChooser palette editor saver methodModified fillScreenOn currentMethod currentClass '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
Morph subclass: #ElementsPaletteFrameMorph
instanceVariableNames: 'header palette editorFrame currentClass '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
BorderedMorph subclass: #ElementsScrollFrameMorph
instanceVariableNames: 'contents hScrollbar vScrollbar cornerMorph hbarInset vbarInset contentsChanged growthFraction '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
!ElementsScrollFrameMorph commentStamp: '<historical>' prior: 0!
I have largely been copied from the Scratch-UI which was originally written by John Maloney and Evelyn Eastmond!
ElementsButtonMorph subclass: #ElementsToggleButtonMorph
instanceVariableNames: 'onColor offColor label on specialEffect '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
ElementsToggleButtonMorph subclass: #ElementsDoubleToggleMorph
instanceVariableNames: 'chooser '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
Morph subclass: #InstanceClassSwitchMorph
instanceVariableNames: 'instance class choice frame '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
ClassChooserMorph subclass: #MethodChooserMorph
instanceVariableNames: 'selector '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
Morph subclass: #PaletteFrameHeadMorph
instanceVariableNames: 'classChooser basics variables classes messages choice lastMsgChoice frame methodsClass '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
StringMorph subclass: #StringElementMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
Morph subclass: #SyntaxElementMorph
instanceVariableNames: 'label name '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
SyntaxElementMorph subclass: #ArgumentElementMorph
instanceVariableNames: 'contents oldColor '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
SyntaxElementMorph subclass: #BlockElementMorph
instanceVariableNames: 'palette steps '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
SyntaxElementMorph subclass: #LiteralElementMorph
instanceVariableNames: 'textBox contents '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
SyntaxElementMorph subclass: #MessageElementMorph
instanceVariableNames: 'receiver selector arguments labels cascade '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
BlockElementMorph subclass: #MethodElementMorph
instanceVariableNames: 'header '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
SyntaxElementMorph subclass: #ObjectElementMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
SyntaxElementMorph subclass: #PaletteElementMorph
instanceVariableNames: 'variables '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
PaletteElementMorph subclass: #MessageHeaderElementMorph
instanceVariableNames: 'selector labels arguments '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
SyntaxElementMorph subclass: #StepElementMorph
instanceVariableNames: 'expression next oldColor '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
StepElementMorph subclass: #PrimitiveElementMorph
instanceVariableNames: 'textBox '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
StepElementMorph subclass: #ReturnElementMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
ArgumentElementMorph subclass: #StepHolderElementMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
SyntaxElementMorph class
instanceVariableNames: ''!
MessageElementMorph class
instanceVariableNames: ''!
ArgumentElementMorph subclass: #TextBoxElementMorph
instanceVariableNames: 'doResizing insetX heightPadding stringMorph insetY selectionColor selectionEnd selectionStart undoState blinkState lastContents isKeyboardFocus acceptWhenFocusLost frame isNumeric client dragStartIndex isEditable '
classVariableNames: ''
poolDictionaries: ''
category: 'Elements'!
ElementsButtonMorph subclass: #TriangleButtonMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Elements-UI'!
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 21:58'!
chooseClass
|menu list packages pkg pkgMenu catMenu |
packages _ Dictionary new.
SystemOrganization categories asSortedCollection do: [:cat |
pkg _ (cat asString findTokens: #( $- )) first.
(packages includesKey: pkg)
ifFalse: [ packages at: pkg put: OrderedCollection new].
(packages at: pkg) add: cat].
menu _ MenuMorph new.
packages keys asSortedCollection do: [:eachPkg |
pkgMenu _ MenuMorph new.
(packages at: eachPkg) asSortedCollection do: [: cat |
catMenu _ self menuForCategory: cat.
pkgMenu add: (self wordsFrom: cat asString)
subMenu: catMenu ].
"pkgMenu add: (self wordsFrom: eachPkg asString)
subMenu: pkgMenu."
menu add: eachPkg subMenu: pkgMenu ].
"
list _ SystemOrganization categories asSortedCollection.
list do: [:each|
menu add: (self wordsFrom: each asString) subMenu: (self menuForCategory: each)].
"
menu popUpAt: button center x @ (self bottom + 5) forHand: World activeHand! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/6/2009 12:30'!
class: aClass
| classToSet |
classToSet _ aClass.
frame ifNotNil: [
(frame currentSide = #class)
& (aClass isKindOf: Metaclass) not
ifTrue: [ classToSet _ aClass class ]].
class = classToSet ifTrue: [^self].
class _ classToSet.
label ifNil: [
label _ StringMorph contents: '' font: self labelFont.
label color: self labelColor.
self addMorphFront: label ].
label contents: (self wordsFrom: class name asString).
self fitMorphs.
frame ifNotNil: [
frame selectClass: class]! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 23:21'!
fitMorphs
button extent: (label height @ label height) * 2//3.
button position: self left @ self top + (label height - button height // 2).
label position: (button right + (button width // 3)) @ self top.
self extent: label bottomRight - self position! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 22:06'!
frame: aMorph
frame _ aMorph! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 01:34'!
handlesMouseDown: evt
^ true
! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 23:20'!
initialize
super initialize.
self color: Color gray.
self addMorph: (button _ TriangleButtonMorph new
target: self;
selector: #chooseClass)
! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 22:46'!
labelColor
^Color white! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 01:23'!
labelFont
^StrikeFont fontName: 'VerdanaBold' size: 12! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 22:41'!
menuForCategory: categoryName
|menu list |
menu _ MenuMorph new
defaultTarget: self.
list _ SystemOrganization listAtCategoryNamed: categoryName.
list asSortedCollection do: [:each|
menu add: (self wordsFrom: each asString) selector: #class: argument: (Smalltalk classNamed: each)].
^menu
! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 01:35'!
mouseDown: evt
self chooseClass! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/4/2009 08:33'!
selectedClass
^class! !
!ClassChooserMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 22:09'!
wordsFrom: camelCase
^SyntaxElementMorph wordsFrom: camelCase
! !
!ElementPaletteMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/2/2009 22:20'!
addElement: anElement
|maxWidth|
self addMorph: anElement.
elements isEmpty
ifTrue:[ anElement position: self position + (2@2)]
ifFalse: [ anElement position: self position + (2@(elements last bottom + 2)) ].
elements add: anElement.
self height: (elements last bottom + 2) - (self top).
maxWidth _ elements last width + 4.
elements do: [:element|
maxWidth _ (element width + 4) max: maxWidth ].
self width: maxWidth! !
!ElementPaletteMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 22:44'!
initialize
super initialize.
elements _ OrderedCollection new.
color _ Color gray.! !
!ElementPaletteMorph methodsFor: 'as yet unclassified' stamp: 'jens 1/12/2009 22:50'!
isPartsBin
^ true
! !
!ElementPaletteMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 20:46'!
rootForGrabOf: aMorph
"I act like a parts bin; answer a new copy of the morph being extracted."
| v |
v _ aMorph ownerThatIsA: SyntaxElementMorph.
v ifNotNil: [
(v isKindOf: ArgumentElementMorph)
ifTrue: [^v owner fullCopy].
^v fullCopy].
^nil! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 6/2/2009 22:31'!
basics
^self new
addElement: StepElementMorph new;
addElement: ReturnElementMorph new;
addElement: PrimitiveElementMorph new;
addElement: BlockElementMorph new;
addElement: (ObjectElementMorph new label: 'self');
addElement: (ObjectElementMorph new label: 'super');
addElement: (ObjectElementMorph new label: 'true');
addElement: (ObjectElementMorph new label: 'false');
" addElement: (ObjectElementMorph new label: 'thisContext');"
addElement: (LiteralElementMorph new);
" addElement: (MessageElementMorph new selector: #new);"
addElement: MessageElementMorph new assign;
addElement: MessageElementMorph new yesNo
! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 6/2/2009 22:55'!
classVarsFor: aClass
| pal |
pal _ self new.
aClass classVarNames asSortedCollection do: [:vname|
pal addElement: (ObjectElementMorph new label: vname asString) ].
pal addElement: ((StringMorph contents: ' inherited:' font: self labelFont) color: self labelColor).
(aClass allClassVarNames reject: [:iv | aClass classVarNames includes: iv]) asSortedCollection do: [:vname|
pal addElement: (ObjectElementMorph new label: vname asString) ].
^pal
! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 2/2/2009 22:42'!
classes
| pal |
pal _ self new.
Smalltalk classNames asSortedCollection do: [:class|
pal addElement: (ObjectElementMorph new label: class asString) ].
^pal
! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 00:20'!
currentPackageClasses: aClass
| pal packages pkg |
pkg _ ((SystemOrganization categoryOfElement: aClass name asSymbol) asString findTokens: #( $- )) first.
packages _ self packageClassesDict.
pal _ self new.
(packages at: pkg) asSortedCollection do: [:class|
pal addElement: (ObjectElementMorph new label: class asString) ].
^pal
! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 2/2/2009 22:41'!
globals
| pal |
pal _ self new.
(Smalltalk keys reject: [:key| Smalltalk classNames includes: key]) asSortedCollection do: [:global|
pal addElement: (ObjectElementMorph new label: global asString) ].
^pal
! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 6/2/2009 22:53'!
instVarsFor: aClass
| pal |
pal _ self new.
aClass instVarNames asSortedCollection do: [:vname|
pal addElement: (ObjectElementMorph new label: vname asString) ].
pal addElement: ((StringMorph contents: ' inherited:' font: self labelFont) color: self labelColor).
(aClass allInstVarNames reject: [:iv | aClass instVarNames includes: iv]) asSortedCollection do: [:vname|
pal addElement: (ObjectElementMorph new label: vname asString) ].
^pal
! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 01:24'!
labelColor
^Color darkGray twiceDarker! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 01:32'!
labelFont
^StrikeFont fontName: 'Verdana' size: 9! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 6/2/2009 22:51'!
messagesFor: aClass
| pal me |
pal _ self new.
pal addElement: ((StringMorph contents: (SyntaxElementMorph wordsFrom: aClass name asString) font: self labelFont) color: self labelColor).
aClass selectors asSortedCollection do: [:selector|
me _ MessageElementMorph new selector: selector.
((selector asString includes: ($:)) not and: [
(aClass lookupSelector: selector) numArgs > 0])
ifTrue: [me beBinary].
pal addElement: me ].
pal addElement: ((StringMorph contents: ' inherited:' font: self labelFont) color: self labelColor).
(aClass allSelectors reject:[:sel| aClass selectors includes: sel ]) asSortedCollection do: [:selector|
me _ MessageElementMorph new selector: selector.
((selector asString includes: ($:)) not and: [
(aClass lookupSelector: selector) numArgs > 0])
ifTrue: [me beBinary].
pal addElement: me ].
^pal
! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 00:16'!
messagesForSelf: aClass
| pal me|
pal _ self new.
aClass allSelectors asSortedCollection do: [:selector|
me _ MessageElementMorph new selector: selector.
((selector asString includes: ($:)) not and: [
(aClass lookupSelector: selector) numArgs > 0])
ifTrue: [me beBinary].
me receiver: (ObjectElementMorph new label: 'self').
pal addElement: me ].
^pal
! !
!ElementPaletteMorph class methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 00:10'!
packageClassesDict
| packages pkg ans |
packages _ Dictionary new.
ans _ Dictionary new.
SystemOrganization categories asSortedCollection do: [:cat |
pkg _ (cat asString findTokens: #( $- )) first.
(packages includesKey: pkg) ifFalse: [
packages at: pkg put: OrderedCollection new.
ans at: pkg put: OrderedCollection new].
(packages at: pkg) add: cat].
packages keys do: [:eachPkg |
(packages at: eachPkg) do: [: cat |
(ans at: eachPkg) addAll: (SystemOrganization listAtCategoryNamed: cat) ]].
^ans! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 23:07'!
borderColorDark
^color twiceDarker! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 23:07'!
borderColorLight
^color twiceLighter lighter! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 23:07'!
borderColorVeryDark
^color twiceDarker darker! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 23:07'!
borderColorVeryLight
^color twiceLighter twiceLighter lighter! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 23:06'!
borderWidth
^1
! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 20:55'!
handlesMouseDown: evt
^ true
! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 23:46'!
labelColor
^Color white! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 23:46'!
labelFont
^StrikeFont fontName: 'VerdanaBold' size: 12! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 20:59'!
mouseDown: evt
target perform: selector! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 20:58'!
selector: aSelector
selector _ aSelector! !
!ElementsButtonMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/3/2009 20:58'!
target: anObject
target _ anObject! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'EMP 7/11/2015 09:06'!
about
self inform: '- Elements -
a graphical Smalltalk
------------------------------
experimental release of Aug. 24 2009
written by Jens Mönig ([email protected])
ported by Edward P. ([email protected])
all rights reserved
inspired by Scratch from the MIT Media Lab
and based in part on the Scratch Source Code.
Implemented in Squeak and in itself.'! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/24/2009 23:05'!
arrangeElements
| current x y spacing |
spacing _ 5.
current _ self currentMethodElement.
x _ editor contents left + spacing.
y _ current stackBottom + spacing.
editor contents submorphsDo: [:element |
(element == current) ifFalse:[
element position: x @ y.
y _ element bottom + spacing ]]
! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 15:47'!
arrangePanes
classChooser position: self topLeft + 2.
sideChooser position: classChooser bottomLeft.
methodChooser position: sideChooser bottomLeft.
editor position: (self left + 4) @ (methodChooser bottom + 4);
extent: (self width - 180 - 8) @ (self bottom - editor top - 4).
palette position: editor right @ (classChooser bottom);
height: self bottom - palette top - 4;
arrangePanes.
saver position: (self position x + (palette left - methodChooser right - saver width // 2) ) @ (methodChooser bottom - saver height)
! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/24/2009 22:36'!
buildPanes
| p m |
classChooser _ ClassChooserMorph new frame: self; class: Object.
sideChooser _ InstanceClassSwitchMorph new frame: self.
methodChooser _ MethodChooserMorph new frame: self; class: Object; selector: #yourself.
editor _ ElementsScrollFrameMorph new
color: Color gray;
borderColor: Color gray.
p _ PasteUpMorph new borderWidth: 0; color: Color gray darker.
m _ MethodElementMorph new selector: '' arguments: #().
editor contents: p.
p addMorph: m.
palette _ ElementsPaletteFrameMorph new editorFrame: self; height: self height; arrangePanes.
saver _ ElementsToggleButtonMorph new flat; label: 'save'; onColor: color offColor: color; target: self; selector: #saveCurrentMethod.
self
addMorph: classChooser;
addMorph: sideChooser;
addMorph: methodChooser;
addMorph: editor;
addMorph: palette;
addMorph: saver.
saver isHidden: true! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 8/24/2009 01:29'!
contextMenu
|m|
m _ CustomMenu new.
m add: 'clean up' action: #arrangeElements.
"
m addLine.
fillScreenOn
ifTrue: [
m add: 'switch to development mode' action: #developmentMode.
]
ifFalse: [m add: 'switch to user mode' action: #userMode.
m add: 'save image in user mode' action: #saveImage ].
"
m addLine.
m add: 'about...' action: #about.
^m! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/6/2009 12:21'!
currentClass
^currentClass! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 22:24'!
currentMethodElement
^editor contents findA: MethodElementMorph
! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/6/2009 12:01'!
currentSide
sideChooser ifNil: [^#instance ].
^sideChooser choice! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 17:35'!
developmentMode
fillScreenOn _ false.
self
position: World topLeft;
extent: World extent - 50;
arrangePanes.
palette arrangePanes.
Preferences disable: #noviceMode.
Preferences enable: #warnIfNoSourcesFile.
Preferences enable: #warnIfNoChangesFile.
! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 17:28'!
handlesMouseDown: evt
"Return true if this morph wants to receive mouseDown events (i.e., mouseDown:, mouseMove:, mouseUp:). The default response is false; subclasses that implement mouse messages should override this to return true."
^ true
! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 02:44'!
initialize
fillScreenOn _ false.
methodModified _ false.
currentClass _ Object.
currentMethod _ #yourself.
super initialize.
self extent: 600 @ 400.
color _ Color gray.
self buildPanes.
self arrangePanes.
self refresh! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 17:29'!
invokeContextMenu
|m choice|
m _ self contextMenu.
m ifNotNil: [
choice _ m startUp.
choice ifNotNil: [self perform: choice] ]! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 13:22'!
maximize
((self position = World position) and: [
self extent = World extent])
ifTrue: [^self].
self
position: World topLeft;
extent: World extent;
arrangePanes.
palette arrangePanes.
self comeToFront
! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 15:48'!
methodModified
methodModified _ true.
saver isHidden: false.
saver position: (self position x + (palette left - methodChooser right - saver width // 2) ) @ (methodChooser bottom - saver height)! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/24/2009 22:47'!
methodTemplate
| m |
m _ MethodElementMorph new selector: '' arguments: #().
self currentMethodElement delete.
m position: editor contents position.
editor contents addMorph: m fitMethod.
self isInWorld ifFalse: [^self].
methodChooser selector: nil.
self methodUnmodified! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 02:32'!
methodUnmodified
methodModified _ false.
saver isHidden: true! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 10:46'!
mouseDown: evt
"Handle a mouse down event."
evt rightButtonPressed
ifTrue: [ ^self invokeContextMenu].
Preferences noviceMode ifTrue: [^self].
self startDrag: evt
! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 01:09'!
refresh
self methodTemplate! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/16/2009 23:58'!
saveCurrentMethod
| se sel|
se _ self currentMethodElement.
sel _ se selector.
currentClass compile: se asSmalltalk
classified: ClassOrganizer nullCategory
notifying: nil.
methodChooser selector: sel.
self selectMethod: sel.
palette refresh! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 01:07'!
saveImage
self userMode.
self maximize.
World allMorphsDo: [:m|
(m isKindOf: SystemWindow)
ifTrue: [m delete ]].
World activeHand saveAndQuit! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/7/2009 20:50'!
selectClass: aClass
editor ifNil: [^self].
(currentClass = aClass)
ifTrue: [^self].
currentClass _ aClass.
classChooser class: currentClass.
methodChooser class: currentClass.
palette class: currentClass.
self methodTemplate
! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/24/2009 21:28'!
selectMethod: aSelector
| myMethod temps se |
currentMethod _ aSelector.
editor ifNil: [^self].
currentMethod ifNil: [^self].
currentClass ifNotNil:
[myMethod _ currentClass compiledMethodAt: currentMethod ifAbsent: [^self methodTemplate].
temps _ (currentClass compilerClass new
parse: myMethod getSourceFromFile asString in: currentClass notifying: nil)
tempNames.
se _ ((currentClass decompilerClass new withTempNames: temps)
decompile: currentMethod in: currentClass method: myMethod) asSyntaxElement.
self currentMethodElement delete.
se position: editor contents position.
editor contents addMorph: se fitMethod.
^self methodUnmodified.
].
^self methodTemplate
! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 17:38'!
step
fillScreenOn
ifTrue: [self maximize]
ifFalse: [^self arrangePanes].! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 8/24/2009 20:10'!
stepTime
^0! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/6/2009 11:17'!
switchToClassSide
self selectClass: currentClass class! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/6/2009 11:17'!
switchToInstanceSide
self selectClass: currentClass allInstances first.! !
!ElementsMethodEditorMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 17:33'!
userMode
fillScreenOn _ true.
Preferences enable: #noviceMode.
Preferences disable: #warnIfNoSourcesFile.
Preferences disable: #warnIfNoChangesFile.
! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 20:30'!
acceptDroppingMorph: aMorph event: evt
"This message is sent when a morph is dropped onto a morph that has agreed to accept the dropped morph by responding 'true' to the wantsDroppedMorph:Event: message. This default implementation just adds the given morph to the receiver."
aMorph delete
! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/5/2009 20:14'!
arrangePanes
header position: self position;
width: self width;
arrangePanes.
palette position: self left @ header bottom;
extent: self width @ (self height - header height)! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 01:25'!
buildPanes
header _ PaletteFrameHeadMorph new frame: self.
palette _ ElementsScrollFrameMorph new
color: Color gray;
borderColor: Color gray.
self
addMorph: header;
addMorph: palette.! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/7/2009 22:06'!
class: aClass
currentClass _ aClass.
header adjustToClass: currentClass.
self refresh! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 21:17'!
classMenu
|menu|
menu _ MenuMorph new defaultTarget: self.
menu add: 'create a subclass...' action: #createSubclass.
menu add: 'remove a class...' action: #removeClass.
^menu! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 21:40'!
classVarMenu
|menu|
menu _ MenuMorph new defaultTarget: self.
menu add: 'add a class variable...' action: #createClassVar.
menu add: 'remove a variable...' action: #removeClassVar.
^menu! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/11/2009 02:41'!
contextMenu
| choice |
choice _ header choice.
(#basics = choice) ifTrue: [^nil ].
(#(allClasses #currentPackageClasses) includes: choice) ifTrue: [
^self classMenu].
(#variables = choice) ifTrue: [
(currentClass isMeta)
ifTrue: [ ^self classVarMenu]
ifFalse: [ ^self instanceVarMenu ]].
(#instanceVars = choice) ifTrue: [^self instanceVarMenu].
(#classVars = choice) ifTrue: [^self classVarMenu].
(#globalVars = choice) ifTrue: [ ^self globalVarMenu].
(#currentMessages = choice) ifTrue: [^self methodMenu].
(#methodsClass = choice) ifTrue: [^nil ].! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 21:41'!
createClassVar
|varName current|
currentClass isMeta
ifTrue: [current _ currentClass theNonMetaClass ]
ifFalse: [current _ currentClass ].
varName _ FillInTheBlank request: 'variable name:' initialAnswer: ''.
varName isEmpty ifTrue: [^self].
current addClassVarName: varName.
self refresh ! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/16/2009 21:07'!
createGlobalVar
|varName |
varName _ FillInTheBlank request: 'variable name:' initialAnswer: ''.
varName isEmpty ifTrue: [^self].
varName _ SyntaxElementMorph classNameFrom: varName.
(Smalltalk includesKey: varName asSymbol)
ifTrue: [^self inform: varName, ' is already in use'].
Smalltalk at: varName asSymbol put: nil.
self refresh ! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/16/2009 21:08'!
createInstVar
|varName current|
currentClass isMeta
ifTrue: [current _ currentClass theNonMetaClass ]
ifFalse: [current _ currentClass ].
varName _ FillInTheBlank request: 'variable name:' initialAnswer: ''.
varName isEmpty ifTrue: [^self].
varName _ SyntaxElementMorph objectNameFrom: varName.
current addInstVarName: varName.
self refresh ! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/16/2009 21:09'!
createSubclass
|className categoryName current newClass|
currentClass isMeta
ifTrue: [current _ currentClass theNonMetaClass ]
ifFalse: [current _ currentClass ].
className _ FillInTheBlank request: 'class name:' initialAnswer: ''.
className isEmpty ifTrue: [^self].
categoryName _ FillInTheBlank request: 'category:' initialAnswer: 'UserObjects'.
categoryName isEmpty ifTrue: [^self].
className _ SyntaxElementMorph classNameFrom: className.
newClass _ current subclass: className asSymbol
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: categoryName.
editorFrame selectClass: newClass
! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/7/2009 21:12'!
currentClass
^currentClass! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/16/2009 12:48'!
currentMethodsClass
| name |
name _ palette contents submorphs last contents.
(name endsWith: ' class') ifTrue: [
name _ (name reversed copyFrom: 6 to: name size) reversed.
name _ name reject: [:c| c = $ ].
^(Smalltalk at: name asSymbol) class ].
name _ name reject: [:c| c = $ ].
^Smalltalk at: name asSymbol! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/6/2009 13:42'!
editorFrame: aMorph
editorFrame _ aMorph! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 21:56'!
globalVarMenu
|menu|
menu _ MenuMorph new defaultTarget: self.
menu add: 'add a global variable...' action: #createGlobalVar.
menu add: 'remove a variable...' action: #removeGlobalVar.
^menu! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 19:50'!
handlesMouseDown: evt
"Return true if this morph wants to receive mouseDown events (i.e., mouseDown:, mouseMove:, mouseUp:). The default response is false; subclasses that implement mouse messages should override this to return true."
^ true! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/7/2009 20:42'!
initialize
super initialize.
currentClass _ Object.
self extent: 180 @ 400.
self buildPanes.
self arrangePanes.
self refresh! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 21:26'!
instanceVarMenu
|menu|
menu _ MenuMorph new defaultTarget: self.
menu add: 'add an instance variable...' action: #createInstVar.
menu add: 'remove a variable...' action: #removeInstVar.
^menu! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 20:45'!
invokeContextMenu
|m |
m _ self contextMenu.
m ifNotNil: [m popUpNearHand]! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 22:13'!
methodMenu
|menu|
menu _ MenuMorph new defaultTarget: self.
menu add: 'remove a method...' action: #removeMethod.
^menu! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/10/2009 19:51'!
mouseDown: evt
"Handle a mouse down event."
evt rightButtonPressed
ifTrue: [ ^self invokeContextMenu].
! !
!ElementsPaletteFrameMorph methodsFor: 'as yet unclassified' stamp: 'jens 2/9/2009 02:02'!
refresh
| choice |
choice _ header choice.
(#basics = choice) ifTrue: [
palette contents: ElementPaletteMorph basics ].
(#allClasses = choice) ifTrue: [
palette contents: ElementPaletteMorph classes ].
(#currentPackageClasses = choice) ifTrue: [
(currentClass isKindOf: Metaclass)
ifTrue: [ palette contents: (ElementPaletteMorph currentPackageClasses: currentClass allInstances first) ]