-
Notifications
You must be signed in to change notification settings - Fork 3
/
getColorObject.e
418 lines (355 loc) · 13.5 KB
/
getColorObject.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
OPT MODULE, OSVERSION=37
MODULE 'reaction/reaction_macros',
'window','classes/window',
'gadgets/layout','layout',
'reaction/reaction_lib',
'button','gadgets/button',
'images/bevel',
'string',
'gadgets/getcolor','getcolor',
'gadgets/chooser','chooser',
'gadgets/checkbox','checkbox',
'images/label','label',
'amigalib/boopsi',
'libraries/gadtools',
'intuition/intuition',
'intuition/screens',
'intuition/imageclass',
'intuition/gadgetclass'
MODULE '*reactionObject','*reactionForm','*sourcegen','*validator'
EXPORT ENUM GETCOLGAD_IDENT, GETCOLGAD_NAME, GETCOLGAD_HINT, GETCOLGAD_TITLE,GETCOLGAD_COLORWHEEL,GETCOLGAD_RGBSLIDERS,GETCOLGAD_HSBSLIDERS,
GETCOLGAD_SWITCHMODE, GETCOLGAD_INITIAL, GETCOLGAD_SHOWRGB, GETCOLGAD_SHOWHSB,GETCOLGAD_DISABLED,
GETCOLGAD_OK, GETCOLGAD_CHILD, GETCOLGAD_CANCEL
CONST NUM_GETCOL_GADS=GETCOLGAD_CANCEL+1
EXPORT OBJECT getColorObject OF reactionObject
title[80]:ARRAY OF CHAR
colorWheel:CHAR
rgbSliders:CHAR
hsbSliders:CHAR
switchMode:CHAR
initial:CHAR
showRGB:CHAR
showHSB:CHAR
disabled:CHAR
ENDOBJECT
OBJECT getColorSettingsForm OF reactionForm
PRIVATE
getColorObject:PTR TO getColorObject
labels1:PTR TO LONG
ENDOBJECT
PROC create() OF getColorSettingsForm
DEF gads:PTR TO LONG
NEW gads[NUM_GETCOL_GADS]
self.gadgetList:=gads
NEW gads[NUM_GETCOL_GADS]
self.gadgetActions:=gads
self.windowObj:=WindowObject,
WA_TITLE, 'GetColor Attribute Setting',
WA_LEFT, 0,
WA_TOP, 0,
WA_HEIGHT, 60,
WA_WIDTH, 260,
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_SPACEINNER, FALSE,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_IDENT ]:=StringObject,
GA_ID, GETCOLGAD_IDENT,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Identifier',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_NAME ]:=StringObject,
GA_ID, GETCOLGAD_NAME,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, '_Label',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_HINT ]:=ButtonObject,
GA_ID, GETCOLGAD_HINT,
GA_TEXT, 'Hint',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_TITLE ]:=StringObject,
GA_ID, GETCOLGAD_TITLE,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Title text',
LabelEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_SPACEINNER, FALSE,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_COLORWHEEL ]:=CheckBoxObject,
GA_ID, GETCOLGAD_COLORWHEEL,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'ColorWheel',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_RGBSLIDERS ]:=CheckBoxObject,
GA_ID, GETCOLGAD_RGBSLIDERS,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Show RGB Sliders',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_HSBSLIDERS ]:=CheckBoxObject,
GA_ID, GETCOLGAD_HSBSLIDERS,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Show HSB Sliders',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_SPACEINNER, FALSE,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_SPACEINNER, FALSE,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_SWITCHMODE ]:=CheckBoxObject,
GA_ID, GETCOLGAD_SHOWRGB,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Switch Mode',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_INITIAL ]:=ChooserObject,
GA_ID, GETCOLGAD_INITIAL,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
CHOOSER_POPUP, TRUE,
CHOOSER_MAXLABELS, 12,
CHOOSER_ACTIVE, 0,
CHOOSER_WIDTH, -1,
CHOOSER_LABELS, self.labels1:=chooserLabelsA(['RGB','HSB',0]),
ChooserEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Initial Mode',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_SHOWRGB ]:=CheckBoxObject,
GA_ID, GETCOLGAD_SHOWRGB,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Show RGB Values',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_SPACEINNER, FALSE,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_SHOWHSB ]:=CheckBoxObject,
GA_ID, GETCOLGAD_SHOWHSB,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_TEXT, 'Show HSB Values',
CHECKBOX_TEXTPLACE, PLACETEXT_LEFT,
CheckBoxEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_DISABLED ]:=CheckBoxObject,
GA_ID, GETCOLGAD_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[ GETCOLGAD_OK ]:=ButtonObject,
GA_ID, GETCOLGAD_OK,
GA_TEXT, '_OK',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_CHILD ]:=ButtonObject,
GA_ID, GETCOLGAD_CHILD,
GA_TEXT, 'C_hild',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ GETCOLGAD_CANCEL ]:=ButtonObject,
GA_ID, GETCOLGAD_CANCEL,
GA_TEXT, '_Cancel',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
CHILD_WEIGHTEDHEIGHT,0,
LayoutEnd,
WindowEnd
self.gadgetActions[GETCOLGAD_CHILD]:={editChildSettings}
self.gadgetActions[GETCOLGAD_HINT]:={editHint}
self.gadgetActions[GETCOLGAD_CANCEL]:=MR_CANCEL
self.gadgetActions[GETCOLGAD_OK]:=MR_OK
ENDPROC
PROC editHint(nself,gadget,id,code) OF getColorSettingsForm
self:=nself
self.setBusy()
self.getColorObject.editHint()
self.clearBusy()
self.updateHint(GETCOLGAD_HINT, self.getColorObject.hintText)
ENDPROC
PROC editChildSettings(nself,gadget,id,code) OF getColorSettingsForm
self:=nself
self.setBusy()
self.getColorObject.editChildSettings()
self.clearBusy()
ENDPROC
PROC end() OF getColorSettingsForm
freeChooserLabels( self.labels1 )
END self.gadgetList[NUM_GETCOL_GADS]
END self.gadgetActions[NUM_GETCOL_GADS]
DisposeObject(self.windowObj)
ENDPROC
EXPORT PROC canClose(modalRes) OF getColorSettingsForm
DEF res
IF modalRes=MR_CANCEL THEN RETURN TRUE
IF checkIdent(self,self.getColorObject,GETCOLGAD_IDENT)=FALSE
RETURN FALSE
ENDIF
ENDPROC TRUE
PROC editSettings(comp:PTR TO getColorObject) OF getColorSettingsForm
DEF res
self.getColorObject:=comp
self.updateHint(GETCOLGAD_HINT, comp.hintText)
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_IDENT ],0,0,[STRINGA_TEXTVAL,comp.ident,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_NAME ],0,0,[STRINGA_TEXTVAL,comp.name,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_TITLE ],0,0,[STRINGA_TEXTVAL,comp.title,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_COLORWHEEL ],0,0,[CHECKBOX_CHECKED,comp.colorWheel,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_RGBSLIDERS ],0,0,[CHECKBOX_CHECKED,comp.rgbSliders,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_HSBSLIDERS ],0,0,[CHECKBOX_CHECKED,comp.hsbSliders,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_SWITCHMODE ],0,0,[CHECKBOX_CHECKED,comp.switchMode,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_INITIAL ],0,0,[CHOOSER_SELECTED,comp.initial,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_SHOWRGB ],0,0,[CHECKBOX_CHECKED,comp.showRGB,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_SHOWHSB ],0,0,[CHECKBOX_CHECKED,comp.showHSB,0])
SetGadgetAttrsA(self.gadgetList[ GETCOLGAD_DISABLED ],0,0,[CHECKBOX_CHECKED,comp.disabled,0])
res:=self.showModal()
IF res=MR_OK
AstrCopy(comp.ident,Gets(self.gadgetList[ GETCOLGAD_IDENT ],STRINGA_TEXTVAL))
AstrCopy(comp.name,Gets(self.gadgetList[ GETCOLGAD_NAME ],STRINGA_TEXTVAL))
AstrCopy(comp.title,Gets(self.gadgetList[ GETCOLGAD_TITLE ],STRINGA_TEXTVAL))
comp.colorWheel:=Gets(self.gadgetList[ GETCOLGAD_COLORWHEEL ],CHECKBOX_CHECKED)
comp.rgbSliders:=Gets(self.gadgetList[ GETCOLGAD_RGBSLIDERS ],CHECKBOX_CHECKED)
comp.hsbSliders:=Gets(self.gadgetList[ GETCOLGAD_HSBSLIDERS ],CHECKBOX_CHECKED)
comp.switchMode:=Gets(self.gadgetList[ GETCOLGAD_SWITCHMODE ],CHECKBOX_CHECKED)
comp.initial:=Gets(self.gadgetList[ GETCOLGAD_INITIAL ],CHOOSER_SELECTED)
comp.showRGB:=Gets(self.gadgetList[ GETCOLGAD_SHOWRGB ],CHECKBOX_CHECKED)
comp.showHSB:=Gets(self.gadgetList[ GETCOLGAD_SHOWHSB ],CHECKBOX_CHECKED)
comp.disabled:=Gets(self.gadgetList[ GETCOLGAD_DISABLED ],CHECKBOX_CHECKED)
ENDIF
ENDPROC res=MR_OK
EXPORT PROC createPreviewObject(scr) OF getColorObject
self.previewObject:=0
IF (getcolorbase)
self.previewObject:=NewObjectA(GetColor_GetClass(), NIL,[TAG_IGNORE,0,
GA_ID, self.id,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_DISABLED, self.disabled,
IF StrLen(self.title) THEN GETCOLOR_TITLETEXT ELSE TAG_IGNORE, self.title,
GETCOLOR_COLORWHEEL,self.colorWheel,
GETCOLOR_RGBSLIDERS,self.rgbSliders,
GETCOLOR_HSBSLIDERS,self.hsbSliders,
GETCOLOR_SWITCHMODE,self.switchMode,
GETCOLOR_INITIAL,self.initial,
GETCOLOR_SHOWRGB,self.showRGB,
GETCOLOR_SHOWHSB,self.showHSB,
GETCOLOR_SCREEN,scr,
TAG_DONE])
ENDIF
IF self.previewObject=0 THEN self.previewObject:=self.createErrorObject(scr)
self.makePreviewChildAttrs(self.name)
ENDPROC
EXPORT PROC create(parent) OF getColorObject
self.type:=TYPE_GETCOLOR
SUPER self.create(parent)
AstrCopy(self.title,'')
self.colorWheel:=TRUE
self.rgbSliders:=TRUE
self.hsbSliders:=0
self.switchMode:=TRUE
self.initial:=0
self.showRGB:=0
self.showHSB:=0
self.disabled:=0
self.libsused:=[TYPE_GETCOLOR, TYPE_LABEL]
ENDPROC
EXPORT PROC editSettings() OF getColorObject
DEF editForm:PTR TO getColorSettingsForm
DEF res
NEW editForm.create()
res:=editForm.editSettings(self)
END editForm
ENDPROC res
EXPORT PROC getTypeName() OF getColorObject
RETURN 'GetColor'
ENDPROC
#define makeProp(a,b) 'a',{self.a},b
EXPORT PROC serialiseData() OF getColorObject IS
[
makeProp(title,FIELDTYPE_STR),
makeProp(colorWheel,FIELDTYPE_CHAR),
makeProp(rgbSliders,FIELDTYPE_CHAR),
makeProp(hsbSliders,FIELDTYPE_CHAR),
makeProp(switchMode,FIELDTYPE_CHAR),
makeProp(initial,FIELDTYPE_CHAR),
makeProp(showRGB,FIELDTYPE_CHAR),
makeProp(showHSB,FIELDTYPE_CHAR),
makeProp(disabled,FIELDTYPE_CHAR)
]
EXPORT PROC genCodeProperties(srcGen:PTR TO srcGen) OF getColorObject
srcGen.componentProperty('GA_RelVerify','TRUE',FALSE)
srcGen.componentProperty('GA_TabCycle','TRUE',FALSE)
IF self.disabled THEN srcGen.componentProperty('GA_Disabled','TRUE',FALSE)
IF StrLen(self.title) THEN srcGen.componentProperty('GETCOLOR_TitleText',self.title,TRUE)
srcGen.componentProperty('GETCOLOR_Screen','gScreen',FALSE)
IF self.colorWheel THEN srcGen.componentProperty('GETCOLOR_ColorWheel','TRUE',FALSE)
IF self.rgbSliders=FALSE THEN srcGen.componentProperty('GETCOLOR_RGBSliders','FALSE',FALSE)
IF self.hsbSliders THEN srcGen.componentProperty('GETCOLOR_HSBSliders','TRUE',FALSE)
IF self.switchMode=FALSE THEN srcGen.componentProperty('GETCOLOR_SwitchMode','FALSE',FALSE)
IF self.switchMode
srcGen.componentPropertyInt('GETCOLOR_Initial',self.initial)
ENDIF
IF self.showRGB THEN srcGen.componentProperty('GETCOLOR_ShowRGB','TRUE',FALSE)
IF self.showHSB THEN srcGen.componentProperty('GETCOLOR_ShowHSB','TRUE',FALSE)
ENDPROC
EXPORT PROC genCodeChildProperties(srcGen:PTR TO srcGen) OF getColorObject
srcGen.componentAddChildLabel(self.name)
SUPER self.genCodeChildProperties(srcGen)
ENDPROC
EXPORT PROC hasCreateMacro() OF getColorObject IS FALSE ->create macro was missing from EVO modules
EXPORT PROC getTypeEndName() OF getColorObject
RETURN 'End'
ENDPROC
EXPORT PROC createGetColorObject(parent)
DEF getcolor:PTR TO getColorObject
NEW getcolor.create(parent)
ENDPROC getcolor