ReadRes.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:94k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  *   wgui_touch_screen.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   wgui-level functions for touch screen.
  48.  *
  49.  * 
  50.  *
  51.  * Author:
  52.  * -------
  53.  * -------
  54.  * -------
  55.  *
  56.  *============================================================================
  57.  *             HISTORY
  58.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  59.  *------------------------------------------------------------------------------
  60.  * removed!
  61.  *
  62.  * removed!
  63.  * removed!
  64.  * removed!
  65.  *
  66.  * removed!
  67.  * removed!
  68.  * removed!
  69.  *
  70.  * removed!
  71.  * removed!
  72.  * removed!
  73.  *
  74.  * removed!
  75.  * removed!
  76.  * removed!
  77.  *
  78.  * removed!
  79.  * removed!
  80.  * removed!
  81.  *
  82.  * removed!
  83.  * removed!
  84.  * removed!
  85.  *
  86.  * removed!
  87.  * removed!
  88.  * removed!
  89.  *
  90.  * removed!
  91.  * removed!
  92.  * removed!
  93.  *
  94.  * removed!
  95.  * removed!
  96.  * removed!
  97.  *
  98.  * removed!
  99.  * removed!
  100.  * removed!
  101.  *
  102.  * removed!
  103.  * removed!
  104.  * removed!
  105.  *
  106.  * removed!
  107.  * removed!
  108.  * removed!
  109.  *
  110.  * removed!
  111.  * removed!
  112.  * removed!
  113.  *
  114.  * removed!
  115.  * removed!
  116.  * removed!
  117.  *
  118.  * removed!
  119.  * removed!
  120.  * removed!
  121.  *
  122.  * removed!
  123.  * removed!
  124.  * removed!
  125.  *
  126.  * removed!
  127.  * removed!
  128.  * removed!
  129.  *
  130.  * removed!
  131.  * removed!
  132.  * removed!
  133.  *
  134.  * removed!
  135.  * removed!
  136.  * removed!
  137.  *
  138.  * removed!
  139.  * removed!
  140.  * removed!
  141.  *
  142.  * removed!
  143.  * removed!
  144.  * removed!
  145.  *
  146.  * removed!
  147.  * removed!
  148.  * removed!
  149.  *
  150.  * removed!
  151.  * removed!
  152.  * removed!
  153.  *
  154.  * removed!
  155.  * removed!
  156.  * removed!
  157.  *
  158.  * removed!
  159.  * removed!
  160.  * removed!
  161.  *
  162.  * removed!
  163.  * removed!
  164.  * removed!
  165.  *
  166.  *------------------------------------------------------------------------------
  167.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  168.  *============================================================================
  169.  ****************************************************************************/
  170. /**
  171.  * Copyright Notice
  172.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  173.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  174.  *  (It is illegal to remove this copyright notice from this software or any
  175.  *  portion of it)
  176.  */
  177. /**********************************************************************************
  178.    FILENAME : ReadRes.c
  179.    PURPOSE     : Helper Functions   to Read/Get the Customizable Resources like Strings,Images,MenuItems..etc. 
  180.    REMARKS     : nil
  181.    AUTHOR      : Subramanya BG   
  182.    DATE     : 20thSept 2002.
  183.    Copyright (c) 2002 All rights reserved by Pixtel Communications
  184. **********************************************************************************/
  185. /*  Include: MMI header file */
  186. #include "string.h"
  187. #include "GlobalMenuItems.h"
  188. #include "PixtelDataTypes.h"
  189. #include "CustDataRes.h"
  190. #include "CustMenuRes.h"
  191. #include "gui_themes.h"
  192. #include "FontDcl.h"
  193. #include "gui.h"
  194. #include "wgui.h"
  195. #include "DownloadProtos.h"
  196. #include "MMI_features.h"
  197. #ifdef __MMI_THEMES_V2_SUPPORT__
  198. #include "ThemeManager.h"
  199. #include "MMIThemes.h"
  200. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  201. /* 101806 E-NFB start */
  202. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  203. #include "ResMemMgrGprot.h"
  204. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  205. /* 101806 E-NFB end */
  206. #include "PhoneSetupGprots.h"
  207. #include "SATDefs.h"
  208. #ifdef __POPULATE_ENGINE_
  209. #include "ExportMMIFunc.h"
  210. #endif 
  211. #include "DebugInitDef.h"
  212. /***************************************************************************** 
  213. * Define
  214. *****************************************************************************/
  215. #define MAX_LANGUAGE_NUM 15
  216. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  217. #define STRING_TYPE_ENFB    0xFF
  218. #endif
  219. /***************************************************************************** 
  220. * Typedef 
  221. *****************************************************************************/
  222. /***************************************************************************** 
  223. * Local Variable
  224. *****************************************************************************/
  225. U8 *gp_language_struct[MAX_LANGUAGE_NUM];
  226. static U8 MenuItemMask[(MAX_MENU_ITEMS_VALUE / 8) + 1];
  227. /***************************************************************************** 
  228. * Local Function
  229. *****************************************************************************/
  230. /***************************************************************************** 
  231. * Global Variable
  232. *****************************************************************************/
  233. #ifdef MMI_ON_HARDWARE_P
  234. extern const CUSTOM_STRING_MAP *gpStringMapRes;
  235. extern const CUSTOM_STRING *gpStringRes;
  236. extern const CUSTOM_STRMAP_SEARCH *gpStrMapSearch;
  237. extern const CUSTOM_IMAGE_MAP ImageIdMap[];
  238. extern const CUSTOM_IMAGE_SEARCH_MAP ImageIdSearchMap[];
  239. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  240. extern const CUSTOM_IMAGE_MAP ImageIdMapEXT[];              /* 040805 CustPack: Calvin added */
  241. extern const CUSTOM_IMAGE_SEARCH_MAP ImageIdSearchMapEXT[]; /* 040805 CustPack: Calvin added */
  242. /* __CUSTPACK_MULTIBIN Calvin END */
  243. extern const CUSTOM_MENU *nCustMenus;//071706 menu resource
  244. #else /* MMI_ON_HARDWARE_P */ 
  245. extern CUSTOM_STRING_MAP *gpStringMapRes;
  246. extern CUSTOM_STRMAP_SEARCH *gpStrMapSearch;
  247. extern CUSTOM_STRING *gpStringRes;
  248. /* MTK Leo add,20040318, for new simulator */
  249. extern CUSTOM_IMAGE_MAP *ImageIdMap;
  250. extern const CUSTOM_IMAGE_SEARCH_MAP *ImageIdSearchMap;
  251. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  252. extern CUSTOM_IMAGE_MAP *ImageIdMapEXT;                     /* 040805 CustPack: Calvin added */
  253. extern const CUSTOM_IMAGE_SEARCH_MAP *ImageIdSearchMapEXT;  /* 040805 CustPack: Calvin added */
  254. /* __CUSTPACK_MULTIBIN Calvin END */
  255. extern CUSTOM_MENU *nCustMenus;
  256. /* MTK Leo end */
  257. #endif /* MMI_ON_HARDWARE_P */ 
  258. /* MTK Elvis for R2L characters */
  259. extern BOOL r2lMMIFlag;
  260. /* MTK end */
  261. extern U16 gMaxDeployedLangs;
  262. extern U16 gCurrLangIndex;
  263. /* extern StringResList gStringList[MAX_LANGUAGES]; */
  264. extern StringResList *gStringList;
  265. extern sLanguageDetails *gLanguageArray;
  266. /* decalred in the CustImageRes.c */
  267. extern CUSTOM_IMAGE *nCustImageNames;
  268. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  269. extern CUSTOM_IMAGE *nCustImageNamesEXT;    /* 040805 CustPack: Calvin added */
  270. /* __CUSTPACK_MULTIBIN Calvin END */
  271. /* decalred in the CustScreenData.c */
  272. extern CUSTOM_SCREEN nCustScreens[MAX_SCREEN_IDS];
  273. /* declared in the CustMenuDataRes.c */
  274. extern U16 CurrMaxStringId;     /* Max String Ids */
  275. extern U16 CurrMaxStringNum;    /* Max Number Ids */
  276. extern U16 CurrMaxStringIdSearch;
  277. extern U16 CurrMaxImageId;  /* Max String Ids */
  278. extern U16 CurrMaxSearchImageId;
  279. extern U16 CurrMaxImageNum; /* Max Number Ids */
  280. /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  281. /* 040805 CustPack: Calvin added */
  282. extern U16 CurrMaxImageIdEXT;   /* Max String Ids */
  283. extern U16 CurrMaxSearchImageIdEXT;
  284. extern U16 CurrMaxImageNumEXT;  /* Max Number Ids */
  285. /* Calvin end */
  286. /* __CUSTPACK_MULTIBIN Calvin END */
  287. /* 101205 audio resource Calvin Start */
  288. #ifdef MMI_ON_HARDWARE_P
  289. extern const CUSTOM_AUDIO_MAP AudioIdMap[];
  290. extern const CUSTOM_AUDIO_SEARCH_MAP AudioIdSearchMap[];
  291. extern const CUSTOM_AUDIO_MAP AudioIdMapEXT[];
  292. extern const CUSTOM_AUDIO_SEARCH_MAP AudioIdSearchMapEXT[];
  293. /* 101806 E-NFB start */
  294. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  295. extern const U32 CurrMaxENFBAssociatedIDNum;
  296. extern const CUSTOM_ENFB AssociatedID_map[];
  297. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  298. /* 101806 E-NFB end */
  299. #else /* MMI_ON_HARDWARE_P */ 
  300. extern CUSTOM_AUDIO_MAP *AudioIdMap;
  301. extern const CUSTOM_AUDIO_SEARCH_MAP *AudioIdSearchMap;
  302. extern CUSTOM_AUDIO_MAP *AudioIdMapEXT;
  303. extern const CUSTOM_AUDIO_SEARCH_MAP *AudioIdSearchMapEXT;
  304. /* 101806 E-NFB start */
  305. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  306. extern const U32 CurrMaxENFBAssociatedIDNum;
  307. extern const CUSTOM_ENFB *AssociatedID_map;
  308. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  309. /* 101806 E-NFB end */
  310. #endif /* MMI_ON_HARDWARE_P */ 
  311. extern CUSTOM_AUDIO *nCustAudioNames;
  312. extern CUSTOM_AUDIO *nCustAudioNamesEXT;
  313. extern U16 CurrMaxAudioId;
  314. extern U16 CurrMaxSearchAudioId;
  315. extern U16 CurrMaxAudioNum;
  316. extern U16 CurrMaxAudioIdEXT;
  317. extern U16 CurrMaxSearchAudioIdEXT;
  318. extern U16 CurrMaxAudioNumEXT;
  319. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  320. extern thm_contex_struct g_thm_cntx;
  321. extern theme_details_struct g_tm_activated_theme;
  322. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  323. U8 g_curr_thm_index = 0;
  324. extern MMI_theme *current_MMI_theme;
  325. /* 101205 audio resource Calvin End */
  326. /***************************************************************************** 
  327. * Global Function
  328. *****************************************************************************/
  329. extern void SATEVDLLangSel(U8 *);
  330. #ifdef DEVAPP_RESOURCE
  331. extern S8* DevAppGetString(U16 StringId);
  332. extern S8* DevAppGetImage(U16 ImageId);
  333. extern S8* DevAppGetAudio(U16 AudioId);
  334. extern U16 DevAppGetParentItemId(U16 ItemId);
  335. extern U16 DevAppGetNumOfChild(U16 ItemId);
  336. extern U16 DevAppGetStringIdOfItem(U16 ItemId);
  337. extern U16 DevAppGetImageIdOfItem(U16 ItemId);
  338. extern U16 DevAppGetDispAttributeOfItem(U16 ItemId);
  339. extern U16 DevAppGetSeqItemId(U16 ParentItemId, U16 Seq);
  340. extern U16 DevAppGetSeqItemStringId(U16 ParentItemId, U16 Seq);
  341. extern U16 DevAppGetSeqItemImageId(U16 ParentItemId, U16 Seq);
  342. extern void DevAppGetSequenceItemIds(U16 ParentItemId, U16 *ItemIds);
  343. extern void DevAppGetSequenceStringIds(U16 ParentItemId, U16 *StringIds);
  344. extern U8 DevAppGetIndexOfStringId(U16 ParentItemId, U16 StringId);
  345. extern void DevAppGetSequenceImageIds(U16 ParentItemId, U16 *ImageIds);
  346. #endif
  347. /* 101806 E-NFB start */
  348. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  349. /*****************************************************************************
  350.  * FUNCTION
  351.  *  mmi_frm_enfb_if_enfb
  352.  * DESCRIPTION
  353.  *  test if img is an E-NFB image resource
  354.  * PARAMETERS
  355.  *  img     [IN]    image pointer
  356.  * RETURNS
  357.  *  MMI_BOOL    MMI_TRUE or MMI_FALSE
  358.  *****************************************************************************/
  359. MMI_BOOL mmi_frm_enfb_if_enfb(const U8 *img)
  360. {
  361.     /*----------------------------------------------------------------*/
  362.     /* Local Variables                                                */
  363.     /*----------------------------------------------------------------*/
  364.     /*----------------------------------------------------------------*/
  365.     /* Code Body                                                      */
  366.     /*----------------------------------------------------------------*/
  367. if (img[0] == IMAGE_TYPE_ENFB)
  368. {
  369. return MMI_TRUE;
  370. }
  371. else
  372. {
  373. return MMI_FALSE;
  374. }
  375. }
  376. /*****************************************************************************
  377.  * FUNCTION
  378.  *  mmi_frm_enfb_if_associated
  379.  * DESCRIPTION
  380.  *  test if img is associated with other images
  381.  * PARAMETERS
  382.  *  img     [IN]    image pointer
  383.  * RETURNS
  384.  *  MMI_BOOL    MMI_TRUE or MMI_FALSE
  385.  *****************************************************************************/
  386. MMI_BOOL mmi_frm_enfb_if_associated(const U8 *img)
  387. {
  388.     /*----------------------------------------------------------------*/
  389.     /* Local Variables                                                */
  390.     /*----------------------------------------------------------------*/
  391.     /*----------------------------------------------------------------*/
  392.     /* Code Body                                                      */
  393.     /*----------------------------------------------------------------*/
  394. if (img[1])
  395. {
  396. return MMI_TRUE;
  397. }
  398. else
  399. {
  400. return MMI_FALSE;
  401. }
  402. }
  403. /*****************************************************************************
  404.  * FUNCTION
  405.  *  mmi_frm_enfb_get_img_assid
  406.  * DESCRIPTION
  407.  *  get associated ID number of E-NFB image resource
  408.  * PARAMETERS
  409.  *  id      [IN]    image pointer
  410.  * RETURNS
  411.  *  U16             associated ID numer
  412.  *****************************************************************************/
  413. U32 mmi_frm_enfb_get_img_assid(const U16 id)
  414. {
  415.     /*----------------------------------------------------------------*/
  416.     /* Local Variables                                                */
  417.     /*----------------------------------------------------------------*/
  418. U32 i;
  419.     U16 j;
  420.     /*----------------------------------------------------------------*/
  421.     /* Code Body                                                      */
  422.     /*----------------------------------------------------------------*/
  423. for (i = 1; i < CurrMaxENFBAssociatedIDNum; i++)
  424. {
  425. const CUSTOM_ENFB *enfb = NULL;
  426.         U16 count;
  427. enfb = AssociatedID_map + i;
  428.         count = AssociatedID_map[i].count;
  429. for (j = 0; j < count; j++)
  430. {
  431. if (enfb->IDs[j] == id)
  432. {
  433. return i;
  434. }
  435. }
  436. }
  437. return 0;
  438. }
  439. /*****************************************************************************
  440.  * FUNCTION
  441.  *  mmi_frm_enfb_get_assid_count
  442.  * DESCRIPTION
  443.  *  get IDs count within an associated ID group
  444.  * PARAMETERS
  445.  *  assid   [IN]    image pointer
  446.  * RETURNS
  447.  *  U32             IDs count
  448.  *****************************************************************************/
  449. U16 mmi_frm_enfb_get_assid_count(const U16 assid)
  450. {
  451.     /*----------------------------------------------------------------*/
  452.     /* Local Variables                                                */
  453.     /*----------------------------------------------------------------*/
  454.     /*----------------------------------------------------------------*/
  455.     /* Code Body                                                      */
  456.     /*----------------------------------------------------------------*/
  457. return AssociatedID_map[assid].count;
  458. }
  459. /*****************************************************************************
  460.  * FUNCTION
  461.  *  mmi_frm_enfb_get_img_offset
  462.  * DESCRIPTION
  463.  *  get E-NFB image offset
  464.  * PARAMETERS
  465.  *  img     [IN]    image pointer
  466.  * RETURNS
  467.  *  U32             image offset
  468.  *****************************************************************************/
  469. U32 mmi_frm_enfb_get_img_offset(const U8 *img)
  470. {
  471.     /*----------------------------------------------------------------*/
  472.     /* Local Variables                                                */
  473.     /*----------------------------------------------------------------*/
  474.     /*----------------------------------------------------------------*/
  475.     /* Code Body                                                      */
  476.     /*----------------------------------------------------------------*/
  477. return (U32)img[4] | (img[5] << 8) | (img[6] << 16) | (img[7] << 24);
  478. }
  479. /*****************************************************************************
  480.  * FUNCTION
  481.  *  mmi_frm_enfb_get_img_size
  482.  * DESCRIPTION
  483.  *  get E-NFB image size
  484.  * PARAMETERS
  485.  *  img     [IN]    image pointer
  486.  * RETURNS
  487.  *  U32             image size
  488.  *****************************************************************************/
  489. U32 mmi_frm_enfb_get_img_size(const U8 *img)
  490. {
  491.     /*----------------------------------------------------------------*/
  492.     /* Local Variables                                                */
  493.     /*----------------------------------------------------------------*/
  494.     /*----------------------------------------------------------------*/
  495.     /* Code Body                                                      */
  496.     /*----------------------------------------------------------------*/
  497. return (U32)img[8] | (img[9] << 8) | (img[10] << 16) | (img[11] << 24);
  498. }
  499. /*****************************************************************************
  500.  * FUNCTION
  501.  *  mmi_frm_enfb_get_img_list
  502.  * DESCRIPTION
  503.  *  get E-NFB image list
  504.  * PARAMETERS
  505.  *  id      [IN]    image id
  506.  *  list    [OUT]   image list
  507.  * RETURNS
  508.  *  U32             image offset
  509.  *****************************************************************************/
  510. MMI_BOOL mmi_frm_enfb_get_img_list(const U16 assid, const U16 count, mmi_frm_resmem_res_info_struct *list)
  511. {
  512.     /*----------------------------------------------------------------*/
  513.     /* Local Variables                                                */
  514.     /*----------------------------------------------------------------*/
  515. U16 i;
  516.     /*----------------------------------------------------------------*/
  517.     /* Code Body                                                      */
  518.     /*----------------------------------------------------------------*/
  519. if (list != NULL)
  520. {
  521. for (i = 0; i < count; i++)
  522. {
  523. const U8 *img;
  524. img = AssociatedID_map[assid].Ptr[i].pImage;
  525. list[i].id = AssociatedID_map[assid].IDs[i];
  526. list[i].offset = mmi_frm_enfb_get_img_offset(img);
  527. list[i].size = mmi_frm_enfb_get_img_size(img);
  528. }
  529. return MMI_TRUE;
  530. }
  531. else
  532. {
  533. return MMI_FALSE;
  534. }
  535. }
  536. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  537. /* 101806 E-NFB end */
  538. /*****************************************************************************
  539.  * FUNCTION
  540.  *  GetStringLang
  541.  * DESCRIPTION
  542.  *  Function to get string associated with the stringId
  543.  *  
  544.  *  The function uses the variable CurrMaxStringId inside the for loop which
  545.  *  is set inside the WriteRes.c file.
  546.  * PARAMETERS
  547.  *  StringId        [IN]        
  548.  *  lang_index      [IN]        
  549.  *  U16(?)          [IN]        StringId
  550.  *  char(?)         [OUT]       Displayed String.
  551.  * RETURNS
  552.  *  the String Mapped with the Id.
  553.  *****************************************************************************/
  554. S8 *GetStringLang(U16 StringId, U16 lang_index)
  555. {
  556.     /*----------------------------------------------------------------*/
  557.     /* Local Variables                                                */
  558.     /*----------------------------------------------------------------*/
  559.     S32 nFirst = 0;
  560.     S32 nLast = CurrMaxStringIdSearch;
  561.     S32 nMid;
  562.     CUSTOM_STRMAP_SEARCH *pStrMapSearch;
  563.     CUSTOM_STRING *pStringRes;
  564.     CUSTOM_STRING_MAP *pStringMapRes;
  565.     /*----------------------------------------------------------------*/
  566.     /* Code Body                                                      */
  567.     /*----------------------------------------------------------------*/
  568.     pStringRes = gStringList[lang_index].pStringRes;
  569.     pStringMapRes = gStringList[lang_index].pStringMap;
  570.     pStrMapSearch = gStringList[lang_index].pStrMapSearch;
  571.     while ((nLast >= nFirst) /* && (nLast!=0) */ )
  572.     {
  573.         nMid = (nFirst + nLast) / 2;;
  574.         if ((pStrMapSearch[nMid].nMinStrId <= StringId) && (pStrMapSearch[nMid].nMaxStrId >= StringId))
  575.         {
  576.         #ifdef __ASCII
  577.             return (S8*) &
  578.                 pStringRes[(pStringMapRes
  579.                             [((pStrMapSearch[nMid].nMapIndex) + (StringId) - (pStrMapSearch[nMid].nMinStrId))])];
  580.         #endif /* __ASCII */ 
  581.         #ifdef __UCS2_ENCODING
  582.             return (S8*) &
  583.                 pStringRes[(pStringMapRes
  584.                             [((pStrMapSearch[nMid].nMapIndex) + (StringId) - (pStrMapSearch[nMid].nMinStrId))]) << 1];
  585.         #endif /* __UCS2_ENCODING */ 
  586.         }
  587.         if (StringId > pStrMapSearch[nMid].nMinStrId)
  588.         {
  589.             nFirst = nMid + 1;
  590.         }
  591.         else
  592.         {
  593.             nLast = nMid - 1;
  594.         }
  595.     }
  596.     return (S8*) "";
  597. }
  598. /*****************************************************************************
  599.  * FUNCTION
  600.  *  GetString
  601.  * DESCRIPTION
  602.  *  Function to get string associated with the stringId
  603.  *  
  604.  *  The function uses the variable CurrMaxStringId inside the for loop which
  605.  *  is set inside the WriteRes.c file.
  606.  * PARAMETERS
  607.  *  StringId        [IN]        
  608.  *  U16(?)          [IN]        StringId
  609.  *  char(?)         [OUT]       Displayed String.
  610.  * RETURNS
  611.  *  the String Mapped with the Id.
  612.  *****************************************************************************/
  613. S8 *GetString(U16 StringId)
  614. {
  615.     /*----------------------------------------------------------------*/
  616.     /* Local Variables                                                */
  617.     /*----------------------------------------------------------------*/
  618.     S32 nFirst = 0;
  619.     S32 nLast = CurrMaxStringIdSearch;
  620.     S32 nMid;
  621.     /*----------------------------------------------------------------*/
  622.     /* Code Body                                                      */
  623.     /*----------------------------------------------------------------*/
  624. #ifdef DEVAPP_RESOURCE
  625.     if (StringId >= DEVAPP_BASE)
  626.     {
  627.         S8 *ret_string = DevAppGetString(StringId);
  628.         return ret_string;
  629.     }
  630. #endif
  631.     while ((nLast >= nFirst) /* && (nLast!=0) */ )
  632.     {
  633.         nMid = (nFirst + nLast) / 2;;
  634.         if ((gpStrMapSearch[nMid].nMinStrId <= StringId) && (gpStrMapSearch[nMid].nMaxStrId >= StringId))
  635.         {
  636.             return (S8*) &
  637.                 gpStringRes[(gpStringMapRes
  638.                              [((gpStrMapSearch[nMid].nMapIndex) + (StringId) -
  639.                                (gpStrMapSearch[nMid].nMinStrId))]) << 1];
  640.         }
  641.         if (StringId > gpStrMapSearch[nMid].nMinStrId)
  642.         {
  643.             nFirst = nMid + 1;
  644.         }
  645.         else
  646.         {
  647.             nLast = nMid - 1;
  648.         }
  649.     }
  650.     return (S8*) "";
  651. }
  652. /*****************************************************************************
  653.  * FUNCTION
  654.  *  fread_all
  655.  * DESCRIPTION
  656.  *  Function to get filename associated with the ImageId
  657.  *  
  658.  *  The function uses the variable CurrMaxImageId inside the for loop which
  659.  *  is set inside the WriteRes.c file.
  660.  * PARAMETERS
  661.  *  handle          [IN]        
  662.  *  dest            [?]         
  663.  *  dest_size       [IN]        
  664.  *  want_size       [IN]        
  665.  *  U16(?)          [IN]        ImageId.
  666.  *  char(?)         [OUT]       Displayed Image Filename.
  667.  * RETURNS
  668.  *  Returns the filename associated with the ImageId.
  669.  *****************************************************************************/
  670. #if defined(MMI_ON_HARDWARE_P) && defined(__MMI_DEFAULT_THEME_3__)
  671. #include "filesystemdef.h"
  672. static U16 cache_image_id;
  673. static U32 cache_image_content[30000 / 4];
  674. /* MTK added, Max: to clear gif cache 0202, modified by JF */
  675. #if !defined(__BW_MMI__) && !defined(WIN32)     /* Target version shall use this library */
  676. extern void GIF_clear_cache(void);
  677. #endif 
  678. /* MTK end */
  679. static kal_bool fread_all(FILE_HANDLE handle, U8 *dest, S32 dest_size, S32 want_size)
  680. {
  681.     /*----------------------------------------------------------------*/
  682.     /* Local Variables                                                */
  683.     /*----------------------------------------------------------------*/
  684.     /*----------------------------------------------------------------*/
  685.     /* Code Body                                                      */
  686.     /*----------------------------------------------------------------*/
  687.     ASSERT(dest_size >= want_size);
  688.     FS_Seek(handle, 0, FS_FILE_BEGIN);
  689.     while (want_size > 0)
  690.     {
  691.         S32 nRead;
  692.         if (FS_Read(handle, dest, want_size, (kal_uint32*) & nRead) != FS_NO_ERROR)
  693.         {
  694.             return KAL_FALSE;
  695.         }
  696.         want_size -= nRead;
  697.         dest += nRead;
  698.     }
  699.     return KAL_TRUE;
  700. }
  701. #endif /* defined(MMI_ON_HARDWARE_P) && defined(__MMI_DEFAULT_THEME_3__) */ 
  702. /*****************************************************************************
  703.  * FUNCTION
  704.  *  GetImageRaw
  705.  * DESCRIPTION
  706.  *  
  707.  * PARAMETERS
  708.  *  ImageId     [IN]        
  709.  * RETURNS
  710.  *  
  711.  *****************************************************************************/
  712. S8 *GetImageRaw(U16 ImageId)
  713. {
  714.     /*----------------------------------------------------------------*/
  715.     /* Local Variables                                                */
  716.     /*----------------------------------------------------------------*/
  717.     S32 nFirst = 0;
  718.     S32 nLast = CurrMaxSearchImageId-1;
  719.     S32 nMid;
  720.     /*----------------------------------------------------------------*/
  721.     /* Code Body                                                      */
  722.     /*----------------------------------------------------------------*/
  723. #ifdef DEVAPP_RESOURCE
  724.     if (ImageId >= DEVAPP_BASE)
  725.     {
  726.         S8 *ret_image = DevAppGetImage(ImageId);
  727.         return ret_image;
  728.     }
  729. #endif
  730.     if (ImageId >= NV_RAM_FILE_IMAGE_ID_BASE && ImageId <= NV_RAM_FILE_IMAGE_ID_BASE_END)
  731.     {
  732.         S8 *image_src = GetImageFileSystem(ImageId);
  733.     #if defined(MMI_ON_HARDWARE_P) && defined(__MMI_DEFAULT_THEME_3__)
  734.         /*
  735.          * Justin 0201. We patch BMP_file_display to avoid display BMP "file" as transparent image
  736.          * * but we do not patch _show_transparent_bitmap in order to prevent possible side-effects 
  737.          * * This is a temporary fix until we use GDI to replace wingui
  738.          */
  739.         if (image_src[0] == IMAGE_TYPE_BMP_FILE)
  740.         {
  741.             return image_src;
  742.         }
  743.         if (cache_image_id != ImageId)
  744.         {
  745.             FILE_HANDLE file = OpenCache((U8*) (image_src + 6), PFS_READ_BINARY);
  746.             if (file != (FILE_HANDLE) NULL)
  747.             {
  748.                 S32 size = GetFSFileSize(file);
  749.                 /* MTK modified, Max: to cast type to signed int 1228 */
  750.                 if (size < (S32) (sizeof(cache_image_content) - 6))     /* test the file size */
  751.                     /* MTK end */
  752.                     if (fread_all
  753.                         (file, ((U8*) cache_image_content) + 6, (S32) (sizeof(cache_image_content) - 6), size))
  754.                     {
  755.                         U8 *header = (U8*) cache_image_content;
  756.                         switch (image_src[0])
  757.                         {
  758.                             case IMAGE_TYPE_BMP_FILE:
  759.                                 header[0] = IMAGE_TYPE_BMP;
  760.                                 break;
  761.                             case IMAGE_TYPE_GIF_FILE:
  762.                                 header[0] = IMAGE_TYPE_GIF;
  763.                                 /* MTK added, Max: to clear gif cache 0202, modified by JF */
  764.                         #if !defined(__BW_MMI__) && !defined(WIN32)     /* Target version shall use this library */
  765.                                 GIF_clear_cache();
  766.                         #endif 
  767.                                 /* MTK end */
  768.                                 break;
  769.                             default:
  770.                                 pfclose(file);
  771.                                 return image_src;
  772.                         }
  773.                         header[1] = (U8) NULL;
  774.                         header[2] = (U8) (size & 0x000000ff);
  775.                         header[3] = (U8) ((size >> 8) & 0x000000ff);
  776.                         header[4] = (U8) ((size >> 16) & 0x000000ff);
  777.                         header[5] = (U8) ((size >> 24) & 0x000000ff);
  778.                         cache_image_id = ImageId;
  779.                         pfclose(file);
  780.                         return (S8*) & (cache_image_content[0]);
  781.                     }
  782.                 pfclose(file);
  783.             }
  784.         }
  785.         else
  786.         {
  787.             return (S8*) & (cache_image_content[0]);
  788.         }
  789.     #endif /* defined(MMI_ON_HARDWARE_P) && defined(__MMI_DEFAULT_THEME_3__) */ 
  790.         return image_src;
  791.     }
  792.     else
  793.     {
  794.     #ifdef __MMI_THEMES_V2_SUPPORT__        /* ritesh */
  795.         U16 image_index;
  796.         S8 *pImageData;
  797.         U32 nImageIndex;
  798.     #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  799.         while ((nLast >= nFirst) /* && (nLast!=0) */ )
  800.         {
  801.             nMid = (nFirst + nLast) / 2;;
  802.             if ((ImageIdSearchMap[nMid].minImageId <= ImageId) && (ImageIdSearchMap[nMid].maxImageId >= ImageId))
  803.             {
  804.             #ifdef __MMI_THEMES_V2_SUPPORT__        /* ritesh */
  805.                 S32 nArrayIndex;
  806.                 image_index =
  807.                     ImageIdMap[(ImageIdSearchMap[nMid].index) + (ImageId) -
  808.                                (ImageIdSearchMap[nMid].minImageId)].nImageNum;
  809.                 if (mmi_tm_does_theme_have_alt_image())
  810.                 {
  811.                     if (mmi_tm_is_theme_dirty_bit_set(image_index))
  812.                     {
  813.                         if (mmi_tm_get_curr_theme_type() == THEME_TYPE_SYSTEM)
  814.                         {
  815.                             pImageData = (S8*)
  816.                                 mmi_tm_get_system_theme_image(mmi_tm_get_theme_image_offset_or_index
  817.                                                               (ImageId, &nArrayIndex));
  818.                             
  819.                             if ( !pImageData )
  820.                             {
  821.                                pImageData = (S8*) (nCustImageNames[image_index].pImage);
  822.                             }
  823.                             return pImageData;
  824.                            
  825.                         }
  826.                     #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__      /* ritesh */
  827.                         else
  828.                         {
  829.                             nImageIndex = mmi_tm_get_theme_image_offset_or_index(ImageId, &nArrayIndex);
  830.                             if (nImageIndex > 0)
  831.                             {
  832.                             #ifdef __MMI_DLT_CACHE_SUPPORT__
  833.                                 U8 image_type = mmi_tm_get_image_load_type(nArrayIndex);
  834.                                 if (image_type != THEME_IMG_LOAD_NEVER)
  835.                                 {
  836.                                     pImageData = (PS8) mmi_tm_find_img_in_cache(nArrayIndex, image_type);
  837.                                     if (!pImageData)
  838.                                     {
  839.                                         pImageData =
  840.                                             (PS8) mmi_tm_add_img_id_to_cache(nArrayIndex, nImageIndex, image_type);
  841.                                         if (!pImageData)
  842.                                         {
  843.                                             pImageData =
  844.                                                 (PS8) mmi_tm_get_downloaded_theme_image(nImageIndex, nArrayIndex);
  845.                                             if ( !pImageData )
  846.                                             {
  847.                                                pImageData = (S8*) (nCustImageNames[image_index].pImage);
  848.                                             }
  849.                                         }
  850.                                     }
  851.                                     return pImageData;
  852.                                 }
  853.                                 else
  854.                             #endif /* __MMI_DLT_CACHE_SUPPORT__ */ 
  855.                                 {
  856.                                     pImageData = (PS8) mmi_tm_get_downloaded_theme_image(nImageIndex, nArrayIndex);
  857.                                     if ( !pImageData )
  858.                                     {
  859.                                         pImageData = (S8*) (nCustImageNames[image_index].pImage);
  860.                                     }
  861.                                     return pImageData;
  862.                                 }
  863.                             }
  864.                             else
  865.                             {
  866.                                 return (S8*) (nCustImageNames[image_index].pImage);
  867.                             }
  868.                         }
  869.                     #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  870.                     }
  871.                 }
  872.                 return (S8*) (nCustImageNames[image_index].pImage);
  873.             #else /* __MMI_THEMES_V2_SUPPORT__ */ 
  874.                 return (S8*)
  875.                     nCustImageNames[ImageIdMap
  876.                                     [(ImageIdSearchMap[nMid].index) + (ImageId) -
  877.                                      (ImageIdSearchMap[nMid].minImageId)].nImageNum].pImage;
  878.             #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  879.             }
  880.             if (ImageId > ImageIdSearchMap[nMid].minImageId)
  881.             {
  882.                 nFirst = nMid + 1;
  883.             }
  884.             else
  885.             {
  886.                 nLast = nMid - 1;
  887.             }
  888.         }
  889.         /* __CUSTPACK_MULTIBIN Calvin BEGIN */
  890.         /* 040805 CustPack: Calvin added for new set of images */
  891.         nFirst = 0;
  892.         nLast = CurrMaxSearchImageIdEXT-1;
  893.         while ((nLast >= nFirst) /* && (nLast!=0) */ )
  894.         {
  895.             nMid = (nFirst + nLast) / 2;;
  896.             if ((ImageIdSearchMapEXT[nMid].minImageId <= ImageId) && (ImageIdSearchMapEXT[nMid].maxImageId >= ImageId))
  897.             {
  898.             #ifdef __MMI_THEMES_V2_SUPPORT__        /* ritesh */
  899.                 S32 nArrayIndex;
  900.                 image_index =
  901.                     ImageIdMapEXT[(ImageIdSearchMapEXT[nMid].index) + (ImageId) -
  902.                                   (ImageIdSearchMapEXT[nMid].minImageId)].nImageNum;
  903.                 if (mmi_tm_does_theme_have_alt_image())
  904.                 {
  905.                     if (mmi_tm_is_theme_dirty_bit_set(image_index))
  906.                     {
  907.                         if (mmi_tm_get_curr_theme_type() == THEME_TYPE_SYSTEM)
  908.                         {
  909.                             pImageData =
  910.                                 mmi_tm_get_system_theme_image(mmi_tm_get_theme_image_offset_or_index
  911.                                                               (ImageId, &nArrayIndex));
  912.                             if ( !pImageData )
  913.                             {
  914.                                pImageData = (S8*) (nCustImageNamesEXT[image_index].pImage);
  915.                             }
  916.                             return pImageData;
  917.                         }
  918.                     #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__      /* ritesh */
  919.                         else
  920.                         {
  921.                             nImageIndex = mmi_tm_get_theme_image_offset_or_index(ImageId, &nArrayIndex);
  922.                             if (nImageIndex > 0)
  923.                             {
  924.                       #ifdef __MMI_DLT_CACHE_SUPPORT__
  925.                                 U8 image_type = mmi_tm_get_image_load_type(nArrayIndex);
  926.                                 if (image_type != THEME_IMG_LOAD_NEVER)
  927.                                 {
  928.                                     pImageData = (PS8) mmi_tm_find_img_in_cache(nArrayIndex, image_type);
  929.                                     if (!pImageData)
  930.                                     {
  931.                                         pImageData =
  932.                                             (PS8) mmi_tm_add_img_id_to_cache(nArrayIndex, nImageIndex, image_type);
  933.                                         if (!pImageData)
  934.                                         {
  935.                                             pImageData =
  936.                                                 (PS8) mmi_tm_get_downloaded_theme_image(nImageIndex, nArrayIndex);
  937.                                             if ( !pImageData )
  938.                                             {
  939.                                                pImageData = (S8*) (nCustImageNamesEXT[image_index].pImage);
  940.                                             }
  941.                                         }
  942.                                     }
  943.                                     return pImageData;
  944.                                 }
  945.                                 else
  946.                             #endif /* __MMI_DLT_CACHE_SUPPORT__ */
  947.                                 {
  948.                                     
  949.                                     pImageData = (PS8) mmi_tm_get_downloaded_theme_image(nImageIndex, nArrayIndex);
  950.                                     
  951.                                     if ( !pImageData )
  952.                                     {
  953.                                         pImageData = (S8*) (nCustImageNamesEXT[image_index].pImage);
  954.                                     }
  955.                                     
  956.                                     return pImageData;
  957.                                 }
  958.                             }
  959.                             else
  960.                             {
  961.                                 return (S8*) (nCustImageNamesEXT[image_index].pImage);
  962.                             }
  963.                         }
  964.                     #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  965.                     }
  966.                 }
  967.                 return (S8*) (nCustImageNamesEXT[image_index].pImage);
  968.             #else /* __MMI_THEMES_V2_SUPPORT__ */ 
  969.                 return (S8*)
  970.                     nCustImageNamesEXT[ImageIdMapEXT
  971.                                        [(ImageIdSearchMapEXT[nMid].index) + (ImageId) -
  972.                                         (ImageIdSearchMapEXT[nMid].minImageId)].nImageNum].pImage;
  973.             #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  974.             }
  975.             if (ImageId > ImageIdSearchMapEXT[nMid].minImageId)
  976.             {
  977.                 nFirst = nMid + 1;
  978.             }
  979.             else
  980.             {
  981.                 nLast = nMid - 1;
  982.             }
  983.         }
  984.         /* Calvin end */
  985.         /* __CUSTPACK_MULTIBIN Calvin END */
  986.         return (S8*) (nCustImageNames[0].pImage);
  987.     }
  988. }
  989. /* 101806 E-NFB start */
  990. /*****************************************************************************
  991.  * FUNCTION
  992.  *  GetImage
  993.  * DESCRIPTION
  994.  *  
  995.  * PARAMETERS
  996.  *  ImageId     [IN]        
  997.  * RETURNS
  998.  *  
  999.  *****************************************************************************/
  1000. S8 *GetImage(U16 ImageId)
  1001. {
  1002.     /*----------------------------------------------------------------*/
  1003.     /* Local Variables                                                */
  1004.     /*----------------------------------------------------------------*/
  1005.     U8 *img = NULL;
  1006.     /*----------------------------------------------------------------*/
  1007.     /* Code Body                                                      */
  1008.     /*----------------------------------------------------------------*/
  1009. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1010.     /* check cache */
  1011.     img = mmi_frm_resmem_if_ramed(ImageId);
  1012.     if (img != NULL)
  1013.     {
  1014.         return (S8*)img;
  1015.     }
  1016. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  1017.     /* load image raw data */
  1018.     img = (U8*)GetImageRaw(ImageId);
  1019.     if (img == NULL)
  1020.     {
  1021. return (S8*)img;
  1022.     }
  1023. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1024.     /* check E-NFB */
  1025.     if (mmi_frm_enfb_if_enfb(img) == MMI_TRUE)
  1026.     {
  1027.         U32 offset, size;
  1028.         /* get size & offset */
  1029.         offset = mmi_frm_enfb_get_img_offset(img);
  1030.         size = mmi_frm_enfb_get_img_size(img);
  1031.         /* check associated */
  1032.         if (mmi_frm_enfb_if_associated(img) == MMI_FALSE)
  1033.         {
  1034.             /* load one image from E-NFB */
  1035.             img = mmi_frm_resmem_load_single_image(ImageId, offset, size);
  1036.         }
  1037.         else
  1038.         {
  1039.             U16 assid, count;
  1040.             mmi_frm_resmem_res_info_struct *list;
  1041.             /* get associated ID & count */
  1042.             assid = mmi_frm_enfb_get_img_assid(ImageId);
  1043.             count = mmi_frm_enfb_get_assid_count(assid);
  1044.             /* allocated memory */
  1045.             list = OslMalloc(count * sizeof(mmi_frm_resmem_res_info_struct));
  1046.             if (list != NULL)
  1047.             {
  1048.                 memset(list, 0, count * sizeof(mmi_frm_resmem_res_info_struct));
  1049.                 /* get associated list */
  1050.                 if (mmi_frm_enfb_get_img_list(assid, count, list) == MMI_TRUE)
  1051.                 {
  1052.                     /* load associated images from E-NFB */
  1053.                     img = mmi_frm_resmem_load_multi_image(ImageId, list, count);
  1054.                 }
  1055.                 /* free memory */
  1056.                 OslMfree(list);
  1057.                 list = NULL;
  1058.             }
  1059.             else
  1060.             {
  1061.                 /* memory allocation failed, load only one image */
  1062.                 img = mmi_frm_resmem_load_single_image(ImageId, offset, size);
  1063.             }
  1064.         }
  1065.     }
  1066. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  1067.     return (S8*)img;
  1068. }
  1069. /* 101806 E-NFB end */
  1070. #ifdef __MMI_THEMES_V2_SUPPORT__        /* ritesh */
  1071. /*****************************************************************************
  1072.  * FUNCTION
  1073.  *  GetImageIndex
  1074.  * DESCRIPTION
  1075.  *  
  1076.  * PARAMETERS
  1077.  *  ImageId     [IN]        
  1078.  * RETURNS
  1079.  *  
  1080.  *****************************************************************************/
  1081. U16 GetImageIndex(U16 ImageId)
  1082. {
  1083.     /*----------------------------------------------------------------*/
  1084.     /* Local Variables                                                */
  1085.     /*----------------------------------------------------------------*/
  1086.     S32 nFirst = 0;
  1087.     S32 nLast = CurrMaxSearchImageId;
  1088.     S32 nMid = (nFirst + nLast) / 2;
  1089.     /*----------------------------------------------------------------*/
  1090.     /* Code Body                                                      */
  1091.     /*----------------------------------------------------------------*/
  1092.     while ((nLast >= nFirst) /* && (nLast!=0) */ )
  1093.     {
  1094.         nMid = (nFirst + nLast) / 2;
  1095.         if ((ImageIdSearchMap[nMid].minImageId <= ImageId) && (ImageIdSearchMap[nMid].maxImageId >= ImageId))
  1096.         {
  1097.             break;
  1098.         }
  1099.         if (ImageId > ImageIdSearchMap[nMid].minImageId)
  1100.         {
  1101.             nFirst = nMid + 1;
  1102.         }
  1103.         else
  1104.         {
  1105.             nLast = nMid - 1;
  1106.         }
  1107.     }
  1108.     return ImageIdMap[(ImageIdSearchMap[nMid].index) + (ImageId) - (ImageIdSearchMap[nMid].minImageId)].nImageNum;
  1109. }
  1110. /*****************************************************************************
  1111.  * FUNCTION
  1112.  *  GetDefaultImage
  1113.  * DESCRIPTION
  1114.  *  
  1115.  * PARAMETERS
  1116.  *  void
  1117.  * RETURNS
  1118.  *  
  1119.  *****************************************************************************/
  1120. S8 *GetDefaultImage(void)
  1121. {
  1122.     /*----------------------------------------------------------------*/
  1123.     /* Local Variables                                                */
  1124.     /*----------------------------------------------------------------*/
  1125.     /*----------------------------------------------------------------*/
  1126.     /* Code Body                                                      */
  1127.     /*----------------------------------------------------------------*/
  1128.     return (S8*) (nCustImageNames[0].pImage);
  1129. }
  1130. #endif /* __MMI_THEMES_V2_SUPPORT__ */ 
  1131. /* 101205 Audio Resource Calvin Start */
  1132. /*****************************************************************************
  1133.  * FUNCTION
  1134.  *  GetAudio
  1135.  * DESCRIPTION
  1136.  *  Function to get audio data associated with the AudioId
  1137.  *  
  1138.  *  The function uses the variable CurrMaxAudioId inside the for loop which
  1139.  *  is set inside the WriteRes.c file.
  1140.  * PARAMETERS
  1141.  *  AudioId     [IN]        
  1142.  *  U16(?)      [IN]        AudioId.
  1143.  *  char(?)     [OUT]       Displayed Audio data pointer
  1144.  * RETURNS
  1145.  *  Returns the audio datad with the AudioId.
  1146.  *****************************************************************************/
  1147. S8 *GetAudio(U16 AudioId)
  1148. {
  1149.     /*----------------------------------------------------------------*/
  1150.     /* Local Variables                                                */
  1151.     /*----------------------------------------------------------------*/
  1152.     S32 nFirst = 0;
  1153.     S32 nLast = CurrMaxSearchAudioId;
  1154.     S32 nMid;
  1155.     /*----------------------------------------------------------------*/
  1156.     /* Code Body                                                      */
  1157.     /*----------------------------------------------------------------*/
  1158. #ifdef DEVAPP_RESOURCE
  1159.     if (AudioId >= DEVAPP_BASE)
  1160.     {
  1161.         S8 *ret_audio = DevAppGetAudio(AudioId);
  1162.         return ret_audio;
  1163.     }
  1164. #endif
  1165.     while ((nLast >= nFirst))
  1166.     {
  1167.         nMid = (nFirst + nLast) / 2;;
  1168.         if ((AudioIdSearchMap[nMid].minAudioId <= AudioId) && (AudioIdSearchMap[nMid].maxAudioId >= AudioId))
  1169.         {
  1170.             return (S8*)
  1171.                 nCustAudioNames[AudioIdMap
  1172.                                 [(AudioIdSearchMap[nMid].index) + (AudioId) -
  1173.                                  (AudioIdSearchMap[nMid].minAudioId)].nAudioNum].pAudio;
  1174.         }
  1175.         if (AudioId > AudioIdSearchMap[nMid].minAudioId)
  1176.         {
  1177.             nFirst = nMid + 1;
  1178.         }
  1179.         else
  1180.         {
  1181.             nLast = nMid - 1;
  1182.         }
  1183.     }
  1184.     /* for custpack */
  1185.     nFirst = 0;
  1186.     nLast = CurrMaxSearchAudioIdEXT;
  1187.     while ((nLast >= nFirst))
  1188.     {
  1189.         nMid = (nFirst + nLast) / 2;;
  1190.         if ((AudioIdSearchMapEXT[nMid].minAudioId <= AudioId) && (AudioIdSearchMapEXT[nMid].maxAudioId >= AudioId))
  1191.         {
  1192.             return (S8*)
  1193.                 nCustAudioNamesEXT[AudioIdMapEXT
  1194.                                    [(AudioIdSearchMapEXT[nMid].index) + (AudioId) -
  1195.                                     (AudioIdSearchMapEXT[nMid].minAudioId)].nAudioNum].pAudio;
  1196.         }
  1197.         if (AudioId > AudioIdSearchMapEXT[nMid].minAudioId)
  1198.         {
  1199.             nFirst = nMid + 1;
  1200.         }
  1201.         else
  1202.         {
  1203.             nLast = nMid - 1;
  1204.         }
  1205.     }
  1206.     return (S8*) (nCustAudioNames[0].pAudio);;
  1207. }
  1208. /* 101205 Audio Resource Calvin End */
  1209. /*****************************************************************************
  1210.  * FUNCTION
  1211.  *  GetParentItemId
  1212.  * DESCRIPTION
  1213.  *  Function to get Parent MenuItemId of the Given MenuItemId.
  1214.  * PARAMETERS
  1215.  *  ItemId      [IN]        
  1216.  *  U16(?)      [OUT]       Parent MenuItemId of the given MenuItemId.
  1217.  * RETURNS
  1218.  *  the Parent MenuItemId.
  1219.  *****************************************************************************/
  1220. U16 GetParentItemId(U16 ItemId)
  1221. {
  1222.     /*----------------------------------------------------------------*/
  1223.     /* Local Variables                                                */
  1224.     /*----------------------------------------------------------------*/
  1225.     /*----------------------------------------------------------------*/
  1226.     /* Code Body                                                      */
  1227.     /*----------------------------------------------------------------*/
  1228. #ifdef DEVAPP_RESOURCE
  1229.     if ( ItemId >= MENU_ID_DEVAPP_START )
  1230.     {
  1231.         return DevAppGetParentItemId(ItemId);
  1232.     }
  1233. #endif
  1234.     return nCustMenus[ItemId - 1].nParentId;
  1235. }
  1236. /* MTK Leo add 20040409, to sync titleicon */
  1237. /*****************************************************************************
  1238.  * FUNCTION
  1239.  *  GetRootParentIndex
  1240.  * DESCRIPTION
  1241.  *  Function to get Parent MenuItemId of the Given MenuItemId in Mainmenu
  1242.  * PARAMETERS
  1243.  *  ItemId      [IN]        
  1244.  *  U16(?)      [OUT]       Parent MenuItemId of the given MenuItemId in Mainmenu.
  1245.  * RETURNS
  1246.  *  the Parent MenuItemId in Mainmenu.
  1247.  *****************************************************************************/
  1248. U16 GetRootParentIndex(U16 ItemId)
  1249. {
  1250.     /*----------------------------------------------------------------*/
  1251.     /* Local Variables                                                */
  1252.     /*----------------------------------------------------------------*/
  1253.     U16 RootId;
  1254.     U16 parent_id;
  1255.     U16 idx;
  1256. #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
  1257.     U16 parent_idx = 0;
  1258.     U16 grand_parent_id = 0;
  1259.     U16 num_of_child = 0;
  1260.     U16 total_idx = 0;
  1261.     /*----------------------------------------------------------------*/
  1262.     /* Code Body                                                      */
  1263.     /*----------------------------------------------------------------*/
  1264.     parent_id = GetParentItemId(ItemId);
  1265.     /* Group menu id */
  1266.     if (parent_id == 1)
  1267.     {
  1268.         return 0;
  1269.     }
  1270.     grand_parent_id = GetParentItemId(parent_id);
  1271.     RootId = ItemId;
  1272.     while (grand_parent_id != IDLE_SCREEN_MENU_ID)
  1273.     {
  1274.         RootId = parent_id;
  1275.         parent_id = grand_parent_id;
  1276.         grand_parent_id = GetParentItemId(grand_parent_id);
  1277.     }
  1278.     num_of_child = GetNumOfChild(IDLE_SCREEN_MENU_ID);
  1279.     for (parent_idx = 0; parent_idx < num_of_child; parent_idx++)
  1280.     {
  1281.         if (GetSeqItemId(IDLE_SCREEN_MENU_ID, parent_idx) == parent_id)
  1282.         {
  1283.             num_of_child = GetNumOfChild(parent_id);
  1284.             for (idx = 0; idx < num_of_child; idx++)
  1285.                 if (GetSeqItemId(parent_id, idx) != RootId)
  1286.                 {
  1287.                     total_idx++;
  1288.                 }
  1289.                 else
  1290.                 {
  1291.                     return total_idx;
  1292.                 }
  1293.         }
  1294.         else
  1295.         {
  1296.             total_idx += GetNumOfChild(parent_id);
  1297.         }
  1298.     }
  1299.     MMI_ASSERT(0);
  1300.     return 0;
  1301. #else /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */ 
  1302.     RootId = ItemId;
  1303.     parent_id = GetParentItemId(ItemId);
  1304.     if (parent_id != IDLE_SCREEN_MENU_ID)
  1305.     {   /* ItemId is not one of the itemIds of mainmenu */
  1306.         RootId = parent_id;
  1307.         parent_id = GetParentItemId(parent_id);
  1308.         while (parent_id != IDLE_SCREEN_MENU_ID)
  1309.         {
  1310.             RootId = parent_id;
  1311.             parent_id = GetParentItemId(parent_id);
  1312.         }
  1313.     }   /* RootId is the menu id in mainmenu */
  1314.     for (idx = 0; idx < nCustMenus[0].nNumofMenuItem; idx++)
  1315.     {
  1316.         if (nCustMenus[0].nOrderMenuItemId[idx] == RootId)
  1317.         {
  1318.             break;
  1319.         }
  1320.     }
  1321.     return idx;
  1322. #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */ 
  1323. }
  1324. /* MTK Leo end */
  1325. /*****************************************************************************
  1326.  * FUNCTION
  1327.  *  GetNumOfChild
  1328.  * DESCRIPTION
  1329.  *  Function to get Number of Childrens of the Given MenuItemId.
  1330.  *  
  1331.  *  Need to check the hide attribute of the MenuItemId.
  1332.  * PARAMETERS
  1333.  *  ItemId      [IN]        
  1334.  *  U16(?)      [OUT]       Number of Childrens of the given MenuItemId.
  1335.  * RETURNS
  1336.  *  Number of Childrens.
  1337.  *****************************************************************************/
  1338. U16 GetNumOfChild(U16 ItemId)
  1339. {
  1340.     /*----------------------------------------------------------------*/
  1341.     /* Local Variables                                                */
  1342.     /*----------------------------------------------------------------*/
  1343.     /*----------------------------------------------------------------*/
  1344.     /* Code Body                                                      */
  1345.     /*----------------------------------------------------------------*/
  1346. #ifdef DEVAPP_RESOURCE
  1347.     if ( ItemId >= MENU_ID_DEVAPP_START )
  1348.     {
  1349.         return DevAppGetNumOfChild(ItemId);
  1350.     }
  1351. #endif
  1352.     return nCustMenus[ItemId - 1].nNumofMenuItem;
  1353. }
  1354. /*****************************************************************************
  1355.  * FUNCTION
  1356.  *  GetStringIdOfItem
  1357.  * DESCRIPTION
  1358.  *  Function to get StringId of the Given MenuItemId.
  1359.  * PARAMETERS
  1360.  *  ItemId      [IN]        
  1361.  *  U16(?)      [OUT]       StringId.
  1362.  * RETURNS
  1363.  *  StringId of the given MenuItemId.
  1364.  *****************************************************************************/
  1365. U16 GetStringIdOfItem(U16 ItemId)
  1366. {
  1367.     /*----------------------------------------------------------------*/
  1368.     /* Local Variables                                                */
  1369.     /*----------------------------------------------------------------*/
  1370.     /*----------------------------------------------------------------*/
  1371.     /* Code Body                                                      */
  1372.     /*----------------------------------------------------------------*/
  1373. #ifdef DEVAPP_RESOURCE
  1374.     if ( ItemId >= MENU_ID_DEVAPP_START )
  1375.     {
  1376.         return DevAppGetStringIdOfItem(ItemId);
  1377.     }
  1378. #endif
  1379.     return nCustMenus[ItemId - 1].nStrId;
  1380. }
  1381. /*****************************************************************************
  1382.  * FUNCTION
  1383.  *  GetImageIdOfItem
  1384.  * DESCRIPTION
  1385.  *  Function to get ImageId of the given MenuItemId.
  1386.  * PARAMETERS
  1387.  *  ItemId      [IN]        
  1388.  *  U16(?)      [OUT]       ImageId.
  1389.  * RETURNS
  1390.  *  ImageId of the given MenuItemId.
  1391.  *****************************************************************************/
  1392. U16 GetImageIdOfItem(U16 ItemId)
  1393. {
  1394.     /*----------------------------------------------------------------*/
  1395.     /* Local Variables                                                */
  1396.     /*----------------------------------------------------------------*/
  1397.     /*----------------------------------------------------------------*/
  1398.     /* Code Body                                                      */
  1399.     /*----------------------------------------------------------------*/
  1400. #ifdef DEVAPP_RESOURCE
  1401.     if ( ItemId >= MENU_ID_DEVAPP_START )
  1402.     {
  1403.         return DevAppGetImageIdOfItem(ItemId);
  1404.     }
  1405. #endif
  1406.     if (ItemId == MAIN_MENU_CALL_HISTORY)
  1407.     {
  1408.         ItemId = MAIN_MENU_CALL_HISTORY;
  1409.     }
  1410.     return nCustMenus[ItemId - 1].nImageId;
  1411. }
  1412. /*****************************************************************************
  1413.  * FUNCTION
  1414.  *  GetDispAttributeOfItem
  1415.  * DESCRIPTION
  1416.  *  Function to get DispAttributes of the given MenuItemId.
  1417.  *  
  1418.  *  DispAttribute are like Matrix,List,Circular,Tab..etc.
  1419.  * PARAMETERS
  1420.  *  ItemId      [IN]        
  1421.  *  U16(?)      [OUT]       DispAttribute.
  1422.  * RETURNS
  1423.  *  DispAttribute which is passed to the UI Element.
  1424.  *****************************************************************************/
  1425. U16 GetDispAttributeOfItem(U16 ItemId)
  1426. {
  1427.     /*----------------------------------------------------------------*/
  1428.     /* Local Variables                                                */
  1429.     /*----------------------------------------------------------------*/
  1430.     /*----------------------------------------------------------------*/
  1431.     /* Code Body                                                      */
  1432.     /*----------------------------------------------------------------*/
  1433. #ifdef DEVAPP_RESOURCE
  1434.     if ( ItemId >= MENU_ID_DEVAPP_START )
  1435.     {
  1436.         return DevAppGetDispAttributeOfItem(ItemId);
  1437.     }
  1438. #endif
  1439.     return nCustMenus[ItemId - 1].nDispAttribute;
  1440. }
  1441. /*****************************************************************************
  1442.  * FUNCTION
  1443.  *  GetSeqItemId
  1444.  * DESCRIPTION
  1445.  *  Function to get MenuItemId of the given MenuItemId & Sequence.
  1446.  *  
  1447.  *  Need to check the hide attribute of the MenuItemId.
  1448.  * PARAMETERS
  1449.  *  ParentItemId        [IN]        
  1450.  *  Seq                 [IN]        
  1451.  *  U16(?)              [OUT]       MenuItemId.
  1452.  * RETURNS
  1453.  *  MenuItemId of the given Parent MenuItemId & Sequence.
  1454.  *****************************************************************************/
  1455. U16 GetSeqItemId(U16 ParentItemId, U16 Seq)
  1456. {
  1457.     /*----------------------------------------------------------------*/
  1458.     /* Local Variables                                                */
  1459.     /*----------------------------------------------------------------*/
  1460.     /*----------------------------------------------------------------*/
  1461.     /* Code Body                                                      */
  1462.     /*----------------------------------------------------------------*/
  1463.     
  1464. #ifdef DEVAPP_RESOURCE
  1465.     if ( ParentItemId >= MENU_ID_DEVAPP_START )
  1466.     {
  1467.         return DevAppGetSeqItemId(ParentItemId, Seq);
  1468.     }
  1469. #endif
  1470.     return nCustMenus[ParentItemId - 1].nOrderMenuItemId[Seq];
  1471. }
  1472. /*****************************************************************************
  1473.  * FUNCTION
  1474.  *  GetSeqItemStringId
  1475.  * DESCRIPTION
  1476.  *  Function to get StringId of the given MenuItemId & Sequence.
  1477.  *  
  1478.  *  Need to check the hide attribute of the MenuItemId.
  1479.  * PARAMETERS
  1480.  *  ParentItemId        [IN]        
  1481.  *  Seq                 [IN]        
  1482.  *  U16(?)              [OUT]       StringId of the MenuItem.
  1483.  * RETURNS
  1484.  *  StringId of the MenuItem of the given Parent MenuItemId & Sequence.
  1485.  *****************************************************************************/
  1486. U16 GetSeqItemStringId(U16 ParentItemId, U16 Seq)
  1487. {
  1488.     /*----------------------------------------------------------------*/
  1489.     /* Local Variables                                                */
  1490.     /*----------------------------------------------------------------*/
  1491.     /*----------------------------------------------------------------*/
  1492.     /* Code Body                                                      */
  1493.     /*----------------------------------------------------------------*/
  1494. #ifdef DEVAPP_RESOURCE
  1495.     if ( ParentItemId >= MENU_ID_DEVAPP_START )
  1496.     {
  1497.         return DevAppGetSeqItemStringId(ParentItemId, Seq);
  1498.     }
  1499. #endif
  1500.     return GetStringIdOfItem(nCustMenus[ParentItemId - 1].nOrderMenuItemId[Seq]);
  1501. }
  1502. /*****************************************************************************
  1503.  * FUNCTION
  1504.  *  GetSeqItemImageId
  1505.  * DESCRIPTION
  1506.  *  Function to get ImageId of the given MenuItemId & Sequence.
  1507.  *  
  1508.  *  Need to check the hide attribute of the MenuItemId.
  1509.  * PARAMETERS
  1510.  *  ParentItemId        [IN]        
  1511.  *  Seq                 [IN]        
  1512.  *  U16(?)              [OUT]       ImageId of the MenuItem.
  1513.  * RETURNS
  1514.  *  ImageId of the MenuItem of the given Parent MenuItemId & Sequence.
  1515.  *****************************************************************************/
  1516. U16 GetSeqItemImageId(U16 ParentItemId, U16 Seq)
  1517. {
  1518.     /*----------------------------------------------------------------*/
  1519.     /* Local Variables                                                */
  1520.     /*----------------------------------------------------------------*/
  1521.     /*----------------------------------------------------------------*/
  1522.     /* Code Body                                                      */
  1523.     /*----------------------------------------------------------------*/
  1524. #ifdef DEVAPP_RESOURCE
  1525.     if ( ParentItemId >= MENU_ID_DEVAPP_START )
  1526.     {
  1527.         return DevAppGetSeqItemImageId(ParentItemId, Seq);
  1528.     }
  1529. #endif
  1530.     return GetImageIdOfItem(nCustMenus[ParentItemId - 1].nOrderMenuItemId[Seq]);
  1531. }
  1532. /*****************************************************************************
  1533.  * FUNCTION
  1534.  *  GetSequenceItemIds
  1535.  * DESCRIPTION
  1536.  *  Function to get all the MenuItemIds in Sequence of the given MenuItemId i.e Parent.
  1537.  *  
  1538.  *  Need to check the hide attribute of the MenuItemId.
  1539.  * PARAMETERS
  1540.  *  ParentItemId        [IN]        
  1541.  *  ItemIds             [?]         
  1542.  *  fills(?)            [OUT]       The input parameter. Memory is allocated by the caller.
  1543.  *  U16(?)              [IN]        MenuItemId i.e Parent & (U16 *) PoU16er containing the Array of MenuItemId.
  1544.  * RETURNS
  1545.  *  void
  1546.  *****************************************************************************/
  1547. void GetSequenceItemIds(U16 ParentItemId, U16 *ItemIds)
  1548. {
  1549.     /*----------------------------------------------------------------*/
  1550.     /* Local Variables                                                */
  1551.     /*----------------------------------------------------------------*/
  1552.     U16 j;
  1553.     /*----------------------------------------------------------------*/
  1554.     /* Code Body                                                      */
  1555.     /*----------------------------------------------------------------*/
  1556. #ifdef DEVAPP_RESOURCE
  1557.     if ( ParentItemId >= MENU_ID_DEVAPP_START )
  1558.     {
  1559.         DevAppGetSequenceItemIds(ParentItemId, ItemIds);
  1560.     }
  1561. #endif
  1562.     for (j = 0; j < nCustMenus[ParentItemId - 1].nNumofMenuItem; j++)
  1563.     {
  1564.         ItemIds[j] = nCustMenus[ParentItemId - 1].nOrderMenuItemId[j];
  1565.     }
  1566. }
  1567. /*****************************************************************************
  1568.  * FUNCTION
  1569.  *  GetSequenceStringIds
  1570.  * DESCRIPTION
  1571.  *  Function to get all the StringIds in Sequence of the given MenuItemId i.e Parent.
  1572.  *  
  1573.  *  Need to check the hide attribute of the MenuItemId.
  1574.  * PARAMETERS
  1575.  *  ParentItemId        [IN]        
  1576.  *  StringIds           [?]         
  1577.  *  fills(?)            [OUT]       The input parameter. Memory is allocated by the caller.
  1578.  *  U16(?)              [IN]        MenuItemId i.e Parent & (U16 *) PoU16er containing the Array of StringIds.
  1579.  * RETURNS
  1580.  *  void
  1581.  *****************************************************************************/
  1582. void GetSequenceStringIds(U16 ParentItemId, U16 *StringIds)
  1583. {
  1584.     /*----------------------------------------------------------------*/
  1585.     /* Local Variables                                                */
  1586.     /*----------------------------------------------------------------*/
  1587.     U16 j;
  1588.     /*----------------------------------------------------------------*/
  1589.     /* Code Body                                                      */
  1590.     /*----------------------------------------------------------------*/
  1591. #ifdef DEVAPP_RESOURCE
  1592.     if ( ParentItemId >= MENU_ID_DEVAPP_START )
  1593.     {
  1594.         DevAppGetSequenceStringIds(ParentItemId, StringIds);
  1595.     }
  1596. #endif
  1597.     for (j = 0; j < nCustMenus[ParentItemId - 1].nNumofMenuItem; j++)
  1598.     {
  1599.         StringIds[j] = GetStringIdOfItem(nCustMenus[ParentItemId - 1].nOrderMenuItemId[j]);
  1600.     }
  1601. }
  1602. /*****************************************************************************
  1603.  * FUNCTION
  1604.  *  GetIndexOfStringId
  1605.  * DESCRIPTION
  1606.  *  Function to get the index of StringIds in the given MenuItemId i.e Parent.
  1607.  *  
  1608.  *  Need to check the hide attribute of the MenuItemId.
  1609.  * PARAMETERS
  1610.  *  ParentItemId        [IN]        
  1611.  *  StringId            [IN]        
  1612.  *  U16(?)              [IN]        MenuItemId i.e Parent & (U16 ) StringId
  1613.  * RETURNS
  1614.  *  U8
  1615.  *****************************************************************************/
  1616. U8 GetIndexOfStringId(U16 ParentItemId, U16 StringId)
  1617. {
  1618.     /*----------------------------------------------------------------*/
  1619.     /* Local Variables                                                */
  1620.     /*----------------------------------------------------------------*/
  1621.     U16 j;
  1622.     /*----------------------------------------------------------------*/
  1623.     /* Code Body                                                      */
  1624.     /*----------------------------------------------------------------*/
  1625.     /*----------------------------------------------------------------*/
  1626. #ifdef DEVAPP_RESOURCE
  1627.     if ( ParentItemId >= MENU_ID_DEVAPP_START )
  1628.     {
  1629.         return DevAppGetIndexOfStringId(ParentItemId, StringId);
  1630.     }
  1631. #endif
  1632.     for (j = 0; j < nCustMenus[ParentItemId - 1].nNumofMenuItem; j++)
  1633.         if (StringId == nCustMenus[ParentItemId - 1].nOrderMenuItemId[j])
  1634.         {
  1635.             return (U8) j;
  1636.         }
  1637.     return (U8) 0;
  1638. }
  1639. /*****************************************************************************
  1640.  * FUNCTION
  1641.  *  GetSequenceImageIds
  1642.  * DESCRIPTION
  1643.  *  Function to get all the ImageIds in Sequence of the given MenuItemId i.e Parent.
  1644.  *  
  1645.  *  Need to check the hide attribute of the MenuItemId.
  1646.  * PARAMETERS
  1647.  *  ParentItemId        [IN]        
  1648.  *  ImageIds            [?]         
  1649.  *  fills(?)            [OUT]       The input parameter. Memory is allocated by the caller.
  1650.  *  U16(?)              [IN]        MenuItemId i.e Parent & (U16 *) PoU16er containing the Array of ImageIds.
  1651.  * RETURNS
  1652.  *  void
  1653.  *****************************************************************************/
  1654. void GetSequenceImageIds(U16 ParentItemId, U16 *ImageIds)
  1655. {
  1656.     /*----------------------------------------------------------------*/
  1657.     /* Local Variables                                                */
  1658.     /*----------------------------------------------------------------*/
  1659.     U16 j;
  1660.     /*----------------------------------------------------------------*/
  1661.     /* Code Body                                                      */
  1662.     /*----------------------------------------------------------------*/
  1663. #ifdef DEVAPP_RESOURCE
  1664.     if ( ParentItemId >= MENU_ID_DEVAPP_START )
  1665.     {
  1666.         DevAppGetSequenceImageIds(ParentItemId, ImageIds);
  1667.     }
  1668. #endif
  1669.     for (j = 0; j < nCustMenus[ParentItemId - 1].nNumofMenuItem; j++)
  1670.     {
  1671.         ImageIds[j] = GetImageIdOfItem(nCustMenus[ParentItemId - 1].nOrderMenuItemId[j]);
  1672.     }
  1673. }
  1674. /* MTK Leo add,20040318, for new simulator */
  1675. #ifndef MMI_ON_HARDWARE_P
  1676. extern S32 n_MMI_themes;
  1677. #ifdef __MMI_THEMES_V2_SUPPORT__        /* ritesh */
  1678. extern theme_details_struct *MMI_themes;
  1679. #else 
  1680. extern MMI_theme **MMI_themes;
  1681. #endif 
  1682. #else /* MMI_ON_HARDWARE_P */ 
  1683. #ifdef __MMI_THEMES_V2_SUPPORT__        /* ritesh */
  1684. extern theme_details_struct *MMI_themes;
  1685. #else 
  1686. extern CONST_HARDWARE MMI_theme **MMI_themes;
  1687. #endif 
  1688. extern S32 n_MMI_themes;
  1689. #endif /* MMI_ON_HARDWARE_P */ 
  1690. /* MTK Leo end */
  1691. /*****************************************************************************
  1692.  * FUNCTION
  1693.  *  GetThemesNames
  1694.  * DESCRIPTION
  1695.  *  Retrieves the existing themes
  1696.  * PARAMETERS
  1697.  *  dest            [?]         
  1698.  *  Array(?)        [OUT]       Of pointers
  1699.  * RETURNS
  1700.  *  Number of themes
  1701.  *****************************************************************************/
  1702. S32 GetThemesNames(U8 **dest[])
  1703. {
  1704.     /*----------------------------------------------------------------*/
  1705.     /* Local Variables                                                */
  1706.     /*----------------------------------------------------------------*/
  1707.     U8 noOfThemes = 0;
  1708.     /*----------------------------------------------------------------*/
  1709.     /* Code Body                                                      */
  1710.     /*----------------------------------------------------------------*/
  1711.     if (dest == NULL)
  1712.     {
  1713.         return noOfThemes;
  1714.     }
  1715.     *dest = NULL;
  1716.     return n_MMI_themes;
  1717. }
  1718. /*****************************************************************************
  1719.  * FUNCTION
  1720.  *  SetThemes
  1721.  * DESCRIPTION
  1722.  *  Set the theme
  1723.  * PARAMETERS
  1724.  *  index       [IN]        To  the global theme structure
  1725.  * RETURNS
  1726.  *  void
  1727.  *****************************************************************************/
  1728. void SetThemes(U8 index)
  1729. {
  1730.     /*----------------------------------------------------------------*/
  1731.     /* Local Variables                                                */
  1732.     /*----------------------------------------------------------------*/
  1733.     /*----------------------------------------------------------------*/
  1734.     /* Code Body                                                      */
  1735.     /*----------------------------------------------------------------*/
  1736.     g_curr_thm_index = index;
  1737.     //      set_MMI_theme((MMI_theme *)MMI_themes[index]);
  1738.     //      MMI_apply_current_theme();
  1739. }
  1740. extern void MMI_apply_current_theme(void);
  1741. /*****************************************************************************
  1742.  * FUNCTION
  1743.  *  mmi_get_phone_model
  1744.  * DESCRIPTION
  1745.  *  This function gets the phone model in theme res
  1746.  * PARAMETERS
  1747.  *  void
  1748.  * RETURNS
  1749.  *  void
  1750.  *****************************************************************************/
  1751. const PS8 mmi_get_phone_model(void)
  1752. {
  1753.     /*----------------------------------------------------------------*/
  1754.     /* Local Variables                                                */
  1755.     /*----------------------------------------------------------------*/
  1756.     /* PMT SUKRIT START 070806 */
  1757. #ifndef DEMO_PROJECT
  1758.     extern PS8 mmi_theme_phone_model;   /* defined in standalone res */
  1759.     /*----------------------------------------------------------------*/
  1760.     /* Code Body                                                      */
  1761.     /*----------------------------------------------------------------*/
  1762.     return mmi_theme_phone_model;/* Customer should define their own phone model */
  1763. #else /* DEMO_PROJECT */ 
  1764.         extern kal_char* release_hw_ver(void); 
  1765.  
  1766.         return release_hw_ver(); /* Demo H/W will use verno string */
  1767. #endif /* DEMO_PROJECT */ 
  1768.     /* PMT SUKRIT END 070806 */
  1769. }
  1770. /*****************************************************************************
  1771.  * FUNCTION
  1772.  *  UpdateUITheme
  1773.  * DESCRIPTION
  1774.  *  
  1775.  * PARAMETERS
  1776.  *  void
  1777.  * RETURNS
  1778.  *  void
  1779.  *****************************************************************************/
  1780. void UpdateUITheme(void)
  1781. {
  1782.     /*----------------------------------------------------------------*/
  1783.     /* Local Variables                                                */
  1784.     /*----------------------------------------------------------------*/
  1785.     /*----------------------------------------------------------------*/
  1786.     /* Code Body                                                      */
  1787.     /*----------------------------------------------------------------*/
  1788. #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  1789.     if (mmi_tm_get_curr_theme_type() != THEME_TYPE_SYSTEM)  /* fixed for usb */
  1790.     {
  1791.         if (g_tm_activated_theme.theme != current_MMI_theme)
  1792.         {
  1793.             set_MMI_theme(g_tm_activated_theme.theme);
  1794.             MMI_apply_current_theme();
  1795.         }
  1796.     }
  1797.     else
  1798.     {
  1799.         if (MMI_themes[g_curr_thm_index-1].theme != current_MMI_theme)
  1800.         {
  1801.             set_MMI_theme((MMI_theme*) MMI_themes[g_curr_thm_index-1].theme);
  1802.             MMI_apply_current_theme();
  1803.         }
  1804.     }
  1805. #else /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  1806.     if (MMI_themes[g_curr_thm_index] != current_MMI_theme)
  1807.     {
  1808.         set_MMI_theme((MMI_theme*) MMI_themes[g_curr_thm_index]);
  1809.         MMI_apply_current_theme();
  1810.     }
  1811. #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  1812. }
  1813. /*****************************************************************************
  1814.  * FUNCTION
  1815.  *  GetLanguages
  1816.  * DESCRIPTION
  1817.  *  Get the language list.
  1818.  * PARAMETERS
  1819.  *  pppLanguages        [IN]        
  1820.  *  U16(?)              [OUT]       
  1821.  *  an(?)               [IN]        Array for getting the language list
  1822.  * RETURNS
  1823.  *  the number of languages deployed
  1824.  *****************************************************************************/
  1825. U16 GetLanguages(U8 ***pppLanguages)
  1826. {
  1827.     /*----------------------------------------------------------------*/
  1828.     /* Local Variables                                                */
  1829.     /*----------------------------------------------------------------*/
  1830.     U16 nCount;
  1831.     /*----------------------------------------------------------------*/
  1832.     /* Code Body                                                      */
  1833.     /*----------------------------------------------------------------*/
  1834.     //Robin 1121, prevent memory leak
  1835.     //*pppLanguages = OslMalloc(gMaxDeployedLangs*sizeof(U8*));
  1836.     *pppLanguages = &gp_language_struct[0];
  1837.     for (nCount = 0; (nCount < gMaxDeployedLangs && nCount < MAX_LANGUAGE_NUM); ++nCount)
  1838.     {
  1839.         (*pppLanguages)[nCount] = (U8*) gLanguageArray[nCount].aName;
  1840.         /* ++nCount; */
  1841.     }
  1842.     //Robin 1121, prevent memory leak
  1843.     //return gMaxDeployedLangs;
  1844.     return nCount;
  1845. }
  1846. /*****************************************************************************
  1847.  * FUNCTION
  1848.  *  GetLanguageIndex
  1849.  * DESCRIPTION
  1850.  *  Get the index of language specified by ssc_string.
  1851.  *  
  1852.  *  Return 0, if not found.
  1853.  * PARAMETERS
  1854.  *  ssc_str         [?]         
  1855.  *  index(?)        [OUT]       (1 based)
  1856.  *  U8(?)           [IN]        * ssc_string of lang
  1857.  * RETURNS
  1858.  *  void
  1859.  *****************************************************************************/
  1860. U16 GetLanguageIndex(S8 *ssc_str)
  1861. {
  1862.     /*----------------------------------------------------------------*/
  1863.     /* Local Variables                                                */
  1864.     /*----------------------------------------------------------------*/
  1865.     U16 idx;
  1866.     /*----------------------------------------------------------------*/
  1867.     /* Code Body                                                      */
  1868.     /*----------------------------------------------------------------*/
  1869.     if (ssc_str == NULL)
  1870.     {
  1871.         return 0xFFFF;
  1872.     }
  1873.     for (idx = 0; idx < gMaxDeployedLangs; idx++)
  1874.     {
  1875.         if (strcmp(ssc_str, (S8*) gLanguageArray[idx].aLangSSC) == 0)
  1876.         {
  1877.             return idx;
  1878.         }
  1879.     }
  1880.     return 0xFFFF;
  1881. }
  1882. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1883. /*****************************************************************************
  1884.  * FUNCTION
  1885.  *  mmi_frm_enfb_if_enfb_str
  1886.  * DESCRIPTION
  1887.  *  test if data is an E-NFB string resource
  1888.  * PARAMETERS
  1889.  *  data    [IN]    data pointer
  1890.  * RETURNS
  1891.  *  MMI_BOOL    MMI_TRUE or MMI_FALSE
  1892.  *****************************************************************************/
  1893. MMI_BOOL mmi_frm_enfb_if_enfb_str(const U8 *data)
  1894. {
  1895.     /*----------------------------------------------------------------*/
  1896.     /* Local Variables                                                */
  1897.     /*----------------------------------------------------------------*/
  1898.     /*----------------------------------------------------------------*/
  1899.     /* Code Body                                                      */
  1900.     /*----------------------------------------------------------------*/
  1901. if (data[0] == STRING_TYPE_ENFB)
  1902. {
  1903. return MMI_TRUE;
  1904. }
  1905. else
  1906. {
  1907. return MMI_FALSE;
  1908. }
  1909. }
  1910. /*****************************************************************************
  1911.  * FUNCTION
  1912.  *  mmi_frm_enfb_get_str_offset
  1913.  * DESCRIPTION
  1914.  *  get E-NFB string offset
  1915.  * PARAMETERS
  1916.  *  data    [IN]    data pointer
  1917.  * RETURNS
  1918.  *  U32             data offset
  1919.  *****************************************************************************/
  1920. U32 mmi_frm_enfb_get_str_offset(const U8 *data)
  1921. {
  1922.     /*----------------------------------------------------------------*/
  1923.     /* Local Variables                                                */
  1924.     /*----------------------------------------------------------------*/
  1925.     /*----------------------------------------------------------------*/
  1926.     /* Code Body                                                      */
  1927.     /*----------------------------------------------------------------*/
  1928. return (U32)data[4] | (data[5] << 8) | (data[6] << 16) | (data[7] << 24);
  1929. }
  1930. /*****************************************************************************
  1931.  * FUNCTION
  1932.  *  mmi_frm_enfb_get_str_size
  1933.  * DESCRIPTION
  1934.  *  get E-NFB string size
  1935.  * PARAMETERS
  1936.  *  data    [IN]    data pointer
  1937.  * RETURNS
  1938.  *  U32             data size
  1939.  *****************************************************************************/
  1940. U32 mmi_frm_enfb_get_str_size(const U8 *data)
  1941. {
  1942.     /*----------------------------------------------------------------*/
  1943.     /* Local Variables                                                */
  1944.     /*----------------------------------------------------------------*/
  1945.     /*----------------------------------------------------------------*/
  1946.     /* Code Body                                                      */
  1947.     /*----------------------------------------------------------------*/
  1948. return (U32)data[8] | (data[9] << 8) | (data[10] << 16) | (data[11] << 24);
  1949. }
  1950. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  1951. /*****************************************************************************
  1952.  * FUNCTION
  1953.  *  SetCurrentLanguage
  1954.  * DESCRIPTION
  1955.  *  Set the current language to the index.
  1956.  * PARAMETERS
  1957.  *  nIndex      [IN]        Of lang to set
  1958.  * RETURNS
  1959.  *  void
  1960.  *****************************************************************************/
  1961. static pBOOL gLanguageSettingOnBootUp = TRUE;
  1962. extern void mmi_phb_callergroup_set_name_by_language(void);
  1963. #if defined(__MMI_VRSI__)
  1964. extern void mmi_vrsi_init_central_change_language_reset(void);
  1965. #endif 
  1966. void SetCurrentLanguage(S8 nIndex)
  1967. {
  1968.     /*----------------------------------------------------------------*/
  1969.     /* Local Variables                                                */
  1970.     /*----------------------------------------------------------------*/
  1971.     /*----------------------------------------------------------------*/
  1972.     /* Code Body                                                      */
  1973.     /*----------------------------------------------------------------*/
  1974.     if (nIndex >= gMaxDeployedLangs)
  1975.     {
  1976.         nIndex = 0;
  1977.     }
  1978.     gCurrLangIndex = nIndex;
  1979.     
  1980.     r2lMMIFlag = IsL2RMMIStyle();
  1981.     
  1982. #ifdef __MMI_HINDI_ALG__
  1983.     set_current_language_for_hindi_rules();
  1984. #endif 
  1985.     
  1986.     gpStringRes = gStringList[gCurrLangIndex].pStringRes;
  1987.     gpStringMapRes = gStringList[gCurrLangIndex].pStringMap;
  1988. #ifdef __MMI_RESOURCE_ENFB_SUPPORT__
  1989.     if(mmi_frm_enfb_if_enfb(gpStringRes) == MMI_TRUE)
  1990.     {
  1991.         U32 offset[2], size[2];
  1992.         U8 *ptr[2] = {0};
  1993.         
  1994.         /* read ENFB string resource information */
  1995.         offset[0] = mmi_frm_enfb_get_str_offset(gpStringRes);
  1996.         size[0] = mmi_frm_enfb_get_str_size(gpStringRes);
  1997.         offset[1] = (U32)gpStringMapRes[0];
  1998.         size[1] = (U32)gpStringMapRes[1];
  1999.         /* load string data */
  2000. mmi_frm_resmem_load_str_suite(ptr, offset, size, 2);
  2001.         
  2002.         /* re-assign pointer */
  2003.         gpStringRes = (CUSTOM_STRING *)ptr[0];
  2004.         gpStringMapRes = (CUSTOM_STRING_MAP *)ptr[1];
  2005.     }
  2006.     else
  2007.     {
  2008.         /* ENFB is enabled,
  2009.          * but the string resource is not a valid one */
  2010.         MMI_ASSERT(0);
  2011.     }
  2012. #endif
  2013.     gpStrMapSearch = gStringList[gCurrLangIndex].pStrMapSearch;
  2014.     CurrMaxStringNum = gStringList[gCurrLangIndex].nTotalStrRes;
  2015.     CurrMaxStringId = gStringList[gCurrLangIndex].nTotalStrMap;
  2016.     CurrMaxStringIdSearch = gStringList[gCurrLangIndex].nTotalStrMapSearch;
  2017.     if (gLanguageSettingOnBootUp == FALSE)
  2018.     {
  2019.         PhnsetReinitHomeCityIdx();
  2020.     }
  2021.     else
  2022.     {
  2023.         gLanguageSettingOnBootUp = FALSE;
  2024.     }
  2025.     /* Change caller group name default vaule when change lanaguage */
  2026.     mmi_phb_callergroup_set_name_by_language();
  2027. #if defined(__MMI_VRSI__)
  2028.     /* Reset voice command central command according to the language. */
  2029.     mmi_vrsi_init_central_change_language_reset();
  2030. #endif /* defined(__MMI_VRSI__) */ 
  2031.     /* micha1016 */
  2032.     switch (nIndex)
  2033.     {
  2034.         case 0:
  2035.             SATEVDLLangSel((PU8) SAT_LANG_ENGLISH);
  2036.             return;
  2037.         case 1:
  2038.         case 2:
  2039.             SATEVDLLangSel((PU8) SAT_LANG_CHINESE);
  2040.             return;
  2041.     }
  2042. }
  2043. /* MTK added, Max: to solve schedule power on/off change home city issue 1202 */
  2044. /*****************************************************************************
  2045.  * FUNCTION
  2046.  *  ResetLanguageSettingFlag
  2047.  * DESCRIPTION
  2048.  *  
  2049.  * PARAMETERS
  2050.  *  void
  2051.  * RETURNS
  2052.  *  void
  2053.  *****************************************************************************/
  2054. void ResetLanguageSettingFlag(void)
  2055. {
  2056.     /*----------------------------------------------------------------*/
  2057.     /* Local Variables                                                */
  2058.     /*----------------------------------------------------------------*/
  2059.     /*----------------------------------------------------------------*/
  2060.     /* Code Body                                                      */
  2061.     /*----------------------------------------------------------------*/
  2062.     gLanguageSettingOnBootUp = TRUE;
  2063. }
  2064. /* MTK end */
  2065. /* MTK Leo add, for mini_tab_bar */
  2066. /*****************************************************************************
  2067.  * FUNCTION
  2068.  *  GetSeqItems
  2069.  * DESCRIPTION
  2070.  *  Get child menuitems.
  2071.  * PARAMETERS
  2072.  *  ParentItemId        [IN]        
  2073.  *  id(?)               [IN]        Of parent
  2074.  * RETURNS
  2075.  *  void
  2076.  *****************************************************************************/
  2077. U16 *GetSeqItems(U16 ParentItemId)
  2078. {
  2079.     /*----------------------------------------------------------------*/
  2080.     /* Local Variables                                                */
  2081.     /*----------------------------------------------------------------*/
  2082.     /*----------------------------------------------------------------*/
  2083.     /* Code Body                                                      */
  2084.     /*----------------------------------------------------------------*/
  2085.     return nCustMenus[ParentItemId - 1].nOrderMenuItemId;
  2086. }
  2087. /* MTK Leo end */
  2088. /* APIs for hide some menuitems at run time */
  2089. /*****************************************************************************
  2090.  * FUNCTION
  2091.  *  mmi_frm_hide_menu_item
  2092.  * DESCRIPTION
  2093.  *  Set the bit represented the menuitem on to hide it
  2094.  * PARAMETERS
  2095.  *  menu_item_id        [IN]        Id of the menuitem
  2096.  * RETURNS
  2097.  *  void
  2098.  *****************************************************************************/
  2099. void mmi_frm_hide_menu_item(U16 menu_item_id)
  2100. {
  2101.     /*----------------------------------------------------------------*/
  2102.     /* Local Variables                                                */
  2103.     /*----------------------------------------------------------------*/
  2104.     U16 idx = 0, reminding = 0;
  2105.     U16 item_id = menu_item_id - 1;
  2106.     /*----------------------------------------------------------------*/
  2107.     /* Code Body                                                      */
  2108.     /*----------------------------------------------------------------*/
  2109.     if (menu_item_id < MAX_MENU_ITEMS_VALUE)
  2110.     {
  2111.         idx = item_id / 8;
  2112.         reminding = item_id - (idx * 8);
  2113.         MenuItemMask[idx] |= (1 << (7 - reminding));
  2114.     }
  2115. }
  2116. /*****************************************************************************
  2117.  * FUNCTION
  2118.  *  mmi_frm_unhide_menu_item
  2119.  * DESCRIPTION
  2120.  *  Reset the bit represented the menuitem on to unhide it
  2121.  * PARAMETERS
  2122.  *  menu_item_id        [IN]        Id of the menuitem
  2123.  * RETURNS
  2124.  *  void
  2125.  *****************************************************************************/
  2126. void mmi_frm_unhide_menu_item(U16 menu_item_id)
  2127. {
  2128.     /*----------------------------------------------------------------*/
  2129.     /* Local Variables                                                */
  2130.     /*----------------------------------------------------------------*/
  2131.     U16 idx = 0, reminding = 0;
  2132.     U16 item_id = menu_item_id - 1;
  2133.     /*----------------------------------------------------------------*/
  2134.     /* Code Body                                                      */
  2135.     /*----------------------------------------------------------------*/
  2136.     if (menu_item_id < MAX_MENU_ITEMS_VALUE)
  2137.     {
  2138.         idx = item_id / 8;
  2139.         reminding = item_id - (idx * 8);
  2140.         MenuItemMask[idx] &= ~(1 << (7 - reminding));
  2141.     }
  2142. }
  2143. /*****************************************************************************
  2144.  * FUNCTION
  2145.  *  mmi_frm_test_menu_item_hide
  2146.  * DESCRIPTION
  2147.  *  test if the menuitem is hidden or not
  2148.  * PARAMETERS
  2149.  *  menu_item_id        [IN]        Id of the menuitem
  2150.  * RETURNS
  2151.  *  MMI_BOOL MMI_TRUE if the menuitem is hidden
  2152.  *****************************************************************************/
  2153. MMI_BOOL mmi_frm_test_menu_item_hide(U16 menu_item_id)
  2154. {
  2155.     /*----------------------------------------------------------------*/
  2156.     /* Local Variables                                                */
  2157.     /*----------------------------------------------------------------*/
  2158.     U16 idx = 0, reminding = 0;
  2159.     U16 item_id = menu_item_id - 1;
  2160.     /*----------------------------------------------------------------*/
  2161.     /* Code Body                                                      */
  2162.     /*----------------------------------------------------------------*/
  2163.     if (menu_item_id < MAX_MENU_ITEMS_VALUE)
  2164.     {
  2165.         idx = item_id / 8;
  2166.         reminding = item_id - (idx * 8);
  2167.         if ((MenuItemMask[idx] >> (7 - reminding)) & 1)
  2168.         {
  2169.             return MMI_TRUE;
  2170.         }
  2171.     }
  2172.     return MMI_FALSE;
  2173. }
  2174. /*****************************************************************************
  2175.  * FUNCTION
  2176.  *  GetNumOfChild_Ext
  2177.  * DESCRIPTION
  2178.  *  Function to get Number of Childrens of the Given MenuItemId considering MenuItemMask.
  2179.  * PARAMETERS
  2180.  *  menu_item_id        [IN]        Id of the menuitem
  2181.  * RETURNS
  2182.  *  U16   Number of Childrens.
  2183.  *****************************************************************************/
  2184. U16 GetNumOfChild_Ext(U16 menu_item_id)
  2185. {
  2186.     /*----------------------------------------------------------------*/
  2187.     /* Local Variables                                                */
  2188.     /*----------------------------------------------------------------*/
  2189.     U16 count = 0, num_child = nCustMenus[menu_item_id - 1].nNumofMenuItem;
  2190.     U8 i = 0;
  2191.     /*----------------------------------------------------------------*/
  2192.     /* Code Body                                                      */
  2193.     /*----------------------------------------------------------------*/
  2194.     for (i = 0; i < num_child; i++)
  2195.     {
  2196.         if (!mmi_frm_test_menu_item_hide(nCustMenus[menu_item_id - 1].nOrderMenuItemId[i]))
  2197.         {
  2198.             count++;
  2199.         }
  2200.     }
  2201.     return count;
  2202. }
  2203. /*****************************************************************************
  2204.  * FUNCTION
  2205.  *  GetSeqItemId_Ext
  2206.  * DESCRIPTION
  2207.  *  Function to get MenuItemId of the given parent_item_id & index considering MenuItemMask.
  2208.  * PARAMETERS
  2209.  *  parent_item_id      [IN]        Id of the parent menuitem
  2210.  *  index               [IN]        Index of the child menuitem
  2211.  * RETURNS
  2212.  *  U16   item id
  2213.  *****************************************************************************/
  2214. U16 GetSeqItemId_Ext(U16 parent_item_id, U16 index)
  2215. {
  2216.     /*----------------------------------------------------------------*/
  2217.     /* Local Variables                                                */
  2218.     /*----------------------------------------------------------------*/
  2219.     U8 i = 0, idx = 0;
  2220.     U16 item_id = 0;
  2221.     U8 child_count = (U8) nCustMenus[parent_item_id - 1].nNumofMenuItem;
  2222.     /*----------------------------------------------------------------*/
  2223.     /* Code Body                                                      */
  2224.     /*----------------------------------------------------------------*/
  2225.     for (i = 0; i < child_count; i++)
  2226.     {
  2227.         item_id = nCustMenus[parent_item_id - 1].nOrderMenuItemId[i];
  2228.         if (!mmi_frm_test_menu_item_hide(item_id))  /* the item is not hidden */
  2229.         {
  2230.             if (idx == index)
  2231.             {
  2232.                 break;
  2233.             }
  2234.             else
  2235.             {
  2236.                 idx++;
  2237.             }
  2238.         }
  2239.     }
  2240.     MMI_ASSERT(i < child_count);    /* all children are hidden */
  2241.     return item_id;
  2242. }
  2243. /*****************************************************************************
  2244.  * FUNCTION
  2245.  *  GetSeqItemStringId_Ext
  2246.  * DESCRIPTION
  2247.  *  Function to get StringId of the given parent_item_id and index considering MenuItemMask.
  2248.  * PARAMETERS
  2249.  *  parent_item_id      [IN]        Id of the parent menuitem
  2250.  *  index               [IN]        Index of the child menuitem
  2251.  * RETURNS
  2252.  *  U16   string id
  2253.  *****************************************************************************/
  2254. U16 GetSeqItemStringId_Ext(U16 parent_item_id, U16 index)
  2255. {
  2256.     /*----------------------------------------------------------------*/
  2257.     /* Local Variables                                                */
  2258.     /*----------------------------------------------------------------*/
  2259.     U8 idx = (U8) GetSeqItemId_Ext(parent_item_id, index);
  2260.     /*----------------------------------------------------------------*/
  2261.     /* Code Body                                                      */
  2262.     /*----------------------------------------------------------------*/
  2263.     return GetStringIdOfItem(idx);
  2264. }
  2265. /*****************************************************************************
  2266.  * FUNCTION
  2267.  *  GetSeqItemImageId_Ext
  2268.  * DESCRIPTION
  2269.  *  Function to get Image Id of the given parent_item_id and index considering MenuItemMask.
  2270.  * PARAMETERS
  2271.  *  parent_item_id      [IN]        Id of the parent menuitem
  2272.  *  index               [IN]        Index of the child menuitem
  2273.  * RETURNS
  2274.  *  U16   image id
  2275.  *****************************************************************************/
  2276. U16 GetSeqItemImageId_Ext(U16 parent_item_id, U16 index)
  2277. {
  2278.     /*----------------------------------------------------------------*/
  2279.     /* Local Variables                                                */
  2280.     /*----------------------------------------------------------------*/
  2281.     U8 idx = (U8) GetSeqItemId_Ext(parent_item_id, index);
  2282.     /*----------------------------------------------------------------*/
  2283.     /* Code Body                                                      */
  2284.     /*----------------------------------------------------------------*/
  2285.     return GetImageIdOfItem(idx);
  2286. }
  2287. /*****************************************************************************
  2288.  * FUNCTION
  2289.  *  GetSequenceItemIds_Ext
  2290.  * DESCRIPTION
  2291.  *  Function to get MenuItemId of the given parent_item_id considering MenuItemMask.
  2292.  * PARAMETERS
  2293.  *  parent_item_id      [IN]            Id of the parent menuitem
  2294.  *  ItemIds             [IN/OUT]        Array of the child menuitem id
  2295.  * RETURNS
  2296.  *  U16 number of child menuitem
  2297.  *****************************************************************************/
  2298. U16 GetSequenceItemIds_Ext(U16 parent_item_id, U16 *ItemIds)
  2299. {
  2300.     /*----------------------------------------------------------------*/
  2301.     /* Local Variables                                                */
  2302.     /*----------------------------------------------------------------*/
  2303.     U16 j, ret_idx = 0;
  2304.     /*----------------------------------------------------------------*/
  2305.     /* Code Body                                                      */
  2306.     /*----------------------------------------------------------------*/
  2307.     for (j = 0; j < nCustMenus[parent_item_id - 1].nNumofMenuItem; j++)
  2308.     {
  2309.         U16 item_id = nCustMenus[parent_item_id - 1].nOrderMenuItemId[j];
  2310.         if (!mmi_frm_test_menu_item_hide(item_id))  /* menuitem id hidden */
  2311.         {
  2312.             ItemIds[ret_idx++] = nCustMenus[parent_item_id - 1].nOrderMenuItemId[j];
  2313.         }
  2314.     }
  2315.     return ret_idx;
  2316. }
  2317. /*****************************************************************************
  2318.  * FUNCTION
  2319.  *  GetSequenceStringIds_Ext
  2320.  * DESCRIPTION
  2321.  *  Function to get StringId of the given parent_item_id considering MenuItemMask.
  2322.  * PARAMETERS
  2323.  *  parent_item_id      [IN]            Id of the parent menuitem
  2324.  *  StringIds           [IN/OUT]        Array of string ids of the child menuitem
  2325.  * RETURNS
  2326.  *  U16 number of child menuitem
  2327.  *****************************************************************************/
  2328. U16 GetSequenceStringIds_Ext(U16 parent_item_id, U16 *StringIds)
  2329. {
  2330.     /*----------------------------------------------------------------*/
  2331.     /* Local Variables                                                */
  2332.     /*----------------------------------------------------------------*/
  2333.     U16 j, ret_idx = 0;
  2334.     /*----------------------------------------------------------------*/
  2335.     /* Code Body                                                      */
  2336.     /*----------------------------------------------------------------*/
  2337.     for (j = 0; j < nCustMenus[parent_item_id - 1].nNumofMenuItem; j++)
  2338.     {
  2339.         U16 item_id = nCustMenus[parent_item_id - 1].nOrderMenuItemId[j];
  2340.         if (!mmi_frm_test_menu_item_hide(item_id))  /* menuitem id hidden */
  2341.         {
  2342.             StringIds[ret_idx++] = GetStringIdOfItem(nCustMenus[parent_item_id - 1].nOrderMenuItemId[j]);
  2343.         }
  2344.     }
  2345.     return ret_idx;
  2346. }
  2347. /*****************************************************************************
  2348.  * FUNCTION
  2349.  *  GetSequenceImageIds_Ext
  2350.  * DESCRIPTION
  2351.  *  Function to get ImageId of the given parent_item_id considering MenuItemMask.
  2352.  * PARAMETERS
  2353.  *  parent_item_id      [IN]            Id of the parent menuitem
  2354.  *  ImageIds            [IN/OUT]        Array of image ids of the child menuitem
  2355.  * RETURNS
  2356.  *  U16 number of child menuitem
  2357.  *****************************************************************************/
  2358. U16 GetSequenceImageIds_Ext(U16 parent_item_id, U16 *ImageIds)
  2359. {
  2360.     /*----------------------------------------------------------------*/
  2361.     /* Local Variables                                                */
  2362.     /*----------------------------------------------------------------*/
  2363.     U16 j, ret_idx = 0;
  2364.     /*----------------------------------------------------------------*/
  2365.     /* Code Body                                                      */
  2366.     /*----------------------------------------------------------------*/
  2367.     for (j = 0; j < nCustMenus[parent_item_id - 1].nNumofMenuItem; j++)
  2368.     {
  2369.         U16 item_id = nCustMenus[parent_item_id - 1].nOrderMenuItemId[j];
  2370.         if (!mmi_frm_test_menu_item_hide(item_id))  /* menuitem id hidden */
  2371.         {
  2372.             ImageIds[ret_idx++] = GetImageIdOfItem(nCustMenus[parent_item_id - 1].nOrderMenuItemId[j]);
  2373.         }
  2374.     }
  2375.     return ret_idx;
  2376. }
  2377. /*****************************************************************************
  2378.  * FUNCTION
  2379.  *  GetIndexOfStringId_Ext
  2380.  * DESCRIPTION
  2381.  *  Function to get ImageId of the given parent_item_id considering MenuItemMask.
  2382.  * PARAMETERS
  2383.  *  parent_item_id      [IN]        Id of the parent menuitem
  2384.  *  StringId            [IN]        Id of the string
  2385.  * RETURNS
  2386.  *  U8 index
  2387.  *****************************************************************************/
  2388. U8 GetIndexOfStringId_Ext(U16 parent_item_id, U16 StringId)
  2389. {
  2390.     /*----------------------------------------------------------------*/
  2391.     /* Local Variables                                                */
  2392.     /*----------------------------------------------------------------*/
  2393.     U16 j, ret_idx = 0;
  2394.     /*----------------------------------------------------------------*/
  2395.     /* Code Body                                                      */
  2396.     /*----------------------------------------------------------------*/
  2397.     for (j = 0; j < nCustMenus[parent_item_id - 1].nNumofMenuItem; j++)
  2398.     {
  2399.         U16 item_id = nCustMenus[parent_item_id - 1].nOrderMenuItemId[j];
  2400.         if (!mmi_frm_test_menu_item_hide(item_id))  /* menuitem id hidden */
  2401.         {
  2402.             ret_idx++;
  2403.             if (StringId == nCustMenus[parent_item_id - 1].nOrderMenuItemId[j])
  2404.             {
  2405.                 return (U8) ret_idx;
  2406.             }
  2407.         }
  2408.     }
  2409.     return (U8) 0;
  2410. }