comparison src/ui3/mfw/mfw_win.c @ 420:e8ddbb0837ed

src/ui3: initial import of TCS3/LoCosto BMI & MFW code
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 Jan 2018 03:09:00 +0000
parents
children
comparison
equal deleted inserted replaced
419:59143cd42ec7 420:e8ddbb0837ed
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_win.c $|
4 | $Author:: Es $ CONDAT GmbH $Revision:: 21 $|
5 | CREATED: 21.09.98 $Modtime:: 23.03.00 9:08 $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : MFW_WIN
10
11 PURPOSE : window handling functions
12
13 EXPORT :
14
15 TO DO :
16
17 $History:: mfw_win.c $
18
19 Oct 09, 2006 DR: OMAPS00095308 - xreddymn
20 Description: mfwFocus is NULL when window callback function for MfwWinResume
21 is invoked in winDelete.
22 Solution: After deleting a window and all its components, set mfwFocus to
23 the previous window, before calling window callback function for
24 MfwWinResume.
25
26 Mar 30, 2005 REF: CRR 29986 xpradipg
27 Description: Optimisation 1: Removal of unused variables and dynamically
28 allocate/ deallocate mbndata
29 Solution: removed the unused varialbe mfw_twh_strlen
30
31 * textMessage
32 * ***************** Version 21 *****************
33 * User: Es Date: 23.03.00 Time: 14:42
34 * Updated in $/GSM/Condat/MS/SRC/MFW
35 * Added 'winUnhide()': no update(), no event.
36 *
37 * ***************** Version 20 *****************
38 * User: Kk Date: 14.03.00 Time: 15:52
39 * Updated in $/GSM/Condat/MS/SRC/MFW
40 * changed update sequence
41 *
42 * ***************** Version 19 *****************
43 * User: Es Date: 3.03.00 Time: 12:04
44 * Updated in $/GSM/Condat/MS/SRC/MFW
45 * winUpdate(): first update windows children, then! call event
46 * handler
47 *
48 * ***************** Version 18 *****************
49 * User: Es Date: 18.02.00 Time: 17:46
50 * Updated in $/GSM/Condat/MS/SRC/MFW
51 * danger in winUpdate
52 *
53 * ***************** Version 17 *****************
54 * User: Nm Date: 17.02.00 Time: 9:23
55 * Updated in $/GSM/Condat/MS/SRC/MFW
56 * updated winIsFocussed
57 *
58 * ***************** Version 16 *****************
59 * User: Kk Date: 17.01.00 Time: 8:56
60 * Updated in $/GSM/Condat/MS/SRC/MFW
61 * added simple check functions for easy checking if win is visible,
62 * focussed, closed
63 *
64 * ***************** Version 15 *****************
65 * User: Kk Date: 10.01.00 Time: 13:46
66 * Updated in $/GSM/Condat/MS/SRC/MFW
67 * some changes done by ES
68 *
69 * ***************** Version 3 *****************
70 * User: Rm Date: 12/22/99 Time: 4:34p
71 * Updated in $/GSM/Condat/SND-MMI/MFW
72 *
73 * ***************** Version 2 *****************
74 * User: Es Date: 22.11.99 Time: 10:30
75 * Updated in $/GSM/Condat/SND-MMI/MFW
76 *
77 * ***************** Version 1 *****************
78 * User: Es Date: 18.11.99 Time: 16:35
79 * Created in $/GSM/Condat/SND-MMI/MFW
80 * Initial
81 *
82 * ***************** Version 13 *****************
83 * User: Es Date: 6.07.99 Time: 12:37
84 * Updated in $/GSM/DEV/MS/SRC/MFW
85 *
86 * ***************** Version 11 *****************
87 * User: Es Date: 14.04.99 Time: 17:34
88 * Updated in $/GSM/DEV/MS/SRC/MFW
89 * moved to CST
90 |
91 | ***************** Version 10 *****************
92 | User: Le Date: 14.04.99 Time: 9:51
93 | Updated in $/GSM/DEV/MS/SRC/MFW
94 *
95 * ***************** Version 9 *****************
96 * User: Es Date: 1.04.99 Time: 17:07
97 * Updated in $/GSM/DEV/MS/SRC/MFW
98 * removed lots of traces
99 *
100 * ***************** Version 8 *****************
101 * User: Es Date: 20.02.99 Time: 19:24
102 * Updated in $/GSM/DEV/MS/SRC/MFW
103 *
104 * ***************** Version 7 *****************
105 * User: Es Date: 20.02.99 Time: 18:22
106 * Updated in $/GSM/DEV/MS/SRC/MFW
107 *
108 * ***************** Version 6 *****************
109 * User: Es Date: 20.02.99 Time: 15:37
110 * Updated in $/GSM/DEV/MS/SRC/MFW
111 *
112 * ***************** Version 5 *****************
113 * User: Es Date: 18.02.99 Time: 17:01
114 * Updated in $/GSM/DEV/MS/SRC/MFW
115 *
116 * ***************** Version 4 *****************
117 * User: Es Date: 17.02.99 Time: 19:11
118 * Updated in $/GSM/DEV/MS/SRC/MFW
119 *
120 * ***************** Version 3 *****************
121 * User: Es Date: 14.01.99 Time: 17:19
122 * Updated in $/GSM/DEV/MS/SRC/MFW
123 *
124 * ***************** Version 2 *****************
125 * User: Es Date: 23.12.98 Time: 16:19
126 * Updated in $/GSM/DEV/MS/SRC/MFW
127 */
128
129
130 #define ENTITY_MFW
131
132 #if defined (NEW_FRAME)
133
134 #include "typedefs.h"
135 #include "vsi.h"
136 #include "custom.h"
137 #include "gsm.h"
138
139 #else
140
141 #include "STDDEFS.H"
142 #include "custom.h"
143 #include "gsm.h"
144 #include "vsi.h"
145
146 #endif
147
148 #include "mfw_mfw.h"
149 #include "mfw_sys.h"
150 #include "gdi.h"
151 #include "dspl.h"
152 #include "mfw_win.h"
153
154 static MfwHdr *autoFocus; /* focus of toplevel window */
155 static U8 winUseAutoFocus = 0; /* automatic focussing flag */
156 static int winCommand (U32 cmd, void *h);
157
158
159
160 /*
161 +--------------------------------------------------------------------+
162 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
163 | STATE : code ROUTINE : winInit |
164 +--------------------------------------------------------------------+
165
166 PURPOSE : initialize window handler
167
168 */
169
170 MfwRes winInit (U16 *sx, U16 *sy)
171 {
172 dspl_DevCaps displayData;
173
174 dspl_Init(); /* init display driver */
175
176 displayData.DisplayType = DSPL_TYPE_GRAPHIC;
177 dspl_SetDeviceCaps(&displayData);
178 dspl_GetDeviceCaps(&displayData);
179 *sx = displayData.Width;
180 *sy = displayData.Height;
181 winUseAutoFocus = 0;
182
183 mfwCommand[MfwTypWin] = (MfwCb) winCommand;
184
185 return MfwResOk;
186 }
187
188
189 /*
190 +--------------------------------------------------------------------+
191 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
192 | STATE : code ROUTINE : winExit |
193 +--------------------------------------------------------------------+
194
195 PURPOSE : finalize window handler
196
197 */
198
199 MfwRes winExit (void)
200 {
201 mfwCommand[MfwTypWin] = 0;
202 dspl_Exit(); /* finit display driver */
203
204 return MfwResOk;
205 }
206
207
208 /*
209 +--------------------------------------------------------------------+
210 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
211 | STATE : code ROUTINE : winCreate |
212 +--------------------------------------------------------------------+
213
214 PURPOSE : create window control
215
216 */
217
218 MfwHnd winCreate (MfwHnd w, MfwWinAttr *a, MfwEvt e, MfwCb f)
219 {
220
221
222 MfwHdr *hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr));
223 MfwWin *win = (MfwWin *) mfwAlloc(sizeof(MfwWin));
224 MfwHdr *eoc = (MfwHdr *) mfwAlloc(sizeof(MfwHdr));
225 MfwHdr *insert_status =0;
226
227 /* xreddymn Aug-09-2004, MMI-SPR-23964 (TII_MMS33)
228 * Implemented suspend and resume functionality for MFW windows
229 * The following code posts MfwWinSuspend event
230 */
231 MfwWin *ee;
232 MfwHnd window;
233 window = mfwParent(mfwFocus);
234 if(window)
235 {
236 ee = (MfwWin*) ((MfwHdr *) window)->data;
237 if(ee && (((MfwHdr *) window)->type == MfwTypWin))
238 {
239 if (ee->handler && ee->mask & MfwWinSuspend)
240 {
241 /*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
242 (void)(ee->handler(MfwWinSuspend,ee));
243 }
244 }
245 }
246 if (!hdr || !win || !eoc)
247 {
248 TRACE_ERROR("ERROR: winCreate() Mem Alloc Failed.");
249
250 if(hdr)
251 mfwFree((U8*)hdr,sizeof(MfwHdr));
252
253 if(win)
254 mfwFree((U8*)win,sizeof(MfwWin));
255
256 if(eoc)
257 mfwFree((U8*)eoc,sizeof(MfwHdr));
258
259 return 0;
260 }
261
262 eoc->next = hdr; /* setup eoc element */
263 eoc->type = MfwTypMax;
264 eoc->data = 0;
265
266 win->mask = e; /* setup window control */
267 win->flags = 0;
268 win->handler = f;
269 win->attr = a;
270 win->elems = eoc;
271 win->user = 0;
272
273 hdr->data = win; /* setup header element */
274 hdr->type = MfwTypWin;
275
276 if (mfwSignallingMethod == 0)
277 insert_status = mfwInsert(w,hdr);
278 else
279 {
280 insert_status = mfwInsert(mfwParent(mfwFocus),hdr);
281 mfwSetFocus(eoc);
282 }
283
284 /* Release memory if handler installation failed. */
285 if(!insert_status)
286 {
287 TRACE_ERROR("ERROR: winCreate() Failed to Install Handler. ");
288 mfwFree((U8*)hdr,sizeof(MfwHdr));
289 mfwFree((U8*)win,sizeof(MfwWin));
290 mfwFree((U8*)eoc,sizeof(MfwHdr));
291 return 0;
292 }
293
294 return insert_status;
295 }
296
297
298 /*
299 +--------------------------------------------------------------------+
300 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
301 | STATE : code ROUTINE : winDelete |
302 +--------------------------------------------------------------------+
303
304 PURPOSE : delete window control
305
306 */
307
308 MfwRes winDelete (MfwHnd w)
309 {
310 MfwCb f;
311 MfwHdr *e, *t, *r;
312 MfwRes res;
313
314 /*NM, p012a*/
315 MfwWin *parent_controlBlock;
316 MfwHdr *parent_win;
317 /* U8 uMode;
318 p012a end*/
319
320 TRACE_FUNCTION("win_delete()");
321
322 if (!w)
323 return MfwResIllHnd;
324 if (((MfwHdr *) w)->type != MfwTypWin)
325 return MfwResIllHnd; /* element is not a window */
326
327 e = ((MfwHdr *) w)->data;
328 if (!e)
329 return MfwResErr;
330
331 ((MfwWin *) e)->flags |= MfwWinDelete;
332 if (((MfwWin *) e)->handler)
333 if (((MfwWin *) e)->mask & MfwWinDelete)
334 (void)(((MfwWin *) e)->handler(MfwWinDelete,e));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
335
336 e = ((MfwWin *) e)->elems;
337 if (!e)
338 return MfwResErr;
339
340 if (mfwFocus == e) /* was focus window */
341 mfwSetFocus(0); /* no focus anymore */
342
343
344
345 while (e && e->type != MfwTypMax) /* try to delete all elems */
346 {
347 t = e->next;
348 if (e->data)
349 {
350 if (mfwSignallingMethod != 0 && e->type == MfwTypWin)
351 {
352 r = (MfwHdr*) mfwParent(w);
353 mfwRemove(e); /* move up child window */
354 /* xreddymn OMAPS00095308 Oct-09-2006
355 * Check if r is valid.
356 */
357 if (r)
358 {
359 mfwAppend(&(((MfwWin*)(r->data))->elems),e);
360 }
361 else
362 {
363 mfwAppend(0,e);
364 }
365 }
366 else
367 {
368 f = mfwCommand[e->type];
369 if (f)
370 (void)(f(MfwCmdDelete,e));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
371 }
372 }
373 e = t;
374 }
375 res = (mfwRemove(w)) ? MfwResOk : MfwResIllHnd;
376
377
378 /*NM, p012d
379 old: after deleting the focus-win start from root to top
380 new: after deleting the focus-win just give the new focus to
381 his parent-win (faster)
382 */
383 if (mfwSignallingMethod != 0 && mfwRoot && (!mfwFocus))
384 {
385 parent_win = (MfwHdr*) mfwParent(w);
386
387 if (((MfwHdr *) parent_win)->type == MfwTypWin)
388 {
389 parent_controlBlock = ((MfwHdr *) parent_win)->data;
390
391 /* xreddymn Aug-09-2004, MMI-SPR-23964 (TII_MMS33)
392 * Implemented suspend and resume functionality for MFW windows
393 * The following code posts MfwWinResume event
394 */
395 if (parent_controlBlock->handler && parent_controlBlock->mask & MfwWinResume)
396 {
397 /* xreddymn OMAPS00095308 Oct-09-2006
398 * Set new value for mfwFocus before invoking the window
399 * handler for MfwWinResume.
400 */
401 mfwFocus = (MfwHdr*)((MfwWin*)parent_controlBlock)->elems;
402 (void)(parent_controlBlock->handler(MfwWinResume, parent_controlBlock));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
403 }
404
405 winUpdate(parent_controlBlock);
406 mfwSetFocus(autoFocus);
407 }
408
409 }
410
411
412
413 mfwFree((MfwHnd) e,sizeof(MfwHdr));
414 mfwFree(((MfwHdr *) w)->data,sizeof(MfwWin));
415 mfwFree(w,sizeof(MfwHdr));
416
417 return res;
418 }
419
420
421 /*
422 +--------------------------------------------------------------------+
423 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
424 | STATE : code ROUTINE : winShow |
425 +--------------------------------------------------------------------+
426
427 PURPOSE : show window (put in front of visibles)
428
429 */
430 //TISH current_mfw_elem should not changed after winShow
431 EXTERN MfwHdr * current_mfw_elem;
432
433 MfwRes winShow (MfwHnd w)
434 {
435 MfwWin *win;
436 MfwHdr * temp_current_mfw_elem;
437
438 TRACE_FUNCTION("winShow()");
439
440 if (!w)
441 return MfwResIllHnd; /* window does not exist */
442
443 if (((MfwHdr *) w)->type != MfwTypWin)
444 return MfwResIllHnd; /* element is not a window */
445
446 win = ((MfwHdr *) w)->data; /* get control block */
447
448 temp_current_mfw_elem = current_mfw_elem;
449 mfwAppend(mfwRemove(w),w); /* to front (draw at last) */
450 current_mfw_elem = temp_current_mfw_elem;
451 win->flags |= MfwWinVisible; /* window is visible */
452
453 winUpdate(win); /* draw window elements */
454 if (winUseAutoFocus) /* automatic focussing */
455 mfwSetFocus(autoFocus); /* determined by update() */
456
457 return MfwResOk;
458 }
459
460
461 /*
462 +--------------------------------------------------------------------+
463 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
464 | STATE : code ROUTINE : winHide |
465 +--------------------------------------------------------------------+
466
467 PURPOSE : hide window (and redraw remaining)
468
469 */
470
471 MfwRes winHide (MfwHnd w)
472 {
473 MfwHdr *r;
474 MfwWin *win;
475
476 if (!w)
477 return MfwResIllHnd; /* element does not exist */
478 if (((MfwHdr *) w)->type != MfwTypWin)
479 return MfwResIllHnd; /* element is not a window */
480
481 win = ((MfwHdr *) w)->data;
482 win->flags &= ~MfwWinVisible; /* window is not visible */
483 if (win->handler) /* call event handler */
484 if (win->mask & MfwWinVisible)
485 (void)(win->handler(MfwWinVisible,win));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
486 r = mfwRoot; /* the beginning */
487 autoFocus = 0; /* reset focus */
488 while (r->type != MfwTypMax) /* more links in chain */
489 {
490 if (r->type == MfwTypWin) /* link is a window */
491 winUpdate(r->data);
492 r = r->next;
493 }
494 if (winUseAutoFocus) /* automatic focussing */
495 mfwSetFocus(autoFocus); /* determined by update() */
496
497 return MfwResOk;
498 }
499
500
501 /*
502 +--------------------------------------------------------------------+
503 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
504 | STATE : code ROUTINE : winUnhide |
505 +--------------------------------------------------------------------+
506
507 PURPOSE : unhide window (without redrawing, no event)
508
509 */
510
511 MfwRes winUnhide (MfwHnd w)
512 {
513 MfwWin *win;
514
515 if (!w)
516 return MfwResIllHnd; /* element does not exist */
517 if (((MfwHdr *) w)->type != MfwTypWin)
518 return MfwResIllHnd; /* element is not a window */
519
520 win = ((MfwHdr *) w)->data;
521 win->flags |= MfwWinVisible; /* window will be visible */
522
523 return MfwResOk;
524 }
525
526
527 /*
528 +--------------------------------------------------------------------+
529 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
530 | STATE : code ROUTINE : winFocus |
531 +--------------------------------------------------------------------+
532
533 PURPOSE : assign input/event focus to window
534
535 */
536
537 MfwHnd winFocus (MfwHnd w)
538 {
539 MfwWin *wNew, *wOld = 0;
540
541 if (winUseAutoFocus) /* automatic focussing */
542 return 0; /* ES!! only for testing !! */
543 if (!w)
544 {
545 w = mfwFocus;
546 mfwSetFocus(0); /* delete focus */
547 return w; /* return old focus */
548 }
549
550 if (((MfwHdr *) w)->type != MfwTypWin)
551 return 0; /* element is not a window */
552
553 if (mfwFocus)
554 {
555 while (mfwFocus->type != MfwTypMax)
556 mfwSetFocus(mfwFocus->next); /* search focus root */
557 mfwSetFocus(mfwFocus->next); /* the focus window */
558 if (mfwFocus->type != MfwTypWin)
559 {
560 mfwSetFocus(0); /* serious error: */
561 return 0; /* element is not a window */
562 }
563 wOld = mfwFocus->data; /* window control block */
564 wOld->flags &= ~MfwWinFocussed; /* input focus / deselected */
565 }
566
567 wNew = ((MfwHdr *) w)->data;
568 w = mfwFocus; /* save old focus */
569 mfwSetFocus(wNew->elems); /* focus on window elements */
570 wNew->flags |= MfwWinFocussed; /* input focus / selected */
571
572 if (wNew->handler) /* call new event handler */
573 if (wNew->mask & MfwWinFocussed)
574 (void)(wNew->handler(MfwWinFocussed,wNew));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
575 if (wOld && wOld->handler) /* call old event handler */
576 if (wOld->mask & MfwWinFocussed)
577 (void)(wOld->handler(MfwWinFocussed,wOld));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
578
579 return w; /* return old focus */
580 }
581
582
583 /*
584 +--------------------------------------------------------------------+
585 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
586 | STATE : code ROUTINE : winAutoFocus |
587 +--------------------------------------------------------------------+
588
589 PURPOSE : set auto focus mode
590
591 */
592
593 U8 winAutoFocus (U8 useit)
594 {
595 U8 winUseAutoFocusOld = winUseAutoFocus; /* save previous state */
596
597 winUseAutoFocus = useit;
598
599 return winUseAutoFocusOld; /* return previous state */
600 }
601
602
603 /*
604 +--------------------------------------------------------------------+
605 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
606 | STATE : code ROUTINE : winClear |
607 +--------------------------------------------------------------------+
608
609 PURPOSE : clear window
610
611 */
612
613 MfwRes winClear (MfwHnd w)
614 {
615 MfwWin *win;
616
617 if (!w)
618 {
619 dspl_ClearAll(); /* clear screen */
620 return MfwResOk;
621 }
622
623 win = ((MfwHdr *) w)->data; /* clear window area */
624 dspl_Clear(win->attr->win.px,win->attr->win.py,
625 (U16) (win->attr->win.sx+win->attr->win.px-2),
626 (U16) (win->attr->win.sy+win->attr->win.py-2));
627
628 return MfwResOk;
629 }
630
631
632 /*
633 +--------------------------------------------------------------------+
634 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
635 | STATE : code ROUTINE : winUpdate |
636 +--------------------------------------------------------------------+
637
638 PURPOSE : draw all visible windows
639
640 */
641
642 MfwRes winUpdate (MfwWin *w)
643 {
644 MfwCb f = 0; /* modules command handler */
645 MfwHdr *e; /* windows elements */
646
647 // TRACE_FUNCTION("winUpdate()");
648
649 if (!w)
650 return MfwResIllHnd;
651
652 if (mfwSignallingMethod == 0)
653 {
654 if (!(w->flags & MfwWinVisible))
655 return MfwResOk; /* hidden window */
656
657 if (w->handler) /* THEN: call event handler */
658 if (w->mask & MfwWinVisible)
659 (void)(w->handler(MfwWinVisible,w));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
660 e = w->elems; /* FIRST: update children */
661 autoFocus = e; /* gets focus of top window */
662 while (e->type != MfwTypMax) /* window has elements */
663 {
664 if (e->type > MfwTypNone && e->type < MfwTypMax)
665 {
666 f = mfwCommand[e->type];
667 if (f) /* cmd function implemented */
668 (void)(f(MfwCmdUpdate,e));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
669 }
670 e = e->next;
671 }
672 }
673 else
674 {
675 if (w->handler && (w->flags & MfwWinVisible))
676 if (w->mask & MfwWinVisible){
677 (void)(w->handler(MfwWinVisible,w));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
678 }
679
680 e = w->elems; /* FIRST: update children */
681 autoFocus = e; /* gets focus of top window */
682 while (e && (e->type != MfwTypMax)) /* OMAPS00145866 Added Null pointer check by Sameer */
683 {
684 if (e->type > MfwTypNone && e->type < MfwTypMax)
685 {
686 f = mfwCommand[e->type];
687 if (f && ((w->flags & MfwWinVisible)
688 || (e->type == MfwTypWin)))
689 (void)(f(MfwCmdUpdate,e));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
690 }
691 e = e->next;
692 }
693 }
694
695 return MfwResOk;
696 }
697
698
699 /*
700 +--------------------------------------------------------------------+
701 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
702 | STATE : code ROUTINE : winNext |
703 +--------------------------------------------------------------------+
704
705 PURPOSE : show next window (for testing purposes only)
706
707 */
708
709 MfwHnd winNext (MfwHnd winCur)
710 {
711 MfwHdr *cw; /* current window pointer */
712
713 if (!winCur)
714 return 0;
715
716 cw = ((MfwWin *) (((MfwHdr *) winCur)->data))->elems;
717 while (cw->type != MfwTypWin)
718 {
719 if (cw->type == MfwTypMax)
720 {
721 cw = cw->next;
722 if (!cw)
723 cw = mfwRoot;
724 else
725 cw = cw->next; /* windows successor */
726 }
727 else
728 cw = cw->next;
729 }
730
731 return cw;
732 }
733
734
735 /*
736 +--------------------------------------------------------------------+
737 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
738 | STATE : code ROUTINE : winPrev |
739 +--------------------------------------------------------------------+
740
741 PURPOSE : show previous window (for testing purposes only)
742
743 */
744
745 MfwHnd winPrev (MfwHnd winCur)
746 {
747 MfwHnd wo, wc;
748
749 wo = wc = winNext(winCur);
750 while (wc != winCur)
751 {
752 wo = wc;
753 wc = winNext(wc);
754 }
755
756 return wo;
757 }
758
759
760 /*
761 +--------------------------------------------------------------------+
762 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
763 | STATE : code ROUTINE : winCommand |
764 +--------------------------------------------------------------------+
765
766 PURPOSE : handle mfw windows command
767
768 */
769
770 static int winCommand (U32 cmd, void *h)
771 {
772 switch (cmd)
773 {
774 case MfwCmdDelete: /* delete me */
775 if (!h)
776 return 0;
777 winDelete(h);
778 return 1;
779 case MfwCmdUpdate: /* repaint */
780 if (!h || ((MfwHdr *) h)->type != MfwTypWin)
781 return 0;
782 winUpdate(((MfwHdr *) h)->data);
783 return 1;
784 default:
785 break;
786 }
787
788 return 0;
789 }
790
791 /*
792 +--------------------------------------------------------------------+
793 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
794 | STATE : code ROUTINE : winIsVisible |
795 +--------------------------------------------------------------------+
796
797 PURPOSE : check if window is visible
798
799 */
800 int winIsVisible(MfwHnd w)
801 {
802 MfwWin *win;
803
804 if (!w)
805 return 0; /* no handle */
806
807 if (((MfwHdr *) w)->type != MfwTypWin)
808 return 0; /* element is not a window */
809
810 win = ((MfwHdr *) w)->data;
811
812 return (win->flags & MfwWinVisible);
813 }
814
815
816 /*
817 +--------------------------------------------------------------------+
818 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
819 | STATE : code ROUTINE : winIsFocussed |
820 +--------------------------------------------------------------------+
821
822 PURPOSE : check if window is focussed
823
824 */
825 int winIsFocussed(MfwHnd w)
826 {
827 MfwWin *win;
828
829 if (!w)
830 return 0; /* no handle */
831
832 if (((MfwHdr *) w)->type != MfwTypWin)
833 return 0; /* element is not a window */
834
835 win = ((MfwHdr *) w)->data;
836
837 return (win->elems == mfwFocus);
838
839 }
840
841
842 /*
843 +--------------------------------------------------------------------+
844 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
845 | STATE : code ROUTINE : winIcClosed |
846 +--------------------------------------------------------------------+
847
848 PURPOSE : check if window is closed
849
850 */
851 int winIsClosed(MfwHnd w)
852 {
853 MfwWin *win;
854
855 if (!w)
856 return 0; /* no handle */
857
858 if (((MfwHdr *) w)->type != MfwTypWin)
859 return 0; /* element is not a window */
860
861 win = ((MfwHdr *) w)->data;
862
863 return (win->flags & MfwWinClosed);
864 }
865
866 MfwHdr* getHdr( MfwHnd win)
867 {
868 return((MfwHdr *) win);
869 }
870 MfwWin* getWinData( MfwHnd win)
871 {
872 MfwHdr* winHdr;
873 winHdr = getHdr(win);
874 return (winHdr->data);
875 }
876
877 #define TWH_MAX_STR_LEN 90
878 #define TWH_MAX_SINGLE_SIZE 21 // This is the length of the Level, Address, Type and Callback in hex plus a zero terminator
879
880 static unsigned char trc_lvl;
881 static char mfw_twh_str[TWH_MAX_STR_LEN];
882
883 // Mar 30, 2005 REF: CRR 29986 xpradipg
884 // remove the definition since its not used
885 #ifndef FF_MMI_OPTIM
886 static unsigned int mfw_twh_strlen;
887 #endif
888
889 static void mfw_twhNext(MfwHdr *next);
890 static char *mfw_twhType(MfwTyp type);
891 static void mfw_twhOut(void *ptr, MfwTyp typ);
892 static void mfw_twhCb(void *ptr);
893 static void mfw_twh_str_purge(void);
894
895 #include <string.h>
896
897 /*
898 +--------------------------------------------------------------------+
899 | PROJECT : MMI-Framework (8417) MODULE : MFW_WIN |
900 | STATE : code ROUTINE : mfw_traceWinHdrs |
901 +--------------------------------------------------------------------+
902
903 PURPOSE : This function will trace out the entire window tree.
904 : EXTREME care should be taken using this function as it will cause a
905 : massive overhead on the CPU and processing WILL be affected!!!!
906
907 */
908 void mfw_traceWinHdrs(void)
909 {
910 TRACE_FUNCTION(">>>>> mfw_traceWinHdrs");
911
912 trc_lvl = 0;
913
914 TRACE_EVENT("mfwRoot");
915
916 if (mfwRoot)
917 mfw_twhNext(mfwRoot);
918
919 /*
920 ** Trace out the last remaining line (there will always be one)
921 */
922 mfw_twh_str_purge();
923
924 TRACE_FUNCTION("<<<<< mfw_traceWinHdrs");
925 return;
926 }
927
928 static void mfw_twhNext(MfwHdr *next)
929 {
930 while (next)
931 {
932 if (next->type != MfwTypMax)
933 {
934 /*
935 ** Trace out this address, and its Type
936 */
937 mfw_twhOut(next, next->type);
938
939 /*
940 ** If this type is a Window, then it may have sub-elements
941 ** Trace them out before continuing the tree on this level
942 */
943 if (next->type == MfwTypWin)
944 {
945 MfwWin *win_ptr = (MfwWin *)next->data;
946
947 if (win_ptr)
948 {
949 MfwHdr *win_elems = win_ptr->elems;
950
951 /*
952 ** Add the Callback Address before doing the sub-elements
953 */
954 mfw_twhCb((void*)win_ptr->handler);
955 trc_lvl++;
956 mfw_twhNext(win_elems);
957 trc_lvl--;
958 }
959 }
960
961 if (next->next == NULL)
962 {
963 mfw_twhOut(0, MfwTypNone); /*a0393213 compiler warnings removal - 0 changed to MfwTypNone*/
964 }
965
966 next = next->next;
967 }
968 else
969 {
970 /*
971 ** Trace out this address, and its Type
972 */
973 mfw_twhOut(next, next->type);
974
975 next = NULL;
976 }
977 }
978
979 return;
980 }
981
982 static char *mfw_twhType(MfwTyp type)
983 {
984 switch (type)
985 {
986 case MfwTypNone: /* no element (first !!) */
987 return("MfwTypNone");
988 // break;
989
990 case MfwTypWin: /* window */
991 return("MfwTypWin");
992 // break;
993
994 case MfwTypEdt: /* editor */
995 return("MfwTypEdt");
996 // break;
997
998 case MfwTypMnu: /* menu handler */
999 return("MfwTypMnu");
1000 // break;
1001
1002 case MfwTypIcn: /* icon handler */
1003 return("MfwTypIcn");
1004 // break;
1005
1006 case MfwTypKbd: /* keyboard */
1007 return("MfwTypKbd");
1008 // break;
1009
1010 case MfwTypTim: /* timer */
1011 return("MfwTypTim");
1012 // break;
1013
1014 case MfwTypMme: /* misc. mobile equipment */
1015 return("MfwTypMme");
1016 // break;
1017
1018 case MfwTypVmm: /* MDL virtual machine */
1019 return("MfwTypVmm");
1020 // break;
1021
1022 case MfwTypNm: /* network */
1023 return("MfwTypNm");
1024 // break;
1025
1026 case MfwTypSim: /* SIM card */
1027 return("MfwTypSim");
1028 // break;
1029
1030 case MfwTypCm: /* call handling */
1031 return("MfwTypCm");
1032 // break;
1033
1034 case MfwTypPhb: /* phonebook handling */
1035 return("MfwTypPhb");
1036 // break;
1037
1038 case MfwTypSms: /* short message handling */
1039 return("MfwTypSms");
1040 // break;
1041
1042 case MfwTypSs: /* supl. services handling */
1043 return("MfwTypSs");
1044 // break;
1045
1046 case MfwTypSat: /* SIM Toolkit handling */
1047 return("MfwTypSat");
1048 // break;
1049
1050 case MfwTypLng: /* language handling */
1051 return("MfwTypLng");
1052 // break;
1053
1054 case MfwTypInp: /* input handling */
1055 return("MfwTypInp");
1056 // break;
1057
1058 case MfwTypNode: /* node element */
1059 return("MfwTypNode");
1060 // break;
1061
1062 case MfwTypCphs: /* CPHS element */
1063 return("MfwTypCphs");
1064 // break;
1065
1066 case MfwTypGprs: /* GPRS handling */
1067 return("MfwTypGprs");
1068 // break;
1069
1070 case MfwTypEm: /*MC, SPR 1209 Eng Mode handling*/
1071 return("MfwTypEm");
1072 // break;
1073
1074 #ifdef BT_INTERFACE
1075 case MfwTypBt: /* bluetooth handling */
1076 return("MfwTypBt");
1077 // break;
1078 #endif
1079
1080 #ifdef BTE_MOBILE
1081 case MfwTypBte: /* bluetooth handling */
1082 return("MfwTypBte");
1083 // break;
1084 #endif
1085
1086 case MfwTypMax: /* end of types (last !!) */
1087 return("MfwTypMax");
1088 // break;
1089
1090 default:
1091 return("Not Known");
1092 }
1093 }
1094
1095 static void mfw_twhOut(void *ptr, MfwTyp typ)
1096 {
1097 unsigned char i;
1098 char fmt_str[30];
1099
1100 memset(fmt_str, 0, 30);
1101
1102 #if 0
1103 /* The code here will output the information in hex format which will need
1104 ** more decoding, but which may be necessary if the amount of information
1105 ** being output causes problems in the BMI. Change the above #if to be '#if 1'
1106 ** to use this format
1107 */
1108 sprintf(fmt_str,"%02x%08lx%02x", trc_lvl, ptr, typ);
1109
1110 /*
1111 ** Determine whether a new string is required
1112 */
1113 if (mfw_twh_strlen > (TWH_MAX_STR_LEN - TWH_MAX_SINGLE_SIZE))
1114 {
1115 /*
1116 ** Need to output the previous trace and start a new line
1117 */
1118 mfw_twh_str_purge();
1119 }
1120
1121 strcat(mfw_twh_str, fmt_str);
1122
1123 mfw_twh_strlen += 12;
1124 #else
1125
1126 memset(mfw_twh_str, 0, TWH_MAX_STR_LEN);
1127
1128 for (i=0; i<trc_lvl; i++)
1129 {
1130 strcat(mfw_twh_str, " ");
1131 }
1132
1133 strcat(mfw_twh_str, "-> ");
1134
1135 sprintf(fmt_str,"N:%08p T:%s", ptr, mfw_twhType(typ));/*a0393213 lint warnings removal-format specifier %08lx changed to %p*/
1136
1137 strcat(mfw_twh_str, fmt_str);
1138
1139 if (typ != MfwTypWin)
1140 {
1141 /*
1142 ** Trace out the details - There will be no callback
1143 */
1144 TRACE_EVENT(mfw_twh_str);
1145 }
1146 #endif
1147 return;
1148 }
1149
1150 static void mfw_twhCb(void *ptr)
1151 {
1152 char fmt_str[20];
1153
1154 memset(fmt_str, 0, 20);
1155 #if 0
1156 /* The code here will output the information in hex format which will need
1157 ** more decoding, but which may be necessary if the amount of information
1158 ** being output causes problems in the BMI. Change the above #if to be '#if 1'
1159 ** to use this format
1160 */
1161 /*
1162 ** No Need to test whether there is enough space for the callback ...already checked in mfw_twhOut()
1163 */
1164 sprintf(fmt_str,"%08lx", ptr);
1165
1166 strcat(mfw_twh_str, fmt_str);
1167
1168 mfw_twh_strlen += 8;
1169 #else
1170 /*
1171 ** No Need to test whether there is enough space for the callback ...already checked in mfw_twhOut()
1172 */
1173 sprintf(fmt_str," Cb:%08p", ptr);/*a0393213 lint warnings removal-format specifier %08lx changed to %p*/
1174
1175 strcat(mfw_twh_str, fmt_str);
1176
1177 TRACE_EVENT(mfw_twh_str);
1178 #endif
1179 return;
1180 }
1181
1182 static void mfw_twh_str_purge(void)
1183 {
1184 #if 0
1185 /* The code here is needed when using the hex format output which will need
1186 ** more decoding, but which may be necessary if the amount of information
1187 ** being output causes problems in the BMI. Change the above #if to be '#if 1'
1188 ** to use this format
1189 */
1190 TRACE_EVENT(mfw_twh_str);
1191
1192 memset(mfw_twh_str, 0, TWH_MAX_STR_LEN);
1193 mfw_twh_strlen = 0;
1194
1195 vsi_t_sleep(VSI_CALLER 10);
1196 #endif
1197 return;
1198 }
1199