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
|
-
|
|
!
-
-
|
|
-
|
|
!
!
-
|
|
!
-
|
|
!
-
|
-
|
|
|
!
!
|
#module GraphicalBtn x, y, w, h, gID, gx, gy, wID, oID
#modinit int _x, int _y, int _w, int _h, int _gID, int _gx, int _gy, int _wID, int _oID
x = _x : y = _y w = _w : h = _h gID = _gID : gX = _gX : gY = _gY wID = _wID oID = _oID return
#modfunc draw_gbutton int mode
gsel wID : pos x, y
gcopy gID, gX, gY + h * ( mode != 0 ), w, h
return
#modfunc inside int _x, int _y, local ret
return ( x <= _x ) & ( y <= _y ) & ( _x < x + w ) & ( _y < y + h )
#modfunc get_oID
return oID
#modfunc get_wID
return wID
#global
#module gBtnCtrl
#defcfunc new_oID@gBtnCtrl local iResult
iResult = length( idlist )
foreach idList
if ( idList( cnt ) == 0 ) {
iResult = cnt
break
}
loop
idList( iResult ) = 1
return iResult
#defcfunc oID_pointed local iResult
iResult = -1, -1
foreach gbuttons
get_wID gbuttons( cnt )
gsel stat
inside gbuttons( cnt ), mousex, mousey
if ( stat ) {
if ( stat != ginfo_act ) {
iResult( 1 ) = cnt
} else {
iResult( 0 ) = cnt
break
}
}
loop
return iResult( iResult( 0 ) == -1 )
#deffunc gbutton int gID, int gX, int gY, int w, int h, local oID
oID = new_oID()
newmod gbuttons, GraphicalBtn, ginfo_cx, ginfo_cy, w, h, gID, gX, gY, ginfo_sel, oID
return oID
#deffunc draw_gbuttons
nPointed = oID_pointed()
foreach gbuttons
get_oID gbuttons( cnt )
draw_gbutton gbuttons( cnt ), ( nPointed == stat )
loop
return
#defcfunc get_num int id, local iResult
iResult = -1
foreach gbuttons
get_oID gbuttons( cnt )
if ( stat == id ) {
iResult = cnt
break
}
loop
return iResult
#defcfunc oID_clicked local iResult
iResult = -1
getkey key, 1
if ( oldKey == 0 ) & ( key == 1 ) {
oID_clickstart = oID_pointed()
}
if ( oldKey == 1 ) & ( key == 0 ) {
if ( oID_clickstart == oID_pointed() ) & ( 0 <= oID_clickstart ) {
iResult = oID_clickstart
}
}
oldKey = key
return iResult
#deffunc del_gbutton int id
delmod gbuttons( get_num( id ) )
idList( id ) = 0
return
#deffunc clear_gbuttons
foreach gbuttons
delmod gbuttons( cnt )
loop
dim idList, 1
return
#global
oID_clickstart@gBtnCtrl = -1
|