-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathguientity_cha.c
More file actions
201 lines (179 loc) · 4.6 KB
/
Copy pathguientity_cha.c
File metadata and controls
201 lines (179 loc) · 4.6 KB
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
#include "types.h"
#include "defs.h"
#include "graphbase.h"
#include "guilayout.h"
#include "ex_mem.h"
#include "guientity_cha.h"
#include "guientity_attrvalue.h"
#include "events.h"
//==============================================
uchar drawCha(dom* elem, int x, int y, int w, int h)
{
int i,j;
uchar picw,pich;
uchar k;
color24 cl;
cha *ent=(cha*)(elem->entity);
int xs=getABSposx(elem)+x;
int ys=getABSposy(elem)+y;
if (ent->chaContent==0)
return 1;
picw=elem->width;
pich=elem->height;
cl = ent->chColor;
for (j=0;j<h;j++)
{
if (y+j>=pich) break;
for (i=0;i<w;i++)
{
if (x+i>=picw) break;
k=*(uchar*)(ent->chaContent+ ((y+j)%pich*picw+(x+i)%picw)*sizeof(uchar) );
if (k==0)
setPixelColor(xs+i,ys+j,cl);
else if (k<255)
setPixelColor(xs+i,ys+j,mingle(getPixelColor(xs+i,ys+j),rgba(cl.r,cl.g,cl.b,k)));
}
}
return 1;
}
uint cha_createDom(cha* chaPtr, int x, int y, int w, int h, uint parent, int pid)
{
memset((uchar*)(&(chaPtr->ds)),0,sizeof(dom));
chaPtr->ds.x=x;
chaPtr->ds.y=y;
chaPtr->ds.width=w;
chaPtr->ds.height=h;
chaPtr->ds._id=(uint)chaPtr;
chaPtr->ds.trans=255;
chaPtr->ds.entity=(void*)chaPtr;
chaPtr->ds.onRender=drawCha;
chaPtr->ds.pid=pid;
chaPtr->ds.onPoint=typicalPointEvent;
chaPtr->ds.onFocus=typicalFocusEvent;
chaPtr->ds.isIntegral=0;
chaPtr->chaContent=0;
chaPtr->chColor=rgb(0,255,0);
chaPtr->ch=0;
if (parent==0xffffffff)
prepend(del,&chaPtr->ds);
else
prepend((dom*)parent,&chaPtr->ds);
return (uint)chaPtr;
}
uint cha_createDomOrphan(cha* chaPtr, int x, int y, int w, int h, int pid)
{
memset((uchar*)(&(chaPtr->ds)),0,sizeof(dom));
chaPtr->ds.x=x;
chaPtr->ds.y=y;
chaPtr->ds.width=w;
chaPtr->ds.height=h;
chaPtr->ds._id=(uint)chaPtr;
chaPtr->ds.trans=255;
chaPtr->ds.entity=(void*)chaPtr;
chaPtr->ds.onRender=drawCha;
chaPtr->ds.pid=pid;
chaPtr->ds.onPoint=typicalPointEvent;
chaPtr->ds.onFocus=typicalFocusEvent;
chaPtr->ds.isIntegral=0;
chaPtr->chaContent=0;
chaPtr->chColor=rgb(0,255,0);
chaPtr->ch=0;
return (uint)chaPtr;
}
uint cha_setColor(uint elem_, color24 color)
{
cha* elem=(cha*)elem_;
elem->chColor=color;
reDraw(&elem->ds);
return (uint)elem;
}
void cha_release(uint elem_)
{
cha* elem=(cha*)elem_;
cha_setContent(elem_,0,0);
if (elem->ds.parent!=0)
delete(&elem->ds);
}
void cha_setContent(uint elem, void* cont, char ch)
{
cha* ent=(cha*)elem;
ent->chaContent=cont;
ent->ch=ch;
reDraw(&ent->ds);
}
void cha_setContentNotRedraw(uint elem, void* cont, char ch)
{
cha* ent=(cha*)elem;
ent->chaContent=cont;
ent->ch=ch;
}
uint cha_setAttr(uint elem_, int attr, void *val)
{
cha *elem=(cha*)elem_;
int i,j;
switch (attr)
{
case GUIATTR_CHA_X:
i=elem->ds.x;
elem->ds.x=*((int*)val);
reDraw_(elem->ds.parent,i,elem->ds.y,elem->ds.width,elem->ds.height);
reDraw(&elem->ds);
return 0;
case GUIATTR_CHA_Y:
j=elem->ds.y;
elem->ds.y=*((int*)val);
reDraw_(elem->ds.parent,elem->ds.x,j,elem->ds.width,elem->ds.height);
reDraw(&elem->ds);
return 0;
case GUIATTR_CHA_WIDTH:
i=elem->ds.width;
elem->ds.width=*((int*)val);
reDraw_(elem->ds.parent,elem->ds.x,elem->ds.y,i,elem->ds.height);
reDraw(&elem->ds);
return 0;
case GUIATTR_CHA_HEIGHT:
j=elem->ds.height;
elem->ds.height=*((int*)val);
reDraw_(elem->ds.parent,elem->ds.x,elem->ds.y,elem->ds.width,j);
reDraw(&elem->ds);
return 0;
case GUIATTR_CHA_COLOR:
elem->chColor=*((color24*)val);
reDraw(&elem->ds);
return 0;
case GUIATTR_CHA_REFRESH:
reDraw(elem->ds.parent);
return 0;
default:
return -1;
}
return 0;
}
uint cha_getAttr(uint elem_, int attr, void *des)
{
cha *elem=(cha*)elem_;
switch (attr)
{
case GUIATTR_CHA_X:
*((int*)des) = elem->ds.x;
break;
case GUIATTR_CHA_Y:
*((int*)des) = elem->ds.y;
break;
case GUIATTR_CHA_WIDTH:
*((int*)des) = elem->ds.width;
break;
case GUIATTR_CHA_HEIGHT:
*((int*)des) = elem->ds.height;
break;
case GUIATTR_CHA_CH:
*((uchar*)des) = elem->ch;
break;
case GUIATTR_CHA_COLOR:
*((color24*)des) = elem->chColor;
break;
default:
return -1;
}
return 0;
}