-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclickTabObject.e
433 lines (359 loc) · 12.7 KB
/
clickTabObject.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
OPT MODULE, OSVERSION=37
MODULE 'reaction/reaction_macros',
'window','classes/window',
'gadgets/layout','layout',
'reaction/reaction_lib',
'button','gadgets/button',
'images/bevel',
'string',
'checkbox','gadgets/checkbox',
'clicktab','gadgets/clicktab',
'gadgets/page',
'gadgets/integer','integer',
'images/label','label',
'amigalib/boopsi',
'libraries/gadtools',
'intuition/intuition',
'intuition/imageclass',
'intuition/gadgetclass'
MODULE '*reactionObject','*reactionForm','*listPicker','*stringlist','*reactionListObject','*reactionLists','*sourceGen','*validator'
EXPORT ENUM CLICKTAB_GAD_IDENT,CLICKTAB_GAD_LABEL, CLICKTAB_GAD_HINT, CLICKTAB_GAD_LISTSELECT,
CLICKTAB_GAD_TOP, CLICKTAB_GAD_LEFT, CLICKTAB_GAD_HEIGHT,
CLICKTAB_GAD_CURRENT, CLICKTAB_GAD_DISABLED,
CLICKTAB_GAD_OK, CLICKTAB_GAD_CHILD, CLICKTAB_GAD_CANCEL
CONST NUM_CLICKTAB_GADS=CLICKTAB_GAD_CANCEL+1
EXPORT OBJECT clickTabObject OF reactionObject
listObjectId:LONG
top:INT
left:INT
height:INT
current:INT
disabled:CHAR
PRIVATE
labels1:PTR TO LONG
pageObject:PTR TO reactionObject
ENDOBJECT
OBJECT clickTabSettingsForm OF reactionForm
PRIVATE
clickTabObject:PTR TO clickTabObject
selectedListId:LONG
ENDOBJECT
PROC create() OF clickTabSettingsForm
DEF gads:PTR TO LONG
NEW gads[NUM_CLICKTAB_GADS]
self.gadgetList:=gads
NEW gads[NUM_CLICKTAB_GADS]
self.gadgetActions:=gads
self.windowObj:=WindowObject,
WA_TITLE, 'ClickTab 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_VERT,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_IDENT ]:=StringObject,
GA_ID, CLICKTAB_GAD_IDENT,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Identifier',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_LABEL ]:=StringObject,
GA_ID, CLICKTAB_GAD_LABEL,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
STRINGA_MAXCHARS, 80,
StringEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, '_Label',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_HINT ]:=ButtonObject,
GA_ID, CLICKTAB_GAD_HINT,
GA_TEXT, 'Hint',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_LISTSELECT ]:=ButtonObject,
GA_ID, CLICKTAB_GAD_LISTSELECT,
GA_TEXT, '_Pick a List',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_TOP ]:=IntegerObject,
GA_ID, CLICKTAB_GAD_TOP,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MINIMUM, 0,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, '_Top',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_LEFT ]:=IntegerObject,
GA_ID, CLICKTAB_GAD_LEFT,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MINIMUM, 0,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, '_Left',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_HEIGHT ]:=IntegerObject,
GA_ID, CLICKTAB_GAD_HEIGHT,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MINIMUM, 0,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Hei_ght',
LabelEnd,
LayoutEnd,
LAYOUT_ADDCHILD, LayoutObject,
LAYOUT_ORIENTATION, LAYOUT_ORIENT_HORIZ,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_CURRENT ]:=IntegerObject,
GA_ID, CLICKTAB_GAD_CURRENT,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
INTEGER_MINIMUM, 0,
IntegerEnd,
CHILD_LABEL, LabelObject,
LABEL_TEXT, 'Cur_rent',
LabelEnd,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_DISABLED ]:=CheckBoxObject,
GA_ID, CLICKTAB_GAD_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[ CLICKTAB_GAD_OK ]:=ButtonObject,
GA_ID, CLICKTAB_GAD_OK,
GA_TEXT, '_OK',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_CHILD ]:=ButtonObject,
GA_ID, CLICKTAB_GAD_CHILD,
GA_TEXT, 'C_hild',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LAYOUT_ADDCHILD, self.gadgetList[ CLICKTAB_GAD_CANCEL ]:=ButtonObject,
GA_ID, CLICKTAB_GAD_CANCEL,
GA_TEXT, '_Cancel',
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
ButtonEnd,
LayoutEnd,
LayoutEnd,
LayoutEnd,
WindowEnd
self.gadgetActions[CLICKTAB_GAD_LISTSELECT]:={selectList}
self.gadgetActions[CLICKTAB_GAD_CHILD]:={editChildSettings}
self.gadgetActions[CLICKTAB_GAD_HINT]:={editHint}
self.gadgetActions[CLICKTAB_GAD_CANCEL]:=MR_CANCEL
self.gadgetActions[CLICKTAB_GAD_OK]:=MR_OK
ENDPROC
PROC selectList(nself,gadget,id,code) OF clickTabSettingsForm
DEF frmListPicker:PTR TO listPickerForm
DEF res
self:=nself
self.setBusy()
NEW frmListPicker.create()
IF (res:=frmListPicker.selectList())<>-1
self.selectedListId:=res
ENDIF
END frmListPicker
self.clearBusy()
ENDPROC
PROC editHint(nself,gadget,id,code) OF clickTabSettingsForm
self:=nself
self.setBusy()
self.clickTabObject.editHint()
self.clearBusy()
self.updateHint(CLICKTAB_GAD_HINT, self.clickTabObject.hintText)
ENDPROC
PROC editChildSettings(nself,gadget,id,code) OF clickTabSettingsForm
self:=nself
self.setBusy()
self.clickTabObject.editChildSettings()
self.clearBusy()
ENDPROC
PROC end() OF clickTabSettingsForm
END self.gadgetList[NUM_CLICKTAB_GADS]
END self.gadgetActions[NUM_CLICKTAB_GADS]
DisposeObject(self.windowObj)
ENDPROC
EXPORT PROC canClose(modalRes) OF clickTabSettingsForm
DEF res
IF modalRes=MR_CANCEL THEN RETURN TRUE
IF checkIdent(self,self.clickTabObject,CLICKTAB_GAD_IDENT)=FALSE
RETURN FALSE
ENDIF
ENDPROC TRUE
PROC editSettings(comp:PTR TO clickTabObject) OF clickTabSettingsForm
DEF res
self.clickTabObject:=comp
self.selectedListId:=comp.listObjectId
self.updateHint(CLICKTAB_GAD_HINT, comp.hintText)
SetGadgetAttrsA(self.gadgetList[ CLICKTAB_GAD_IDENT ],0,0,[STRINGA_TEXTVAL,comp.ident,0])
SetGadgetAttrsA(self.gadgetList[ CLICKTAB_GAD_LABEL ],0,0,[STRINGA_TEXTVAL,comp.label,0])
SetGadgetAttrsA(self.gadgetList[ CLICKTAB_GAD_TOP ],0,0,[INTEGER_NUMBER,comp.top,0])
SetGadgetAttrsA(self.gadgetList[ CLICKTAB_GAD_LEFT ],0,0,[INTEGER_NUMBER,comp.left,0])
SetGadgetAttrsA(self.gadgetList[ CLICKTAB_GAD_HEIGHT ],0,0,[INTEGER_NUMBER,comp.height,0])
SetGadgetAttrsA(self.gadgetList[ CLICKTAB_GAD_CURRENT ],0,0,[INTEGER_NUMBER,comp.current,0])
SetGadgetAttrsA(self.gadgetList[ CLICKTAB_GAD_DISABLED ],0,0,[CHECKBOX_CHECKED,comp.disabled,0])
res:=self.showModal()
IF res=MR_OK
AstrCopy(comp.ident,Gets(self.gadgetList[ CLICKTAB_GAD_IDENT ],STRINGA_TEXTVAL))
AstrCopy(comp.label,Gets(self.gadgetList[ CLICKTAB_GAD_LABEL ],STRINGA_TEXTVAL))
comp.listObjectId:=self.selectedListId
comp.top:=Gets(self.gadgetList[ CLICKTAB_GAD_TOP ],INTEGER_NUMBER)
comp.left:=Gets(self.gadgetList[ CLICKTAB_GAD_LEFT ],INTEGER_NUMBER)
comp.height:=Gets(self.gadgetList[ CLICKTAB_GAD_HEIGHT ],INTEGER_NUMBER)
comp.current:=Gets(self.gadgetList[ CLICKTAB_GAD_CURRENT ],INTEGER_NUMBER)
comp.disabled:=Gets(self.gadgetList[ CLICKTAB_GAD_DISABLED ],CHECKBOX_CHECKED)
ENDIF
ENDPROC res=MR_OK
PROC makeClickTabsList(id) OF clickTabObject
DEF i,res
DEF reactionList=0:PTR TO reactionListObject
DEF findObject:PTR TO reactionListObject
DEF newlist
DEF reactionLists:PTR TO stdlist
reactionLists:=getReactionLists()
FOR i:=0 TO reactionLists.count()-1
findObject:=reactionLists.item(i)
IF findObject.id = id
reactionList:=findObject
ENDIF
ENDFOR
IF reactionList
newlist:=List(reactionList.items.count()+1)
FOR i:=0 TO reactionList.items.count()-1
ListAddItem(newlist,reactionList.items.item(i))
ENDFOR
ELSE
newlist:=List(1)
ENDIF
ListAddItem(newlist,0)
res:=clickTabsA(newlist)
DisposeLink(newlist)
ENDPROC res
EXPORT PROC createPreviewObject(scr) OF clickTabObject
IF self.labels1 THEN freeClickTabs( self.labels1 )
self.previewObject:=ClickTabObject,
GA_ID, self.id,
GA_RELVERIFY, TRUE,
GA_TABCYCLE, TRUE,
GA_DISABLED, self.disabled,
GA_TOP, self.top,
GA_LEFT, self.left,
GA_HEIGHT, self.height,
CLICKTAB_CURRENT, self.current,
CLICKTAB_LABELS, self.labels1:=self.makeClickTabsList(self.listObjectId),
CLICKTAB_PAGEGROUP, self.pageObject:=PageObject,
LAYOUT_DEFERLAYOUT, TRUE,
PageEnd,
ClickTabEnd
IF self.previewObject=0 THEN self.previewObject:=self.createErrorObject(scr)
self.makePreviewChildAttrs(0)
ENDPROC
EXPORT PROC create(parent) OF clickTabObject
self.type:=TYPE_CLICKTAB
SUPER self.create(parent)
self.listObjectId:=-1
self.top:=0
self.left:=0
self.height:=0
self.current:=0
self.disabled:=0
self.labels1:=0
self.libsused:=[TYPE_CLICKTAB]
ENDPROC
PROC end() OF clickTabObject
freeClickTabs( self.labels1 )
SUPER self.end()
ENDPROC
EXPORT PROC editSettings() OF clickTabObject
DEF editForm:PTR TO clickTabSettingsForm
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 clickTabObject IS
[
makeProp(listObjectId,FIELDTYPE_LONG),
makeProp(top,FIELDTYPE_INT),
makeProp(left,FIELDTYPE_INT),
makeProp(height,FIELDTYPE_INT),
makeProp(current,FIELDTYPE_INT),
makeProp(disabled,FIELDTYPE_CHAR)
]
EXPORT PROC genCodeProperties(srcGen:PTR TO srcGen) OF clickTabObject
DEF tempStr[200]:STRING
srcGen.componentProperty('GA_RelVerify','TRUE',FALSE)
srcGen.componentProperty('GA_TabCycle','TRUE',FALSE)
IF self.disabled THEN srcGen.componentProperty('GA_Disabled','TRUE',FALSE)
srcGen.componentPropertyInt('GA_Left',self.left)
srcGen.componentPropertyInt('GA_Top',self.top)
srcGen.componentPropertyInt('GA_Height',self.height)
IF self.current THEN srcGen.componentPropertyInt('CLICKTAB_Current',self.current)
IF self.listObjectId>=0
StringF(tempStr,'labels\d',self.id)
srcGen.componentProperty('CLICKTAB_Labels',tempStr,FALSE)
ENDIF
ENDPROC
EXPORT PROC genChildObjectsHeader(srcGen:PTR TO srcGen) OF clickTabObject
srcGen.componentProperty('CLICKTAB_PageGroup','PageObject',FALSE)
srcGen.increaseIndent()
srcGen.componentProperty('LAYOUT_DeferLayout','TRUE',FALSE)
ENDPROC
EXPORT PROC genChildObjectsFooter(srcGen:PTR TO srcGen) OF clickTabObject
srcGen.componentEnd('PageEnd,')
ENDPROC
EXPORT PROC genCodeChildProperties(srcGen:PTR TO srcGen) OF clickTabObject
srcGen.componentAddChildLabel(self.label)
SUPER self.genCodeChildProperties(srcGen)
ENDPROC
EXPORT PROC getTypeName() OF clickTabObject
RETURN 'ClickTab'
ENDPROC
EXPORT PROC allowChildren() OF clickTabObject IS -1
EXPORT PROC addChildTag() OF clickTabObject IS PAGE_ADD
EXPORT PROC removeChildTag() OF clickTabObject IS PAGE_REMOVE
EXPORT PROC addImageTag() OF clickTabObject IS PAGE_ADD
EXPORT PROC addChildTo() OF clickTabObject IS self.pageObject
EXPORT PROC createClickTabObject(parent)
DEF clickTab:PTR TO clickTabObject
NEW clickTab.create(parent)
ENDPROC clickTab