FreeCalypso > hg > tcs211-c139
comparison g23m/condat/ms/src/mfw/mfw_icn.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +--------------------------------------------------------------------+ | |
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_icn.c $| | |
4 | $Author:: Es $ CONDAT GmbH $Revision:: 6 $| | |
5 | CREATED: 24.11.98 $Modtime:: 23.03.00 8:36 $| | |
6 | STATE : code | | |
7 +--------------------------------------------------------------------+ | |
8 | |
9 MODULE : MFW_ICN | |
10 | |
11 PURPOSE : icon handling functions | |
12 | |
13 EXPORT : | |
14 | |
15 TO DO : | |
16 | |
17 $History:: mfw_icn.c $ | |
18 * | |
19 * ***************** Version 6 ***************** | |
20 * User: Es Date: 23.03.00 Time: 14:41 | |
21 * Updated in $/GSM/Condat/MS/SRC/MFW | |
22 * Added icnUnhide(); removed 'update()' from 'hide()' and 'unhide()' | |
23 | | |
24 | ***************** Version 5 ***************** | |
25 | User: Le Date: 6.01.00 Time: 9:23 | |
26 | Updated in $/GSM/Condat/MS/SRC/MFW | |
27 | Alignment of MFW versions | |
28 * | |
29 * ***************** Version 4 ***************** | |
30 * User: Rm Date: 12/03/99 Time: 10:15a | |
31 * Updated in $/GSM/Condat/SND-MMI/MFW | |
32 * new parameter by icnCycle | |
33 * | |
34 * ***************** Version 3 ***************** | |
35 * User: Es Date: 24.11.99 Time: 11:54 | |
36 * Updated in $/GSM/Condat/SND-MMI/MFW | |
37 * improved 'icnHide()' (really hides the icon now). | |
38 * | |
39 * ***************** Version 2 ***************** | |
40 * User: Es Date: 22.11.99 Time: 10:29 | |
41 * Updated in $/GSM/Condat/SND-MMI/MFW | |
42 * | |
43 * ***************** Version 1 ***************** | |
44 * User: Es Date: 18.11.99 Time: 16:35 | |
45 * Created in $/GSM/Condat/SND-MMI/MFW | |
46 * Initial | |
47 */ | |
48 | |
49 #include "mfw_sys.h" | |
50 #include "mfw_mfw.h" | |
51 #include "gdi.h" | |
52 #include "dspl.h" | |
53 #include "mfw_icn.h" | |
54 | |
55 | |
56 static int icnCommand (U32 cmd, void *h); | |
57 | |
58 | |
59 /* | |
60 +--------------------------------------------------------------------+ | |
61 | PROJECT : MMI-Framework (8417) MODULE : MFW_ICN | | |
62 | STATE : code ROUTINE : icnInit | | |
63 +--------------------------------------------------------------------+ | |
64 | |
65 PURPOSE : initialize icon handler | |
66 | |
67 */ | |
68 | |
69 MfwRes icnInit (void) | |
70 { | |
71 mfwCommand[MfwTypIcn] = (MfwCb) icnCommand; | |
72 | |
73 return MfwResOk; | |
74 } | |
75 | |
76 | |
77 /* | |
78 +--------------------------------------------------------------------+ | |
79 | PROJECT : MMI-Framework (8417) MODULE : MFW_ICN | | |
80 | STATE : code ROUTINE : icnExit | | |
81 +--------------------------------------------------------------------+ | |
82 | |
83 PURPOSE : finalize icon handler | |
84 | |
85 */ | |
86 | |
87 MfwRes icnExit (void) | |
88 { | |
89 mfwCommand[MfwTypIcn] = 0; | |
90 | |
91 return MfwResOk; | |
92 } | |
93 | |
94 | |
95 /* | |
96 +--------------------------------------------------------------------+ | |
97 | PROJECT : MMI-Framework (8417) MODULE : MFW_ICN | | |
98 | STATE : code ROUTINE : icnCreate | | |
99 +--------------------------------------------------------------------+ | |
100 | |
101 PURPOSE : create icon control | |
102 | |
103 */ | |
104 | |
105 MfwHnd icnCreate (MfwHnd w, MfwIcnAttr * a, MfwEvt e, MfwCb f) | |
106 { | |
107 MfwHdr *hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr)); | |
108 MfwIcn *icn = (MfwIcn *) mfwAlloc(sizeof(MfwIcn)); | |
109 MfwHdr *insert_status =0; | |
110 | |
111 if (!hdr || !icn) | |
112 { | |
113 TRACE_ERROR("ERROR: icnCreate() Mem Alloc Failed."); | |
114 | |
115 if(hdr) | |
116 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
117 if(icn) | |
118 mfwFree((U8*)icn,sizeof(MfwIcn)); | |
119 return 0; | |
120 } | |
121 | |
122 icn->mask = e; | |
123 icn->flags = 0; | |
124 icn->handler = f; | |
125 icn->attr = a; | |
126 icn->index = 0; | |
127 | |
128 hdr->data = icn; | |
129 hdr->type = MfwTypIcn; | |
130 | |
131 insert_status = mfwInsert(w, hdr); | |
132 | |
133 if(!insert_status) | |
134 { | |
135 TRACE_ERROR("ERROR: icnCreate() Failed to Install Handler. "); | |
136 mfwFree((U8*)hdr,sizeof(MfwHdr)); | |
137 mfwFree((U8*)icn,sizeof(MfwIcn)); | |
138 return 0; | |
139 } | |
140 return insert_status; | |
141 } | |
142 | |
143 | |
144 /* | |
145 +--------------------------------------------------------------------+ | |
146 | PROJECT : MMI-Framework (8417) MODULE : MFW_ICN | | |
147 | STATE : code ROUTINE : icnDelete | | |
148 +--------------------------------------------------------------------+ | |
149 | |
150 PURPOSE : delete icon control | |
151 | |
152 */ | |
153 | |
154 MfwRes icnDelete (MfwHnd i) | |
155 { | |
156 MfwRes res; | |
157 | |
158 if (!i) | |
159 return MfwResIllHnd; | |
160 | |
161 icnHide(i); | |
162 res = (mfwRemove(i)) ? MfwResOk : MfwResIllHnd; | |
163 | |
164 mfwFree(((MfwHdr *) i)->data,sizeof(MfwIcn)); | |
165 mfwFree(i,sizeof(MfwHdr)); | |
166 | |
167 return res; | |
168 } | |
169 | |
170 | |
171 /* | |
172 +--------------------------------------------------------------------+ | |
173 | PROJECT : MMI-Framework (8417) MODULE : MFW_ICN | | |
174 | STATE : code ROUTINE : icnShow | | |
175 +--------------------------------------------------------------------+ | |
176 | |
177 PURPOSE : show icon | |
178 | |
179 */ | |
180 | |
181 MfwRes icnShow (MfwHnd i) | |
182 { | |
183 MfwIcn *icn; | |
184 | |
185 if (!i) | |
186 return MfwResIllHnd; | |
187 | |
188 icn = ((MfwHdr *) i)->data; | |
189 icn->flags |= E_ICN_VISIBLE; | |
190 | |
191 return icnUpdate(icn); | |
192 } | |
193 | |
194 | |
195 /* | |
196 +--------------------------------------------------------------------+ | |
197 | PROJECT : MMI-Framework (8417) MODULE : MFW_ICN | | |
198 | STATE : code ROUTINE : icnHide | | |
199 +--------------------------------------------------------------------+ | |
200 | |
201 PURPOSE : hide icon (without drawing) | |
202 | |
203 */ | |
204 | |
205 MfwRes icnHide (MfwHnd i) | |
206 { | |
207 MfwIcn *icn; | |
208 | |
209 if (!i) | |
210 return MfwResIllHnd; /* icon does not exist */ | |
211 | |
212 icn = ((MfwHdr *) i)->data; /* get control block */ | |
213 icn->flags &= ~E_ICN_VISIBLE; /* icon is not visible */ | |
214 icn->index = 0; | |
215 if (icn->handler) | |
216 if (icn->mask & E_ICN_VISIBLE) | |
217 icn->handler(E_ICN_VISIBLE,icn); | |
218 | |
219 return MfwResOk; | |
220 } | |
221 | |
222 | |
223 /* | |
224 +--------------------------------------------------------------------+ | |
225 | PROJECT : MMI-Framework (8417) MODULE : MFW_ICN | | |
226 | STATE : code ROUTINE : icnUnhide | | |
227 +--------------------------------------------------------------------+ | |
228 | |
229 PURPOSE : unhide icon (without drawing) | |
230 | |
231 */ | |
232 | |
233 MfwRes icnUnhide (MfwHnd i) | |
234 { | |
235 MfwIcn *icn; | |
236 | |
237 if (!i) | |
238 return MfwResIllHnd; /* icon does not exist */ | |
239 | |
240 icn = ((MfwHdr *) i)->data; /* get control block */ | |
241 icn->flags |= E_ICN_VISIBLE; /* icon is visible */ | |
242 icn->index = 0; | |
243 if (icn->handler) | |
244 if (icn->mask & E_ICN_VISIBLE) | |
245 icn->handler(E_ICN_VISIBLE,icn); | |
246 | |
247 return MfwResOk; | |
248 } | |
249 | |
250 | |
251 /* | |
252 +--------------------------------------------------------------------+ | |
253 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU | | |
254 | STATE : code ROUTINE : icnUpdate | | |
255 +--------------------------------------------------------------------+ | |
256 | |
257 PURPOSE : draw icon | |
258 | |
259 */ | |
260 | |
261 MfwRes icnUpdate (MfwIcn *i) | |
262 { | |
263 if (!i) | |
264 return MfwResIllHnd; | |
265 | |
266 if (!(i->flags & E_ICN_VISIBLE)) | |
267 { | |
268 dspl_Clear(i->attr->area.px,i->attr->area.py, | |
269 (U16)(i->attr->area.px+i->attr->area.sx-1), | |
270 (U16)(i->attr->area.py+i->attr->area.sy-1)); | |
271 } | |
272 else | |
273 { | |
274 dspl_BitBlt2(i->attr->area.px,i->attr->area.py, | |
275 i->attr->area.sx,i->attr->area.sy, | |
276 i->attr->icons,i->index,i->attr->icnType); | |
277 } | |
278 | |
279 if (i->handler) | |
280 if (i->mask & E_ICN_VISIBLE) | |
281 i->handler(E_ICN_VISIBLE, i); | |
282 | |
283 return MfwResOk; | |
284 } | |
285 | |
286 /* | |
287 +--------------------------------------------------------------------+ | |
288 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU | | |
289 | STATE : code ROUTINE : icnCycle | | |
290 +--------------------------------------------------------------------+ | |
291 | |
292 PURPOSE : one-step-icon-animation | |
293 | |
294 */ | |
295 | |
296 MfwRes icnCycle (MfwHnd i,int offset) | |
297 { | |
298 MfwIcn *icn; | |
299 | |
300 if (!i) return MfwResIllHnd; | |
301 if (((MfwHdr *) i)->type != MfwTypIcn) return MfwResIllHnd; | |
302 | |
303 icn = ((MfwHdr *) i)->data; | |
304 | |
305 icn->index = (U8) ((icn->index + offset) % icn->attr->nIcons); | |
306 | |
307 dspl_BitBlt(icn->attr->area.px,icn->attr->area.py, | |
308 icn->attr->area.sx,icn->attr->area.sy, | |
309 icn->index,icn->attr->icons,0); | |
310 | |
311 return MfwResOk; | |
312 } | |
313 | |
314 | |
315 /* | |
316 +--------------------------------------------------------------------+ | |
317 | PROJECT : MMI-Framework (8417) MODULE : MFW_ICN | | |
318 | STATE : code ROUTINE : icnCommand | | |
319 +--------------------------------------------------------------------+ | |
320 | |
321 PURPOSE : handle mfw windows command | |
322 | |
323 */ | |
324 | |
325 static int icnCommand (U32 cmd, void *h) | |
326 { | |
327 switch (cmd) | |
328 { | |
329 case MfwCmdDelete: /* delete me */ | |
330 if (!h) | |
331 return 0; | |
332 icnDelete(h); | |
333 return 1; | |
334 case MfwCmdUpdate: /* repaint */ | |
335 if (!h || ((MfwHdr *) h)->type != MfwTypIcn) | |
336 return 0; | |
337 icnUpdate(((MfwHdr *) h)->data); | |
338 return 1; | |
339 default: | |
340 break; | |
341 } | |
342 | |
343 return 0; | |
344 } | |
345 |