forked from dmcoles/ReBuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketchboardObject.e
439 lines (374 loc) · 14 KB
/
sketchboardObject.e
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
OPT MODULE, OSVERSION=37
MODULE 'reaction/reaction_macros',
'window','classes/window',
'gadgets/layout','layout',
'reaction/reaction_lib',
'button','gadgets/button',
'images/bevel',
'string',
'gadgets/sketchboard','sketchboard',
'gadgets/checkbox','checkbox',
'gadgets/integer','integer',
'gadgets/chooser','chooser',
'gadgets/button','button',
'images/label','label',
'amigalib/boopsi',
'libraries/gadtools',
'intuition/intuition',
'intuition/screens',
'intuition/imageclass',
'intuition/gadgetclass'
MODULE '*reactionObject','*reactionForm','*colourPicker', '*sourcegen','*validator'
EXPORT ENUM SBOARDGAD_IDENT, SBOARDGAD_LABEL, SBOARDGAD_HINT, SBOARDGAD_WIDTH, SBOARDGAD_HEIGHT, SBOARDGAD_PEN, SBOARDGAD_ACTIVETOOL,
SBOARDGAD_GRID, SBOARDGAD_SCALE, SBOARDGAD_BEVEL, SBOARDGAD_READONLY, SBOARDGAD_DISABLED,
SBOARDGAD_OK, SBOARDGAD_CHILD, SBOARDGAD_CANCEL
CONST NUM_SBOARD_GADS=SBOARDGAD_CANCEL+1
EXPORT OBJECT sketchboardObject OF reactionObject
width:INT
height:INT
pen:CHAR
activeTool:CHAR
grid:CHAR
scale:INT
bevel:CHAR
readOnly:CHAR
disabled:CHAR
ENDOBJECT
OBJECT sketchboardSettingsForm OF reactionForm
PRIVATE
sketchboardObject:PTR TO sketchboardObject
tmpPen:INT
labels1:LONG
ENDOBJECT
PROC create() OF sketchboardSettingsForm
DEF gads:PTR TO LONG
NEW gads[NUM_SBOARD_GADS]
self.gadgetList:=gads
NEW gads[NUM_SBOARD_GADS]
self.gadgetActions:=gads
self.windowObj:=WindowObject,
WA_TITLE, 'Sketchboard Attribute Setting',
WA_LEFT, 0,
WA_TOP, 0,
WA_HEIGHT, 60,
WA_WIDTH, 450,
WA_MINWIDTH, 150,
WA_MAXWIDTH, 8192,
WA_MINHEIGHT, 60,
WA_MAXHEIGHT, 8192,
WA_ACTIVATE, TRUE,
WINDOW_POSITION, WPOS_CENTERSCREEN,
WA_PUBSCREEN, 0,
->WA_CustomScreen, gScreen,
->WINDOW_AppPort, gApp_port,
WA_CLOSEGADGET, TRUE,
WA_DEPTHGADGET, TRUE,
WA_SIZEGADGET, TRUE,
WA_DRAGBAR, TRUE,
WA_IDCMP,IDCMP_GADGETDOWN OR IDCMP_GADGETUP OR IDCMP_CLOSEWINDOW OR 0,
WINDOW_PARENTGROUP, VLayoutObject,
LAYOUT_SPACEOUTER, TRUE,
LAYOUT_DEFERLAYOUT, TRUE,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_IDENT ]:=StringObject,
GA_ID, SBOARDGAD_IDENT,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Identifier',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_LABEL ]:=StringObject,
GA_ID, SBOARDGAD_LABEL,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, '_Label',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_HINT ]:=ButtonObject,
GA_ID, SBOARDGAD_HINT,
GA_TEXT, 'Hint',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_PEN ]:=ButtonObject,
GA_ID, SBOARDGAD_PEN,
GA_TEXT, 'Pen',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_WIDTH ]:=IntegerObject,
GA_ID, SBOARDGAD_WIDTH,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MAXCHARS, 4,
INTEGER_MINIMUM, 0,
INTEGER_MAXIMUM, 9999,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Width',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_HEIGHT ]:=IntegerObject,
GA_ID, SBOARDGAD_HEIGHT,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MAXCHARS, 4,
INTEGER_MINIMUM, 0,
INTEGER_MAXIMUM, 9999,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Height',
LabelEnd,
LayoutEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_ACTIVETOOL ]:=ChooserObject,
GA_ID, SBOARDGAD_ACTIVETOOL,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
CHOOSER_POPUP, TRUE,
CHOOSER_MAXLABELS, 12,
CHOOSER_ACTIVE, 0,
CHOOSER_WIDTH, -1,
CHOOSER_LABELS, self.labels1:=chooserLabelsA(['SGTOOL_FREEHAND_DOTS','SGTOOL_FREEHAND','SGTOOL_ELLIPSE','SGTOOL_ELLIPSE_FILLED','SGTOOL_RECT',
'SGTOOL_RECT_FILLED','SGTOOL_LINE','SGTOOL_FILL','SGTOOL_GETPEN','SGTOOL_HOTSPOT','SGTOOL_SELECT',
'SGTOOL_MOVE',0]),
ChooserEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Active Tool',
LabelEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_SCALE ]:=IntegerObject,
GA_ID, SBOARDGAD_SCALE,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MAXCHARS, 2,
INTEGER_MINIMUM, 0,
INTEGER_MAXIMUM, 99,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Scale',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_GRID ]:=CheckBoxObject,
GA_ID, SBOARDGAD_GRID,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Grid',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_BEVEL ]:=CheckBoxObject,
GA_ID, SBOARDGAD_BEVEL,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Bevel',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_READONLY ]:=CheckBoxObject,
GA_ID, SBOARDGAD_READONLY,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'ReadOnly',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_DISABLED ]:=CheckBoxObject,
GA_ID, SBOARDGAD_DISABLED,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Disabled',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_OK ]:=ButtonObject,
GA_ID, SBOARDGAD_OK,
GA_TEXT, '_OK',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_CHILD ]:=ButtonObject,
GA_ID, SBOARDGAD_CHILD,
GA_TEXT, 'C_hild',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ SBOARDGAD_CANCEL ]:=ButtonObject,
GA_ID, SBOARDGAD_CANCEL,
GA_TEXT, '_Cancel',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
CHILD_WEIGHTEDHEIGHT,0,
LayoutEnd,
WindowEnd
self.gadgetActions[SBOARDGAD_PEN]:={selectPen}
self.gadgetActions[SBOARDGAD_CHILD]:={editChildSettings}
self.gadgetActions[SBOARDGAD_HINT]:={editHint}
self.gadgetActions[SBOARDGAD_CANCEL]:=MR_CANCEL
self.gadgetActions[SBOARDGAD_OK]:=MR_OK
ENDPROC
PROC selectPen(nself,gadget,id,code) OF sketchboardSettingsForm
DEF frmColourPicker:PTR TO colourPickerForm
DEF selColour
DEF colourProp:PTR TO INT
self:=nself
self.setBusy()
colourProp:={self.tmpPen}
NEW frmColourPicker.create()
IF (selColour:=frmColourPicker.selectColour(colourProp[]))<>-1
colourProp[]:=selColour
ENDIF
END frmColourPicker
self.clearBusy()
ENDPROC
PROC editChildSettings(nself,gadget,id,code) OF sketchboardSettingsForm
self:=nself
self.setBusy()
self.sketchboardObject.editChildSettings()
self.clearBusy()
ENDPROC
PROC end() OF sketchboardSettingsForm
freeChooserLabels( self.labels1 )
END self.gadgetList[NUM_SBOARD_GADS]
END self.gadgetActions[NUM_SBOARD_GADS]
DisposeObject(self.windowObj)
ENDPROC
EXPORT PROC canClose(modalRes) OF sketchboardSettingsForm
DEF res
IF modalRes=MR_CANCEL THEN RETURN TRUE
IF checkIdent(self,self.sketchboardObject,SBOARDGAD_IDENT)=FALSE
RETURN FALSE
ENDIF
ENDPROC TRUE
PROC editHint(nself,gadget,id,code) OF sketchboardSettingsForm
self:=nself
self.setBusy()
self.sketchboardObject.editHint()
self.clearBusy()
self.updateHint(SBOARDGAD_HINT, self.sketchboardObject.hintText)
ENDPROC
PROC editSettings(comp:PTR TO sketchboardObject) OF sketchboardSettingsForm
DEF res
self.sketchboardObject:=comp
self.tmpPen:=comp.pen
self.updateHint(SBOARDGAD_HINT, comp.hintText)
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_IDENT ],0,0,[STRINGA_TEXTVAL,comp.ident,0])
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_LABEL ],0,0,[STRINGA_TEXTVAL,comp.label,0])
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_WIDTH ],0,0,[INTEGER_NUMBER,comp.width,0])
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_HEIGHT ],0,0,[INTEGER_NUMBER,comp.height,0])
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_ACTIVETOOL ],0,0,[CHOOSER_SELECTED,comp.activeTool,0])
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_GRID ],0,0,[CHECKBOX_CHECKED,comp.grid,0])
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_SCALE ],0,0,[INTEGER_NUMBER,comp.scale,0])
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_BEVEL ],0,0,[CHECKBOX_CHECKED,comp.bevel,0])
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_READONLY ],0,0,[CHECKBOX_CHECKED,comp.readOnly,0])
SetGadgetAttrsA(self.gadgetList[ SBOARDGAD_DISABLED ],0,0,[CHECKBOX_CHECKED,comp.disabled,0])
res:=self.showModal()
IF res=MR_OK
comp.pen:=self.tmpPen
AstrCopy(comp.ident,Gets(self.gadgetList[ SBOARDGAD_IDENT ],STRINGA_TEXTVAL))
AstrCopy(comp.label,Gets(self.gadgetList[ SBOARDGAD_LABEL ],STRINGA_TEXTVAL))
comp.width:=Gets(self.gadgetList[ SBOARDGAD_WIDTH ],INTEGER_NUMBER)
comp.height:=Gets(self.gadgetList[ SBOARDGAD_HEIGHT ],INTEGER_NUMBER)
comp.activeTool:=Gets(self.gadgetList[ SBOARDGAD_ACTIVETOOL ],CHOOSER_SELECTED)
comp.grid:=Gets(self.gadgetList[ SBOARDGAD_GRID ],CHECKBOX_CHECKED)
comp.scale:=Gets(self.gadgetList[ SBOARDGAD_BEVEL ],INTEGER_NUMBER)
comp.bevel:=Gets(self.gadgetList[ SBOARDGAD_BEVEL ],CHECKBOX_CHECKED)
comp.readOnly:=Gets(self.gadgetList[ SBOARDGAD_READONLY ],CHECKBOX_CHECKED)
comp.disabled:=Gets(self.gadgetList[ SBOARDGAD_DISABLED ],CHECKBOX_CHECKED)
ENDIF
ENDPROC res=MR_OK
EXPORT PROC createPreviewObject(scr) OF sketchboardObject
self.previewObject:=0
IF (sketchboardbase)
self.previewObject:=NewObjectA( SketchBoard_GetClass(), NIL,[TAG_IGNORE,0,
GA_ID, self.id,
GA_READONLY, self.readOnly,
GA_DISABLED, self.disabled,
SGA_WIDTH, self.width,
SGA_HEIGHT, self.height,
SGA_APEN, self.pen,
SGA_TOOL, ListItem([SGTOOL_FREEHAND_DOTS,SGTOOL_FREEHAND,SGTOOL_ELLIPSE,SGTOOL_ELLIPSE_FILLED,SGTOOL_RECT,
SGTOOL_RECT_FILLED,SGTOOL_LINE,SGTOOL_FILL,SGTOOL_GETPEN,SGTOOL_HOTSPOT,SGTOOL_SELECT,
SGTOOL_MOVE],self.activeTool),
SGA_SHOWGRID, self.grid,
SGA_SCALE, self.scale,
SGA_WITHBEVEL, self.bevel,
TAG_END])
ENDIF
IF self.previewObject=0 THEN self.previewObject:=self.createErrorObject(scr)
self.makePreviewChildAttrs(0)
ENDPROC
EXPORT PROC create(parent) OF sketchboardObject
self.type:=TYPE_SKETCH
SUPER self.create(parent)
self.width:=32
self.height:=32
self.pen:=1
self.activeTool:=0
self.grid:=TRUE
self.scale:=3
self.bevel:=TRUE
self.readOnly:=0
self.disabled:=0
self.libsused:=[TYPE_SKETCH]
ENDPROC
EXPORT PROC editSettings() OF sketchboardObject
DEF editForm:PTR TO sketchboardSettingsForm
DEF res
NEW editForm.create()
res:=editForm.editSettings(self)
END editForm
ENDPROC res
EXPORT PROC getTypeName() OF sketchboardObject
RETURN 'SketchBoard'
ENDPROC
#define makeProp(a,b) 'a',{self.a},b
EXPORT PROC serialiseData() OF sketchboardObject IS
[
makeProp(width,FIELDTYPE_INT),
makeProp(height,FIELDTYPE_INT),
makeProp(pen,FIELDTYPE_CHAR),
makeProp(activeTool,FIELDTYPE_CHAR),
makeProp(grid,FIELDTYPE_CHAR),
makeProp(scale,FIELDTYPE_INT),
makeProp(bevel,FIELDTYPE_CHAR),
makeProp(readOnly,FIELDTYPE_CHAR),
makeProp(disabled,FIELDTYPE_CHAR)
]
EXPORT PROC genCodeProperties(srcGen:PTR TO srcGen) OF sketchboardObject
srcGen.componentProperty('GA_RelVerify','TRUE',FALSE)
srcGen.componentProperty('GA_TabCycle','TRUE',FALSE)
IF self.disabled THEN srcGen.componentProperty('GA_Disabled','TRUE',FALSE)
IF self.readOnly THEN srcGen.componentProperty('GA_ReadOnly','TRUE',FALSE)
srcGen.componentPropertyInt('SGA_Width',self.width)
srcGen.componentPropertyInt('SGA_Height',self.height)
IF self.activeTool THEN srcGen.componentProperty('SGA_Tool', ListItem(['SGTOOL_FREEHAND_DOTS','SGTOOL_FREEHAND','SGTOOL_ELLIPSE','SGTOOL_ELLIPSE_FILLED','SGTOOL_RECT',
'SGTOOL_RECT_FILLED','SGTOOL_LINE','SGTOOL_FILL','SGTOOL_GETPEN','SGTOOL_HOTSPOT','SGTOOL_SELECT',
'SGTOOL_MOVE'],self.activeTool),FALSE)
IF self.pen<>-1 THEN srcGen.componentPropertyInt('SGA_APen',self.pen)
IF self.grid THEN srcGen.componentProperty('SGA_ShowGrid','TRUE',FALSE)
IF self.scale THEN srcGen.componentProperty('SGA_Scale','1',FALSE)
IF self.bevel THEN srcGen.componentProperty('SGA_WithBevel','TRUE',FALSE)
ENDPROC
EXPORT PROC genCodeChildProperties(srcGen:PTR TO srcGen) OF sketchboardObject
srcGen.componentAddChildLabel(self.label)
SUPER self.genCodeChildProperties(srcGen)
ENDPROC
EXPORT PROC hasCreateMacro() OF sketchboardObject IS FALSE
EXPORT PROC getTypeEndName() OF sketchboardObject
RETURN 'End'
ENDPROC
EXPORT PROC createSketchboardObject(parent)
DEF sketch:PTR TO sketchboardObject
NEW sketch.create(parent)
ENDPROC sketch