-
Notifications
You must be signed in to change notification settings - Fork 3
/
reactionForm.e
107 lines (90 loc) · 3.02 KB
/
reactionForm.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
OPT MODULE, OSVERSION=37
MODULE 'reaction/reaction_macros',
'classes/window',
'intuition/gadgetclass',
'reaction/reaction_lib',
'gadgets/button',
'amigalib/boopsi',
'intuition/intuition'
MODULE '*stringlist'
EXPORT ENUM MR_NONE, MR_OK, MR_CANCEL
EXPORT OBJECT reactionForm
windowObj:LONG
modalResult:LONG
gadgetList:PTR TO LONG
gadgetActions:PTR TO LONG
hintText:PTR TO CHAR
hintInfo:PTR TO hintinfo
ENDOBJECT
EXPORT PROC gadgetPress(id,codeval) OF reactionForm
DEF action,gadget
IF (action:=self.gadgetActions[id])
IF (action=MR_OK) OR (action=MR_CANCEL)
IF self.canClose(action) THEN self.modalResult:=action
ELSE
gadget:=self.gadgetList[id]
action(self,gadget,id,codeval)
ENDIF
ENDIF
ENDPROC
EXPORT PROC setBusy() OF reactionForm
IF self.windowObj THEN Sets(self.windowObj,WA_BUSYPOINTER,TRUE)
ENDPROC
EXPORT PROC clearBusy() OF reactionForm
IF self.windowObj THEN Sets(self.windowObj,WA_BUSYPOINTER,FALSE)
ENDPROC
EXPORT PROC canClose(modalRes) OF reactionForm IS TRUE
EXPORT PROC ticker() OF reactionForm IS 0
EXPORT PROC menuPick(menu,menuitem,subItem) OF reactionForm IS 0
PROC updateHint(gadid,hintText:PTR TO stringlist) OF reactionForm
DEF win
win:=Gets(self.windowObj,WINDOW_WINDOW)
IF self.hintInfo=0
self.hintInfo:=New(SIZEOF hintinfo*2)
self.hintInfo.code:=-1
self.hintInfo[1].gadgetid:=-1
self.hintInfo[1].code:=-1
ENDIF
self.hintInfo.gadgetid:=gadid
SetGadgetAttrsA(self.gadgetList[ gadid ],win,0,[BUTTON_TEXTPEN,IF hintText.count() THEN 2 ELSE 1,0])
IF self.hintText THEN DisposeLink(self.hintText)
self.hintText:=hintText.makeTextString()
self.hintInfo.text:=self.hintText
Sets(self.windowObj,WINDOW_HINTINFO,self.hintInfo)
Sets(self.windowObj,WINDOW_GADGETHELP,TRUE)
ENDPROC
EXPORT PROC showModal() OF reactionForm HANDLE
DEF running=TRUE,menu,menuitem,subitem
DEF win:PTR TO window,wsig,code,tmp,sig,result=0
self.modalResult:=MR_NONE
IF (win:=RA_OpenWindow(self.windowObj))
GetAttr( WINDOW_SIGMASK, self.windowObj, {wsig} )
WHILE running AND (self.modalResult=MR_NONE)
sig:=Wait(wsig)
IF (sig AND (wsig))
WHILE ((result:=RA_HandleInput(self.windowObj,{code}+2)) <> WMHI_LASTMSG)
tmp:=(result AND WMHI_CLASSMASK)
SELECT tmp
CASE WMHI_GADGETUP
self.gadgetPress(result AND $FFFF,code AND $FFFF)
CASE WMHI_CLOSEWINDOW
IF self.canClose(MR_CANCEL) THEN running:=FALSE
CASE WMHI_INTUITICK
self.ticker()
CASE WMHI_MENUPICK
menu:=MENUNUM(result)
menuitem:=ITEMNUM(result)
subitem:=SUBNUM(result)
self.menuPick(menu,menuitem,subitem)
ENDSELECT
ENDWHILE
ENDIF
ENDWHILE
RA_CloseWindow(self.windowObj)
ELSE
Raise("WIN")
ENDIF
IF self.hintText THEN DisposeLink(self.hintText)
IF self.hintInfo THEN Dispose(self.hintInfo)
EXCEPT DO
ENDPROC self.modalResult