comparison src/ui/mfw/mfw_mnu.c @ 3:67bfe9f274f6

src/ui: import of src/ui3 from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:33:10 +0000
parents
children 92abb46dc1ba
comparison
equal deleted inserted replaced
2:3a14ee9a9843 3:67bfe9f274f6
1 /*
2 +--------------------------------------------------------------------+
3 | PROJECT: MMI-Framework (8417) $Workfile:: mfw_mnu.c $|
4 | $Author:: Kk $ CONDAT GmbH $Revision:: 18 $|
5 | CREATED: 24.11.98 $Modtime:: 24.02.00 8:07 $|
6 | STATE : code |
7 +--------------------------------------------------------------------+
8
9 MODULE : MFW_MNU
10
11 PURPOSE : menu handling functions
12
13 EXPORT :
14
15 TO DO :
16
17 $History:: mfw_mnu.c $
18
19 June 05, 2006 REF:OMAPS00060424 x0045876
20 Description: Header Toggling
21 Solution: Implemented the toggling of header when displaying the length text in SELECT ITEM and SET UP MENU
22
23 May 18, 2006 REF: DRT OMAPS00076438 xdeepadh
24 Description: Scrolling not implemented in Imageviewer
25 Solution: The support for scrolling has been provided.
26
27
28 May 03, 2006 REF: DRT OMAPS00076439 xdeepadh
29 Description: Image viewer back not working
30 Solution: The Preview List will be repopulated, when the list window is
31 resumed.
32
33 Shashi Shekar B.S., a0876501, 16 Mar, 2006, OMAPS00061462
34 Icon support for SetupMenu & Select item.
35
36 *
37 * ************************************************
38
39
40
41 Dec 22, 2005 REF: ENH xdeepadh
42 Description: Image Viewer Application
43 Solution: Implemeted the Image Viewer to view the jpeg images
44
45 * User: xreddymn Date: Sep-30-2005
46 * Updated in $/GSM/Condat/MS/SRC/MFW
47 * Added header display for menus on monochrome
48 * screens for MMI-SPR-33781
49 *
50 * ************************************************
51 * User: xreddymn Date: Dec-16-2004
52 * Updated in $/GSM/Condat/MS/SRC/MFW
53 * Added double line display for MFW list menu items
54 *
55 * ***************** Version 18 *****************
56 * User: Kk Date: 28.02.00 Time: 10:33
57 * Updated in $/GSM/Condat/MS/SRC/MFW
58 * font usage corrected for page and list menus. free menus still
59 * need rework.
60 *
61 * ***************** Version 17 *****************
62 * User: Es Date: 17.01.00 Time: 17:37
63 * Updated in $/GSM/Condat/MS/SRC/MFW
64 * menu mode handling bug (uses only first level settings)
65 |
66 | ***************** Version 16 *****************
67 | User: Le Date: 6.01.00 Time: 9:23
68 | Updated in $/GSM/Condat/MS/SRC/MFW
69 | Alignment of MFW versions
70 *
71 * ***************** Version 2 *****************
72 * User: Es Date: 22.11.99 Time: 10:29
73 * Updated in $/GSM/Condat/SND-MMI/MFW
74 *
75 * ***************** Version 1 *****************
76 * User: Es Date: 18.11.99 Time: 16:35
77 * Created in $/GSM/Condat/SND-MMI/MFW
78 * Initial
79 */
80
81 #include <stdio.h>
82 #include <string.h>
83
84 #define ENTITY_MFW
85
86 #if defined (NEW_FRAME)
87
88 #include "typedefs.h"
89 #include "vsi.h"
90 #include "custom.h"
91 #include "gsm.h"
92
93 #else
94
95 #include "STDDEFS.H"
96 #include "custom.h"
97 #include "gsm.h"
98 #include "vsi.h"
99
100 #endif
101
102 #include "mfw_sys.h"
103 #include "mfw_mfw.h"
104 #include "mfw_kbd.h"
105 #include "gdi.h"
106 #include "dspl.h"
107 #include "mfw_lng.h"
108 /* SPR#1428 - SH - New Editor changes */
109 #ifndef NEW_EDITOR
110 #include "mfw_edt.h"
111 #endif
112 #include "mfw_icn.h"
113 #include "mfw_mnu.h"
114
115
116 #include "message.h"
117 #include "prim.h"
118 #include "aci_cmh.h"
119
120 #include "mfw_mmi.h"
121
122 /* START: 05-June-2006, x0045876 (OMAPS00060424 - Header Toggle) */
123 #include "mfw_tim.h"
124 #include "ATBCommon.h"
125 #include "ATBDisplay.h"
126
127 #define MNU_TOGGLE_TIMEOUT 3000
128
129 static USHORT g_title_pos;
130 static USHORT g_title_next_pos;
131 MfwHnd g_title_timer;
132
133 extern MfwHnd g_win;
134 /* END: 05-June-2006, x0045876 (OMAPS00060424 - Header Toggle) */
135
136 static int menuIsEmpty (MfwMnu *m, MfwMnuAttr *ma);
137 static int countVisible (MfwMnu *m, MfwMnuAttr *ma, int start);
138 static void drawPageMenu (MfwMnu *mnu);
139 static void drawListMenu (MfwMnu *m);
140 static void drawIconsListMenu(MfwMnu *m);
141 static void drawFreeMenu (MfwMnu *m);
142 //May 18, 2006 REF: DRT OMAPS00076438 xdeepadh
143 static int mnuCommand (U32 cmd, void *h);
144
145 /* 05-June-2006, x0045876 (OMAPS00060424 - Header Toggle) */
146 static int Menu_edit_TitleTimerCb(MfwEvt e, MfwTim *t);
147
148 #define TIME_TRACE_EVENT
149
150 /*
151 +--------------------------------------------------------------------+
152 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
153 | STATE : code ROUTINE : mnuInit |
154 +--------------------------------------------------------------------+
155
156 PURPOSE : initialize menu handler
157
158 */
159
160 MfwRes mnuInit (void)
161 {
162 mfwCommand[MfwTypMnu] = (MfwCb) mnuCommand;
163
164 return MfwResOk;
165 }
166
167
168 /*
169 +--------------------------------------------------------------------+
170 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
171 | STATE : code ROUTINE : mnuExit |
172 +--------------------------------------------------------------------+
173
174 PURPOSE : finalize menu handler
175
176 */
177
178 MfwRes mnuExit (void)
179 {
180 mfwCommand[MfwTypMnu] = 0;
181
182 return MfwResOk;
183 }
184
185
186 /*
187 +--------------------------------------------------------------------+
188 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
189 | STATE : code ROUTINE : mnuCreate |
190 +--------------------------------------------------------------------+
191
192 PURPOSE : create menu control
193 GW 05/10/01 - Changed single value 'lng' to 2 values indicating if ID's should be
194 used (useStrID) and if the strings are ascii or unicode (uesDefLang).
195
196 */
197
198 MfwHnd mnuCreate (MfwHnd w, MfwMnuAttr *a, MfwEvt e, MfwCb f)
199 {
200 MfwHdr *hdr = (MfwHdr *) mfwAlloc(sizeof(MfwHdr));
201 MfwMnu *mnu = (MfwMnu *) mfwAlloc(sizeof(MfwMnu));
202 MfwHdr *insert_status =0;
203
204 if (!hdr || !mnu)
205 {
206 TRACE_ERROR("ERROR: mnuCreate() Mem Alloc Failed.");
207
208 if(hdr)
209 mfwFree((U8*)hdr,sizeof(MfwHdr));
210 if(mnu)
211 mfwFree((U8*)mnu,sizeof(MfwMnu));
212
213 return 0;
214 }
215
216 mnu->mask = e;
217 mnu->flags = 0;
218 mnu->handler = f;
219 mnu->attr = a;
220 mnu->curAttr = a;
221
222 mnu->useStrID = 0;
223 mnu->useDefLang = 0;
224 /* SPR#1983 - SH - Stores character type, ASCII/UNICODE */
225 mnu->textDCS = MNU_LIST_LANGUAGE_DEFAULT;
226 mnu->level = 0;
227 memset(mnu->lCursor,UNUSED,sizeof(mnu->lCursor));
228 memset(mnu->lShift,1,sizeof(mnu->lShift));
229 mnu->lCursor[0] = 0;
230 mnu->scrollMode = 1;
231 hdr->data = mnu;
232 hdr->type = MfwTypMnu;
233
234 insert_status = mfwInsert(w,hdr);
235 if(!insert_status)
236 {
237 TRACE_ERROR("ERROR: mnuCreate() Failed to Install Handler. ");
238 mfwFree((U8*)hdr,sizeof(MfwHdr));
239 mfwFree((U8*)mnu ,sizeof(MfwMnu));
240 return 0;
241 }
242 return insert_status;
243 }
244
245
246 /*
247 +--------------------------------------------------------------------+
248 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
249 | STATE : code ROUTINE : mnuDelete |
250 +--------------------------------------------------------------------+
251
252 PURPOSE : delete menu control
253
254 */
255
256 MfwRes mnuDelete (MfwHnd m)
257 {
258 MfwRes res;
259
260 if (!m)
261 return MfwResIllHnd;
262
263 mnuHide(m);
264 res = (mfwRemove(m)) ? MfwResOk : MfwResIllHnd;
265
266 mfwFree(((MfwHdr *) m)->data,sizeof(MfwMnu));
267 mfwFree(m,sizeof(MfwHdr));
268
269 return res;
270 }
271
272
273 /*
274 +--------------------------------------------------------------------+
275 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
276 | STATE : code ROUTINE : mnuLang |
277 +--------------------------------------------------------------------+
278
279 PURPOSE : set / get whether the string is associated with an ID or if it is null-terminated
280
281 GW 05/10/01 - Changed single value 'lng' to 2 values indicating if ID's should be
282 used (useStrID) and if the strings are ascii or unicode (uesDefLang).
283 */
284
285 MfwHnd mnuLang (MfwHnd m, MfwHnd l)
286 {
287 MfwHnd ol;
288 MfwMnu *mnu;
289
290 if( (mnu = mfwControl(m)) == 0)
291 return (MfwHnd) MfwResIllHnd;
292
293 ol = mnu->useStrID;
294 mnu->useStrID = l;
295 mnu->useDefLang = l;
296
297 /* SPR#1983 - SH - Set character type appropriately */
298 if (l)
299 {
300 mnu->textDCS = MNU_LIST_LANGUAGE_DEFAULT;
301 }
302 else
303 {
304 mnu->textDCS = MNU_LIST_LANGUAGE_ASCII;
305 }
306
307 return ol;
308 }
309
310 /*
311 +--------------------------------------------------------------------+
312 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
313 | STATE : code ROUTINE : mnuStrType |
314 +--------------------------------------------------------------------+
315
316 PURPOSE : set / get language in use (1=use default ascii/unicode, 0=assume ascii)
317
318 GW 05/10/01 - Changed single value 'lng' to 2 values indicating if ID's should be
319 used (useStrID) and if the strings are ascii or unicode (uesDefLang).
320 */
321 MfwHnd mnuStrType (MfwHnd m, MfwHnd l)
322 {
323 MfwHnd ol;
324 MfwMnu *mnu;
325
326 if( (mnu = mfwControl(m)) == 0)
327 return (MfwHnd) MfwResIllHnd;
328
329 ol = mnu->useDefLang;
330 mnu->useDefLang = l;
331
332 /* SPR#1983 - SH - Set character type appropriately*/
333 if (l)
334 {
335 mnu->textDCS = MNU_LIST_LANGUAGE_UNICODE;
336 }
337 else
338 {
339 mnu->textDCS = MNU_LIST_LANGUAGE_DEFAULT;
340 }
341
342 return ol;
343 }
344
345
346 /*
347 +--------------------------------------------------------------------+
348 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
349 | STATE : code ROUTINE : mnuDCSType |
350 +--------------------------------------------------------------------+
351
352 PURPOSE : SPR#1983 - SH - Added.
353 Set the character type of the menu text
354 */
355
356 UBYTE mnuDCSType (MfwHnd m, UBYTE listLanguageType)
357 {
358 UBYTE ol;
359 MfwMnu *mnu;
360
361 if( (mnu = mfwControl(m)) == 0)
362 return NULL;
363
364 ol = mnu->textDCS;
365 mnu->textDCS = listLanguageType;
366
367 return ol;
368 }
369
370
371
372 /*
373 +--------------------------------------------------------------------+
374 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
375 | STATE : code ROUTINE : mnuShow |
376 +--------------------------------------------------------------------+
377
378 PURPOSE : show menu
379
380 */
381
382 MfwRes mnuShow (MfwHnd m)
383 {
384 MfwMnu *mnu;
385
386 if( (mnu = mfwControl(m)) == 0)
387 return MfwResIllHnd;
388
389 mnu->flags |= E_MNU_VISIBLE;
390 mnuUpdate(mnu);
391
392 return MfwResOk;
393 }
394
395
396 /*
397 +--------------------------------------------------------------------+
398 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
399 | STATE : code ROUTINE : mnuHide |
400 +--------------------------------------------------------------------+
401
402 PURPOSE : hide menu
403
404 */
405
406 MfwRes mnuHide (MfwHnd m)
407 {
408 MfwMnu *mnu;
409 // U8 dsplOld;
410
411 if ((mnu = mfwControl(m)) == 0)
412 return MfwResIllHnd;
413
414 mnu->flags &= ~E_MNU_VISIBLE;
415 if (mnu->handler)
416 if (mnu->mask & E_MNU_VISIBLE)
417 (void)(mnu->handler(E_MNU_VISIBLE,mnu));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
418
419 return MfwResOk;
420 }
421
422
423 /*
424 +--------------------------------------------------------------------+
425 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
426 | STATE : code ROUTINE : mnuUnhide |
427 +--------------------------------------------------------------------+
428
429 PURPOSE : unhide menu (without drawing)
430
431 */
432
433 MfwRes mnuUnhide (MfwHnd m)
434 {
435 MfwMnu *mnu;
436 // U8 dsplOld;
437
438 if ((mnu = mfwControl(m)) == 0)
439 return MfwResIllHnd;
440
441 mnu->flags |= E_MNU_VISIBLE;
442 if (mnu->handler)
443 if (mnu->mask & E_MNU_VISIBLE)
444 (void)(mnu->handler(E_MNU_VISIBLE,mnu));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
445 return MfwResOk;
446 }
447
448
449 /*
450 +--------------------------------------------------------------------+
451 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
452 | STATE : code ROUTINE : mnuUpdate |
453 +--------------------------------------------------------------------+
454
455 PURPOSE : draw menu
456
457 */
458
459 MfwRes mnuUpdate (MfwMnu *m)
460 {
461
462 // U8 dsplOld;
463
464
465 if (!m)
466 return MfwResIllHnd;
467 if (!(m->flags & E_MNU_VISIBLE))
468 return MfwResOk;
469
470 if (m->handler)
471 if (m->mask & E_MNU_VISIBLE)
472 (void)(m->handler(E_MNU_VISIBLE,m));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
473
474 /*JVJE Update to fit the menu to a visible item */
475 {
476 MfwMnuAttr *ma = m->curAttr;
477 int index= m->lCursor[m->level];
478 // int iloop;
479 U16 retVal;
480
481 if (ma->items[index].flagFunc)
482 retVal = ma->items[index].flagFunc(m,ma,&(ma->items[index]));
483 else
484 retVal = 0;
485
486 while (retVal & MNU_ITEM_HIDE)
487 {
488 index++;
489 if (index>=ma->nItems)
490 index =0;
491
492 if (ma->items[index].flagFunc)
493 retVal = ma->items[index].flagFunc(m,ma,&(ma->items[index]));
494 else
495 retVal = 0;
496
497 }
498 m->lCursor[m->level]=index;
499 }
500
501 if ((m->curAttr->mode & MNU_DISPLAY) == MNU_OVERLAPPED)
502 drawFreeMenu(m);
503 //May 18, 2006 REF: DRT OMAPS00076438 xdeepadh
504 else if ((m->curAttr->mode & MNU_DISPLAY) == MNU_PAGED)
505 drawPageMenu(m);
506 else if ((m->curAttr->mode & MNU_DISPLAY) == MNU_LIST)
507 drawListMenu(m);
508 else if ((m->curAttr->mode & MNU_DISPLAY) ==MNU_LIST_ICONS)
509 drawIconsListMenu(m);
510 /* xreddymn Dec-16-2004 MMI-SPR-27384: Two line height list display */
511 else if ((m->curAttr->mode & MNU_DISPLAY) == MNU_LIST_2_LINE)
512 drawListMenu(m);
513 else if ((m->curAttr->mode & MNU_DISPLAY) == MNU_LIST_COLOUR)
514 drawListMenu(m);
515 if (m->handler)
516 if (m->mask & E_MNU_POSTDRAW)
517 (void)(m->handler(E_MNU_POSTDRAW,m));
518
519 return MfwResOk;
520 }
521
522
523 /*
524 +--------------------------------------------------------------------+
525 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
526 | STATE : code ROUTINE : mnuUp |
527 +--------------------------------------------------------------------+
528
529 PURPOSE : one step up
530
531 */
532
533 MfwRes mnuUp (MfwHnd m)
534 {
535 MfwMnu *mnu;
536 MfwMnuAttr *ca;
537 MfwMnuItem *ci;
538 // U8 uMode;
539
540 if ((mnu = mfwControl(m)) == 0)
541 return MfwResIllHnd;
542
543
544 ca = mnu->curAttr;
545 do
546 {
547 if (mnu->lCursor[mnu->level] == 0)
548 {
549 mnu->lCursor[mnu->level] = ca->nItems - 1;
550 mnu->flags |= E_MNU_TOPPED;
551 if (mnu->handler)
552 if (mnu->mask & E_MNU_TOPPED)
553 (void)(mnu->handler(E_MNU_TOPPED,mnu));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
554 }
555 else
556 {
557 mnu->lCursor[mnu->level] -= (U8) 1;
558 mnu->flags &= ~E_MNU_TOPPED;
559 }
560 ci = ca->items + mnu->lCursor[mnu->level];
561 } while (ci->flagFunc(mnu,ca,ci) & MNU_ITEM_HIDE);
562
563 if (mnu->scrollMode) /* Simple scrolling */
564 {
565 U8 shift = mnu->lShift[mnu->level];
566 U8 index = countVisible(mnu,ca,mnu->lCursor[mnu->level]);
567 U8 visibleItems = countVisible(mnu,ca,ca->nItems);
568 int nLines = mnu->nLines;
569
570 if (visibleItems<nLines)
571 nLines = visibleItems;
572 if (shift>1)
573 shift--;
574 mnu->lShift[mnu->level] = shift;
575
576 }
577 mnuUpdate(mnu);
578 return MfwResOk;
579 }
580
581
582 /*
583 +--------------------------------------------------------------------+
584 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
585 | STATE : code ROUTINE : mnuDown |
586 +--------------------------------------------------------------------+
587
588 PURPOSE : one step down
589
590 */
591
592 MfwRes mnuDown (MfwHnd m)
593 {
594 MfwMnu *mnu;
595 MfwMnuAttr *ca;
596 MfwMnuItem *ci;
597
598
599 if ((mnu = mfwControl(m)) == 0)
600 return MfwResIllHnd;
601 ca = mnu->curAttr;
602 do
603 {
604 if (mnu->lCursor[mnu->level] >= mnu->curAttr->nItems - 1)
605 {
606 mnu->lCursor[mnu->level] = 0;
607 mnu->flags |= E_MNU_BOTTOMED;
608 if (mnu->handler)
609 if (mnu->mask & E_MNU_BOTTOMED)
610 (void)(mnu->handler(E_MNU_BOTTOMED,mnu));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
611 }
612 else
613 {
614 mnu->lCursor[mnu->level] += (U8) 1;
615 mnu->flags &= ~E_MNU_BOTTOMED;
616 }
617 ci = ca->items + mnu->lCursor[mnu->level];
618 } while (ci->flagFunc(mnu,ca,ci) & MNU_ITEM_HIDE);
619
620 if (mnu->scrollMode) /* Simple scrolling */
621 {
622 U8 shift = mnu->lShift[mnu->level];
623 U8 index = countVisible(mnu,ca,mnu->lCursor[mnu->level]);
624 U8 visibleItems = countVisible(mnu,ca,ca->nItems);
625 int nLines = mnu->nLines;
626
627 if (visibleItems<nLines)
628 nLines = visibleItems;
629 if (shift<nLines)
630 shift++;
631 mnu->lShift[mnu->level] = shift;
632
633 }
634 mnuUpdate(mnu);
635 return MfwResOk;
636 }
637
638
639 /*
640 +--------------------------------------------------------------------+
641 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
642 | STATE : code ROUTINE : mnuSelect |
643 +--------------------------------------------------------------------+
644
645 PURPOSE : select a menu item; if there is a submenu, go one level
646 down
647
648 */
649
650 MfwRes mnuSelect (MfwHnd m)
651 {
652 MfwMnu *mnu;
653 MfwMnuAttr *submenu, *ca;
654 MenuFunc func;
655 // U8 dsplOld;
656
657 if ((mnu = mfwControl(m)) == 0)
658 return MfwResIllHnd;
659
660 ca = mnu->curAttr;
661 submenu = ca->items[mnu->lCursor[mnu->level]].menu;
662 func = ca->items[mnu->lCursor[mnu->level]].func;
663
664 if (func) /* perform submenu */
665 {
666 (void)(func(mnu,&ca->items[mnu->lCursor[mnu->level]]));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
667 }
668
669 if (submenu) /* call menu function */
670 {
671 if (menuIsEmpty(mnu,submenu))
672 {
673 mnu->flags |= E_MNU_EMPTY;
674 if (mnu->handler && mnu->mask & E_MNU_EMPTY)
675 (void)(mnu->handler(E_MNU_EMPTY,mnu));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
676 mnu->flags &= ~E_MNU_EMPTY;
677 }
678 else
679 {
680 dspl_Clear(ca->area->px, ca->area->py,
681 (U16) (ca->area->sx+ca->area->px-1),
682 (U16) (ca->area->sy+ca->area->py-1));
683 mnu->level++;
684 mnu->lCursor[mnu->level] = 0;
685 ca = mnu->curAttr = submenu;
686 if (ca->items->flagFunc(mnu,ca,ca->items) & MNU_ITEM_HIDE)
687 mnuDown(m);
688 else
689 mnuUpdate(mnu);
690 }
691 return MfwResOk; /* we do not have to check for !submenu */
692 }
693
694 if (!func && !submenu) /* inform mmi */
695 {
696 mnu->flags |= E_MNU_SELECT;
697 if (mnu->handler && mnu->mask & E_MNU_SELECT)
698 (void)(mnu->handler(E_MNU_SELECT,mnu));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
699 }
700 return MfwResOk;
701 }
702
703
704 /*
705 +--------------------------------------------------------------------+
706 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
707 | STATE : code ROUTINE : mnuEscape |
708 +--------------------------------------------------------------------+
709
710 PURPOSE : go back one level or leave the menu
711
712 */
713
714 MfwRes mnuEscape (MfwHnd m)
715 {
716 MfwMnu *mnu;
717 MfwMnuAttr *attr;
718 U8 lvl;
719 // U8 dsplOld;
720
721 if ((mnu = mfwControl(m)) == 0)
722 return MfwResIllHnd;
723
724 if (mnu->level != 0)
725 {
726 mnu->lCursor[mnu->level] = (U8)UNUSED; /*a0393213 removing compiler warnings - UNUSED type casted*/
727 mnu->lShift[mnu->level] = 1;
728 mnu->level--;
729 lvl = 0; /* set level 0 */
730 attr = mnu->attr; /* set start point */
731 while (lvl != mnu->level)
732 {
733 attr = attr->items[mnu->lCursor[lvl]].menu;
734 lvl++;
735 }
736 mnu->curAttr = attr;
737 mnuUpdate(mnu);
738 }
739 else
740 {
741 mnu->flags |= E_MNU_ESCAPE;
742 if (mnu->handler)
743 if (mnu->mask & E_MNU_ESCAPE)
744 (void)(mnu->handler(E_MNU_ESCAPE,mnu));/*a0393213 lint warnings removal - void cast is done to avoid lint warning though the function returns int*/
745 }
746 return MfwResOk;
747 }
748
749
750 /*
751 +--------------------------------------------------------------------+
752 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
753 | STATE : code ROUTINE : mnuDone |
754 +--------------------------------------------------------------------+
755
756 PURPOSE : reset menu
757
758 */
759
760 MfwRes mnuDone (MfwHnd m)
761 {
762 MfwMnu *mnu;
763
764 if ((mnu = mfwControl(m)) == 0)
765 return MfwResIllHnd;
766
767 mnu->curAttr = mnu->attr;
768 mnu->level = 0;
769 memset(mnu->lCursor,UNUSED,sizeof(mnu->lCursor));
770 memset(mnu->lShift,1,sizeof(mnu->lShift));
771 mnu->lCursor[0] = 0;
772
773 return MfwResOk;
774 }
775
776
777 /*
778 +--------------------------------------------------------------------+
779 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
780 | STATE : code ROUTINE : mnuKeyAction |
781 +--------------------------------------------------------------------+
782
783 PURPOSE : perform direct jumping if there was pressed KCD_1
784 through KCD_9; in this case function returns 1;
785 otherwise function returns 0
786
787 */
788
789 MfwRes mnuKeyAction (MfwHnd m, U8 keycode)
790 {
791 MfwMnu *mnu;
792 U8 directAccess;
793
794 if ((mnu = mfwControl(m)) == 0)
795 return MfwResIllHnd;
796
797 switch (keycode)
798 {
799 case KCD_1: directAccess = 0; break;
800 case KCD_2: directAccess = 1; break;
801 case KCD_3: directAccess = 2; break;
802 case KCD_4: directAccess = 3; break;
803 case KCD_5: directAccess = 4; break;
804 case KCD_6: directAccess = 5; break;
805 case KCD_7: directAccess = 6; break;
806 case KCD_8: directAccess = 7; break;
807 case KCD_9: directAccess = 8; break;
808 default: return MfwResOk; /*a0393213 compiler warning removal --- 0 converted into MfwResOk*/
809 }
810
811 if (directAccess >= mnu->curAttr->nItems)
812 return MfwResOk; /*a0393213 compiler warning removal --- 0 converted into MfwResOk*/
813
814 mnu->lCursor[mnu->level] = directAccess;
815 mnuShow(m);
816 mnuSelect(m);
817
818 return MfwResDone; /*a0393213 compiler warning removal --- 1 converted into MfwResDone*/
819 }
820
821
822 /*
823 +--------------------------------------------------------------------+
824 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
825 | STATE : code ROUTINE : mnuChooseItem |
826 +--------------------------------------------------------------------+
827
828 PURPOSE : Chooses the nItemst Item.
829
830 */
831
832 MfwRes mnuChooseVisibleItem(MfwHnd m,U8 nItem)
833 {
834
835 MfwMnu *mnu;
836 int i;
837
838 if ((mnu = mfwControl(m)) == 0)
839 return MfwResIllHnd;
840
841 /*a0393213 compiler warning removal - commented*/
842 /* if (nItem<0)
843 return MfwResIllHnd;*/
844 for (i = 0; i < mnu->curAttr->nItems; i++)
845 {
846 if (!(mnu->curAttr->items[i].flagFunc(mnu,
847 mnu->curAttr,
848 &(mnu->curAttr->items[i]))
849 & MNU_ITEM_HIDE))
850 {
851 if (!nItem)
852 {
853 mnu->lCursor[mnu->level] = i;
854 mnuUpdate(mnu);
855 return MfwResOk;
856 }
857 else
858 nItem--;
859 }
860 }
861 return MfwResIllHnd;
862
863 }
864
865
866
867 /*
868 +--------------------------------------------------------------------+
869 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
870 | STATE : code ROUTINE : menuIsEmpty |
871 +--------------------------------------------------------------------+
872
873 PURPOSE : check for empty submenu
874
875 */
876
877 static int menuIsEmpty (MfwMnu *m, MfwMnuAttr *ma)
878 {
879 int i;
880
881 for (i = 0; i < ma->nItems; i++)
882 if (!(ma->items[i].flagFunc(m,ma,&(ma->items[i]))
883 & MNU_ITEM_HIDE))
884 return 0;
885
886 return 1;
887 }
888
889
890
891
892
893 /*
894 +--------------------------------------------------------------------+
895 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
896 | STATE : code ROUTINE : countVisible |
897 +--------------------------------------------------------------------+
898
899 PURPOSE : count visible items up to current item
900
901 */
902
903 static int countVisible (MfwMnu *m, MfwMnuAttr *ma, int start)
904 {
905 int i, count;
906
907 for (i = 0, count = 0; i < start; i++)
908 if (!(ma->items[i].flagFunc(m,ma,&(ma->items[i]))
909 & MNU_ITEM_HIDE))
910 count++;
911
912 return count;
913 }
914
915 /*
916 +--------------------------------------------------------------------+
917 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
918 | STATE : code ROUTINE : countVisibleItems |
919 +--------------------------------------------------------------------+
920
921 PURPOSE : count visible items in the current branch
922
923 */
924
925 U8 mnuCountVisibleItems (MfwHnd m)
926 {
927 MfwMnu *mnu;
928
929 if ((mnu = mfwControl(m)) == 0)
930 return 0;
931
932 return (U8)countVisible(mnu, mnu->curAttr,mnu->curAttr->nItems);
933 }
934
935
936 /*
937 +--------------------------------------------------------------------------+
938 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
939 | STATE : code ROUTINE : countCurrentVisibleItem |
940 +--------------------------------------------------------------------------+
941
942 PURPOSE : returns the position of the current Item
943 */
944
945 U8 mnuCountCurrentVisibleItem(MfwHnd m)
946 {
947 MfwMnu *mnu;
948 U8 i;
949 U8 pos=0;
950
951 if ((mnu = mfwControl(m)) == 0)
952 return 0;
953
954 for (i = 0; i < mnu->curAttr->nItems; i++)
955 {
956 if ((mnu->lCursor[mnu->level]) == i)
957 return pos;
958 if (!(mnu->curAttr->items[i].flagFunc(mnu,
959 mnu->curAttr,
960 &(mnu->curAttr->items[i]))
961 & MNU_ITEM_HIDE))
962 pos++;
963 }
964 return pos;
965
966 }
967
968
969
970
971 /*
972 +--------------------------------------------------------------------+
973 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
974 | STATE : code ROUTINE : checkPredraw |
975 +--------------------------------------------------------------------+
976
977 PURPOSE : check / generate predraw event
978
979 */
980
981 static int checkPredraw (MfwMnu *mnu, MfwMnuItem *mi,
982 char **t, MfwIcnAttr **icn)
983 {
984 int res = 0;
985
986 if (mi->flagFunc(mnu,mnu->curAttr,mi) & MNU_ITEM_NOTIFY)
987 {
988 mnu->flags |= E_MNU_PREDRAW;
989 if (mnu->handler)
990 if (mnu->mask & E_MNU_PREDRAW)
991 {
992 if (mi->exta)
993 {
994 ((MfwItmExtPredraw*)(mi->exta))->str = *t;
995 ((MfwItmExtPredraw*)(mi->exta))->icon = *icn;
996 }
997 res = mnu->handler(E_MNU_PREDRAW,mi);
998 if (mi->exta)
999 {
1000 *t = ((MfwItmExtPredraw*)(mi->exta))->str;
1001 *icn = ((MfwItmExtPredraw*)(mi->exta))->icon;
1002 }
1003 }
1004 mnu->flags &= ~E_MNU_PREDRAW;
1005 }
1006
1007 return res;
1008 }
1009
1010
1011 /*
1012 +--------------------------------------------------------------------+
1013 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
1014 | STATE : code ROUTINE : checkPostdraw |
1015 +--------------------------------------------------------------------+
1016
1017 PURPOSE : check / generate postdraw event
1018
1019 */
1020
1021 static int checkPostdraw (MfwMnu *mnu, MfwMnuItem *mi)
1022 {
1023 int res = 0;
1024
1025 if (mi->flagFunc(mnu,mnu->curAttr,mi) & MNU_ITEM_NOTIFY)
1026 {
1027 mnu->flags |= E_MNU_POSTDRAW;
1028 if (mnu->handler)
1029 if (mnu->mask & E_MNU_POSTDRAW)
1030 res = mnu->handler(E_MNU_POSTDRAW,mi);
1031 mnu->flags &= ~E_MNU_POSTDRAW;
1032 }
1033
1034 return res;
1035 }
1036
1037
1038 /*
1039 +--------------------------------------------------------------------+
1040 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
1041 | STATE : code ROUTINE : checkStatus |
1042 +--------------------------------------------------------------------+
1043
1044 PURPOSE : check / insert item status (string MUST be in RAM)
1045
1046 SPR998 - SH - Changed to allow checkbox menu items.
1047 */
1048
1049 static int checkStatus (MfwMnu *m, MfwMnuAttr *ma, MfwMnuItem *mi,
1050 char *menuString)
1051 {
1052 char *e; /* ES!! UNICODE */
1053 int index = 0;
1054 /*a0393213 compiler warning removal - variable unicode removed*/
1055 U16 flagResult;
1056
1057 flagResult = mi->flagFunc(m,ma,mi);
1058 switch (flagResult)
1059 {
1060 case MNU_ITEM_STATED:
1061 e = mi->exta;
1062 if (!e)
1063 return 0;
1064 while (menuString[index])
1065 {
1066 if (menuString[index] == '%') /* ES!! : UNICODE */
1067 {
1068 switch (menuString[index+1])
1069 {
1070 case 'c': /* single char */
1071 strcpy(&menuString[index+1],&menuString[index+2]);
1072 menuString[index] = *e;
1073 e++;
1074 break;
1075 }
1076 }
1077 index++;
1078 }
1079 break;
1080
1081 /* SPR998 - SH - Checked or unchecked option.
1082 * Don't need to do anything here. */
1083
1084 case MNU_ITEM_UNCHECKED:
1085 case MNU_ITEM_CHECKED:
1086 break;
1087
1088 default:
1089 break;
1090 }
1091
1092 return flagResult; /* SPR#998 - SH - Now returns item type */
1093 }
1094
1095
1096 static void mnuDrawHeader(MfwMnuAttr *mnuAttr, MfwRect* areaLeft, char *hdrString)
1097 {
1098 int mode = mnuAttr->mode;
1099 MfwRect* mnuArea = mnuAttr->area;
1100 int mnuColour = mnuAttr->mnuColour;
1101 char* txt=hdrString;
1102 int nPixels;
1103 int xPos,yPos,sy,txtXpos; // Removed txtLen, sx
1104
1105 /* START: 05-June 2006, x0045876 (OMAPS00060424 - Header Toggle) */
1106 dspl_DevCaps disData;
1107
1108 T_DS_TEXTFORMAT format;
1109
1110 T_ATB_TEXT title;
1111 T_ATB_TEXT newTitle;
1112
1113 USHORT titleWidth;
1114 /*a0393213 warning removal-variable titleHeight removed*/
1115 USHORT textIndex;
1116 USHORT lastSpace;
1117 USHORT character;
1118 /* END: 05-June 2006, x0045876 (OMAPS00060424 - Header Toggle) */
1119
1120 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1121 #ifdef FF_MMI_SAT_ICON
1122 USHORT titleIconWidth = 0;
1123 USHORT iconX, iconY;
1124 #endif
1125
1126 xPos = mnuArea->px;
1127 yPos = mnuArea->py;
1128 sy = res_getTitleHeight();
1129 resources_setTitleColour(mnuColour);
1130 dspl_Clear(xPos,yPos,(U16)(mnuArea->sx+xPos-1),(U16)(mnuArea->sy+yPos-1));
1131
1132 if ((mode & MNU_HDR_ALIGN) == MNU_HDR_LEFT)
1133 {
1134 txtXpos = xPos;
1135 }
1136 else
1137 {
1138 /* START: 05-June-2006, x0045876 (OMAPS00060424 - Header Toggle) */
1139 if ((mode & MNU_HDR_ALIGN) == MNU_HDR_RIGHT)
1140 {
1141 nPixels = dspl_GetTextExtent( txt, 0);
1142 txtXpos = xPos + mnuArea->sx - nPixels;
1143 }
1144 else
1145 { //Display in middle
1146 /* START: 05-June-2006, x0045876 (OMAPS00060424 - Header Toggle) */
1147 if (mnuAttr->header_toggle)
1148 {
1149 title.dcs = ATB_DCS_ASCII;
1150 title.data = (UBYTE*)txt;/*a0393213 warnings removal-typecasting done*/
1151 title.len = ATB_string_Length(&title);
1152
1153 ATB_display_SetFormatAttr(&format, 0, FALSE);
1154 titleWidth = ATB_display_StringWidth(&title, &format)+2;
1155 /*titleHeight = ATB_display_StringHeight(&title, &format);*//*a0393213 warning removal-titleHeight assigned but never used*/
1156
1157 dspl_GetDeviceCaps(&disData);
1158
1159 if (titleWidth>(disData.Width-2))
1160 {
1161 if (!g_title_timer)
1162 {
1163 g_title_timer = timCreate(g_win, MNU_TOGGLE_TIMEOUT, (MfwCb) Menu_edit_TitleTimerCb);
1164 g_title_pos = 0;
1165 g_title_next_pos = 0;
1166 timStart(g_title_timer);
1167 }
1168
1169 titleWidth = 0;
1170 textIndex = g_title_pos;
1171 lastSpace = 0;
1172
1173 while (titleWidth<(disData.Width -2) && textIndex<title.len)
1174 {
1175 character = ATB_string_GetChar(&title, textIndex);
1176 titleWidth+=ATB_display_GetCharWidth(character, &format);
1177 textIndex++;
1178 if (character==UNICODE_SPACE)
1179 lastSpace = textIndex;
1180 }
1181
1182 if (textIndex==title.len)
1183 g_title_next_pos = 0;
1184 else
1185 {
1186 if (lastSpace>0)
1187 textIndex = lastSpace;
1188 g_title_next_pos = textIndex;
1189 }
1190
1191 newTitle.len = textIndex-g_title_pos;
1192 newTitle.data = (UBYTE *)mfwAlloc((newTitle.len+1)*ATB_string_Size(&title));
1193 newTitle.dcs = title.dcs;
1194
1195 for (textIndex=0; textIndex<newTitle.len; textIndex++)
1196 {
1197 ATB_string_SetChar(&newTitle, textIndex, ATB_string_GetChar(&title, g_title_pos+textIndex));
1198 }
1199 ATB_string_SetChar(&newTitle, newTitle.len, UNICODE_EOLN);
1200 ATB_display_Text(0,0,&format, &newTitle);
1201 mfwFree((UBYTE *)newTitle.data, (newTitle.len+1)*ATB_string_Size(&title));
1202
1203 areaLeft->px = xPos;
1204 areaLeft->sx = mnuArea->sx;
1205 areaLeft->py = yPos+sy;
1206 areaLeft->sy = mnuArea->sy-sy;
1207
1208 resources_restoreMnuColour();
1209 return;
1210
1211 }
1212 else
1213 {
1214 nPixels = dspl_GetTextExtent( txt, 0);
1215 txtXpos = xPos + (mnuArea->sx - nPixels)/2;
1216 }
1217 }
1218 else
1219 {
1220 nPixels = dspl_GetTextExtent( txt, 0);
1221 txtXpos = xPos + (mnuArea->sx - nPixels)/2;
1222 }
1223 /* END: 05-June-2006, x0045876 (OMAPS00060424 - Header Toggle) */
1224 }
1225 }
1226
1227 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1228 #ifdef FF_MMI_SAT_ICON
1229 if (mnuAttr->icon != NULL)
1230 {
1231 if (mnuAttr->icon->area.sx > TITLE_ICON_WIDTH)
1232 {
1233 titleIconWidth = TITLE_ICON_WIDTH;
1234 }
1235 else
1236 {
1237 titleIconWidth = mnuAttr->icon->area.sx;
1238 }
1239 }
1240 else
1241 {
1242 titleIconWidth = 0;
1243 }
1244
1245 if(titleIconWidth)
1246 txtXpos = txtXpos + titleIconWidth + 1;
1247
1248 if (mnuAttr->icon != NULL)
1249 {
1250 if(mnuAttr->icon->selfExplanatory == FALSE)
1251 {
1252 if (txt[0] != (char)0x80) /*a0393213 lint warnings removal - typecast done*/
1253 dspl_ScrText (txtXpos, yPos, txt, 0);
1254 else
1255 dspl_TextOut(txtXpos, yPos, DSPL_TXTATTR_CURRENT_MODE, txt );
1256 }
1257 }
1258 else
1259 {
1260 if (txt[0] != (char)0x80) /*a0393213 lint warnings removal - typecast done*/
1261 dspl_ScrText (txtXpos, yPos, txt, 0);
1262 else
1263 dspl_TextOut(txtXpos, yPos, DSPL_TXTATTR_CURRENT_MODE, txt );
1264 }
1265 #else
1266 if (txt[0] != 0x80)
1267 dspl_ScrText (txtXpos, yPos, txt, 0);
1268 else
1269 dspl_TextOut(txtXpos, yPos, DSPL_TXTATTR_CURRENT_MODE, txt );
1270 #endif
1271
1272 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1273 #ifdef FF_MMI_SAT_ICON
1274 if (mnuAttr->icon != NULL)
1275 {
1276 if (mnuAttr->icon->icons != NULL)
1277 {
1278 if ((mnuAttr->icon->area.sx > TITLE_ICON_WIDTH) || (mnuAttr->icon->area.sy > TITLE_ICON_HEIGHT))
1279 {
1280 /* iconY calculates place holder to place the icon
1281 at the center of the screen. */
1282 iconX = 1;
1283 iconY = 1+ ((sy-2) / 2) - (10 / 2);
1284 dspl_BitBlt2(iconX, iconY, 8,
1285 10, (void*)SATIconQuestionMark, 0, BMP_FORMAT_256_COLOUR);
1286 }
1287 else
1288 {
1289 dspl_BitBlt2(mnuAttr->icon->area.px, mnuAttr->icon->area.py,
1290 mnuAttr->icon->area.sx, mnuAttr->icon->area.sy,
1291 mnuAttr->icon->icons, 0, mnuAttr->icon->icnType);
1292 }
1293 }
1294 }
1295 #endif
1296
1297 areaLeft->px = xPos;
1298 areaLeft->sx = mnuArea->sx;
1299 areaLeft->py = yPos+sy;
1300 areaLeft->sy = mnuArea->sy-sy;
1301 #ifdef MFW_DEBUG_DISPLAY_SIZE
1302 dspl_DrawRect(xPos,yPos,(xPos+mnuArea->sx-1),(yPos+sy-1));
1303 #endif
1304 resources_restoreMnuColour();
1305 }
1306
1307 // Sep 30, 2005 REF: CRR MMI-SPR-33781 xreddymn
1308 // Description: Menu header not displayed for Golite
1309 // Solution: Added functionality to display menu header
1310 /*
1311 +--------------------------------------------------------------------+
1312 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
1313 | STATE : code ROUTINE : mnuDrawHeaderBW |
1314 +--------------------------------------------------------------------+
1315
1316 PURPOSE : Displays menu header (title) on monochrome displays.
1317 Code is based on mnuDrawHeader. See also mnuDrawHeader.
1318 */
1319 static void mnuDrawHeaderBW(MfwMnuAttr *mnuAttr, MfwRect* areaLeft, char *hdrString)
1320 {
1321 int mode = mnuAttr->mode;
1322 MfwRect *mnuArea = mnuAttr->area;
1323 int mnuColour = mnuAttr->mnuColour;
1324 char *txt = hdrString;
1325 int nPixels;
1326 int xPos, yPos, sy, txtXpos; /*a0393213 compiler warning removal, removed sx and txtLen*/
1327
1328 xPos = mnuArea->px;
1329 yPos = mnuArea->py;
1330 sy = res_getTitleHeight();
1331 resources_setTitleColour(mnuColour);
1332 dspl_Clear(xPos, yPos, (U16)(mnuArea->sx + xPos - 1), (U16)(mnuArea->sy + yPos - 1));
1333 dspl_DrawLine(xPos, (U16)(sy + yPos - 2), (U16)(mnuArea->sx + xPos - 1), (U16)(sy + yPos - 2));
1334 if ((mode & MNU_HDR_ALIGN) == MNU_HDR_LEFT)
1335 { //Position is correct
1336 txtXpos = xPos;
1337 }
1338 else
1339 {
1340 nPixels = dspl_GetTextExtent( txt, 0);
1341 if ((mode & MNU_HDR_ALIGN) == MNU_HDR_RIGHT)
1342 {
1343 txtXpos = xPos + mnuArea->sx - nPixels;
1344 }
1345 else
1346 { //Display in middle
1347 txtXpos = xPos + (mnuArea->sx - nPixels)/2;
1348 }
1349 }
1350 if (txt[0] != (char)0x80) /*a0393213 lint warnings removal-typecast done*/
1351 dspl_ScrText (txtXpos, yPos, txt, 0);
1352 else
1353 dspl_TextOut(txtXpos, yPos, DSPL_TXTATTR_CURRENT_MODE, txt);
1354 // Remaining area is calculated so that it does not touch
1355 // or overlap with the menu header
1356 areaLeft->px = xPos;
1357 areaLeft->sx = mnuArea->sx;
1358 areaLeft->py = yPos+sy + 1;
1359 areaLeft->sy = mnuArea->sy - sy - 1;
1360 resources_restoreMnuColour();
1361 }
1362
1363 /*
1364 +--------------------------------------------------------------------+
1365 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
1366 | STATE : code ROUTINE : drawPageMenu |
1367 +--------------------------------------------------------------------+
1368
1369 PURPOSE : draws menu in page mode
1370
1371 GW 05/10/01 - Changed single value 'lng' to 2 values indicating if ID's should be
1372 used (useStrID) and if the strings are ascii or unicode (uesDefLang).
1373
1374 */
1375 void fastCopyBitmap(int startX, int startY, // start position of bitmap
1376 int bmpSx, int bmpSy, //size of bitmap
1377 char* srcBitmap,
1378 int posX, int posY, // start of area to be copied into
1379 int sx, int sy, // size of area to be copied into
1380 U32 bgd_col, int bmptype);
1381
1382 static void drawPageMenu (MfwMnu *mnu)
1383 {
1384 MfwMnuAttr *ma; /* menu attributes */
1385 //U16 th, tw, tl; /* text height, width, len */
1386 U16 ax, ay, aw, ah; // , x; /* menu area dimensions */
1387 // int tLines; /* lines in item text */
1388 // int nLines; /* lines in menu area */
1389 char *txt; // Removed *t2, save; /* item text & clip saver */
1390 MfwIcnAttr * icn; /* item icon */
1391 U8 oldFont = (U8)-1; /* save previous font */ /*a0393213 compiler warnings removal - explicit casting done*/
1392 MfwMnuItem *mi; /* current item */
1393 // char *t; // Removed tt [64] /* temp item string */
1394
1395
1396 ma = mnu->curAttr;
1397 if (ma->font != (U8) -1)
1398 oldFont = dspl_SelectFontbyID(ma->font); /* setup font */
1399
1400 ax = ma->area->px; ay = ma->area->py;
1401 aw = ma->area->sx; ah = ma->area->sy;
1402
1403 mi = ma->items + mnu->lCursor[mnu->level];
1404 icn = mi->icon;
1405 txt = mi->str;
1406 resources_setColour(ma->mnuColour);
1407
1408 if ((ma->mode & MNU_HDRFORMAT_STR)==0) /* header is a text ID */
1409 txt = (char*)MmiRsrcGetText((int)txt);
1410 checkPredraw(mnu,mi,&txt,&icn); /* ES!! */
1411 {
1412 MfwRect areaLeft;
1413 mnuDrawHeader(ma,&areaLeft,txt);
1414 ax = areaLeft.px; ay = areaLeft.py;
1415 aw = areaLeft.sx; ah = areaLeft.sy;
1416 }
1417 if ((dspl_getDisplayType()==DSPL_COLOUR) && (ma->bgdBitmap != NULL))
1418 {
1419 MfwRect *bmpArea = &ma->bgdBitmap->area;
1420 if ((ma->bgdBitmap->icons != NULL) && (bmpArea->sx >0) && (bmpArea->sy >0))
1421 {
1422 fastCopyBitmap( (int)bmpArea->px, (int)bmpArea->py, (int)bmpArea->sx, (int)bmpArea->sy,
1423 ma->bgdBitmap->icons,
1424 (int)ax,(int)ay, (int)aw, (int)ah,
1425 dspl_GetBgdColour(),
1426 ma->bgdBitmap->icnType);
1427 }
1428 else
1429 {
1430 dspl_Clear(ax,ay,(U16)(ax+aw-1),(U16)(ay+ah-1));
1431 }
1432 }
1433 else
1434 {
1435 dspl_Clear(ax,ay,(U16)(ax+aw-1),(U16)(ay+ah-1));
1436 }
1437
1438
1439
1440 if (icn != NULL)
1441 { /* show associated icon */
1442 dspl_BitBlt2(icn->area.px,icn->area.py,
1443 icn->area.sx,icn->area.sy,
1444 icn->icons,0,icn->icnType);
1445
1446 }
1447 if (oldFont != (U8) -1)
1448 dspl_SelectFontbyID(oldFont); /* restore previous font */
1449
1450 checkPostdraw(mnu,mi); /* ES!! */
1451
1452 #ifdef MFW_DEBUG_DISPLAY_SIZE
1453 dspl_DrawRect(ax,ay,(ax+aw-1),(ay+ah-1));
1454 #endif
1455 resources_restoreColour();
1456 }
1457
1458
1459 /*
1460 +--------------------------------------------------------------------+
1461 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
1462 | STATE : code ROUTINE : drawListMenu |
1463 +--------------------------------------------------------------------+
1464
1465 PURPOSE : draws menu in list mode
1466
1467 GW 05/10/01 - Changed single value 'lng' to 2 values indicating if ID's should be
1468 used (useStrID) and if the strings are ascii or unicode (uesDefLang).
1469 */
1470 #define MAX_STR_CHAR 64
1471 static void drawListMenu (MfwMnu *mnu)
1472 {
1473 MfwMnuAttr *ma; /* menu attributes */
1474 U16 fh, fw; /* font height & width */
1475 U16 ax, ay, aw, ah; /* menu area dimensions */
1476 U16 x, x2=0, EOL_position=0, hfh=0;
1477 int nLines;
1478 int i;
1479 int nIdx;
1480 int nTextLen;
1481 MfwIcnAttr * icn;
1482 // int fit;
1483 char *txtStr; /* item text */
1484 char txt[MAX_STR_CHAR];
1485 U8 oldFont =(U8) -1; /* save previous font */ /*a0393213 compiler warnings removal - explicit type casting done*/
1486 int simpleScrolling;
1487 int status; /* SPR#998 - SH - Status for each menu item */
1488 const USHORT checkbox_width = 7; /* SPR#998 - SH - Checkbox width in pixels */
1489 const USHORT checkbox_height = 7; /* SPR#998 - SH - Checkbox height in pixels */
1490 const USHORT checkbox_spacing_left = 1; /* SPR#998 - SH - Gap between left edge of menu and checkbox */
1491 const USHORT checkbox_spacing_right = 2; /* SPR#998 - SH - Gap between right edge of checkbox and menu text */
1492 USHORT checkbox_x; /* SPR#998 - SH - X position of checkbox */
1493 USHORT checkbox_y; /* SPR#998 - SH - Y position of checkbox */
1494
1495 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1496 #ifdef FF_MMI_SAT_ICON
1497 USHORT titleIconWidth = 0;
1498 /*a0393213 compiler warnings removal - iconX, iconY removed*/
1499 #endif
1500
1501 TRACE_EVENT("drawListMenu() start"); /*a0393213 compiler warnings removal - TIME_TRACE_EVENT changed to TRACE_EVENT*/
1502 ma = mnu->curAttr;
1503
1504 /* SPR#1983 - SH - Ignore language type now */
1505
1506 if (ma->font != (U8) -1)
1507 oldFont = dspl_SelectFontbyID(ma->font); /* setup font */
1508
1509 /* xreddymn Dec-16-2004 MMI-SPR-27384: Two line height list display */
1510 if((ma->mode & MNU_DISPLAY)== MNU_LIST_2_LINE)
1511 {
1512 hfh = dspl_GetFontHeight(); /* height of one line */
1513 fh = hfh<<1; /* height of two lines */
1514 }
1515 else
1516 fh = dspl_GetFontHeight();
1517 fw = dspl_GetTextExtent("X",1); // ES!! only for normal fonts !
1518
1519 //Display header info (if required)
1520 if ((ma->hdrId != 0) && (dspl_getDisplayType()==DSPL_COLOUR))
1521 {
1522 MfwRect areaLeft;
1523 char *hdrStr;
1524 if ((ma->mode & MNU_HDRFORMAT_STR)==0) /* header is a text ID */
1525 hdrStr = MmiRsrcGetText(ma->hdrId);
1526 else
1527 hdrStr = (char*)(ma->hdrId);
1528 mnuDrawHeader(ma,&areaLeft,hdrStr);
1529 ax = areaLeft.px; ay = areaLeft.py;
1530 aw = areaLeft.sx; ah = areaLeft.sy;
1531 }
1532 // Sep 30, 2005 REF: CRR MMI-SPR-33781 xreddymn
1533 // Description: Menu header not displayed for Golite
1534 // Solution: Added functionality to display menu header
1535 // Display a different header in case of monochrome screens
1536 else if((ma->hdrId != 0) && (DSPL_BW == dspl_getDisplayType()))
1537 {
1538 MfwRect areaLeft;
1539 char *hdrStr;
1540 if ((ma->mode & MNU_HDRFORMAT_STR) == 0) /* header is a text ID */
1541 hdrStr = MmiRsrcGetText(ma->hdrId);
1542 else
1543 hdrStr = (char*)(ma->hdrId);
1544 mnuDrawHeaderBW(ma, &areaLeft, hdrStr);
1545 ax = areaLeft.px; ay = areaLeft.py;
1546 aw = areaLeft.sx; ah = areaLeft.sy;
1547 }
1548 else
1549 {
1550 ax = ma->area->px; ay = ma->area->py;
1551 aw = ma->area->sx; ah = ma->area->sy;
1552 }
1553 resources_setColour(ma->mnuColour);
1554 dspl_Clear(ax,ay,(U16)(aw+ax-1),(U16)(ah+ay-1));
1555 nLines = ah / fh;
1556 mnu->nLines = nLines; //Store the number of lines we are drawing for scrolling up/down
1557 {
1558 // TRACE_EVENT_P5(" ax:%d ay:%d aw:%d ah:%d lines:%d",ax,ay,aw,ah, nLines);
1559 }
1560 if ((!mnu->scrollMode)||(countVisible(mnu,ma,ma->nItems)<=nLines)) /* Simple scrolling */
1561 simpleScrolling = TRUE;
1562 else
1563 simpleScrolling = FALSE;
1564
1565 if (simpleScrolling)
1566 {
1567 nIdx = (countVisible(mnu,ma,mnu->lCursor[mnu->level])/nLines)*nLines;
1568 }
1569 else
1570 {
1571 int count=mnu->lShift[mnu->level];
1572 int index= mnu->lCursor[mnu->level]+1;
1573 int nVisibles = countVisible(mnu,ma,ma->nItems);
1574
1575 while (ma->items[index-1].flagFunc(mnu,ma,&(ma->items[index-1])) & MNU_ITEM_HIDE)
1576 {
1577 index++;
1578 }
1579
1580 while (count>0){
1581 if (index<=0)
1582 index = ma->nItems-1;
1583 else
1584 index--;
1585 if (!(ma->items[index].flagFunc(mnu,ma,&(ma->items[index]))& MNU_ITEM_HIDE))
1586 count--;
1587 }
1588 if (nVisibles<nLines)
1589 nLines = nVisibles;
1590 nIdx = index;
1591 }
1592
1593 for (i = 0; i < nLines; nIdx++) /* ES!! not so nice... */
1594 {
1595 if (nIdx >= ma->nItems)
1596 {
1597 if (simpleScrolling)
1598 break;
1599 else
1600 nIdx=0;
1601 }
1602
1603 if (ma->items[nIdx].flagFunc(mnu,ma,&(ma->items[nIdx]))
1604 & MNU_ITEM_HIDE)
1605 continue;
1606 if (mnu->useStrID) /* use language handler */
1607 txtStr = (char*)MmiRsrcGetText((int)ma->items[nIdx].str); //JVJE
1608 else
1609 txtStr = ma->items[nIdx].str;
1610 icn = ma->items[nIdx].icon;
1611
1612 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1613 #ifdef FF_MMI_SAT_ICON
1614 if (icn != NULL)
1615 {
1616 if (icn->area.sx > TITLE_ICON_WIDTH)
1617 {
1618 titleIconWidth = TITLE_ICON_WIDTH;
1619 }
1620 else
1621 {
1622 titleIconWidth = icn->area.sx;
1623 }
1624 }
1625 else
1626 {
1627 titleIconWidth = 0;
1628 }
1629 #endif
1630
1631 checkPredraw(mnu,ma->items+nIdx,&txtStr,&icn); /* ES!! */
1632 memcpy(txt,txtStr,MAX_STR_CHAR);
1633 status = checkStatus(mnu,ma,ma->items+nIdx,txt); /* SPR#998 - SH - Store the resulting status */
1634
1635 if ((mnu->useStrID) &&
1636 ((ma->mode & MNU_DISPLAY) == MNU_LIST_COLOUR))
1637 {
1638 resources_setColourMnuItem( (int)ma->items[nIdx].str );
1639 }
1640
1641 /* xreddymn Dec-16-2004 MMI-SPR-27384: For two line menu item display */
1642 if((ma->mode & MNU_DISPLAY)== MNU_LIST_2_LINE)
1643 {
1644 EOL_position=0;
1645 #ifdef NO_ASCIIZ
1646 if(txt[0] == (char)0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE) /*a0393213 lint warnings removal - typecast done*/
1647 {
1648 while((((U16*)txt)[EOL_position]!='\n') && (((U16*)txt)[EOL_position]!='\0')) EOL_position++;
1649 if(((U16*)txt)[EOL_position]=='\0') /* Less than two lines to display */
1650 EOL_position=0;
1651 else /* Two lines to display, break each line with a '\0' */
1652 {
1653 ((U16*)txt)[EOL_position]='\0';
1654 EOL_position++;
1655 }
1656 }
1657 else
1658 #endif
1659 {
1660 while((txt[EOL_position]!='\n') && (txt[EOL_position]!='\0')) EOL_position++;
1661 if(txt[EOL_position]=='\0') /* Less than two lines to display */
1662 EOL_position=0;
1663 else /* Two lines to display, break each line with a '\0' */
1664 {
1665 txt[EOL_position]='\0';
1666 EOL_position++;
1667 }
1668 }
1669 if(EOL_position>0)
1670 {
1671 #ifdef NO_ASCIIZ
1672 if(txt[0] == (char)0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE) /*a0393213 lint warnings removal - typecast done*/
1673 nTextLen = dspl_GetTextExtent((char*)(txt+(EOL_position<<1)),(U16)dspl_str_length(txt));
1674 else
1675 #endif
1676 nTextLen = dspl_GetTextExtent((char*)(txt+EOL_position),(U16)dspl_str_length(txt));
1677
1678 /* SPR#998 - SH - If list is a checkbox list, include space for checkbox in width */
1679 if (status==MNU_ITEM_CHECKED || status==MNU_ITEM_UNCHECKED)
1680 {
1681 nTextLen+=(checkbox_spacing_left+checkbox_width+checkbox_spacing_right);
1682 }
1683 /* end of SPR#998 */
1684
1685 if ((ma->mode & MNU_ALIGN) == MNU_CENTER)
1686 x2 = (U16) (ax + (aw - nTextLen) / 2);
1687 else if ((ma->mode & MNU_ALIGN) == MNU_RIGHT)
1688 x2 = (U16) (ax + aw - nTextLen);
1689 else
1690 x2 = (U16) (ax + fw); /* MNU_LEFT (default) */
1691 if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_LINE)
1692 x2 =ax;
1693 }
1694 }
1695
1696 nTextLen = dspl_GetTextExtent(txt,(U16)dspl_str_length(txt));
1697
1698 /* SPR#998 - SH - If list is a checkbox list, include space for checkbox in width */
1699
1700 if (status==MNU_ITEM_CHECKED || status==MNU_ITEM_UNCHECKED)
1701 {
1702 nTextLen+=(checkbox_spacing_left+checkbox_width+checkbox_spacing_right);
1703 }
1704
1705 /* end of SPR#998 */
1706
1707 if ((ma->mode & MNU_ALIGN) == MNU_CENTER)
1708 x = (U16) (ax + (aw - nTextLen) / 2);
1709 else if ((ma->mode & MNU_ALIGN) == MNU_RIGHT)
1710 x = (U16) (ax + aw - nTextLen);
1711 else
1712 x = (U16) (ax + fw); /* MNU_LEFT (default) */
1713 if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_LINE)
1714 x =ax;
1715
1716 /* SPR#998 - SH - Draw checkboxes if required */
1717
1718 if (status==MNU_ITEM_CHECKED || status==MNU_ITEM_UNCHECKED)
1719 {
1720 checkbox_x = x+checkbox_spacing_left;
1721 checkbox_y = ay+i*fh+(fh-checkbox_height)/2;
1722
1723 if (status==MNU_ITEM_CHECKED)
1724 {
1725 /* NOTE: for some reason, a filled rect must have x2, y2 +1 of the same size
1726 * of unfilled rect...compare parameters here and below */
1727 dspl_DrawFilledRect(checkbox_x, checkbox_y, checkbox_x+checkbox_width+1,
1728 checkbox_y+checkbox_height+1);
1729 }
1730 else
1731 {
1732 dspl_DrawRect(checkbox_x, checkbox_y, checkbox_x+checkbox_width,
1733 checkbox_y+checkbox_height);
1734 }
1735 x+=(checkbox_spacing_left+checkbox_width+checkbox_spacing_right); /* Text box now starts just to the right of checkbox */
1736
1737 /* xreddymn Dec-16-2004 MMI-SPR-27384: For two line menu item display */
1738 x2+=(checkbox_spacing_left+checkbox_width+checkbox_spacing_right);
1739 }
1740
1741 /* end of SPR#998 */
1742
1743 {
1744 #ifdef NO_ASCIIZ
1745 /*MC, use universal height rather than smaller chinese font height*/
1746 /*MC, SPR1526, send whole string to dspl_TextOut, rather than missing out unicode tag*/
1747 /* SPR#1983 - SH - If unicode is set, send text as unicode */
1748
1749 if (txt[0] == (char)0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE) /*a0393213 lint warnings removal - typecast done*/
1750 {
1751 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1752 #ifdef FF_MMI_SAT_ICON
1753 if (icn != NULL)
1754 {
1755 if(icn->selfExplanatory == FALSE)
1756 dspl_TextOut(titleIconWidth + 1 + x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
1757 }
1758 else
1759 dspl_TextOut(x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
1760 #else
1761 dspl_TextOut(x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
1762 #endif
1763 if(EOL_position>0) /* xreddymn Dec-16-2004 MMI-SPR-27384: two line display */
1764 {
1765 dspl_TextOut(x2,(U16)ay+i*fh+hfh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,(char*)(txt+(EOL_position<<1)));
1766
1767 }
1768 }
1769 else
1770 #endif
1771 {
1772 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1773 #ifdef FF_MMI_SAT_ICON
1774 if (icn != NULL)
1775 {
1776 if(icn->selfExplanatory == FALSE)
1777 dspl_TextOut(titleIconWidth + 1 + x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,txt);
1778 }
1779 else
1780 dspl_TextOut(x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,txt);
1781 #else
1782 dspl_TextOut(x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,txt);
1783 #endif
1784 if(EOL_position>0) /* xreddymn Dec-16-2004 MMI-SPR-27384: two line display */
1785 {
1786 dspl_TextOut(x2,(U16)(ay+i*fh+hfh),DSPL_TXTATTR_CURRENT_MODE,(char*)(txt+EOL_position));
1787 }
1788 }
1789 }
1790
1791 if (nIdx == mnu->lCursor[mnu->level])
1792 {
1793 if ((ma->mode & MNU_ITEMSEL) == MNU_FRAMED)
1794 dspl_DrawRect(ax,(U16)(ay+i*fh),(U16)(aw-2+ax),
1795 (U16)(fh-1+ay+i*fh));
1796 else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_ARROW)
1797 dspl_TextOut(ax,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,">");
1798 else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_STAR)
1799 dspl_TextOut(ax,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,"*");
1800 else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_BLOCK)
1801 dspl_TextOut(ax,(U16)(ay+i*fh),
1802 DSPL_TXTATTR_CURRENT_MODE|DSPL_TXTATTR_INVERS," ");
1803 else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_LINE)
1804 {
1805 if (dspl_getDisplayType()==DSPL_BW)
1806 {
1807 dspl_DrawFilledColRect(x,ay+i*fh,aw,ay+(i+1)*fh,0x00FFFFFF);
1808 #ifdef NO_ASCIIZ
1809 /* SPR#1983 - SH - If unicode is set, send text as unicode */
1810 if (txt[0] == (char)0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE) /*a0393213 lint warnings removal - typecast done*/
1811 {
1812 dspl_TextOut(x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,txt);
1813 if(EOL_position>0) /* xreddymn Dec-16-2004 MMI-SPR-27384: two line display */
1814 {
1815 dspl_TextOut(x2,(U16)ay+i*fh+hfh/*MC, 1319*/,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,(char*)(txt+(EOL_position<<1)));
1816 }
1817 }
1818 else
1819 #endif
1820 {
1821 dspl_TextOut(x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE|DSPL_TXTATTR_INVERS,txt);
1822 if(EOL_position>0) /* xreddymn Dec-16-2004 MMI-SPR-27384: two line display */
1823 {
1824 dspl_TextOut(x2,(U16)(ay+i*fh+hfh),DSPL_TXTATTR_CURRENT_MODE|DSPL_TXTATTR_INVERS,(char*)(txt+EOL_position));
1825 }
1826 }
1827 }
1828 else
1829 {
1830 resources_setHLColour(ma->mnuColour);
1831 dspl_DrawFilledBgdRect(x,ay+i*fh,aw,ay+(i+1)*fh);
1832 #ifdef NO_ASCIIZ
1833 /* SPR#1983 - SH - If unicode is set, send text as unicode */
1834 if (txt[0] == (char)0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE) /*a0393213 lint warnings removal-typecast done*/
1835 {
1836 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1837 #ifdef FF_MMI_SAT_ICON
1838 if (icn != NULL)
1839 {
1840 if(icn->selfExplanatory == FALSE)
1841 dspl_TextOut(titleIconWidth + x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
1842 }
1843 else
1844 dspl_TextOut(x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
1845 #else
1846 dspl_TextOut(x,(U16)ay+i*fh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
1847 #endif
1848 if(EOL_position>0) /* xreddymn Dec-16-2004 MMI-SPR-27384: two line display */
1849 {
1850 dspl_TextOut(x2,(U16)ay+i*fh+hfh/*MC, 1319*/,DSPL_TXTATTR_UNICODE,(char*)(txt+(EOL_position<<1)));
1851 }
1852 }
1853 else
1854 #endif
1855 {
1856 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1857 #ifdef FF_MMI_SAT_ICON
1858 if (icn != NULL)
1859 {
1860 if(icn->selfExplanatory == FALSE)
1861 dspl_TextOut(titleIconWidth + x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,txt);
1862 }
1863 else
1864 dspl_TextOut(x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,txt);
1865 #else
1866 dspl_TextOut(x,(U16)(ay+i*fh),DSPL_TXTATTR_CURRENT_MODE,txt);
1867 #endif
1868 if(EOL_position>0) /* xreddymn Dec-16-2004 MMI-SPR-27384: two line display */
1869 {
1870 dspl_TextOut(x2,(U16)(ay+i*fh+hfh),DSPL_TXTATTR_CURRENT_MODE,(char*)(txt+EOL_position));
1871 }
1872 }
1873 resources_restoreMnuColour();
1874
1875 }
1876 }
1877 if (icn != NULL)// && icn->nIcons > nIdx)
1878 {
1879 // Shashi Shekar B.S., a0876501, Feb 4, 2006, DR: OMAPS00061462
1880 #ifdef FF_MMI_SAT_ICON
1881 /* There is a problem when this icon is displayed.
1882 The last parameter was not taken into consideration & a default '0' was been set. This is corrected now.*/
1883 /* dspl_BitBlt2(icn->area.px, icn->area.py,
1884 icn->area.sx, icn->area.sy,
1885 icn->icons, 0, icn->icnType);*/
1886
1887 if ((icn->area.sx > LINE_ICON_WIDTH) || (icn->area.sy > fh))
1888 {
1889 dspl_BitBlt2(icn->area.px, icn->area.py,
1890 icn->area.sx, icn->area.sy, (void*)SATIconQuestionMark, 0, BMP_FORMAT_256_COLOUR);
1891 }
1892 else
1893 {
1894 dspl_BitBlt2(icn->area.px, icn->area.py,
1895 icn->area.sx, icn->area.sy,
1896 icn->icons, 0, icn->icnType);
1897 }
1898 #else
1899 dspl_BitBlt2(icn->area.px,icn->area.py,
1900 icn->area.sx,icn->area.sy,
1901 icn->icons,(U16)nIdx,0);
1902 #endif
1903 }
1904 }
1905 i++;
1906 checkPostdraw(mnu,ma->items+nIdx); /* ES!! */
1907 }
1908
1909 if (oldFont != (U8) -1)
1910 dspl_SelectFontbyID(oldFont); /* restore previous font */
1911
1912 /* SPR#1983 - SH - No longer have to change text type back */
1913
1914 resources_restoreColour();
1915 #ifdef MFW_DEBUG_DISPLAY_SIZE
1916 dspl_DrawRect(ax,ay,(ax+aw-1),(ay+ah-1));
1917 #endif
1918 TRACE_EVENT("drawListMenu() end"); /*a0393213 warnings removal-TIME_TRACE_EVENT changed to TRACE_EVENT*/
1919
1920 }
1921
1922
1923 static void drawIconsListMenu(MfwMnu *mnu)
1924 {
1925 MfwMnuAttr *ma; /* menu attributes */
1926 U16 fh, fw; /* font height & width */
1927 U16 ax, ay, aw, ah; /* menu area dimensions */
1928 U16 x;
1929 int nLines;
1930 int i;
1931 int nIdx;
1932 int nTextLen;
1933 MfwIcnAttr * icn;
1934 char *txtStr; /* item text */
1935 char txt[MAX_STR_CHAR];
1936 U8 oldFont = (U8)-1; /* save previous font */ /* x0020906 - Type Cast - 14-08-2006 */
1937 int simpleScrolling;
1938 int icon_w=0;
1939 int icon_h=0;
1940 TRACE_FUNCTION("drawIconsListMenu()"); /* Replace TIME_TRACE_EVENT to TRACE_FUNCTION - x0020906 - Warning Correction */
1941 ma = mnu->curAttr;
1942 /* SPR#1983 - SH - Ignore language type now */
1943
1944 if (ma->font != (U8) -1)
1945 oldFont = dspl_SelectFontbyID(ma->font); /* setup font */
1946
1947 fh = dspl_GetFontHeight();
1948 fw = dspl_GetTextExtent("X",1); // ES!! only for normal fonts !
1949
1950 //Display header info (if required)
1951 if ((ma->hdrId != 0) && (dspl_getDisplayType()==DSPL_COLOUR))
1952 {
1953 MfwRect areaLeft;
1954 char *hdrStr;
1955 if ((ma->mode & MNU_HDRFORMAT_STR)==0) /* header is a text ID */
1956 hdrStr = MmiRsrcGetText(ma->hdrId);
1957 else
1958 hdrStr = (char*)(ma->hdrId);
1959 mnuDrawHeader(ma,&areaLeft,hdrStr);
1960 ax = areaLeft.px; ay = areaLeft.py;
1961 aw = areaLeft.sx; ah = areaLeft.sy;
1962 }
1963 // Sep 30, 2005 REF: CRR MMI-SPR-33781 xreddymn
1964 // Description: Menu header not displayed for Golite
1965 // Solution: Added functionality to display menu header
1966 // Display a different header in case of monochrome screens
1967 else if((ma->hdrId != 0) && (DSPL_BW == dspl_getDisplayType()))
1968 {
1969 MfwRect areaLeft;
1970 char *hdrStr;
1971 if ((ma->mode & MNU_HDRFORMAT_STR) == 0) /* header is a text ID */
1972 hdrStr = MmiRsrcGetText(ma->hdrId);
1973 else
1974 hdrStr = (char*)(ma->hdrId);
1975 mnuDrawHeaderBW(ma, &areaLeft, hdrStr);
1976 ax = areaLeft.px; ay = areaLeft.py;
1977 aw = areaLeft.sx; ah = areaLeft.sy;
1978 }
1979 else
1980 {
1981 ax = ma->area->px; ay = ma->area->py;
1982 aw = ma->area->sx; ah = ma->area->sy;
1983 }
1984 resources_setColour(ma->mnuColour);
1985 dspl_Clear(ax,ay,(U16)(aw+ax-1),(U16)(ah+ay-1));
1986 //nLines = ah / fh;
1987 if(ma->items[0].icon != NULL)
1988 {
1989 icon_w=ma->items[0].icon->area.sx+10;
1990 icon_h = ma->items[0].icon->area.sy;
1991 }
1992 else
1993 {
1994 icon_w = 0;
1995 icon_h = fh;
1996 }
1997 nLines=ah/icon_h;
1998 mnu->nLines= nLines;
1999 icon_h=ah/nLines;
2000 mnu->lineHeight = icon_h;
2001 mnu->nLines = nLines; //Store the number of lines we are drawing for scrolling up/down
2002 if ((!mnu->scrollMode)||(countVisible(mnu,ma,ma->nItems)<=nLines)) /* Simple scrolling */
2003 simpleScrolling = TRUE;
2004 else
2005 simpleScrolling = FALSE;
2006
2007 if (simpleScrolling)
2008 {
2009 nIdx = (countVisible(mnu,ma,mnu->lCursor[mnu->level])/nLines)*nLines;
2010 }
2011 else
2012 {
2013 int count=mnu->lShift[mnu->level];
2014 int index= mnu->lCursor[mnu->level]+1;
2015 int nVisibles = countVisible(mnu,ma,ma->nItems);
2016
2017 while (ma->items[index-1].flagFunc(mnu,ma,&(ma->items[index-1])) & MNU_ITEM_HIDE)
2018 {
2019 index++;
2020 }
2021
2022 while (count>0){
2023 if (index<=0)
2024 index = ma->nItems-1;
2025 else
2026 index--;
2027 if (!(ma->items[index].flagFunc(mnu,ma,&(ma->items[index]))& MNU_ITEM_HIDE))
2028 count--;
2029 }
2030 if (nVisibles<nLines)
2031 nLines = nVisibles;
2032 nIdx = index;
2033 }
2034 if(ma->items[0].icon != NULL)
2035 {
2036 ma->items[0].icon->area.px=ax;
2037 ma->items[0].icon->area.py=ay;
2038 }
2039 for (i = 0; i < nLines; nIdx++) /* ES!! not so nice... */
2040 {
2041 if (nIdx >= ma->nItems)
2042 {
2043 if (simpleScrolling)
2044 break;
2045 else
2046 nIdx=0;
2047 }
2048 if (ma->items[nIdx].flagFunc(mnu,ma,&(ma->items[nIdx]))
2049 & MNU_ITEM_HIDE)
2050 continue;
2051 if (mnu->useStrID) /* use language handler */
2052 txtStr = (char*)MmiRsrcGetText((int)ma->items[nIdx].str); //JVJE
2053 else
2054 txtStr = ma->items[nIdx].str;
2055 icn = ma->items[nIdx].icon;
2056
2057 checkPredraw(mnu,ma->items+nIdx,&txtStr,&icn); /* ES!! */
2058 memcpy(txt,txtStr,MAX_STR_CHAR);
2059 checkStatus(mnu,ma,ma->items+nIdx,txt); /* SPR#998 - SH - Store the resulting status */
2060
2061 if ((mnu->useStrID) &&
2062 ((ma->mode & MNU_DISPLAY) == MNU_LIST_COLOUR))
2063 {
2064 resources_setColourMnuItem( (int)ma->items[nIdx].str );
2065 }
2066
2067 nTextLen = dspl_GetTextExtent(txt,(U16)dspl_str_length(txt));
2068
2069 if ((ma->mode & MNU_ALIGN) == MNU_CENTER)
2070 x = (U16) (ax + (aw - nTextLen) / 2);
2071 else if ((ma->mode & MNU_ALIGN) == MNU_RIGHT)
2072 x = (U16) (ax + aw - nTextLen);
2073 else
2074 x = (U16) (ax + fw); /* MNU_LEFT (default) */
2075 if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_LINE)
2076 x =ax;
2077
2078 /* SPR#998 - SH - Draw checkboxes if required */
2079
2080
2081
2082 /* end of SPR#998 */
2083
2084 {
2085 #ifdef NO_ASCIIZ
2086 /*MC, use universal height rather than smaller chinese font height*/
2087 /*MC, SPR1526, send whole string to dspl_TextOut, rather than missing out unicode tag*/
2088 /* SPR#1983 - SH - If unicode is set, send text as unicode */
2089
2090 if (txt[0] == (char)0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE)
2091 {
2092 dspl_TextOut(x+icon_w,(U16)ay+i*icon_h/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
2093 }
2094 else
2095 #endif
2096 {
2097
2098 dspl_TextOut(x+icon_w,(U16)(ay+i*icon_h),DSPL_TXTATTR_CURRENT_MODE,txt);
2099 }
2100 }
2101
2102 if (nIdx == mnu->lCursor[mnu->level])
2103 {
2104 if ((ma->mode & MNU_ITEMSEL) == MNU_FRAMED)
2105 dspl_DrawRect(ax,(U16)(ay+i*icon_h),(U16)(aw-2+ax),
2106 (U16)(icon_h-1+ay+i*icon_h));
2107 else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_ARROW)
2108 dspl_TextOut(ax+icon_w,(U16)(ay+i*icon_h),DSPL_TXTATTR_CURRENT_MODE,">");
2109 else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_STAR)
2110 dspl_TextOut(ax+icon_w,(U16)(ay+i*icon_h),DSPL_TXTATTR_CURRENT_MODE,"*");
2111 else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_BLOCK)
2112 dspl_TextOut(ax+icon_w,(U16)(ay+i*icon_h),
2113 DSPL_TXTATTR_CURRENT_MODE|DSPL_TXTATTR_INVERS," ");
2114 else if ((ma->mode & MNU_ITEMSEL) == MNU_CUR_LINE)
2115 {
2116 if (dspl_getDisplayType()==DSPL_BW)
2117 {
2118 dspl_DrawFilledColRect(x,ay+i*icon_h,aw,ay+(i+1)*icon_h,0x00FFFFFF);
2119 #ifdef NO_ASCIIZ
2120 /* SPR#1983 - SH - If unicode is set, send text as unicode */
2121 if (txt[0] == (char)0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE)
2122 {
2123 dspl_TextOut(x+icon_w,(U16)ay+i*icon_h/*MC, 1319*/,DSPL_TXTATTR_UNICODE|DSPL_TXTATTR_INVERS,txt);
2124 }
2125 else
2126 #endif
2127 {
2128 dspl_TextOut(x+icon_w,(U16)(ay+i*icon_h),DSPL_TXTATTR_CURRENT_MODE|DSPL_TXTATTR_INVERS,txt);
2129 }
2130 }
2131 else
2132 {
2133 resources_setHLColour(ma->mnuColour);
2134 dspl_DrawFilledBgdRect(x,ay+i*icon_h,aw,ay+(i+1)*icon_h);
2135 #ifdef NO_ASCIIZ
2136 /* SPR#1983 - SH - If unicode is set, send text as unicode */
2137 if (txt[0] == (char)0x80 || mnu->textDCS==MNU_LIST_LANGUAGE_UNICODE)
2138 {
2139
2140 dspl_TextOut(x+icon_w,(U16)ay+i*icon_h/*MC, 1319*/,DSPL_TXTATTR_UNICODE,txt);
2141 }
2142 else
2143 #endif
2144 {
2145
2146 dspl_TextOut(x+icon_w,(U16)(ay+i*icon_h),DSPL_TXTATTR_CURRENT_MODE,txt);
2147
2148 }
2149 resources_restoreMnuColour();
2150
2151 }
2152 }
2153 if (icn != NULL)// && icn->nIcons > nIdx)
2154 {
2155 dspl_BitBlt2(ax,ay+i*icon_h,
2156 icn->area.sx,icn->area.sy,
2157 icn->icons,0,icn->icnType);
2158 }
2159 }
2160 else
2161 {
2162 if (icn != NULL){
2163 dspl_BitBlt2(ax,ay+i*icon_h,
2164 icn->area.sx,icn->area.sy,
2165 icn->icons,0,icn->icnType); }
2166 }
2167 i++;
2168 checkPostdraw(mnu,ma->items+nIdx); /* ES!! */
2169 }
2170
2171 if (oldFont != (U8) -1)
2172 dspl_SelectFontbyID(oldFont); /* restore previous font */
2173
2174
2175 resources_restoreColour();
2176 #ifdef MFW_DEBUG_DISPLAY_SIZE
2177 dspl_DrawRect(ax,ay,(ax+aw-1),(ay+ah-1));
2178 #endif
2179
2180 }
2181
2182
2183 /*
2184 +--------------------------------------------------------------------+
2185 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
2186 | STATE : code ROUTINE : drawFreeMenu |
2187 +--------------------------------------------------------------------+
2188
2189 PURPOSE : draws menu in overlapped mode
2190
2191 */
2192 static void drawFreeMenu (MfwMnu *mnu)
2193 {
2194 // ES!! to be revised
2195 //kk needs font entry
2196 int nFontHeight;
2197 int i, x;
2198 int nIdx;
2199 int nTextLen;
2200 MfwIcnAttr * icn;
2201
2202 MfwMnuAttr *wa; /* working attribute */
2203 wa = mnu->curAttr;
2204 dspl_Clear(wa->area->px,wa->area->py,
2205 (U16)(wa->area->sx+wa->area->px-1),
2206 (U16)(wa->area->sy+wa->area->py-1));
2207 nFontHeight = dspl_GetFontHeight();
2208 nTextLen = dspl_GetTextExtent(wa->items[mnu->lCursor[mnu->level]].str,
2209 (U16)dspl_str_length(wa->items[mnu->lCursor[mnu->level]].str));
2210
2211 if ((wa->mode & MNU_ALIGN) == MNU_CENTER)
2212 x = wa->area->px + (wa->area->sx - nTextLen) / 2;
2213 else if ((wa->mode & MNU_ALIGN) == MNU_RIGHT)
2214 x = wa->area->px + wa->area->sx - nTextLen;
2215 else
2216 x = wa->area->px;
2217
2218 dspl_TextOut((U16)x,(U16)(wa->area->py+wa->area->sy-nFontHeight),DSPL_TXTATTR_CURRENT_MODE,
2219 wa->items[mnu->lCursor[mnu->level]].str);
2220
2221 for (i = 0; i < wa->nItems; i++)
2222 {
2223 nIdx = (mnu->lCursor[mnu->level] + i + 1) % wa->nItems;
2224 icn = wa->items[nIdx].icon;
2225
2226 if (icn != NULL)
2227 dspl_BitBlt(icn->area.px,icn->area.py,
2228 icn->area.sx,icn->area.sy,
2229 0/*icn->usIndex*/,icn->icons,0);
2230 }
2231 }
2232
2233 /*
2234 +--------------------------------------------------------------------+
2235 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
2236 | STATE : code ROUTINE : mnuCommand |
2237 +--------------------------------------------------------------------+
2238
2239 PURPOSE : handle mfw windows command
2240
2241 */
2242
2243 static int mnuCommand (U32 cmd, void *h)
2244 {
2245 switch (cmd)
2246 {
2247 case MfwCmdDelete: /* delete me */
2248 if (!h)
2249 return 0;
2250 mnuDelete(h);
2251 return 1;
2252 case MfwCmdUpdate: /* repaint */
2253 if (!h || ((MfwHdr *) h)->type != MfwTypMnu)
2254 return 0;
2255 mnuUpdate(((MfwHdr *) h)->data);
2256 return 1;
2257 default:
2258 break;
2259 }
2260
2261 return 0;
2262 }
2263
2264
2265 /*
2266 +--------------------------------------------------------------------+
2267 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
2268 | STATE : code ROUTINE : mnuScrollMode |
2269 +--------------------------------------------------------------------+
2270
2271 PURPOSE : handle mfw windows command
2272
2273 */
2274
2275 void mnuScrollMode (MfwHnd menu,U8 mode)
2276 {
2277 MfwMnu *mnu;
2278
2279 if ((mnu = mfwControl(menu)) == 0)
2280 return;
2281 mnu->scrollMode = mode;
2282 }
2283
2284
2285 void mnuInitDataItem(MfwMnuItem* mnuItem)
2286 {
2287 mnuItem->icon = 0;
2288 mnuItem->exta = 0;
2289 mnuItem->menu = 0;
2290 mnuItem->func = 0;
2291 mnuItem->str = NULL;
2292 mnuItem->flagFunc = 0;
2293
2294 }
2295
2296 /*
2297 +--------------------------------------------------------------------+
2298 | PROJECT : MMI-Framework (8417) MODULE : MFW_MNU |
2299 | STATE : code ROUTINE : mnuIdentify |
2300 +--------------------------------------------------------------------+
2301
2302 PURPOSE : SPR998 - SH - Identify menu option. Returns the index of the option, or -1
2303 if option is not found.
2304
2305 */
2306
2307 int mnuIdentify(struct MfwMnuAttrTag *attr, struct MfwMnuItemTag *item)
2308 {
2309 int index;
2310 int currentOption;
2311
2312 /* Identify current menu option */
2313
2314 currentOption = -1;
2315
2316 for (index=0; index < attr->nItems; index++)
2317 {
2318 if (&attr->items[index]==item)
2319 currentOption = index;
2320 }
2321
2322 return currentOption;
2323 }
2324
2325
2326 void MMI_TRACE_P1(char* str, int err)
2327 {
2328 TRACE_EVENT_P2("%s:%d",str,err);
2329 }
2330
2331 /* START: 05-June-2006, x0045876 (OMAPS00060424 - Header Toggle) */
2332 /*******************************************************************************
2333
2334 $Function: Menu_edit_TitleTimerCb
2335
2336 $Description: Callback function for the Menu title timer. Recalculates title_pos so that
2337 the next part of the string is displayed.
2338
2339 $Returns: None.
2340
2341 $Arguments: event - the event type
2342 timer - the timer
2343
2344 *******************************************************************************/
2345 static int Menu_edit_TitleTimerCb (MfwEvt e, MfwTim *t)
2346 {
2347 TRACE_FUNCTION("Menu_edit_TitleTimerCb");
2348
2349 if (g_title_next_pos!=g_title_pos)
2350 g_title_pos = g_title_next_pos;
2351 winShow(g_win);
2352 timStart(g_title_timer);
2353
2354 return 1;
2355 }
2356 /* END: 05-June-2006, x0045876 (OMAPS00060424 - Header Toggle) */
2357