comparison src/aci2/mfw/mfw_mnu.c @ 3:93999a60b835

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