-
Notifications
You must be signed in to change notification settings - Fork 3
/
paletteObject.e
305 lines (255 loc) · 8.79 KB
/
paletteObject.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
OPT MODULE, OSVERSION=37
MODULE 'reaction/reaction_macros',
'window','classes/window',
'gadgets/layout','layout',
'reaction/reaction_lib',
'button','gadgets/button',
'images/bevel',
'string',
'palette','gadgets/palette',
'gadgets/integer','integer',
'gadgets/checkbox','checkbox',
'images/label','label',
'amigalib/boopsi',
'libraries/gadtools',
'intuition/intuition',
'intuition/imageclass',
'intuition/gadgetclass'
MODULE '*reactionObject','*reactionForm','*sourceGen','*validator'
EXPORT ENUM PALGAD_IDENT, PALGAD_NAME, PALGAD_HINT, PALGAD_DISABLED,
PALGAD_INITIAL, PALGAD_OFFSET, PALGAD_NUMCOLS,
PALGAD_OK, PALGAD_CHILD, PALGAD_CANCEL
CONST NUM_PAL_GADS=PALGAD_CANCEL+1
EXPORT OBJECT paletteObject OF reactionObject
disabled:CHAR
initial:INT
offset:INT
numcols:INT
ENDOBJECT
OBJECT paletteSettingsForm OF reactionForm
PRIVATE
paletteObject:PTR TO paletteObject
ENDOBJECT
PROC create() OF paletteSettingsForm
DEF gads:PTR TO LONG
NEW gads[NUM_PAL_GADS]
self.gadgetList:=gads
NEW gads[NUM_PAL_GADS]
self.gadgetActions:=gads
self.windowObj:=WindowObject,
WA_TITLE, 'Palette 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, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ PALGAD_IDENT ]:=StringObject,
GA_ID, PALGAD_IDENT,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Identifier',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ PALGAD_NAME ]:=StringObject,
GA_ID, PALGAD_NAME,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, '_Label',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ PALGAD_HINT ]:=ButtonObject,
GA_ID, PALGAD_HINT,
GA_TEXT, 'Hint',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ PALGAD_INITIAL ]:=IntegerObject,
GA_ID, PALGAD_INITIAL,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MINIMUM, 0,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Initial Colour',
LabelEnd,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ PALGAD_OFFSET ]:=IntegerObject,
GA_ID, PALGAD_OFFSET,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MINIMUM, 0,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Colour _Offset',
LabelEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ADDCHILD, self.gadgetList[ PALGAD_NUMCOLS ]:=IntegerObject,
GA_ID, PALGAD_NUMCOLS,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MINIMUM, 0,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'NumColours',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ PALGAD_DISABLED ]:=CheckBoxObject,
GA_ID, PALGAD_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[ PALGAD_OK ]:=ButtonObject,
GA_ID, PALGAD_OK,
GA_TEXT, '_OK',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ PALGAD_CHILD ]:=ButtonObject,
GA_ID, PALGAD_CHILD,
GA_TEXT, 'C_hild',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ PALGAD_CANCEL ]:=ButtonObject,
GA_ID, PALGAD_CANCEL,
GA_TEXT, '_Cancel',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
LayoutEnd,
WindowEnd
self.gadgetActions[PALGAD_CHILD]:={editChildSettings}
self.gadgetActions[PALGAD_HINT]:={editHint}
self.gadgetActions[PALGAD_CANCEL]:=MR_CANCEL
self.gadgetActions[PALGAD_OK]:=MR_OK
ENDPROC
PROC editChildSettings(nself,gadget,id,code) OF paletteSettingsForm
self:=nself
self.setBusy()
self.paletteObject.editChildSettings()
self.clearBusy()
ENDPROC
PROC end() OF paletteSettingsForm
END self.gadgetList[NUM_PAL_GADS]
END self.gadgetActions[NUM_PAL_GADS]
DisposeObject(self.windowObj)
ENDPROC
EXPORT PROC canClose(modalRes) OF paletteSettingsForm
DEF res
IF modalRes=MR_CANCEL THEN RETURN TRUE
IF checkIdent(self,self.paletteObject,PALGAD_IDENT)=FALSE
RETURN FALSE
ENDIF
ENDPROC TRUE
PROC editHint(nself,gadget,id,code) OF paletteSettingsForm
self:=nself
self.setBusy()
self.paletteObject.editHint()
self.clearBusy()
self.updateHint(PALGAD_HINT, self.paletteObject.hintText)
ENDPROC
PROC editSettings(comp:PTR TO paletteObject) OF paletteSettingsForm
DEF res
self.paletteObject:=comp
SetGadgetAttrsA(self.gadgetList[ PALGAD_IDENT ],0,0,[STRINGA_TEXTVAL,comp.ident,0])
SetGadgetAttrsA(self.gadgetList[ PALGAD_NAME ],0,0,[STRINGA_TEXTVAL,comp.name,0])
SetGadgetAttrsA(self.gadgetList[ PALGAD_DISABLED ],0,0,[CHECKBOX_CHECKED,comp.disabled,0])
SetGadgetAttrsA(self.gadgetList[ PALGAD_INITIAL ],0,0,[INTEGER_NUMBER,comp.initial,0])
SetGadgetAttrsA(self.gadgetList[ PALGAD_OFFSET ],0,0,[INTEGER_NUMBER,comp.offset,0])
SetGadgetAttrsA(self.gadgetList[ PALGAD_NUMCOLS ],0,0,[INTEGER_NUMBER,comp.numcols,0])
res:=self.showModal()
IF res=MR_OK
AstrCopy(comp.ident,Gets(self.gadgetList[ PALGAD_IDENT ],STRINGA_TEXTVAL))
AstrCopy(comp.name,Gets(self.gadgetList[ PALGAD_NAME ],STRINGA_TEXTVAL))
comp.disabled:=Gets(self.gadgetList[ PALGAD_DISABLED],CHECKBOX_CHECKED)
comp.initial:=Gets(self.gadgetList[ PALGAD_INITIAL ],INTEGER_NUMBER)
comp.offset:=Gets(self.gadgetList[ PALGAD_OFFSET ],INTEGER_NUMBER)
comp.numcols:=Gets(self.gadgetList[ PALGAD_NUMCOLS ],INTEGER_NUMBER)
ENDIF
ENDPROC res=MR_OK
EXPORT PROC createPreviewObject(scr) OF paletteObject
self.previewObject:=PaletteObject,
GA_ID, self.id,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
PALETTE_COLOUR, self.initial,
PALETTE_COLOUROFFSET, self.offset,
PALETTE_NUMCOLOURS, self.numcols,
PaletteEnd
IF self.previewObject=0 THEN self.previewObject:=self.createErrorObject(scr)
self.makePreviewChildAttrs(self.name)
ENDPROC
EXPORT PROC create(parent) OF paletteObject
self.type:=TYPE_PALETTE
SUPER self.create(parent)
self.disabled:=FALSE
self.initial:=0
self.offset:=0
self.numcols:=4
self.libsused:=[TYPE_PALETTE]
ENDPROC
EXPORT PROC editSettings() OF paletteObject
DEF editForm:PTR TO paletteSettingsForm
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 paletteObject IS
[
makeProp(disabled,FIELDTYPE_CHAR),
makeProp(initial,FIELDTYPE_INT),
makeProp(offset,FIELDTYPE_INT),
makeProp(numcols,FIELDTYPE_INT)
]
EXPORT PROC genCodeProperties(srcGen:PTR TO srcGen) OF paletteObject
srcGen.componentProperty('GA_RelVerify','TRUE',FALSE)
srcGen.componentProperty('GA_TabCycle','TRUE',FALSE)
IF self.disabled THEN srcGen.componentProperty('GA_Disabled','TRUE',FALSE)
IF self.initial<>0 THEN srcGen.componentPropertyInt('PALETTE_Colour',self.initial)
IF self.offset<>0 THEN srcGen.componentPropertyInt('PALETTE_ColourOffset',self.offset)
IF self.numcols<>2 THEN srcGen.componentPropertyInt('PALETTE_NumColours',self.numcols)
ENDPROC
EXPORT PROC genCodeChildProperties(srcGen:PTR TO srcGen) OF paletteObject
srcGen.componentAddChildLabel(self.name)
SUPER self.genCodeChildProperties(srcGen)
ENDPROC
EXPORT PROC getTypeName() OF paletteObject
RETURN 'Palette'
ENDPROC
EXPORT PROC createPaletteObject(parent)
DEF palette:PTR TO paletteObject
NEW palette.create(parent)
ENDPROC palette