-
Notifications
You must be signed in to change notification settings - Fork 3
/
bitmapObject.e
341 lines (286 loc) · 10.1 KB
/
bitmapObject.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
OPT MODULE, OSVERSION=37
MODULE 'reaction/reaction_macros',
'window','classes/window',
'gadgets/layout','layout',
'reaction/reaction_lib',
'button','gadgets/button',
'images/bevel',
'string',
'bitmap','images/bitmap',
'gadgets/integer','integer',
'gadgets/checkbox','checkbox',
'gadgets/getfile','getfile',
'images/label','label',
'amigalib/boopsi',
'libraries/gadtools',
'intuition/intuition',
'intuition/imageclass',
'intuition/gadgetclass'
MODULE '*reactionObject','*reactionForm','*sourceGen','*validator'
EXPORT DEF errorState
EXPORT ENUM BITMAPGAD_IDENT, BITMAPGAD_LABEL, BITMAPGAD_LEFTEDGE, BITMAPGAD_TOPEDGE,
BITMAPGAD_WIDTH, BITMAPGAD_HEIGHT, BITMAPGAD_SOURCEFILE, BITMAPGAD_MASKING,
BITMAPGAD_OK, BITMAPGAD_CHILD, BITMAPGAD_CANCEL
CONST NUM_BITMAP_GADS=BITMAPGAD_CANCEL+1
EXPORT OBJECT bitmapObject OF reactionObject
leftEdge:INT
topEdge:INT
width:INT
height:INT
sourceFile[255]:ARRAY OF CHAR
masking:CHAR
ENDOBJECT
OBJECT bitmapSettingsForm OF reactionForm
PRIVATE
bitmapObject:PTR TO bitmapObject
ENDOBJECT
PROC create() OF bitmapSettingsForm
DEF gads:PTR TO LONG
NEW gads[NUM_BITMAP_GADS]
self.gadgetList:=gads
NEW gads[NUM_BITMAP_GADS]
self.gadgetActions:=gads
self.windowObj:=WindowObject,
WA_TITLE, 'Bitmap Attribute Setting',
WA_LEFT, 0,
WA_TOP, 0,
WA_HEIGHT, 80,
WA_WIDTH, 150,
WA_MINWIDTH, 150,
WA_MAXWIDTH, 8192,
WA_MINHEIGHT, 80,
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, self.gadgetList[ BITMAPGAD_IDENT ]:=StringObject,
GA_ID, BITMAPGAD_IDENT,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Identifier',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ BITMAPGAD_LABEL ]:=StringObject,
GA_ID, BITMAPGAD_LABEL,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, '_Label',
LabelEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ BITMAPGAD_LEFTEDGE ]:=IntegerObject,
GA_ID, BITMAPGAD_LEFTEDGE,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MAXCHARS, 4,
INTEGER_MINIMUM, 0,
INTEGER_MAXIMUM, 9999,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, '_LeftEdge',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ BITMAPGAD_TOPEDGE ]:=IntegerObject,
GA_ID, BITMAPGAD_TOPEDGE,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MAXCHARS, 4,
INTEGER_MINIMUM, 0,
INTEGER_MAXIMUM, 9999,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Top_Edge',
LabelEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ BITMAPGAD_WIDTH ]:=IntegerObject,
GA_ID, BITMAPGAD_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[ BITMAPGAD_HEIGHT ]:=IntegerObject,
GA_ID, BITMAPGAD_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[ BITMAPGAD_SOURCEFILE ]:=GetFileObject,
GA_ID, BITMAPGAD_SOURCEFILE,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GETFILE_TITLETEXT, 'Select your image file',
GETFILE_READONLY, FALSE,
TAG_DONE]),
LAYOUT_ADDCHILD, self.gadgetList[ BITMAPGAD_MASKING ]:=CheckBoxObject,
GA_ID, BITMAPGAD_MASKING,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Masking',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ BITMAPGAD_OK ]:=ButtonObject,
GA_ID, BITMAPGAD_OK,
GA_TEXT, '_OK',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ BITMAPGAD_CHILD ]:=ButtonObject,
GA_ID, BITMAPGAD_CHILD,
GA_TEXT, 'C_hild',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ BITMAPGAD_CANCEL ]:=ButtonObject,
GA_ID, BITMAPGAD_CANCEL,
GA_TEXT, '_Cancel',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
LayoutEnd,
WindowEnd
self.gadgetActions[BITMAPGAD_CHILD]:={editChildSettings}
self.gadgetActions[BITMAPGAD_SOURCEFILE]:={triggerFileSelect}
self.gadgetActions[BITMAPGAD_CANCEL]:=MR_CANCEL
self.gadgetActions[BITMAPGAD_OK]:=MR_OK
ENDPROC
PROC triggerFileSelect(nself,gadget,id,code) OF bitmapSettingsForm
DEF win
self:=nself
win:=Gets(self.windowObj,WINDOW_WINDOW)
gfRequestFile(self.gadgetList[BITMAPGAD_SOURCEFILE],win)
ENDPROC
PROC editChildSettings(nself,gadget,id,code) OF bitmapSettingsForm
self:=nself
self.setBusy()
self.bitmapObject.editChildSettings()
self.clearBusy()
ENDPROC
PROC end() OF bitmapSettingsForm
END self.gadgetList[NUM_BITMAP_GADS]
END self.gadgetActions[NUM_BITMAP_GADS]
DisposeObject(self.windowObj)
ENDPROC
EXPORT PROC canClose(modalRes) OF bitmapSettingsForm
DEF res
IF modalRes=MR_CANCEL THEN RETURN TRUE
IF checkIdent(self,self.bitmapObject,BITMAPGAD_IDENT)=FALSE
RETURN FALSE
ENDIF
ENDPROC TRUE
PROC editSettings(comp:PTR TO bitmapObject) OF bitmapSettingsForm
DEF res
self.bitmapObject:=comp
SetGadgetAttrsA(self.gadgetList[ BITMAPGAD_IDENT ],0,0,[STRINGA_TEXTVAL,comp.ident,0])
SetGadgetAttrsA(self.gadgetList[ BITMAPGAD_LABEL ],0,0,[STRINGA_TEXTVAL,comp.label,0])
SetGadgetAttrsA(self.gadgetList[ BITMAPGAD_SOURCEFILE ],0,0,[GETFILE_FULLFILE,comp.sourceFile,0])
SetGadgetAttrsA(self.gadgetList[ BITMAPGAD_LEFTEDGE ],0,0,[INTEGER_NUMBER,comp.leftEdge,0])
SetGadgetAttrsA(self.gadgetList[ BITMAPGAD_TOPEDGE ],0,0,[INTEGER_NUMBER,comp.topEdge,0])
SetGadgetAttrsA(self.gadgetList[ BITMAPGAD_WIDTH ],0,0,[INTEGER_NUMBER,comp.width,0])
SetGadgetAttrsA(self.gadgetList[ BITMAPGAD_HEIGHT ],0,0,[INTEGER_NUMBER,comp.height,0])
SetGadgetAttrsA(self.gadgetList[ BITMAPGAD_MASKING ],0,0,[CHECKBOX_CHECKED,comp.masking,0])
res:=self.showModal()
IF res=MR_OK
AstrCopy(comp.ident,Gets(self.gadgetList[ BITMAPGAD_IDENT ],STRINGA_TEXTVAL))
AstrCopy(comp.label,Gets(self.gadgetList[ BITMAPGAD_LABEL ],STRINGA_TEXTVAL))
AstrCopy(comp.sourceFile,Gets(self.gadgetList[ BITMAPGAD_SOURCEFILE ],GETFILE_FULLFILE),255)
comp.leftEdge:=Gets(self.gadgetList[ BITMAPGAD_LEFTEDGE ],INTEGER_NUMBER)
comp.topEdge:=Gets(self.gadgetList[ BITMAPGAD_TOPEDGE ],INTEGER_NUMBER)
comp.width:=Gets(self.gadgetList[ BITMAPGAD_WIDTH ],INTEGER_NUMBER)
comp.height:=Gets(self.gadgetList[ BITMAPGAD_HEIGHT ],INTEGER_NUMBER)
comp.masking:=Gets(self.gadgetList[ BITMAPGAD_MASKING ],CHECKBOX_CHECKED)
ENDIF
ENDPROC res=MR_OK
EXPORT PROC createPreviewObject(scr) OF bitmapObject
self.previewObject:=BitMapObject,
IA_LEFT, self.leftEdge,
IA_TOP, self.topEdge,
IA_WIDTH, self.width,
IA_HEIGHT, self.height,
BITMAP_MASKING, self.masking,
BITMAP_SOURCEFILE, self.sourceFile,
BITMAP_SCREEN, scr,
->LABEL_DRAWINFO, self.drawInfo,
BitMapEnd
IF self.previewObject=0 THEN self.previewObject:=self.createErrorObject(scr)
errorState:=FALSE
self.makePreviewChildAttrs(0)
ENDPROC
EXPORT PROC create(parent) OF bitmapObject
self.type:=TYPE_BITMAP
SUPER self.create(parent)
self.leftEdge:=0
self.topEdge:=0
self.width:=0
self.height:=0
self.masking:=FALSE
AstrCopy(self.sourceFile,'')
self.libsused:=[TYPE_BITMAP]
ENDPROC
EXPORT PROC editSettings() OF bitmapObject
DEF editForm:PTR TO bitmapSettingsForm
DEF res
NEW editForm.create()
res:=editForm.editSettings(self)
END editForm
ENDPROC res
#define makeProp(a,b) 'a',{self.a},b
EXPORT PROC serialiseData() OF bitmapObject IS
[
makeProp(leftEdge,FIELDTYPE_INT),
makeProp(topEdge,FIELDTYPE_INT),
makeProp(width,FIELDTYPE_INT),
makeProp(height,FIELDTYPE_INT),
makeProp(sourceFile,FIELDTYPE_STR),
makeProp(masking,FIELDTYPE_CHAR)
]
EXPORT PROC genCodeProperties(srcGen:PTR TO srcGen) OF bitmapObject
srcGen.componentPropertyInt('IA_Left',self.leftEdge)
srcGen.componentPropertyInt('IA_Top',self.topEdge)
srcGen.componentPropertyInt('IA_Width',self.width)
srcGen.componentPropertyInt('IA_Height',self.height)
srcGen.componentProperty('BITMAP_Screen','gScreen',FALSE)
srcGen.componentProperty('BITMAP_SourceFile',self.sourceFile,TRUE)
IF self.masking THEN srcGen.componentProperty('BITMAP_Masking','TRUE',FALSE)
ENDPROC
EXPORT PROC genCodeChildProperties(srcGen:PTR TO srcGen) OF bitmapObject
srcGen.componentAddChildLabel(self.label)
SUPER self.genCodeChildProperties(srcGen)
ENDPROC
EXPORT PROC getTypeName() OF bitmapObject
RETURN 'BitMap'
ENDPROC
EXPORT PROC isImage() OF bitmapObject IS TRUE
EXPORT PROC createBitmapObject(parent)
DEF bitmap:PTR TO bitmapObject
NEW bitmap.create(parent)
ENDPROC bitmap