-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPyramidBackgroundImageModalPresenter.class.st
More file actions
452 lines (361 loc) · 11.5 KB
/
Copy pathPyramidBackgroundImageModalPresenter.class.st
File metadata and controls
452 lines (361 loc) · 11.5 KB
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
Class {
#name : #PyramidBackgroundImageModalPresenter,
#superclass : #SpPresenter,
#instVars : [
'radioProxy',
'radioBitmap',
'codeBitmap',
'inputReceiverProxy',
'inputSelectorProxy',
'inputArgumentsProxy',
'buttonInspect',
'buttonExampleDefault',
'buttonExampleFileSystem',
'buttonExampleBloc'
],
#category : #'Pyramid-Bloc-plugin-bloc-visuals'
}
{ #category : #'as yet unclassified' }
PyramidBackgroundImageModalPresenter class >> ensurePharoBigFileExists [
'./pharoBig.png' asFileReference exists ifTrue: [ ^ self ].
PNGReadWriter putForm: (Smalltalk ui icons iconNamed: #pharoBig) onFileNamed: './pharoBig.png'
]
{ #category : #layout }
PyramidBackgroundImageModalPresenter >> baseLayout [
^ SpBoxLayout newVertical
spacing: 4;
add: (SpLabelPresenter new
label: 'Type';
displayBold: [ :t | true ];
yourself)
expand: false;
add: (SpBoxLayout newHorizontal
spacing: 4;
add: self radioProxy;
add: self radioBitmap;
yourself)
expand: false;
add:
'The proxy allow you to call methods during the materialization of the object.'
expand: false;
add:
'Use the bitmap to have a direct access to the image object.'
expand: false;
add:
'Be carefull it will increase the size of the serialized strings.'
expand: false;
add:
'Use a proxy to reduce the size of the serialized image.'
expand: false;
yourself
]
{ #category : #layout }
PyramidBackgroundImageModalPresenter >> bitmapLayout [
^ self baseLayout
add: (SpLabelPresenter new
label: 'Code';
displayBold: [ :t | true ];
yourself)
expand: false;
add: self codeBitmap;
add: self buttonInpectLayout expand: false;
yourself
]
{ #category : #'special objects' }
PyramidBackgroundImageModalPresenter >> bitmapObject [
^ self codeBitmap
evaluate: self codeBitmap text
onCompileError: [ :err | ^ self ]
onError: [ :err | err pass ]
]
{ #category : #initialization }
PyramidBackgroundImageModalPresenter >> buttonExampleBloc [
^ buttonExampleBloc
]
{ #category : #initialization }
PyramidBackgroundImageModalPresenter >> buttonExampleDefault [
^ buttonExampleDefault
]
{ #category : #initialization }
PyramidBackgroundImageModalPresenter >> buttonExampleFileSystem [
^ buttonExampleFileSystem
]
{ #category : #layout }
PyramidBackgroundImageModalPresenter >> buttonInpectLayout [
^ SpBoxLayout newHorizontal
add: self buttonExampleDefault expand: false;
add: self buttonExampleFileSystem expand: false;
add: self buttonExampleBloc expand: false;
add: SpNullPresenter new expand: true;
add: self buttonInspect expand: false;
yourself
]
{ #category : #accessing }
PyramidBackgroundImageModalPresenter >> buttonInspect [
^ buttonInspect
]
{ #category : #accessing }
PyramidBackgroundImageModalPresenter >> codeBitmap [
^ codeBitmap
]
{ #category : #action }
PyramidBackgroundImageModalPresenter >> currentObject [
^ (self isProxySelected
ifTrue: [ self proxyObject ]
ifFalse: [ self bitmapObject ])
]
{ #category : #layout }
PyramidBackgroundImageModalPresenter >> defaultLayout [
self isProxySelected ifTrue: [ ^ self proxyLayout ].
^ self bitmapLayout
]
{ #category : #action }
PyramidBackgroundImageModalPresenter >> image: aForm [
| source |
self codeBitmap beForObject: aForm.
self codeBitmap text: self textBitmap , 'self
'.
(aForm isPyramidProxy) ifFalse: [ ^ self ].
source := aForm pyramidExternalRessourceSource.
self inputReceiverProxy text: (Stash new serialize: source target).
self inputSelectorProxy text: (Stash new serialize: source selector).
self inputArgumentsProxy text:
(Stash new serialize: source arguments)
]
{ #category : #initialization }
PyramidBackgroundImageModalPresenter >> initializePresenters [
radioProxy := SpRadioButtonPresenter new
label: 'Proxy';
help:
'Create a proxy for an image. Take less place for the serialization.';
yourself.
radioBitmap := SpRadioButtonPresenter new
label: 'Bitmap';
help:
'Create an image. Take more place for the serialization.';
yourself.
radioProxy associatedRadioButtons: { radioBitmap }.
radioProxy whenChangedDo: [ :state | self updatePresenter ].
buttonInspect := SpButtonPresenter new
help: 'Verify the image.';
label: 'Inspect';
icon: (Smalltalk ui icons iconNamed: #smallInspectIt);
action: [ self inspectCurrent ];
yourself.
codeBitmap := SpCodePresenter new
beForScripting;
text: self textBitmapDefault;
yourself.
inputReceiverProxy := SpCodePresenter new
beForScripting;
text: self textReceiverDefault;
yourself.
inputSelectorProxy := SpCodePresenter new
beForScripting;
text: self textSelectorDefault;
yourself.
inputArgumentsProxy := SpCodePresenter new
beForScripting;
text: self textArgumentsDefault;
yourself.
buttonExampleDefault := SpButtonPresenter new
label: 'Example image';
action: [ self setTextToDefault ];
yourself.
buttonExampleFileSystem := SpButtonPresenter new
label: 'Example file';
action: [ self setTextToFile ];
yourself.
buttonExampleBloc := SpButtonPresenter new
label: 'Example bloc';
action: [ self setTextToBloc ];
yourself
]
{ #category : #accessing }
PyramidBackgroundImageModalPresenter >> inputArgumentsProxy [
^ inputArgumentsProxy
]
{ #category : #accessing }
PyramidBackgroundImageModalPresenter >> inputReceiverProxy [
^ inputReceiverProxy
]
{ #category : #accessing }
PyramidBackgroundImageModalPresenter >> inputSelectorProxy [
^ inputSelectorProxy
]
{ #category : #action }
PyramidBackgroundImageModalPresenter >> inspectCurrent [
(self currentObject) inspect
]
{ #category : #layout }
PyramidBackgroundImageModalPresenter >> isProxySelected [
^ self radioProxy state
]
{ #category : #layout }
PyramidBackgroundImageModalPresenter >> proxyLayout [
^ self baseLayout
add: (SpLabelPresenter new
label: 'Receiver';
displayBold: [ :t | true ];
yourself)
expand: false;
add: self inputReceiverProxy;
add: (SpLabelPresenter new
label: 'Selector';
displayBold: [ :t | true ];
yourself)
expand: false;
add: self inputSelectorProxy;
add: (SpLabelPresenter new
label: 'Arguments';
displayBold: [ :t | true ];
yourself)
expand: false;
add: self inputArgumentsProxy;
add: self buttonInpectLayout expand: false;
yourself
]
{ #category : #'special objects' }
PyramidBackgroundImageModalPresenter >> proxyObject [
| receiver selector arguments proxySource |
receiver := self inputReceiverProxy
evaluate: self inputReceiverProxy text
onCompileError: [ :err | ^ self ]
onError: [ :err | err pass ].
selector := self inputSelectorProxy
evaluate: self inputSelectorProxy text
onCompileError: [ :err | ^ self ]
onError: [ :err | err pass ].
arguments := self inputArgumentsProxy
evaluate: self inputArgumentsProxy text
onCompileError: [ :err | ^ self ]
onError: [ :err | err pass ].
proxySource := PyramidExternalRessourceSource
target: receiver
selector: selector
arguments: arguments.
^ PyramidExternalRessourceProxy fromSource: proxySource
]
{ #category : #accessing }
PyramidBackgroundImageModalPresenter >> radioBitmap [
^ radioBitmap
]
{ #category : #accessing }
PyramidBackgroundImageModalPresenter >> radioProxy [
^ radioProxy
]
{ #category : #initialization }
PyramidBackgroundImageModalPresenter >> setTextToBloc [
self codeBitmap text: self textBitmapBloc.
self inputReceiverProxy text: self textReceiverBloc.
self inputSelectorProxy text: self textSelectorBloc.
self inputArgumentsProxy text: self textArgumentsBloc
]
{ #category : #initialization }
PyramidBackgroundImageModalPresenter >> setTextToDefault [
self codeBitmap text: self textBitmapDefault.
self inputReceiverProxy text: self textReceiverDefault.
self inputSelectorProxy text: self textSelectorDefault.
self inputArgumentsProxy text: self textArgumentsDefault.
]
{ #category : #initialization }
PyramidBackgroundImageModalPresenter >> setTextToFile [
self codeBitmap text: self textBitmapFile.
self inputReceiverProxy text: self textReceiverFile.
self inputSelectorProxy text: self textSelectorFile.
self inputArgumentsProxy text: self textArgumentsFile
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textArguments [
^ '"Use it like a Playground. Last object must be a Collection that will be used as arguments."
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textArgumentsBloc [
^ self textArguments , '{ }
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textArgumentsDefault [
^ self textArguments, '#(#pharoBig)
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textArgumentsFile [
^ self textArguments , '{ ''./pharoBig.png'' }
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textBitmap [
^ '"Use it like a Playground. Last object must be a Form."
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textBitmapBloc [
^ self textBitmap , 'BlElement new background: Color red; size: 25 @ 50; asForm
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textBitmapDefault [
^ self textBitmap, 'Object iconNamed: #pharoBig
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textBitmapFile [
^ self textBitmap
, 'PyramidBackgroundImageModalPresenter ensurePharoBigFileExists.
Form fromFileNamed: ''./pharoBig.png'' asFileReference.
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textReceiver [
^ '"Use it like a Playground. Last object will be the serialized receiver."
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textReceiverBloc [
^ self textReceiver , 'BlElement new
background: Color red;
size: 25 @ 50;
yourself.
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textReceiverDefault [
^ self textReceiver , 'Object
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textReceiverFile [
^ self textReceiver , 'PyramidBackgroundImageModalPresenter ensurePharoBigFileExists.
Form
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textSelector [
^ '"Use it like a Playground. Last object must be a Symbol that will be performed on the receiver."
'
]
{ #category : #'as yet unclassified' }
PyramidBackgroundImageModalPresenter >> textSelectorBloc [
^ self textSelector, '#asForm'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textSelectorDefault [
^ self textSelector, '#iconNamed:
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textSelectorFile [
^ self textSelector , '#fromFileNamed:
'
]
{ #category : #text }
PyramidBackgroundImageModalPresenter >> textSelectorbloc [
^ self textSelector , '#asForm
'
]
{ #category : #update }
PyramidBackgroundImageModalPresenter >> updatePresenter [
self layout: self defaultLayout
]