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

MTK

开发平台:

C/C++

  1.     UI_UNUSED_PARAMETER(r);
  2.     UI_UNUSED_PARAMETER(g);
  3.     UI_UNUSED_PARAMETER(b);
  4.     return (0);
  5. }
  6. /*****************************************************************************
  7.  * FUNCTION
  8.  *  UI_color
  9.  * DESCRIPTION
  10.  *  
  11.  * PARAMETERS
  12.  *  r       [IN]        
  13.  *  g       [IN]        
  14.  *  b       [IN]        
  15.  * RETURNS
  16.  *  
  17.  *****************************************************************************/
  18. color UI_color(U8 r, U8 g, U8 b)
  19. {
  20.     /*----------------------------------------------------------------*/
  21.     /* Local Variables                                                */
  22.     /*----------------------------------------------------------------*/
  23.     color c;
  24.     /*----------------------------------------------------------------*/
  25.     /* Code Body                                                      */
  26.     /*----------------------------------------------------------------*/
  27.     c.r = r;
  28.     c.b = b;
  29.     c.g = g;
  30.     c.alpha = 100;
  31.     return (c);
  32. }
  33. /*****************************************************************************
  34.  * FUNCTION
  35.  *  UI_color32
  36.  * DESCRIPTION
  37.  *  
  38.  * PARAMETERS
  39.  *  r           [IN]        
  40.  *  g           [IN]        
  41.  *  b           [IN]        
  42.  *  alpha       [IN]        
  43.  * RETURNS
  44.  *  
  45.  *****************************************************************************/
  46. color UI_color32(U8 r, U8 g, U8 b, U8 alpha)
  47. {
  48.     /*----------------------------------------------------------------*/
  49.     /* Local Variables                                                */
  50.     /*----------------------------------------------------------------*/
  51.     color c;
  52.     /*----------------------------------------------------------------*/
  53.     /* Code Body                                                      */
  54.     /*----------------------------------------------------------------*/
  55.     c.r = r;
  56.     c.b = b;
  57.     c.g = g;
  58.     c.alpha = alpha;
  59.     return (c);
  60. }
  61. /*****************************************************************************
  62.  * FUNCTION
  63.  *  UI_color_RGB
  64.  * DESCRIPTION
  65.  *  
  66.  * PARAMETERS
  67.  *  c       [IN]        
  68.  *  r       [?]         
  69.  *  g       [?]         
  70.  *  b       [?]         
  71.  * RETURNS
  72.  *  void
  73.  *****************************************************************************/
  74. void UI_color_RGB(color c, U8 *r, U8 *g, U8 *b)
  75. {
  76.     /*----------------------------------------------------------------*/
  77.     /* Local Variables                                                */
  78.     /*----------------------------------------------------------------*/
  79.     /*----------------------------------------------------------------*/
  80.     /* Code Body                                                      */
  81.     /*----------------------------------------------------------------*/
  82.     *r = c.r;
  83.     *g = c.g;
  84.     *b = c.b;
  85. }
  86. /*****************************************************************************
  87.  * FUNCTION
  88.  *  UI_lock_double_buffer
  89.  * DESCRIPTION
  90.  *  
  91.  * PARAMETERS
  92.  *  void
  93.  * RETURNS
  94.  *  void
  95.  *****************************************************************************/
  96. void UI_lock_double_buffer(void)
  97. {
  98.     /*----------------------------------------------------------------*/
  99.     /* Local Variables                                                */
  100.     /*----------------------------------------------------------------*/
  101.     /*----------------------------------------------------------------*/
  102.     /* Code Body                                                      */
  103.     /*----------------------------------------------------------------*/
  104.     gdi_layer_lock_frame_buffer();
  105. }
  106. /*****************************************************************************
  107.  * FUNCTION
  108.  *  UI_unlock_double_buffer
  109.  * DESCRIPTION
  110.  *  
  111.  * PARAMETERS
  112.  *  void
  113.  * RETURNS
  114.  *  void
  115.  *****************************************************************************/
  116. void UI_unlock_double_buffer(void)
  117. {
  118.     /*----------------------------------------------------------------*/
  119.     /* Local Variables                                                */
  120.     /*----------------------------------------------------------------*/
  121.     /*----------------------------------------------------------------*/
  122.     /* Code Body                                                      */
  123.     /*----------------------------------------------------------------*/
  124.     gdi_layer_unlock_frame_buffer();
  125. }
  126. /*****************************************************************************
  127.  * FUNCTION
  128.  *  UI_BLT_double_buffer
  129.  * DESCRIPTION
  130.  *  
  131.  * PARAMETERS
  132.  *  x1      [IN]        
  133.  *  y1      [IN]        
  134.  *  x2      [IN]        
  135.  *  y2      [IN]        
  136.  * RETURNS
  137.  *  void
  138.  *****************************************************************************/
  139. void UI_BLT_double_buffer(S32 x1, S32 y1, S32 x2, S32 y2)
  140. {
  141.     /*----------------------------------------------------------------*/
  142.     /* Local Variables                                                */
  143.     /*----------------------------------------------------------------*/
  144.     /*----------------------------------------------------------------*/
  145.     /* Code Body                                                      */
  146.     /*----------------------------------------------------------------*/
  147.     gdi_layer_blt_previous(x1, y1, x2, y2);
  148. }
  149. #if(MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32)
  150. /* System keyboard handler          */
  151. void keyboard_key_handler(S32 vkey_code, S32 key_state);
  152. void keyboard_input_handler(S32 vkey_code);
  153. void keyboard_global_key_handler(S32 vkey_code, S32 key_state);
  154. void keyboard_global_input_handler(S32 vkey_code);
  155. extern void toggle_temp_sublcd_display(void);
  156. /*****************************************************************************
  157.  * FUNCTION
  158.  *  MMI_system_keybord_handler
  159.  * DESCRIPTION
  160.  *  
  161.  * PARAMETERS
  162.  *  key_code        [IN]        
  163.  *  key_state       [IN]        
  164.  * RETURNS
  165.  *  void
  166.  *****************************************************************************/
  167. void MMI_system_keybord_handler(S32 key_code, S32 key_state)
  168. {
  169.     /*----------------------------------------------------------------*/
  170.     /* Local Variables                                                */
  171.     /*----------------------------------------------------------------*/
  172.     /*----------------------------------------------------------------*/
  173.     /* Code Body                                                      */
  174.     /*----------------------------------------------------------------*/
  175.     keyboard_global_key_handler(key_code, key_state);
  176.     keyboard_key_handler(key_code, key_state);
  177.     /* Character input for the MMI         */
  178.     if (!((key_code >= 0x70) && (key_code <= 0x7F)) &&
  179.         (key_code != 0x91) &&
  180.         (key_code != 0x90) && !((key_code >= 0x21) && (key_code <= 0x28)) && (key_code != 0x2D) && (key_code != 0x2E))
  181.     {
  182.         if (key_state == WM_KEYBRD_PRESS)
  183.         {   /* Translate the key_code to ASCII here   */
  184.             /* Need to add Translation of code        */
  185.             /* Check for Shift, Caps key --etc        */
  186.             keyboard_input_handler(key_code);
  187.             keyboard_global_input_handler(key_code);
  188.         }
  189.     }
  190.     /* Temp: Toggles a sample Sub LCD display */
  191.     if ((key_state == 256) && (key_code == 116))
  192.     {
  193.         toggle_temp_sublcd_display();
  194.     }
  195. }
  196. #elif(MMI_BUILD_TYPE==BUILD_TYPE_HW_PLUTO)
  197. /*****************************************************************************
  198.  * FUNCTION
  199.  *  MMI_system_keybord_handler
  200.  * DESCRIPTION
  201.  *  
  202.  * PARAMETERS
  203.  *  key_code        [IN]        
  204.  *  key_state       [IN]        
  205.  * RETURNS
  206.  *  void
  207.  *****************************************************************************/
  208. void MMI_system_keybord_handler(S32 key_code, S32 key_state)
  209. {
  210.     /*----------------------------------------------------------------*/
  211.     /* Local Variables                                                */
  212.     /*----------------------------------------------------------------*/
  213.     /*----------------------------------------------------------------*/
  214.     /* Code Body                                                      */
  215.     /*----------------------------------------------------------------*/
  216.     UI_UNUSED_PARAMETER(key_code);
  217.     UI_UNUSED_PARAMETER(key_state);
  218. }
  219. #endif 
  220. #if(!WINGUI_USE_OS_TIMERS)
  221. /* Software timers required by the UI  */
  222. typedef struct _timer
  223. {
  224.     S32 counter;
  225.     void (*callback) (void);
  226. } timer;
  227. #include "TimerEvents.h"
  228. timer timer_functions[MAX_TIMERS];
  229. S32 n_timers = 0;
  230. S32 patch_timer_counter = 0;
  231. U8 UI_timer_active = 1;
  232. extern U16 StartMyTimerInt(U16 nTimerId, U32 nTimeDuration, oslTimerFuncPtr TimerExpiry, U8 alignment);
  233. extern U16 StopMyTimer(U16 nTimerId);
  234. /*****************************************************************************
  235.  * FUNCTION
  236.  *  SW_StartTimer
  237.  * DESCRIPTION
  238.  *  
  239.  * PARAMETERS
  240.  *  timerid     [IN]        
  241.  *  delay       [IN]        
  242.  *  funcPtr     [IN]        
  243.  * RETURNS
  244.  *  void
  245.  *****************************************************************************/
  246. void SW_StartTimer(U16 timerid, U32 delay, FuncPtr funcPtr)
  247. {
  248.     /*----------------------------------------------------------------*/
  249.     /* Local Variables                                                */
  250.     /*----------------------------------------------------------------*/
  251.     /*----------------------------------------------------------------*/
  252.     /* Code Body                                                      */
  253.     /*----------------------------------------------------------------*/
  254.     StartMyTimerInt(timerid, delay, (oslTimerFuncPtr) funcPtr, 1);
  255. }
  256. /*****************************************************************************
  257.  * FUNCTION
  258.  *  SW_StopTimer
  259.  * DESCRIPTION
  260.  *  
  261.  * PARAMETERS
  262.  *  timerid     [IN]        
  263.  * RETURNS
  264.  *  void
  265.  *****************************************************************************/
  266. void SW_StopTimer(U16 timerid)
  267. {
  268.     /*----------------------------------------------------------------*/
  269.     /* Local Variables                                                */
  270.     /*----------------------------------------------------------------*/
  271.     /*----------------------------------------------------------------*/
  272.     /* Code Body                                                      */
  273.     /*----------------------------------------------------------------*/
  274.     StopMyTimer(timerid);
  275. }
  276. void UI_timer(void);
  277. /*****************************************************************************
  278.  * FUNCTION
  279.  *  UI_timer_control
  280.  * DESCRIPTION
  281.  *  
  282.  * PARAMETERS
  283.  *  void
  284.  * RETURNS
  285.  *  void
  286.  *****************************************************************************/
  287. void UI_timer_control(void)
  288. {
  289.     /*----------------------------------------------------------------*/
  290.     /* Local Variables                                                */
  291.     /*----------------------------------------------------------------*/
  292.     /*----------------------------------------------------------------*/
  293.     /* Code Body                                                      */
  294.     /*----------------------------------------------------------------*/
  295.     SW_StartTimer(UI_ELEMENTS_TIMER, UI_TIMER_RESOLUTION, UI_timer_control);
  296.     UI_timer_active = 1;
  297.     UI_timer();
  298. }
  299. /*****************************************************************************
  300.  * FUNCTION
  301.  *  UI_start_timer
  302.  * DESCRIPTION
  303.  *  
  304.  * PARAMETERS
  305.  *  count           [IN]        
  306.  *  callback        [IN]        
  307.  * RETURNS
  308.  *  void
  309.  *****************************************************************************/
  310. void UI_start_timer(S32 count, void (*callback) (void))
  311. {
  312.     /*----------------------------------------------------------------*/
  313.     /* Local Variables                                                */
  314.     /*----------------------------------------------------------------*/
  315.     S32 i, j;
  316.     /*----------------------------------------------------------------*/
  317.     /* Code Body                                                      */
  318.     /*----------------------------------------------------------------*/
  319.     /* start the OS/hardware timer if necessary                    */
  320.     if (n_timers >= MAX_TIMERS)
  321.     {
  322.         return;
  323.     }
  324.     /* Patch for the timer start bug:
  325.        Note, for some reasons, the OS timer will not call UI_timer_control.
  326.        So, when UI_start_timer is called again, we'll check if the OS timer
  327.        is stuck. If its stuck, then we'll start the OS timer again       */
  328.     if (n_timers > 0)
  329.     {
  330.         if (timer_functions[0].counter == patch_timer_counter)
  331.         {
  332.             SW_StartTimer(UI_ELEMENTS_TIMER, UI_TIMER_RESOLUTION, UI_timer_control);
  333.             UI_timer_active = 1;
  334.         }
  335.     }
  336.     if ((n_timers == 0) || (!UI_timer_active))
  337.     {
  338.         SW_StartTimer(UI_ELEMENTS_TIMER, UI_TIMER_RESOLUTION, UI_timer_control);
  339.         UI_timer_active = 1;
  340.     }
  341.     else
  342.     {   /* check if this function has already been hooked. If yes, remove it */
  343.         for (i = 0; i < n_timers; i++)
  344.         {
  345.             if (timer_functions[i].callback == callback)
  346.             {
  347.                 for (j = i; j < n_timers - 1; j++)
  348.                 {
  349.                     timer_functions[j] = timer_functions[j + 1];
  350.                 }
  351.                 n_timers--;
  352.             }
  353.         }
  354.     }
  355.     timer_functions[n_timers].counter = count / UI_TIMER_RESOLUTION;
  356.     timer_functions[n_timers].callback = callback;
  357.     n_timers++;
  358.     /* Patch for the timer start bug                               */
  359.     patch_timer_counter = timer_functions[0].counter;
  360. }
  361. /*****************************************************************************
  362.  * FUNCTION
  363.  *  UI_cancel_timer
  364.  * DESCRIPTION
  365.  *  
  366.  * PARAMETERS
  367.  *  callback        [IN]        
  368.  * RETURNS
  369.  *  void
  370.  *****************************************************************************/
  371. void UI_cancel_timer(void (*callback) (void))
  372. {
  373.     /*----------------------------------------------------------------*/
  374.     /* Local Variables                                                */
  375.     /*----------------------------------------------------------------*/
  376.     S32 i, j;
  377.     /*----------------------------------------------------------------*/
  378.     /* Code Body                                                      */
  379.     /*----------------------------------------------------------------*/
  380.     if (n_timers <= 0)
  381.     {
  382.         return;
  383.     }
  384.     /* If the callback function has already been hooked, remove it          */
  385.     for (i = 0; i < n_timers; i++)
  386.     {
  387.         if (timer_functions[i].callback == callback)
  388.         {
  389.             for (j = i; j < n_timers - 1; j++)
  390.             {
  391.                 timer_functions[j] = timer_functions[j + 1];
  392.             }
  393.             n_timers--;
  394.         }
  395.     }
  396.     /* if all software timers have expired, release the OS/hardware timer      */
  397.     if (n_timers == 0)
  398.     {
  399.         SW_StopTimer(UI_ELEMENTS_TIMER);
  400.     }
  401. }
  402. /*****************************************************************************
  403.  * FUNCTION
  404.  *  UI_cancel_all_timers
  405.  * DESCRIPTION
  406.  *  
  407.  * PARAMETERS
  408.  *  void
  409.  * RETURNS
  410.  *  void
  411.  *****************************************************************************/
  412. void UI_cancel_all_timers(void)
  413. {
  414.     /*----------------------------------------------------------------*/
  415.     /* Local Variables                                                */
  416.     /*----------------------------------------------------------------*/
  417.     /*----------------------------------------------------------------*/
  418.     /* Code Body                                                      */
  419.     /*----------------------------------------------------------------*/
  420.     n_timers = 0;
  421.     SW_StopTimer(UI_ELEMENTS_TIMER);
  422. }
  423. /*****************************************************************************
  424.  * FUNCTION
  425.  *  UI_timer
  426.  * DESCRIPTION
  427.  *  
  428.  * PARAMETERS
  429.  *  void
  430.  * RETURNS
  431.  *  void
  432.  *****************************************************************************/
  433. void UI_timer(void)
  434. {
  435.     /*----------------------------------------------------------------*/
  436.     /* Local Variables                                                */
  437.     /*----------------------------------------------------------------*/
  438.     S32 i, j;
  439.     /*----------------------------------------------------------------*/
  440.     /* Code Body                                                      */
  441.     /*----------------------------------------------------------------*/
  442.     void (*callback) (void);
  443.     if (n_timers == 0)
  444.     {
  445.         if (UI_timer_active)
  446.         {
  447.             SW_StopTimer(UI_ELEMENTS_TIMER);
  448.         }
  449.         return;
  450.     }
  451.     for (i = 0; i < n_timers; i++)
  452.     {
  453.         timer_functions[i].counter--;
  454.         if (timer_functions[i].counter <= 0)
  455.         {
  456.             callback = timer_functions[i].callback;
  457.             for (j = i; j < n_timers - 1; j++)
  458.             {
  459.                 timer_functions[j] = timer_functions[j + 1];
  460.             }
  461.             n_timers--;
  462.             callback();
  463.         }
  464.     }
  465.     /* if all software timers have expired, release the OS/hardware timer      */
  466.     if (n_timers == 0)
  467.     {
  468.         SW_StopTimer(UI_ELEMENTS_TIMER);
  469.     }
  470. }
  471. #else /* (!WINGUI_USE_OS_TIMERS) */ 
  472. /* Externals   */
  473. extern U16 StartMyTimerInt(U16 nTimerId, U32 nTimeDuration, oslTimerFuncPtr TimerExpiry, U8 alignment);
  474. extern U16 StopMyTimer(U16 nTimerId);
  475. U8 HW_alignment_timer_flag = TIMER_IS_ALIGNMENT;
  476. /*****************************************************************************
  477.  * FUNCTION
  478.  *  UI_enable_alignment_timers
  479.  * DESCRIPTION
  480.  *  
  481.  * PARAMETERS
  482.  *  void
  483.  * RETURNS
  484.  *  void
  485.  *****************************************************************************/
  486. void UI_enable_alignment_timers(void)
  487. {
  488.     /*----------------------------------------------------------------*/
  489.     /* Local Variables                                                */
  490.     /*----------------------------------------------------------------*/
  491.     /*----------------------------------------------------------------*/
  492.     /* Code Body                                                      */
  493.     /*----------------------------------------------------------------*/
  494.     HW_alignment_timer_flag = TIMER_IS_ALIGNMENT;
  495. }
  496. /*****************************************************************************
  497.  * FUNCTION
  498.  *  UI_disable_alignment_timers
  499.  * DESCRIPTION
  500.  *  
  501.  * PARAMETERS
  502.  *  void
  503.  * RETURNS
  504.  *  void
  505.  *****************************************************************************/
  506. void UI_disable_alignment_timers(void)
  507. {
  508.     /*----------------------------------------------------------------*/
  509.     /* Local Variables                                                */
  510.     /*----------------------------------------------------------------*/
  511.     /*----------------------------------------------------------------*/
  512.     /* Code Body                                                      */
  513.     /*----------------------------------------------------------------*/
  514.     HW_alignment_timer_flag = TIMER_IS_NO_ALIGNMENT;
  515. }
  516. /*****************************************************************************
  517.  * FUNCTION
  518.  *  HW_StartTimer
  519.  * DESCRIPTION
  520.  *  
  521.  * PARAMETERS
  522.  *  timerid     [IN]        
  523.  *  delay       [IN]        
  524.  *  funcPtr     [IN]        
  525.  * RETURNS
  526.  *  void
  527.  *****************************************************************************/
  528. void HW_StartTimer(U16 timerid, U32 delay, FuncPtr funcPtr)
  529. {
  530.     /*----------------------------------------------------------------*/
  531.     /* Local Variables                                                */
  532.     /*----------------------------------------------------------------*/
  533.     /*----------------------------------------------------------------*/
  534.     /* Code Body                                                      */
  535.     /*----------------------------------------------------------------*/
  536.     StartMyTimerInt(timerid, delay, (oslTimerFuncPtr) funcPtr, TIMER_IS_NO_ALIGNMENT);
  537. }
  538. /*****************************************************************************
  539.  * FUNCTION
  540.  *  HW_StopTimer
  541.  * DESCRIPTION
  542.  *  
  543.  * PARAMETERS
  544.  *  timerid     [IN]        
  545.  * RETURNS
  546.  *  void
  547.  *****************************************************************************/
  548. void HW_StopTimer(U16 timerid)
  549. {
  550.     /*----------------------------------------------------------------*/
  551.     /* Local Variables                                                */
  552.     /*----------------------------------------------------------------*/
  553.     /*----------------------------------------------------------------*/
  554.     /* Code Body                                                      */
  555.     /*----------------------------------------------------------------*/
  556.     StopMyTimer(timerid);
  557. }
  558. #define MAX_UI_TIMERS      (sizeof(UI_timer_IDs)/sizeof(UI_timer_IDs[0]))
  559. U16 UI_timer_IDs[] = 
  560. {
  561.     UI_TIMER_ID_BASE + 0,
  562.     UI_TIMER_ID_BASE + 1,
  563.     UI_TIMER_ID_BASE + 2,
  564.     UI_TIMER_ID_BASE + 3,
  565.     UI_TIMER_ID_BASE + 4,
  566.     UI_TIMER_ID_BASE + 5,
  567.     UI_TIMER_ID_BASE + 6,
  568.     UI_TIMER_ID_BASE + 7,
  569.     UI_TIMER_ID_BASE + 8,
  570.     UI_TIMER_ID_BASE + 9,
  571. };
  572. void (*UI_timer_callbacks[MAX_UI_TIMERS]) (void);
  573. /* Flag=0 indicates timer is available */
  574. U8 UI_timer_ID_flags[MAX_UI_TIMERS];
  575. /* OS callback functions   */
  576. /*****************************************************************************
  577.  * FUNCTION
  578.  *  UI_timer_callback_0
  579.  * DESCRIPTION
  580.  *  
  581.  * PARAMETERS
  582.  *  void
  583.  * RETURNS
  584.  *  void
  585.  *****************************************************************************/
  586. void UI_timer_callback_0(void)
  587. {
  588.     /*----------------------------------------------------------------*/
  589.     /* Local Variables                                                */
  590.     /*----------------------------------------------------------------*/
  591.     /*----------------------------------------------------------------*/
  592.     /* Code Body                                                      */
  593.     /*----------------------------------------------------------------*/
  594.     HW_StopTimer(UI_timer_IDs[0]);
  595.     UI_timer_ID_flags[0] = 0;
  596. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  597.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  598. #endif
  599.     UI_timer_callbacks[0] ();
  600. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  601. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  602. #endif
  603. }
  604. /*****************************************************************************
  605.  * FUNCTION
  606.  *  UI_timer_callback_1
  607.  * DESCRIPTION
  608.  *  
  609.  * PARAMETERS
  610.  *  void
  611.  * RETURNS
  612.  *  void
  613.  *****************************************************************************/
  614. void UI_timer_callback_1(void)
  615. {
  616.     /*----------------------------------------------------------------*/
  617.     /* Local Variables                                                */
  618.     /*----------------------------------------------------------------*/
  619.     /*----------------------------------------------------------------*/
  620.     /* Code Body                                                      */
  621.     /*----------------------------------------------------------------*/
  622.     HW_StopTimer(UI_timer_IDs[1]);
  623.     UI_timer_ID_flags[1] = 0;
  624. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  625.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  626. #endif
  627.     UI_timer_callbacks[1] ();
  628. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  629. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  630. #endif
  631. }
  632. /*****************************************************************************
  633.  * FUNCTION
  634.  *  UI_timer_callback_2
  635.  * DESCRIPTION
  636.  *  
  637.  * PARAMETERS
  638.  *  void
  639.  * RETURNS
  640.  *  void
  641.  *****************************************************************************/
  642. void UI_timer_callback_2(void)
  643. {
  644.     /*----------------------------------------------------------------*/
  645.     /* Local Variables                                                */
  646.     /*----------------------------------------------------------------*/
  647.     /*----------------------------------------------------------------*/
  648.     /* Code Body                                                      */
  649.     /*----------------------------------------------------------------*/
  650.     HW_StopTimer(UI_timer_IDs[2]);
  651.     UI_timer_ID_flags[2] = 0;
  652. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  653.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  654. #endif
  655.     UI_timer_callbacks[2] ();
  656. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  657. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  658. #endif
  659. }
  660. /*****************************************************************************
  661.  * FUNCTION
  662.  *  UI_timer_callback_3
  663.  * DESCRIPTION
  664.  *  
  665.  * PARAMETERS
  666.  *  void
  667.  * RETURNS
  668.  *  void
  669.  *****************************************************************************/
  670. void UI_timer_callback_3(void)
  671. {
  672.     /*----------------------------------------------------------------*/
  673.     /* Local Variables                                                */
  674.     /*----------------------------------------------------------------*/
  675.     /*----------------------------------------------------------------*/
  676.     /* Code Body                                                      */
  677.     /*----------------------------------------------------------------*/
  678.     HW_StopTimer(UI_timer_IDs[3]);
  679.     UI_timer_ID_flags[3] = 0;
  680. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  681.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  682. #endif
  683.     UI_timer_callbacks[3] ();
  684. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  685. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  686. #endif
  687. }
  688. /*****************************************************************************
  689.  * FUNCTION
  690.  *  UI_timer_callback_4
  691.  * DESCRIPTION
  692.  *  
  693.  * PARAMETERS
  694.  *  void
  695.  * RETURNS
  696.  *  void
  697.  *****************************************************************************/
  698. void UI_timer_callback_4(void)
  699. {
  700.     /*----------------------------------------------------------------*/
  701.     /* Local Variables                                                */
  702.     /*----------------------------------------------------------------*/
  703.     /*----------------------------------------------------------------*/
  704.     /* Code Body                                                      */
  705.     /*----------------------------------------------------------------*/
  706.     HW_StopTimer(UI_timer_IDs[4]);
  707.     UI_timer_ID_flags[4] = 0;
  708. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  709.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  710. #endif
  711.     UI_timer_callbacks[4] ();
  712. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  713. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  714. #endif
  715. }
  716. /*****************************************************************************
  717.  * FUNCTION
  718.  *  UI_timer_callback_5
  719.  * DESCRIPTION
  720.  *  
  721.  * PARAMETERS
  722.  *  void
  723.  * RETURNS
  724.  *  void
  725.  *****************************************************************************/
  726. void UI_timer_callback_5(void)
  727. {
  728.     /*----------------------------------------------------------------*/
  729.     /* Local Variables                                                */
  730.     /*----------------------------------------------------------------*/
  731.     /*----------------------------------------------------------------*/
  732.     /* Code Body                                                      */
  733.     /*----------------------------------------------------------------*/
  734.     HW_StopTimer(UI_timer_IDs[5]);
  735.     UI_timer_ID_flags[5] = 0;
  736. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  737.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  738. #endif
  739.     UI_timer_callbacks[5] ();
  740. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  741. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  742. #endif
  743. }
  744. /*****************************************************************************
  745.  * FUNCTION
  746.  *  UI_timer_callback_6
  747.  * DESCRIPTION
  748.  *  
  749.  * PARAMETERS
  750.  *  void
  751.  * RETURNS
  752.  *  void
  753.  *****************************************************************************/
  754. void UI_timer_callback_6(void)
  755. {
  756.     /*----------------------------------------------------------------*/
  757.     /* Local Variables                                                */
  758.     /*----------------------------------------------------------------*/
  759.     /*----------------------------------------------------------------*/
  760.     /* Code Body                                                      */
  761.     /*----------------------------------------------------------------*/
  762.     HW_StopTimer(UI_timer_IDs[6]);
  763.     UI_timer_ID_flags[6] = 0;
  764. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  765.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  766. #endif
  767.     UI_timer_callbacks[6] ();
  768. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  769. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  770. #endif
  771. }
  772. /*****************************************************************************
  773.  * FUNCTION
  774.  *  UI_timer_callback_7
  775.  * DESCRIPTION
  776.  *  
  777.  * PARAMETERS
  778.  *  void
  779.  * RETURNS
  780.  *  void
  781.  *****************************************************************************/
  782. void UI_timer_callback_7(void)
  783. {
  784.     /*----------------------------------------------------------------*/
  785.     /* Local Variables                                                */
  786.     /*----------------------------------------------------------------*/
  787.     /*----------------------------------------------------------------*/
  788.     /* Code Body                                                      */
  789.     /*----------------------------------------------------------------*/
  790.     HW_StopTimer(UI_timer_IDs[7]);
  791.     UI_timer_ID_flags[7] = 0;
  792. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  793.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  794. #endif
  795.     UI_timer_callbacks[7] ();
  796. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  797. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  798. #endif
  799. }
  800. /*****************************************************************************
  801.  * FUNCTION
  802.  *  UI_timer_callback_8
  803.  * DESCRIPTION
  804.  *  
  805.  * PARAMETERS
  806.  *  void
  807.  * RETURNS
  808.  *  void
  809.  *****************************************************************************/
  810. void UI_timer_callback_8(void)
  811. {
  812.     /*----------------------------------------------------------------*/
  813.     /* Local Variables                                                */
  814.     /*----------------------------------------------------------------*/
  815.     /*----------------------------------------------------------------*/
  816.     /* Code Body                                                      */
  817.     /*----------------------------------------------------------------*/
  818.     HW_StopTimer(UI_timer_IDs[8]);
  819.     UI_timer_ID_flags[8] = 0;
  820. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  821.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  822. #endif
  823.     UI_timer_callbacks[8] ();
  824. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  825. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  826. #endif
  827. }
  828. /*****************************************************************************
  829.  * FUNCTION
  830.  *  UI_timer_callback_9
  831.  * DESCRIPTION
  832.  *  
  833.  * PARAMETERS
  834.  *  void
  835.  * RETURNS
  836.  *  void
  837.  *****************************************************************************/
  838. void UI_timer_callback_9(void)
  839. {
  840.     /*----------------------------------------------------------------*/
  841.     /* Local Variables                                                */
  842.     /*----------------------------------------------------------------*/
  843.     /*----------------------------------------------------------------*/
  844.     /* Code Body                                                      */
  845.     /*----------------------------------------------------------------*/
  846.     HW_StopTimer(UI_timer_IDs[9]);
  847.     UI_timer_ID_flags[9] = 0;
  848. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  849.     g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_TRUE;
  850. #endif
  851.     UI_timer_callbacks[9] ();
  852. #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
  853. g_mmi_frm_cntx.dump_screen_info.allow_dump_screen_str = MMI_FALSE;
  854. #endif
  855. }
  856. /*****************************************************************************
  857.  * FUNCTION
  858.  *  UI_start_timer
  859.  * DESCRIPTION
  860.  *  
  861.  * PARAMETERS
  862.  *  count           [IN]        
  863.  *  callback        [IN]        
  864.  * RETURNS
  865.  *  void
  866.  *****************************************************************************/
  867. void UI_start_timer(S32 count, void (*callback) (void))
  868. {
  869.     /*----------------------------------------------------------------*/
  870.     /* Local Variables                                                */
  871.     /*----------------------------------------------------------------*/
  872.     S16 i;
  873.     U8 all_timers_used = 1;
  874.     /*----------------------------------------------------------------*/
  875.     /* Code Body                                                      */
  876.     /*----------------------------------------------------------------*/
  877.     /* check if this function has already been hooked. If yes, remove it */
  878.     for (i = 0; i < MAX_UI_TIMERS; i++)
  879.     {
  880.         if ((UI_timer_ID_flags[i]) && (UI_timer_callbacks[i] == callback))
  881.         {
  882.             HW_StopTimer(UI_timer_IDs[i]);
  883.             UI_timer_callbacks[i] = UI_dummy_function;
  884.             UI_timer_ID_flags[i] = 0;
  885.         }
  886.     }
  887.     /* Check for free timer       */
  888.     for (i = 0; i < MAX_UI_TIMERS; i++)
  889.     {
  890.         if (UI_timer_ID_flags[i] == 0)
  891.         {
  892.             all_timers_used = 0;
  893.             break;
  894.         }
  895.     }
  896.     /* If all timers are used, return   */
  897.     if (all_timers_used)
  898.     {
  899.         return;
  900.     }
  901.     /* Hook the callback function and start the OS timer  */
  902.     UI_timer_callbacks[i] = callback;
  903.     switch (i)
  904.     {
  905.         case 0:
  906.             HW_StartTimer(UI_timer_IDs[0], (U16) count, UI_timer_callback_0);
  907.             break;
  908.         case 1:
  909.             HW_StartTimer(UI_timer_IDs[1], (U16) count, UI_timer_callback_1);
  910.             break;
  911.         case 2:
  912.             HW_StartTimer(UI_timer_IDs[2], (U16) count, UI_timer_callback_2);
  913.             break;
  914.         case 3:
  915.             HW_StartTimer(UI_timer_IDs[3], (U16) count, UI_timer_callback_3);
  916.             break;
  917.         case 4:
  918.             HW_StartTimer(UI_timer_IDs[4], (U16) count, UI_timer_callback_4);
  919.             break;
  920.         case 5:
  921.             HW_StartTimer(UI_timer_IDs[5], (U16) count, UI_timer_callback_5);
  922.             break;
  923.         case 6:
  924.             HW_StartTimer(UI_timer_IDs[6], (U16) count, UI_timer_callback_6);
  925.             break;
  926.         case 7:
  927.             HW_StartTimer(UI_timer_IDs[7], (U16) count, UI_timer_callback_7);
  928.             break;
  929.         case 8:
  930.             HW_StartTimer(UI_timer_IDs[8], (U16) count, UI_timer_callback_8);
  931.             break;
  932.         case 9:
  933.             HW_StartTimer(UI_timer_IDs[9], (U16) count, UI_timer_callback_9);
  934.             break;
  935.     }
  936.     /* Set the timer to busy   */
  937.     UI_timer_ID_flags[i] = 1;
  938. }
  939. /*****************************************************************************
  940.  * FUNCTION
  941.  *  UI_cancel_timer
  942.  * DESCRIPTION
  943.  *  
  944.  * PARAMETERS
  945.  *  callback        [IN]        
  946.  * RETURNS
  947.  *  void
  948.  *****************************************************************************/
  949. void UI_cancel_timer(void (*callback) (void))
  950. {
  951.     /*----------------------------------------------------------------*/
  952.     /* Local Variables                                                */
  953.     /*----------------------------------------------------------------*/
  954.     S16 i;
  955.     /*----------------------------------------------------------------*/
  956.     /* Code Body                                                      */
  957.     /*----------------------------------------------------------------*/
  958.     /* Check if this callback function is hooked */
  959.     for (i = 0; i < MAX_UI_TIMERS; i++)
  960.     {
  961.         if (UI_timer_ID_flags[i] && UI_timer_callbacks[i] == callback)
  962.         {
  963.             UI_timer_ID_flags[i] = 0;
  964.             HW_StopTimer(UI_timer_IDs[i]);
  965.             break;
  966.         }
  967.     }
  968. }
  969. /*****************************************************************************
  970.  * FUNCTION
  971.  *  UI_cancel_all_timers
  972.  * DESCRIPTION
  973.  *  
  974.  * PARAMETERS
  975.  *  void
  976.  * RETURNS
  977.  *  void
  978.  *****************************************************************************/
  979. void UI_cancel_all_timers(void)
  980. {
  981.     /*----------------------------------------------------------------*/
  982.     /* Local Variables                                                */
  983.     /*----------------------------------------------------------------*/
  984.     S16 i;
  985.     /*----------------------------------------------------------------*/
  986.     /* Code Body                                                      */
  987.     /*----------------------------------------------------------------*/
  988.     for (i = 0; i < MAX_UI_TIMERS; i++)
  989.     {
  990.         if (UI_timer_ID_flags[i])
  991.         {
  992.             UI_timer_ID_flags[i] = 0;
  993.             HW_StopTimer(UI_timer_IDs[i]);
  994.             break;
  995.         }
  996.     }
  997. }
  998. #endif /* (!WINGUI_USE_OS_TIMERS) */ 
  999. /* Internal bitmap format: Device specific      */
  1000. animated_image *animated_images[MAX_ANIMATED_IMAGES];
  1001. S32 n_animated_images = 0;
  1002. void (*UI_hide_animation_frame_function) (void) = UI_dummy_function;
  1003. /*****************************************************************************
  1004.  * FUNCTION
  1005.  *  _measure_bitmap
  1006.  * DESCRIPTION
  1007.  *  
  1008.  * PARAMETERS
  1009.  *  b           [?]     
  1010.  *  width       [?]     
  1011.  *  height      [?]     
  1012.  * RETURNS
  1013.  *  void
  1014.  *****************************************************************************/
  1015. void _measure_bitmap(bitmap *b, S32 *width, S32 *height)
  1016. {
  1017.     /*----------------------------------------------------------------*/
  1018.     /* Local Variables                                                */
  1019.     /*----------------------------------------------------------------*/
  1020.     /*----------------------------------------------------------------*/
  1021.     /* Code Body                                                      */
  1022.     /*----------------------------------------------------------------*/
  1023.     if (b == NULL)
  1024.     {
  1025.         *width = 0;
  1026.         *height = 0;
  1027.     }
  1028.     else
  1029.     {
  1030.         *width = b->xsize;
  1031.         *height = b->ysize;
  1032.     }
  1033. }
  1034. /*****************************************************************************
  1035.  * FUNCTION
  1036.  *  _show_bitmap
  1037.  * DESCRIPTION
  1038.  *  
  1039.  * PARAMETERS
  1040.  *  x1      [IN]        
  1041.  *  y1      [IN]        
  1042.  *  b       [?]         
  1043.  * RETURNS
  1044.  *  void
  1045.  *****************************************************************************/
  1046. void _show_bitmap(S32 x1, S32 y1, bitmap *b)
  1047. {
  1048.     /*----------------------------------------------------------------*/
  1049.     /* Local Variables                                                */
  1050.     /*----------------------------------------------------------------*/
  1051.     S32 i;
  1052.     S32 layer_width;
  1053.     S32 layer_height;
  1054.     S32 layer_offset_x;
  1055.     S32 layer_offset_y;
  1056.     S32 layer_clip_x1;
  1057.     S32 layer_clip_x2;
  1058.     S32 layer_clip_y1;
  1059.     S32 layer_clip_y2;
  1060.     S32 start_x, end_x, start_y, end_y;
  1061.     U8 *layer_buf_ptr;
  1062.     U8 *bmp_data_ptr;
  1063.     S32 x2, y2;
  1064.     S32 vlaid_width;
  1065.     S32 byte_per_pixel;
  1066.     /* set active layer to base layer for pixtel's drawing */
  1067.     gdi_handle base_handle;
  1068.     /*----------------------------------------------------------------*/
  1069.     /* Code Body                                                      */
  1070.     /*----------------------------------------------------------------*/
  1071.     gdi_layer_get_base_handle(&base_handle);
  1072.     gdi_layer_push_and_set_active(base_handle);
  1073.     bmp_data_ptr = b->data;
  1074.     gdi_layer_get_buffer_ptr(&layer_buf_ptr);
  1075.     gdi_layer_get_clip(&layer_clip_x1, &layer_clip_y1, &layer_clip_x2, &layer_clip_y2);
  1076.     gdi_layer_get_dimension(&layer_width, &layer_height);
  1077.     gdi_layer_get_position(&layer_offset_x, &layer_offset_y);
  1078.     byte_per_pixel = gdi_layer_get_bit_per_pixel()>>3;
  1079.     layer_clip_x1 -= layer_offset_x;
  1080.     layer_clip_x2 -= layer_offset_x;
  1081.     layer_clip_y1 -= layer_offset_y;
  1082.     layer_clip_y2 -= layer_offset_y;
  1083.     x2 = x1 + b->xsize - 1;
  1084.     y2 = y1 + b->ysize - 1;
  1085.     /* out of clip region */
  1086.     if ((x1 > layer_clip_x2) || (y1 > layer_clip_y2) || (x2 < layer_clip_x1) || (y2 < layer_clip_y1))
  1087.     {
  1088.         gdi_layer_pop_and_restore_active();
  1089.         return;
  1090.     }
  1091.     /* Calculate valid region */
  1092.     if (x1 < layer_clip_x1)
  1093.     {
  1094.         start_x = layer_clip_x1;
  1095.     }
  1096.     else
  1097.     {
  1098.         start_x = x1;
  1099.     }
  1100.     if (x2 > layer_clip_x2)
  1101.     {
  1102.         end_x = layer_clip_x2;
  1103.     }
  1104.     else
  1105.     {
  1106.         end_x = x2;
  1107.     }
  1108.     if (y1 < layer_clip_y1)
  1109.     {
  1110.         start_y = layer_clip_y1;
  1111.     }
  1112.     else
  1113.     {
  1114.         start_y = y1;
  1115.     }
  1116.     if (y2 > layer_clip_y2)
  1117.     {
  1118.         end_y = layer_clip_y2;
  1119.     }
  1120.     else
  1121.     {
  1122.         end_y = y2;
  1123.     }
  1124.     /* find update width */
  1125.     vlaid_width = end_x - start_x + 1;
  1126.     /* shift to bmp buffer start position */
  1127.     /* PMT VIKAS START 20051209 */
  1128.     bmp_data_ptr += (start_y - y1) * b->row_bytes + (start_x - x1) * byte_per_pixel;
  1129.     /* PMT VIKAS END 20051209 */
  1130.     /* shift to layer buffer start position */
  1131.     layer_buf_ptr += ((start_y - layer_offset_y) * layer_width + (start_x - layer_offset_x)) * byte_per_pixel;
  1132.     /* fill bitmap buffer */
  1133.     for (i = start_y; i <= end_y; i++)
  1134.     {
  1135.         memcpy(layer_buf_ptr, bmp_data_ptr, vlaid_width * byte_per_pixel);
  1136.         bmp_data_ptr += b->row_bytes;
  1137.         layer_buf_ptr += layer_width * byte_per_pixel;
  1138.     }
  1139.     /* restore current active layer */
  1140.     gdi_layer_pop_and_restore_active();
  1141. }
  1142. /*****************************************************************************
  1143.  * FUNCTION
  1144.  *  _get_bitmap
  1145.  * DESCRIPTION
  1146.  *  
  1147.  * PARAMETERS
  1148.  *  x1      [IN]        
  1149.  *  y1      [IN]        
  1150.  *  x2      [IN]        
  1151.  *  y2      [IN]        
  1152.  *  b       [?]         
  1153.  * RETURNS
  1154.  *  void
  1155.  *****************************************************************************/
  1156. void _get_bitmap(S32 x1, S32 y1, S32 x2, S32 y2, bitmap *b)
  1157. {
  1158.     /*----------------------------------------------------------------*/
  1159.     /* Local Variables                                                */
  1160.     /*----------------------------------------------------------------*/
  1161.     S32 i;
  1162.     S32 layer_width;
  1163.     S32 layer_height;
  1164.     S32 layer_offset_x;
  1165.     S32 layer_offset_y;
  1166.     S32 layer_clip_x1;
  1167.     S32 layer_clip_x2;
  1168.     S32 layer_clip_y1;
  1169.     S32 layer_clip_y2;
  1170.     S32 start_x, end_x, start_y, end_y;
  1171.     U8 *layer_buf_ptr;
  1172.     U8 *bmp_data_ptr;
  1173.     S32 byte_per_pixel;
  1174.     /* set active layer to base layer for pixtel's drawing */
  1175.     gdi_handle base_handle;
  1176.     /*----------------------------------------------------------------*/
  1177.     /* Code Body                                                      */
  1178.     /*----------------------------------------------------------------*/
  1179.     gdi_layer_get_base_handle(&base_handle);
  1180.     gdi_layer_push_and_set_active(base_handle);
  1181.     bmp_data_ptr = b->data;
  1182.     gdi_layer_get_buffer_ptr(&layer_buf_ptr);
  1183.     gdi_layer_get_clip(&layer_clip_x1, &layer_clip_y1, &layer_clip_x2, &layer_clip_y2);
  1184.     gdi_layer_get_dimension(&layer_width, &layer_height);
  1185.     gdi_layer_get_position(&layer_offset_x, &layer_offset_y);
  1186.     byte_per_pixel = gdi_layer_get_bit_per_pixel()>>3;
  1187.     layer_clip_x1 -= layer_offset_x;
  1188.     layer_clip_x2 -= layer_offset_x;
  1189.     layer_clip_y1 -= layer_offset_y;
  1190.     layer_clip_y2 -= layer_offset_y;
  1191.     /* out of clip region */
  1192.     if ((x1 > layer_clip_x2) || (y1 > layer_clip_y2) || (x2 < layer_clip_x1) || (y2 < layer_clip_y1))
  1193.     {
  1194.         b->xsize = 0;
  1195.         b->xsize = 0;
  1196.         b->row_bytes = 0;
  1197.         gdi_layer_pop_and_restore_active();
  1198.         return;
  1199.     }
  1200.     /* Calculate valid region */
  1201.     if (x1 < layer_clip_x1)
  1202.     {
  1203.         start_x = layer_clip_x1;
  1204.     }
  1205.     else
  1206.     {
  1207.         start_x = x1;
  1208.     }
  1209.     if (x2 > layer_clip_x2)
  1210.     {
  1211.         end_x = layer_clip_x2;
  1212.     }
  1213.     else
  1214.     {
  1215.         end_x = x2;
  1216.     }
  1217.     if (y1 < layer_clip_y1)
  1218.     {
  1219.         start_y = layer_clip_y1;
  1220.     }
  1221.     else
  1222.     {
  1223.         start_y = y1;
  1224.     }
  1225.     if (y2 > layer_clip_y2)
  1226.     {
  1227.         end_y = layer_clip_y2;
  1228.     }
  1229.     else
  1230.     {
  1231.         end_y = y2;
  1232.     }
  1233.     /* fill bitmap info */
  1234.     b->xsize = end_x - start_x + 1;
  1235.     b->ysize = end_y - start_y + 1;
  1236.     b->row_bytes = b->xsize * byte_per_pixel;   /* 16-bit specific   */
  1237.     /* find source buffer start position of the active layer */
  1238.     /* shift to layer's coordiante */
  1239.     layer_offset_x = start_x - layer_offset_x;
  1240.     layer_offset_y = start_y - layer_offset_y;
  1241.     layer_buf_ptr += (layer_offset_y * layer_width + layer_offset_x) * byte_per_pixel;       /* 16-bit */
  1242.     /* fill bitmap buffer */
  1243.     for (i = 0; i < b->ysize; i++)
  1244.     {
  1245.         memcpy(bmp_data_ptr, layer_buf_ptr, b->row_bytes);
  1246.         bmp_data_ptr += b->row_bytes;
  1247.         layer_buf_ptr += layer_width * byte_per_pixel;   /* just to next row */
  1248.     }
  1249.     /* restore current active layer */
  1250.     gdi_layer_pop_and_restore_active();
  1251. }
  1252. /*****************************************************************************
  1253.  * FUNCTION
  1254.  *  UI_dummy_hide_animation_function
  1255.  * DESCRIPTION
  1256.  *  
  1257.  * PARAMETERS
  1258.  *  x1      [IN]        
  1259.  *  y1      [IN]        
  1260.  *  x2      [IN]        
  1261.  *  y2      [IN]        
  1262.  * RETURNS
  1263.  *  void
  1264.  *****************************************************************************/
  1265. void UI_dummy_hide_animation_function(S32 x1, S32 y1, S32 x2, S32 y2)
  1266. {
  1267.     /*----------------------------------------------------------------*/
  1268.     /* Local Variables                                                */
  1269.     /*----------------------------------------------------------------*/
  1270.     /*----------------------------------------------------------------*/
  1271.     /* Code Body                                                      */
  1272.     /*----------------------------------------------------------------*/
  1273.     UI_UNUSED_PARAMETER(x1);
  1274.     UI_UNUSED_PARAMETER(y1);
  1275.     UI_UNUSED_PARAMETER(x2);
  1276.     UI_UNUSED_PARAMETER(y2);
  1277. }
  1278. /*****************************************************************************
  1279.  * FUNCTION
  1280.  *  _measure_image
  1281.  * DESCRIPTION
  1282.  *  
  1283.  * PARAMETERS
  1284.  *  image       [?]     
  1285.  *  width       [?]     
  1286.  *  height      [?]     
  1287.  * RETURNS
  1288.  *  void
  1289.  *****************************************************************************/
  1290. void _measure_image(U8 *image, S32 *width, S32 *height)
  1291. {
  1292.     /*----------------------------------------------------------------*/
  1293.     /* Local Variables                                                */
  1294.     /*----------------------------------------------------------------*/
  1295.     /*----------------------------------------------------------------*/
  1296.     /* Code Body                                                      */
  1297.     /*----------------------------------------------------------------*/
  1298.     if (image == NULL)
  1299.     {
  1300.         return;
  1301.     }
  1302.     gdi_image_get_dimension((U8*) image, width, height);
  1303. }
  1304. /*****************************************************************************
  1305.  * FUNCTION
  1306.  *  UI_get_image_n_frames
  1307.  * DESCRIPTION
  1308.  *  
  1309.  * PARAMETERS
  1310.  *  image       [?]     
  1311.  * RETURNS
  1312.  *  
  1313.  *****************************************************************************/
  1314. S32 UI_get_image_n_frames(U8 *image)
  1315. {
  1316.     /*----------------------------------------------------------------*/
  1317.     /* Local Variables                                                */
  1318.     /*----------------------------------------------------------------*/
  1319.     bytestream bfile;
  1320.     S32 image_length /* ,n */ ;
  1321.     U8 image_identifier;
  1322.     S32 frame_count;
  1323.     /*----------------------------------------------------------------*/
  1324.     /* Code Body                                                      */
  1325.     /*----------------------------------------------------------------*/
  1326.     if (image == NULL)
  1327.     {
  1328.         return (0);
  1329.     }
  1330.     image_identifier = (U8) (image[0]);
  1331.     if (image_identifier == IMAGE_TYPE_INVALID)
  1332.     {
  1333.         return (0);
  1334.     }
  1335.     image_length = _read_image_length(image);
  1336.     bytestream_initialize(&bfile, (U8*) (image + 6), image_length);
  1337.     switch (image_identifier)
  1338.     {
  1339.         case IMAGE_TYPE_BMP:
  1340.         case IMAGE_TYPE_BMP_SEQUENCE:
  1341.         case IMAGE_TYPE_GIF:
  1342.         case IMAGE_TYPE_DEVICE_BITMAP:
  1343.         case IMAGE_TYPE_DEVICE_BITMAP_SEQUENCE:
  1344.         case IMAGE_TYPE_JPG:                /* JL 040616 added for JPEG image ID */
  1345.         case IMAGE_TYPE_AVI:                /* 120304 Calvin added */
  1346.         case IMAGE_TYPE_3GP:                /* 120304 Calvin added */
  1347.         case IMAGE_TYPE_MP4:                /* 120304 Calvin added */
  1348.     #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__
  1349.         case IMAGE_TYPE_BMP_FILE_OFFSET:    /* Vikram added BMPFILEOFFSET Support */
  1350.         case IMAGE_TYPE_GIF_FILE_OFFSET:
  1351.     #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ 
  1352.             gdi_image_get_frame_count(image, &frame_count);
  1353.             return frame_count;
  1354.     }
  1355.     return (0);
  1356. }
  1357. /*****************************************************************************
  1358.  * FUNCTION
  1359.  *  _show_animation
  1360.  * DESCRIPTION
  1361.  *  
  1362.  * PARAMETERS
  1363.  *  x           [IN]        
  1364.  *  y           [IN]        
  1365.  *  image       [?]         
  1366.  * RETURNS
  1367.  *  
  1368.  *****************************************************************************/
  1369. animated_image *_show_animation(S32 x, S32 y, U8 *image)
  1370. {
  1371.     /*----------------------------------------------------------------*/
  1372.     /* Local Variables                                                */
  1373.     /*----------------------------------------------------------------*/
  1374.     animated_image *a = NULL;
  1375.     U8 image_identifier;
  1376.     /*----------------------------------------------------------------*/
  1377.     /* Code Body                                                      */
  1378.     /*----------------------------------------------------------------*/
  1379.     if (image == NULL)
  1380.     {
  1381.         return (NULL);
  1382.     }
  1383.     image_identifier = (U8) (image[0]);
  1384.     if (image_identifier == IMAGE_TYPE_INVALID)
  1385.     {
  1386.         return (NULL);
  1387.     }
  1388.     if ((image_identifier == IMAGE_TYPE_BMP) || (image_identifier == IMAGE_TYPE_BMP_FILE) ||
  1389.         (image_identifier == IMAGE_TYPE_WBMP_FILE))
  1390.     {
  1391.         gdi_image_draw(x, y, image);
  1392.         return (NULL);
  1393.     }
  1394.     if (n_animated_images >= MAX_ANIMATED_IMAGES)
  1395.     {
  1396.         return (NULL);
  1397.     }
  1398.     a = (animated_image*) gui_malloc(sizeof(animated_image));
  1399.     if (a == NULL)
  1400.     {
  1401.         return (NULL);
  1402.     }
  1403.     a->last_frame_function = NULL;
  1404.     GET_GRAPHICS_CONTEXT(a->graphics_context);
  1405.     a->x = x;
  1406.     a->y = y;
  1407.     gui_get_clip(&a->clip_x1, &a->clip_y1, &a->clip_x2, &a->clip_y2);
  1408.     a->frame_rate = ANIMATED_IMAGE_FRAME_RATE;
  1409.     a->flags = 0;
  1410.     a->frame_counter = 0;
  1411.     a->hide_function = UI_dummy_hide_animation_function;
  1412.     _load_animation_frames(image, a);
  1413.     a->start_frame = 0;
  1414.     a->end_frame = (S16) (a->n_frames - 1);
  1415.     if (a->n_frames > 0)
  1416.     {
  1417.         _show_animated_image(x, y, a);
  1418.         return (a);
  1419.     }
  1420.     else
  1421.     {
  1422.         gui_free(a);
  1423.         gdi_image_draw(x, y, image);
  1424.         return (NULL);
  1425.     }
  1426. }
  1427. /* 071205 Calvin removed */
  1428. #if 0
  1429. /* under construction !*/
  1430. /* under construction !*/
  1431. /* under construction !*/
  1432. /* under construction !*/
  1433. /* under construction !*/
  1434. /* under construction !*/
  1435. /* under construction !*/
  1436. /* under construction !*/
  1437. /* under construction !*/
  1438. /* under construction !*/
  1439. /* under construction !*/
  1440. /* under construction !*/
  1441. /* under construction !*/
  1442. /* under construction !*/
  1443. /* under construction !*/
  1444. /* under construction !*/
  1445. /* under construction !*/
  1446. /* under construction !*/
  1447. /* under construction !*/
  1448. /* under construction !*/
  1449. /* under construction !*/
  1450. /* under construction !*/
  1451. /* under construction !*/
  1452. /* under construction !*/
  1453. /* under construction !*/
  1454. /* under construction !*/
  1455. /* under construction !*/
  1456. /* under construction !*/
  1457. /* under construction !*/
  1458. /* under construction !*/
  1459. /* under construction !*/
  1460. /* under construction !*/
  1461. /* under construction !*/
  1462. /* under construction !*/
  1463. /* under construction !*/
  1464. /* under construction !*/
  1465. /* under construction !*/
  1466. /* under construction !*/
  1467. /* under construction !*/
  1468. /* under construction !*/
  1469. /* under construction !*/
  1470. /* under construction !*/
  1471. /* under construction !*/
  1472. /* under construction !*/
  1473. /* under construction !*/
  1474. /* under construction !*/
  1475. /* under construction !*/
  1476. /* under construction !*/
  1477. /* under construction !*/
  1478. /* under construction !*/
  1479. /* under construction !*/
  1480. /* under construction !*/
  1481. /* under construction !*/
  1482. /* under construction !*/
  1483. /* under construction !*/
  1484. /* under construction !*/
  1485. /* under construction !*/
  1486. /* under construction !*/
  1487. /* under construction !*/
  1488. /* under construction !*/
  1489. /* under construction !*/
  1490. /* under construction !*/
  1491. /* under construction !*/
  1492. /* under construction !*/
  1493. /* under construction !*/
  1494. /* under construction !*/
  1495. /* under construction !*/
  1496. /* under construction !*/
  1497. /* under construction !*/
  1498. /* under construction !*/
  1499. /* under construction !*/
  1500. /* under construction !*/
  1501. /* under construction !*/
  1502. /* under construction !*/
  1503. /* under construction !*/
  1504. /* under construction !*/
  1505. /* under construction !*/
  1506. /* under construction !*/
  1507. /* under construction !*/
  1508. /* under construction !*/
  1509. /* under construction !*/
  1510. #endif /* 0 */ 
  1511. /* 071205 Calvin end */
  1512. /*****************************************************************************
  1513.  * FUNCTION
  1514.  *  _load_animation_frames
  1515.  * DESCRIPTION
  1516.  *  
  1517.  * PARAMETERS
  1518.  *  image       [?]     
  1519.  *  a           [?]     
  1520.  * RETURNS
  1521.  *  void
  1522.  *****************************************************************************/
  1523. void _load_animation_frames(U8 *image, animated_image *a)
  1524. {
  1525.     /*----------------------------------------------------------------*/
  1526.     /* Local Variables                                                */
  1527.     /*----------------------------------------------------------------*/
  1528.     S32 image_length;
  1529.     U8 image_identifier;
  1530.     S32 n_frames = 0, i;
  1531.     U32 offset = 0;
  1532.     S16 image_counter = 0;
  1533.     /*----------------------------------------------------------------*/
  1534.     /* Code Body                                                      */
  1535.     /*----------------------------------------------------------------*/
  1536.     if (image == NULL)
  1537.     {
  1538.         return;
  1539.     }
  1540.     image_identifier = (U8) (image[0]);
  1541.     switch (image_identifier)
  1542.     {
  1543.         case IMAGE_TYPE_INVALID:
  1544.             return;
  1545.         case IMAGE_TYPE_BMP_SEQUENCE:
  1546.         {
  1547.             n_frames = (S16) image[1];
  1548.             if (a == NULL)
  1549.             {
  1550.                 return;
  1551.             }
  1552.             a->n_frames = 0;
  1553.             if (n_frames <= 0)
  1554.             {
  1555.                 return;
  1556.             }
  1557.             for (i = 0; i < n_frames; i++)
  1558.             {
  1559.                 image_identifier = (U8) (image[offset]);
  1560.                 image_length = _read_image_length((U8*) (image + offset));
  1561.                 if (image_identifier != 0)
  1562.                 {
  1563.                     a->images[image_counter] = (U8*) (image + offset);
  1564.                     image_counter++;
  1565.                 }
  1566.                 offset += (image_length + 6);
  1567.             }
  1568.         }
  1569.             break;
  1570.         case IMAGE_TYPE_GIF:
  1571.         {
  1572.             if (a == NULL)
  1573.             {
  1574.                 return;
  1575.             }
  1576.             a->n_frames = 0;
  1577.             image_length = _read_image_length((U8*) image);
  1578.             gdi_image_get_frame_count(image, &n_frames);
  1579.             a->images[image_counter] = (U8*) image;
  1580.         }
  1581.             break;
  1582.     }
  1583.     a->n_frames = (S16) n_frames;
  1584. }
  1585. /*****************************************************************************
  1586.  * FUNCTION
  1587.  *  _show_animated_image
  1588.  * DESCRIPTION
  1589.  *  
  1590.  * PARAMETERS
  1591.  *  x       [IN]        
  1592.  *  y       [IN]        
  1593.  *  a       [?]         
  1594.  * RETURNS
  1595.  *  void
  1596.  *****************************************************************************/
  1597. void _show_animated_image(S32 x, S32 y, animated_image *a)
  1598. {
  1599.     /*----------------------------------------------------------------*/
  1600.     /* Local Variables                                                */
  1601.     /*----------------------------------------------------------------*/
  1602.     /*----------------------------------------------------------------*/
  1603.     /* Code Body                                                      */
  1604.     /*----------------------------------------------------------------*/
  1605.     UI_UNUSED_PARAMETER(x);
  1606.     UI_UNUSED_PARAMETER(y);
  1607.     if (n_animated_images >= MAX_ANIMATED_IMAGES)
  1608.     {
  1609.         return;
  1610.     }
  1611.     animated_images[n_animated_images] = a;
  1612.     n_animated_images++;
  1613.     if (n_animated_images == 1)
  1614.     {
  1615.         _animated_image_processor();
  1616.     }
  1617.     else
  1618.     {
  1619.         U8 gc_flag;
  1620.         S32 x1, y1, x2, y2;
  1621.         S32 width, height;
  1622.         U8 image_identifier = (U8) a->images[0][0];
  1623.         gui_push_clip();
  1624.         if ((image_identifier == 3) || (image_identifier == 7))
  1625.         {
  1626.             _measure_image(a->images[0], &width, &height);
  1627.         }
  1628.         else
  1629.         {
  1630.             _measure_image(a->images[a->frame_counter], &width, &height);
  1631.         }
  1632.         x1 = a->x;
  1633.         y1 = a->y;
  1634.         x2 = x1 + width - 1;
  1635.         y2 = y1 + height - 1;
  1636.         SWITCH_GRAPHICS_CONTEXT(a->graphics_context, gc_flag);
  1637.         gui_reset_clip();
  1638.         a->hide_function(x1, y1, x2, y2);
  1639.         gui_set_clip(a->clip_x1, a->clip_y1, a->clip_x2, a->clip_y2);
  1640.         if ((image_identifier == 3) || (image_identifier == 7))
  1641.         {
  1642.             if (a->flags & ANIMATED_IMAGE_TRANSPARENT)
  1643.             {
  1644.                 _show_transparent_animation_frame(x1, y1, a->images[0], 0, a->frame_counter);
  1645.             }
  1646.             else
  1647.             {
  1648.                 _show_animation_frame(x1, y1, a->images[0], a->frame_counter);
  1649.             }
  1650.         }
  1651.         else
  1652.         {
  1653.             if (a->flags & ANIMATED_IMAGE_TRANSPARENT)
  1654.             {
  1655.                 _show_transparent_image(x1, y1, (a->images[a->frame_counter]), 0);
  1656.             }
  1657.             else
  1658.             {
  1659.                 gdi_image_draw(x1, y1, (a->images[a->frame_counter]));
  1660.             }
  1661.         }
  1662.         gui_BLT_double_buffer(x1, y1, x2, y2);
  1663.         RESTORE_GRAPHICS_CONTEXT(gc_flag);
  1664.         gui_pop_clip();
  1665.     }
  1666. }
  1667. /* 071205 Calvin removed */
  1668. #if 0
  1669. /* under construction !*/
  1670. /* under construction !*/
  1671. /* under construction !*/
  1672. /* under construction !*/
  1673. /* under construction !*/
  1674. /* under construction !*/
  1675. /* under construction !*/
  1676. /* under construction !*/
  1677. /* under construction !*/
  1678. /* under construction !*/
  1679. /* under construction !*/
  1680. /* under construction !*/
  1681. /* under construction !*/
  1682. /* under construction !*/
  1683. /* under construction !*/
  1684. /* under construction !*/
  1685. /* under construction !*/
  1686. /* under construction !*/
  1687. /* under construction !*/
  1688. /* under construction !*/
  1689. /* under construction !*/
  1690. /* under construction !*/
  1691. /* under construction !*/
  1692. /* under construction !*/
  1693. /* under construction !*/
  1694. /* under construction !*/
  1695. /* under construction !*/
  1696. /* under construction !*/
  1697. /* under construction !*/
  1698. /* under construction !*/
  1699. /* under construction !*/
  1700. /* under construction !*/
  1701. /* under construction !*/
  1702. /* under construction !*/
  1703. #endif /* 0 */ 
  1704. /* 071205 Calvin end */
  1705. /*****************************************************************************
  1706.  * FUNCTION
  1707.  *  _animated_image_processor
  1708.  * DESCRIPTION
  1709.  *  
  1710.  * PARAMETERS
  1711.  *  void
  1712.  * RETURNS
  1713.  *  void
  1714.  *****************************************************************************/
  1715. void _animated_image_processor(void)
  1716. {
  1717.     /*----------------------------------------------------------------*/
  1718.     /* Local Variables                                                */
  1719.     /*----------------------------------------------------------------*/
  1720.     S32 i, x1, y1, x2, y2;
  1721.     S32 width, height;
  1722.     animated_image *a;
  1723.     U8 gc_flag;
  1724.     U8 image_identifier;
  1725.     /*----------------------------------------------------------------*/
  1726.     /* Code Body                                                      */
  1727.     /*----------------------------------------------------------------*/
  1728.     gui_push_clip();
  1729.     UI_hide_animation_frame_function();
  1730.     for (i = 0; i < n_animated_images; i++)
  1731.     {
  1732.         a = animated_images[i];
  1733.         image_identifier = a->images[0][0];
  1734.         if ((image_identifier == 3) || (image_identifier == 7))
  1735.         {
  1736.             _measure_image(a->images[0], &width, &height);
  1737.         }
  1738.         else
  1739.         {
  1740.             _measure_image(a->images[a->frame_counter], &width, &height);
  1741.         }
  1742.         x1 = a->x;
  1743.         y1 = a->y;
  1744.         x2 = x1 + width - 1;
  1745.         y2 = y1 + height - 1;
  1746.         a->frame_counter++;
  1747.         if (a->frame_counter > a->end_frame)
  1748.         {
  1749.             a->frame_counter = a->start_frame;
  1750.         }
  1751.         SWITCH_GRAPHICS_CONTEXT(a->graphics_context, gc_flag);
  1752.         gui_reset_clip();
  1753.         a->hide_function(x1, y1, x2, y2);
  1754.         gui_set_clip(a->clip_x1, a->clip_y1, a->clip_x2, a->clip_y2);
  1755.         if ((image_identifier == 3) || (image_identifier == 7))
  1756.         {
  1757.             if (a->flags & ANIMATED_IMAGE_TRANSPARENT)
  1758.             {
  1759.                 if (_show_transparent_animation_frame(x1, y1, a->images[0], 0, a->frame_counter))
  1760.                 {
  1761.                     if (a->n_frames > (a->frame_counter + 1))
  1762.                     {
  1763.                         a->n_frames = a->frame_counter + 1;
  1764.                         if (a->end_frame > (a->n_frames - 1))
  1765.                         {
  1766.                             a->end_frame = a->n_frames - 1;
  1767.                         }
  1768.                         if (a->frame_counter > a->end_frame)
  1769.                         {
  1770.                             a->frame_counter = a->start_frame;
  1771.                         }
  1772.                     }
  1773.                     if (a->last_frame_function != NULL)
  1774.                     {
  1775.                         a->last_frame_function();
  1776.                     }
  1777.                 }
  1778.                 else if ((a->n_frames >= 0) && (a->frame_counter >= (a->n_frames - 1)))
  1779.                 {
  1780.                     if (a->last_frame_function != NULL)
  1781.                     {
  1782.                         a->last_frame_function();
  1783.                     }
  1784.                 }
  1785.             }
  1786.             else
  1787.             {
  1788.                 if (_show_animation_frame(x1, y1, a->images[0], a->frame_counter))
  1789.                 {
  1790.                     if (a->n_frames > (a->frame_counter + 1))
  1791.                     {
  1792.                         a->n_frames = a->frame_counter + 1;
  1793.                         if (a->end_frame > (a->n_frames - 1))
  1794.                         {
  1795.                             a->end_frame = a->n_frames - 1;
  1796.                         }
  1797.                         if (a->frame_counter > a->end_frame)
  1798.                         {
  1799.                             a->frame_counter = a->start_frame;
  1800.                         }
  1801.                     }
  1802.                     if (a->last_frame_function != NULL)
  1803.                     {
  1804.                         a->last_frame_function();
  1805.                     }
  1806.                 }
  1807.                 else if ((a->n_frames >= 0) && (a->frame_counter >= (a->n_frames - 1)))
  1808.                 {
  1809.                     if (a->last_frame_function != NULL)
  1810.                     {
  1811.                         a->last_frame_function();
  1812.                     }
  1813.                 }
  1814.             }
  1815.         }
  1816.         else
  1817.         {
  1818.             if (a->flags & ANIMATED_IMAGE_TRANSPARENT)
  1819.             {
  1820.                 _show_transparent_image(x1, y1, (a->images[a->frame_counter]), 0);
  1821.             }
  1822.             else
  1823.             {
  1824.                 gdi_image_draw(x1, y1, (a->images[a->frame_counter]));
  1825.             }
  1826.         }
  1827.         gui_BLT_double_buffer(x1, y1, x2, y2);
  1828.         RESTORE_GRAPHICS_CONTEXT(gc_flag);
  1829.     }
  1830.     gui_pop_clip();
  1831.     gui_start_timer(ANIMATED_IMAGE_FRAME_RATE, _animated_image_processor);
  1832. }
  1833. /* 071205 Calvin removed */
  1834. #if 0
  1835. /* under construction !*/
  1836. /* under construction !*/
  1837. /* under construction !*/
  1838. /* under construction !*/
  1839. #endif /* 0 */ 
  1840. /* 071205 Calvin end */
  1841. /*****************************************************************************
  1842.  * FUNCTION
  1843.  *  mtk_show_animation_frames
  1844.  * DESCRIPTION
  1845.  *  Gets the number of images (frames) in a GIF file
  1846.  *  
  1847.  *  !!! FUNCTION IS NOT OPTIMIZED. DECODES THE ENTIRE FILE
  1848.  *  JUST TO FIND THE NUMBER OF FRAMES !!!
  1849.  * PARAMETERS
  1850.  *  x                   [IN]        
  1851.  *  y                   [IN]        
  1852.  *  image               [?]         
  1853.  *  start_frame         [IN]        
  1854.  *  file(?)             [IN]        The GIF file in bytestream format
  1855.  *  total_frames(?)     [OUT]       Is the number of frames in the GIF.
  1856.  * RETURNS
  1857.  *  0  if GIF_get_n_frames failed (invalid GIF image)(?)
  1858.  *  1  if GIF_get_n_frames is successful(?)
  1859.  *****************************************************************************/
  1860. /* Image related procedures for Images stored in memory  */
  1861. /* File system storage of images has been discontinued      */
  1862. void (*wingui_animation_last_frame_function) (void) = NULL;
  1863. /* Bear 040303 - Fix cant show download gif problem - still adapt to pixtel draw from file */
  1864. void mtk_show_animation_frames(S32 x, S32 y, U8 *image, S32 start_frame)
  1865. {
  1866.     /*----------------------------------------------------------------*/
  1867.     /* Local Variables                                                */
  1868.     /*----------------------------------------------------------------*/
  1869.     U8 image_identifier;
  1870.     /*----------------------------------------------------------------*/
  1871.     /* Code Body                                                      */
  1872.     /*----------------------------------------------------------------*/
  1873.     if (image == NULL)
  1874.     {
  1875.         return;
  1876.     }
  1877.     image_identifier = image[0];
  1878.     switch (image_identifier)
  1879.     {
  1880.         case IMAGE_TYPE_INVALID:
  1881.             return;                     /* not used */
  1882.         case IMAGE_TYPE_BMP:            /* same as case 2 */
  1883.         case IMAGE_TYPE_BMP_SEQUENCE:   /* BMP */
  1884.         {
  1885.             /* MTK added by Bear 030923 for transparent BMP issue */
  1886.             _show_transparent_image(x, y, image, 0);
  1887.             /* MTK end */
  1888.             return;
  1889.         }
  1890.         case IMAGE_TYPE_GIF:    /* GIF */
  1891.         {
  1892.             gdi_image_draw_animation_frames(x, y, image, NULL, (U16) start_frame);
  1893.         }
  1894.             break;
  1895.         case IMAGE_TYPE_DEVICE_BITMAP:
  1896.         case IMAGE_TYPE_DEVICE_BITMAP_SEQUENCE:
  1897.         case IMAGE_TYPE_BMP_FILE:
  1898.         case IMAGE_TYPE_WBMP_FILE:
  1899.         {
  1900.             gdi_image_draw(x, y, image);
  1901.             return;
  1902.         }
  1903.         case IMAGE_TYPE_GIF_FILE:
  1904.         {
  1905.             _show_animation(x, y, image);
  1906.             return;
  1907.         }
  1908.         default:
  1909.             break;
  1910.             /* assert(0); */
  1911.     }
  1912. }
  1913. /*****************************************************************************
  1914.  * FUNCTION
  1915.  *  mtk_show_animation
  1916.  * DESCRIPTION
  1917.  *  
  1918.  * PARAMETERS
  1919.  *  x           [IN]        
  1920.  *  y           [IN]        
  1921.  *  image       [?]         
  1922.  * RETURNS
  1923.  *  void
  1924.  *****************************************************************************/
  1925. void mtk_show_animation(S32 x, S32 y, U8 *image)
  1926. {
  1927.     /*----------------------------------------------------------------*/
  1928.     /* Local Variables                                                */
  1929.     /*----------------------------------------------------------------*/
  1930.     /*----------------------------------------------------------------*/
  1931.     /* Code Body                                                      */
  1932.     /*----------------------------------------------------------------*/
  1933.     mtk_show_animation_frames(x, y, image, 0);
  1934. }
  1935. /*****************************************************************************
  1936.  * FUNCTION
  1937.  *  _show_image
  1938.  * DESCRIPTION
  1939.  *  
  1940.  * PARAMETERS
  1941.  *  x           [IN]        
  1942.  *  y           [IN]        
  1943.  *  image       [?]         
  1944.  * RETURNS
  1945.  *  void
  1946.  *****************************************************************************/
  1947. void _show_image(S32 x, S32 y, U8 *image)
  1948. {
  1949.     /*----------------------------------------------------------------*/
  1950.     /* Local Variables                                                */
  1951.     /*----------------------------------------------------------------*/
  1952.     /*----------------------------------------------------------------*/
  1953.     /* Code Body                                                      */
  1954.     /*----------------------------------------------------------------*/
  1955.     /* Leo add 20040823 */
  1956.     gdi_image_draw(x, y, image);
  1957. }
  1958. /*****************************************************************************
  1959.  * FUNCTION
  1960.  *  _show_transparent_image
  1961.  * DESCRIPTION
  1962.  *  
  1963.  * PARAMETERS
  1964.  *  x           [IN]        
  1965.  *  y           [IN]        
  1966.  *  image       [?]         
  1967.  *  t           [IN]        
  1968.  * RETURNS
  1969.  *  void
  1970.  *****************************************************************************/
  1971. void _show_transparent_image(S32 x, S32 y, U8 *image, UI_transparent_color_type t)
  1972. {
  1973.     /*----------------------------------------------------------------*/
  1974.     /* Local Variables                                                */
  1975.     /*----------------------------------------------------------------*/
  1976.     /*----------------------------------------------------------------*/
  1977.     /* Code Body                                                      */
  1978.     /*----------------------------------------------------------------*/
  1979.     /* ignore transparent function and treat as normal image */
  1980.     gdi_image_draw(x, y, image);
  1981. }
  1982. /*****************************************************************************
  1983.  * FUNCTION
  1984.  *  _show_animation_frame
  1985.  * DESCRIPTION
  1986.  *  
  1987.  * PARAMETERS
  1988.  *  x                   [IN]        
  1989.  *  y                   [IN]        
  1990.  *  image               [?]         
  1991.  *  frame_number        [IN]        
  1992.  * RETURNS
  1993.  *  
  1994.  *****************************************************************************/
  1995. U8 _show_animation_frame(S32 x, S32 y, U8 *image, S16 frame_number)
  1996. {
  1997.     /*----------------------------------------------------------------*/
  1998.     /* Local Variables                                                */
  1999.     /*----------------------------------------------------------------*/
  2000.     U8 image_identifier;
  2001.     S32 ret;
  2002.     /* set active layer to base layer for pixtel's drawing */
  2003.     gdi_handle base_handle;
  2004.     /*----------------------------------------------------------------*/
  2005.     /* Code Body                                                      */
  2006.     /*----------------------------------------------------------------*/
  2007.     if (image == NULL)
  2008.     {
  2009.         return (0);
  2010.     }
  2011.     gdi_layer_get_base_handle(&base_handle);
  2012.     gdi_layer_push_and_set_active(base_handle);
  2013.     image_identifier = (U8) (image[0]);
  2014.     switch (image_identifier)
  2015.     {
  2016.         case IMAGE_TYPE_INVALID:
  2017.             break;
  2018.         case IMAGE_TYPE_BMP:
  2019.         case IMAGE_TYPE_BMP_SEQUENCE:
  2020.         case IMAGE_TYPE_GIF:
  2021.         case IMAGE_TYPE_DEVICE_BITMAP:
  2022.         case IMAGE_TYPE_DEVICE_BITMAP_SEQUENCE:
  2023.             ret = gdi_image_draw_animation_single_frame(x, y, image, (U16) frame_number);
  2024.             gdi_layer_pop_and_restore_active();
  2025.             if (ret == GDI_IMAGE_SUCCEED)
  2026.             {
  2027.                 return (1);
  2028.             }
  2029.             else
  2030.             {
  2031.                 return (0);
  2032.             }
  2033.     }
  2034.     /* restore current active layer */
  2035.     gdi_layer_pop_and_restore_active();
  2036.     return (1);
  2037. }
  2038. /*****************************************************************************
  2039.  * FUNCTION
  2040.  *  _show_transparent_animation_frame
  2041.  * DESCRIPTION
  2042.  *  
  2043.  * PARAMETERS
  2044.  *  x                   [IN]        
  2045.  *  y                   [IN]        
  2046.  *  image               [?]         
  2047.  *  t                   [IN]        
  2048.  *  frame_number        [IN]        
  2049.  * RETURNS
  2050.  *  
  2051.  *****************************************************************************/
  2052. U8 _show_transparent_animation_frame(S32 x, S32 y, U8 *image, UI_transparent_color_type t, S16 frame_number)
  2053. {
  2054.     /*----------------------------------------------------------------*/
  2055.     /* Local Variables                                                */
  2056.     /*----------------------------------------------------------------*/
  2057.     /* set active layer to base layer for pixtel's drawing */
  2058.     gdi_handle base_handle;
  2059.     U8 image_identifier;
  2060.     S32 ret;
  2061.     /*----------------------------------------------------------------*/
  2062.     /* Code Body                                                      */
  2063.     /*----------------------------------------------------------------*/
  2064.     if (image == NULL)
  2065.     {
  2066.         return (0);
  2067.     }
  2068.     gdi_layer_get_base_handle(&base_handle);
  2069.     gdi_layer_push_and_set_active(base_handle);
  2070.     image_identifier = (U8) (image[0]);
  2071.     switch (image_identifier)
  2072.     {
  2073.         case IMAGE_TYPE_INVALID:
  2074.             gdi_layer_pop_and_restore_active();
  2075.             return (0);
  2076.         case IMAGE_TYPE_BMP:
  2077.         case IMAGE_TYPE_BMP_SEQUENCE:
  2078.         case IMAGE_TYPE_GIF:
  2079.         case IMAGE_TYPE_DEVICE_BITMAP:
  2080.         case IMAGE_TYPE_DEVICE_BITMAP_SEQUENCE:
  2081.     #ifdef __MMI_DOWNLOADABLE_THEMES_SUPPORT__      /* ritesh */
  2082.         case IMAGE_TYPE_BMP_FILE_OFFSET:
  2083.         case IMAGE_TYPE_GIF_FILE_OFFSET:
  2084.     #endif /* __MMI_DOWNLOADABLE_THEMES_SUPPORT__ */ /* ritesh */
  2085.             ret = gdi_image_draw_animation_single_frame(x, y, image, (U16) frame_number);
  2086.             gdi_layer_pop_and_restore_active();
  2087.             if (ret == GDI_IMAGE_SUCCEED)
  2088.             {
  2089.                 return (1);
  2090.             }
  2091.             else
  2092.             {
  2093.                 return (0);
  2094.             }
  2095.     }
  2096.     /* restore current active layer */
  2097.     gdi_layer_pop_and_restore_active();
  2098.     return (0);
  2099. }
  2100. /*****************************************************************************
  2101.  * FUNCTION
  2102.  *  _hide_animations
  2103.  * DESCRIPTION
  2104.  *  
  2105.  * PARAMETERS
  2106.  *  void
  2107.  * RETURNS
  2108.  *  void
  2109.  *****************************************************************************/
  2110. void _hide_animations(void)
  2111. {
  2112.     /*----------------------------------------------------------------*/
  2113.     /* Local Variables                                                */
  2114.     /*----------------------------------------------------------------*/
  2115.     S32 i, j;
  2116.     animated_image *a;
  2117.     S32 n = n_animated_images;
  2118.     /*----------------------------------------------------------------*/
  2119.     /* Code Body                                                      */
  2120.     /*----------------------------------------------------------------*/
  2121.     for (i = 0; i < n_animated_images; i++)
  2122.     {
  2123.         a = animated_images[i];
  2124.         if (TEST_MAIN_LCD_GRAPHICS_CONTEXT(a->graphics_context))
  2125.         {
  2126.             gui_free(a);
  2127.             for (j = i; j < n_animated_images - 1; j++)
  2128.             {
  2129.                 animated_images[j] = animated_images[j + 1];
  2130.             }
  2131.             n_animated_images--;
  2132.         }
  2133.     }
  2134.     if ((n > 0) && (n_animated_images <= 0))
  2135.     {
  2136.         UI_cancel_timer(_animated_image_processor);
  2137.     }
  2138.     /* MTK00612 Bear */
  2139.     /* stop MTK animator timer */
  2140.     gdi_image_stop_animation_all();
  2141. }
  2142. /* Character set functions */
  2143. /*****************************************************************************
  2144.  * FUNCTION
  2145.  *  UI_get_next_UCS2_character
  2146.  * DESCRIPTION
  2147.  *  
  2148.  * PARAMETERS
  2149.  *  s       [?]     
  2150.  * RETURNS
  2151.  *  
  2152.  *****************************************************************************/
  2153. UI_character_type UI_get_next_UCS2_character(UI_string_type *s)
  2154. {
  2155.     /*----------------------------------------------------------------*/
  2156.     /* Local Variables                                                */
  2157.     /*----------------------------------------------------------------*/
  2158.     UI_character_type c = **s;
  2159.     /*----------------------------------------------------------------*/
  2160.     /* Code Body                                                      */
  2161.     /*----------------------------------------------------------------*/
  2162.     (*s)++;
  2163.     return (c);
  2164. }
  2165. /*****************************************************************************
  2166.  * FUNCTION
  2167.  *  UI_get_previous_UCS2_character
  2168.  * DESCRIPTION
  2169.  *  
  2170.  * PARAMETERS
  2171.  *  s       [?]     
  2172.  * RETURNS
  2173.  *  
  2174.  *****************************************************************************/
  2175. UI_character_type UI_get_previous_UCS2_character(UI_string_type *s)
  2176. {
  2177.     /*----------------------------------------------------------------*/
  2178.     /* Local Variables                                                */
  2179.     /*----------------------------------------------------------------*/
  2180.     UI_character_type c = **s;
  2181.     /*----------------------------------------------------------------*/
  2182.     /* Code Body                                                      */
  2183.     /*----------------------------------------------------------------*/
  2184.     (*s)--;
  2185.     return (c);
  2186. }
  2187. /************************************************************************/
  2188. /* LCD Context Swtich                                                   */
  2189. /************************************************************************/
  2190. /* this function will be called by categories */
  2191. /*****************************************************************************
  2192.  * FUNCTION
  2193.  *  UI_test_sub_LCD_graphics_context
  2194.  * DESCRIPTION
  2195.  *  
  2196.  * PARAMETERS
  2197.  *  void
  2198.  * RETURNS
  2199.  *  
  2200.  *****************************************************************************/
  2201. U8 UI_test_sub_LCD_graphics_context(void)
  2202. {
  2203.     /*----------------------------------------------------------------*/
  2204.     /* Local Variables                                                */
  2205.     /*----------------------------------------------------------------*/
  2206.     gdi_handle act_lcd_handle;
  2207.     /*----------------------------------------------------------------*/
  2208.     /* Code Body                                                      */
  2209.     /*----------------------------------------------------------------*/
  2210.     gdi_lcd_get_active(&act_lcd_handle);
  2211.     if (act_lcd_handle == GDI_LCD_SUB_LCD_HANDLE)
  2212.     {
  2213.         return 1;
  2214.     }
  2215.     else
  2216.     {
  2217.         return 0;
  2218.     }
  2219. }
  2220. /* UI wrappers to perform graphics context switching  */
  2221. /*****************************************************************************
  2222.  * FUNCTION
  2223.  *  UI_set_main_LCD_graphics_context
  2224.  * DESCRIPTION
  2225.  *  
  2226.  * PARAMETERS
  2227.  *  void
  2228.  * RETURNS
  2229.  *  void
  2230.  *****************************************************************************/
  2231. void UI_set_main_LCD_graphics_context(void)
  2232. {
  2233.     /*----------------------------------------------------------------*/
  2234.     /* Local Variables                                                */
  2235.     /*----------------------------------------------------------------*/
  2236.     gdi_handle act_lcd_handle;
  2237.     /*----------------------------------------------------------------*/
  2238.     /* Code Body                                                      */
  2239.     /*----------------------------------------------------------------*/
  2240.     gdi_lcd_get_active(&act_lcd_handle);
  2241.     /* already is Main LCD, do nothing */
  2242.     if (act_lcd_handle == GDI_LCD_MAIN_LCD_HANDLE)
  2243.     {
  2244.         return;
  2245.     }
  2246.     /* set Main Lcd as active lcd */
  2247.     gdi_lcd_set_active(GDI_LCD_MAIN_LCD_HANDLE);
  2248.     current_LCD_device_bitmap = &main_LCD_device_bitmap;
  2249.     /* init UI golbal var for Main LCD */
  2250.     UI_device_width = MAIN_LCD_device_width;
  2251.     UI_device_height = MAIN_LCD_device_height;
  2252.     UI_clip_x1 = 0;
  2253.     UI_clip_x2 = UI_device_width - 1;
  2254.     UI_clip_y1 = 0;
  2255.     UI_clip_y2 = UI_device_height - 1;
  2256.     UI_old_clip_x1 = 0;
  2257.     UI_old_clip_y1 = 0;
  2258.     UI_old_clip_x2 = UI_device_width - 1;
  2259.     UI_old_clip_y2 = UI_device_height - 1;
  2260.     UI_text_x = 0;
  2261.     UI_text_y = 0;
  2262. }
  2263. /*****************************************************************************
  2264.  * FUNCTION
  2265.  *  UI_set_sub_LCD_graphics_context
  2266.  * DESCRIPTION
  2267.  *  
  2268.  * PARAMETERS
  2269.  *  void
  2270.  * RETURNS
  2271.  *  void
  2272.  *****************************************************************************/
  2273. void UI_set_sub_LCD_graphics_context(void)
  2274. {
  2275. #ifdef __MMI_SUBLCD__
  2276.     /*----------------------------------------------------------------*/
  2277.     /* Local Variables                                                */
  2278.     /*----------------------------------------------------------------*/
  2279.     gdi_handle act_lcd_handle;
  2280.     /*----------------------------------------------------------------*/
  2281.     /* Code Body                                                      */
  2282.     /*----------------------------------------------------------------*/
  2283.     gdi_lcd_get_active(&act_lcd_handle);
  2284.     /* already is Main LCD, do nothing */
  2285.     if (act_lcd_handle == GDI_LCD_SUB_LCD_HANDLE)
  2286.     {
  2287.         return;
  2288.     }
  2289.     /* set Sub Lcd and active lcd */
  2290.     gdi_lcd_set_active(GDI_LCD_SUB_LCD_HANDLE);
  2291.     current_LCD_device_bitmap = &sub_LCD_device_bitmap;
  2292.     /* init UI golbal var for Sub LCD */
  2293.     UI_device_width = SUB_LCD_device_width;
  2294.     UI_device_height = SUB_LCD_device_height;
  2295.     UI_clip_x1 = 0;
  2296.     UI_clip_x2 = SUB_LCD_device_width - 1;
  2297.     UI_clip_y1 = 0;
  2298.     UI_clip_y2 = SUB_LCD_device_height - 1;
  2299.     UI_old_clip_x1 = 0;
  2300.     UI_old_clip_y1 = 0;
  2301.     UI_old_clip_x2 = SUB_LCD_device_width - 1;
  2302.     UI_old_clip_y2 = SUB_LCD_device_height - 1;
  2303.     UI_text_x = 0;
  2304.     UI_text_y = 0;
  2305. #endif /* __MMI_SUBLCD__ */ 
  2306. }
  2307. /*****************************************************************************
  2308.  * FUNCTION
  2309.  *  setup_UI_wrappers
  2310.  * DESCRIPTION
  2311.  *  
  2312.  * PARAMETERS
  2313.  *  void
  2314.  * RETURNS
  2315.  *  void
  2316.  *****************************************************************************/
  2317. void setup_UI_wrappers(void)
  2318. {
  2319.     /*----------------------------------------------------------------*/
  2320.     /* Local Variables                                                */
  2321.     /*----------------------------------------------------------------*/
  2322.     /*----------------------------------------------------------------*/
  2323.     /* Code Body                                                      */
  2324.     /*----------------------------------------------------------------*/
  2325.     /* Setup the main LCD device bitmap */
  2326.     /* this is uses some where out side wingui, cant be removed */
  2327.     main_LCD_device_bitmap.xsize = MAIN_LCD_device_width;
  2328.     main_LCD_device_bitmap.ysize = MAIN_LCD_device_height;
  2329.     main_LCD_device_bitmap.color_depth = GDI_MAINLCD_BIT_PER_PIXEL;     /* internal use 565 */
  2330.     main_LCD_device_bitmap.row_bytes = (MAIN_LCD_device_width * GDI_MAINLCD_BIT_PER_PIXEL) >> 3;
  2331.     main_LCD_device_bitmap.palette = NULL;
  2332. #ifdef __MMI_SUBLCD__
  2333.     /* Setup the sub LCD device bitmap     */
  2334.     /* this is uses some where out side wingui, cant be removed */
  2335.     sub_LCD_device_bitmap.xsize = SUB_LCD_device_width;
  2336.     sub_LCD_device_bitmap.ysize = SUB_LCD_device_height;
  2337.     sub_LCD_device_bitmap.color_depth = GDI_SUBLCD_BIT_PER_PIXEL;       /* internal use 565 */
  2338.     sub_LCD_device_bitmap.row_bytes = (SUB_LCD_device_width * GDI_SUBLCD_BIT_PER_PIXEL) >> 3;
  2339.     sub_LCD_device_bitmap.palette = NULL;
  2340. #endif /* __MMI_SUBLCD__ */ 
  2341.     /* init Main LCD first */
  2342.     current_LCD_device_bitmap = &main_LCD_device_bitmap;
  2343.     /* init UI golbal var for Main LCD */
  2344.     UI_device_width = MAIN_LCD_device_width;
  2345.     UI_device_height = MAIN_LCD_device_height;
  2346.     UI_clip_x1 = 0;
  2347.     UI_clip_x2 = UI_device_width - 1;
  2348.     UI_clip_y1 = 0;
  2349.     UI_clip_y2 = UI_device_height - 1;
  2350.     UI_old_clip_x1 = 0;
  2351.     UI_old_clip_y1 = 0;
  2352.     UI_old_clip_x2 = UI_device_width - 1;
  2353.     UI_old_clip_y2 = UI_device_height - 1;
  2354.     UI_text_x = 0;
  2355.     UI_text_y = 0;
  2356.     UI_text_color.alpha = 100;
  2357.     UI_text_color.r = 0;
  2358.     UI_text_color.g = 0;
  2359.     UI_text_color.b = 0;
  2360.     /* assign UI function pointers */
  2361.     gui_cross_hatch_fill_rectangle = UI_cross_hatch_fill_rectangle;
  2362.     gui_hatch_fill_rectangle = UI_hatch_fill_rectangle;
  2363.     gui_alternate_cross_hatch_fill_rectangle = UI_alternate_cross_hatch_fill_rectangle;
  2364.     gui_alternate_hatch_fill_rectangle = UI_alternate_hatch_fill_rectangle;
  2365.     gui_line = UI_line;
  2366.     gui_wline = UI_wline;
  2367.     gui_set_text_clip = UI_set_text_clip;
  2368.     gui_get_text_clip = UI_get_text_clip;
  2369.     gui_set_text_clip_preset = UI_set_text_clip_preset;
  2370.     gui_set_clip = UI_set_clip;
  2371.     gui_set_clip_with_bounding_box = UI_set_clip_with_bounding_box;
  2372.     gui_get_clip = UI_get_clip;
  2373.     gui_set_clip_preset = UI_set_clip_preset;
  2374.     gui_reset_clip = UI_reset_clip;
  2375.     gui_reset_text_clip = UI_reset_text_clip;
  2376.     gui_move_text_cursor = UI_move_text_cursor;
  2377.     gui_set_line_height = UI_set_line_height;
  2378.     gui_set_text_color = UI_set_text_color;
  2379.     gui_set_text_border_color = UI_set_text_border_color;
  2380.     gui_printf = UI_printf;
  2381.     gui_sprintf = UI_sprintf;
  2382.     gui_print_text = UI_print_text;
  2383.     gui_print_bordered_text = UI_print_bordered_text;
  2384.     /* MTk Terry Add to support print n characters */
  2385.     gui_print_text_n = UI_print_text_n;
  2386.     gui_print_bordered_text_n = UI_print_bordered_text_n;
  2387.     /* MTK end */
  2388.     gui_print_character = UI_print_character;
  2389.     /* MTK Elvis for stacked characters */
  2390.     gui_print_stacked_character = UI_print_stacked_character;
  2391.     gui_print_bordered_stacked_character = UI_print_bordered_stacked_character;
  2392.     /* MTK end */
  2393.     gui_print_bordered_character = UI_print_bordered_character;
  2394.     gui_push_text_clip = UI_push_text_clip;
  2395.     gui_pop_text_clip = UI_pop_text_clip;
  2396.     gui_push_clip = UI_push_clip;
  2397.     gui_pop_clip = UI_pop_clip;
  2398.     gui_malloc = UI_malloc;
  2399.     gui_free = UI_free;
  2400.     gui_get_character_width = UI_get_character_width;
  2401.     gui_get_character_height = UI_get_character_height;
  2402.     gui_measure_character = UI_measure_character;
  2403.     gui_get_string_width = UI_get_string_width;
  2404.     gui_get_string_width_n = UI_get_string_width_n;
  2405.     gui_get_string_width_w = UI_get_string_width_w;
  2406.     gui_get_string_width_wn = UI_get_string_width_wn;
  2407.     gui_get_string_height = UI_get_string_height;
  2408.     gui_measure_string = UI_measure_string;
  2409.     gui_measure_string_n = UI_measure_string_n;
  2410.     gui_measure_string_w = UI_measure_string_w;
  2411.     gui_measure_string_wn = UI_measure_string_wn;
  2412.     gui_strlen = UI_strlen;
  2413.     gui_strcpy = UI_strcpy;
  2414.     gui_strncpy = UI_strncpy;
  2415.     gui_strcmp = UI_strcmp;
  2416.     gui_strncmp = UI_strncmp;
  2417.     gui_strcat = UI_strcat;
  2418.     gui_itoa = UI_itoa;
  2419.     gui_atoi = UI_atoi;
  2420.     gui_set_font = UI_set_font;
  2421.     //      gui_show_animated_image                                                 =       _show_animation;
  2422.     //      gui_show_transparent_animated_image                     =       _show_transparent_animation;
  2423.     //      gui_show_transparent_animated_image_frames= _show_transparent_animation_frames;//071205 Calvin removed
  2424.     gui_measure_image = _measure_image;
  2425.     gui_start_timer = UI_start_timer;
  2426.     gui_cancel_timer = UI_cancel_timer;
  2427.     gui_transparent_color = UI_transparent_color;
  2428.     gui_color = UI_color;
  2429.     gui_color32 = UI_color32;
  2430.     gui_color_RGB = UI_color_RGB;
  2431.     gui_image_n_frames = UI_get_image_n_frames;
  2432.     gui_memcpy = UI_memcpy;
  2433.     gui_get_next_character = UI_get_next_UCS2_character;
  2434.     gui_get_previous_character = UI_get_previous_UCS2_character;
  2435.     gui_putpixel = UI_putpixel;
  2436.     gui_draw_vertical_line = UI_draw_vertical_line;
  2437.     gui_draw_horizontal_line = UI_draw_horizontal_line;
  2438.     gui_fill_rectangle = UI_fill_rectangle;
  2439.     gui_draw_rectangle = UI_draw_rectangle;
  2440.     gui_hide_animations = _hide_animations;
  2441.     gui_show_image = _show_image;
  2442.     gui_show_transparent_image = _show_transparent_image;
  2443.     gui_show_animated_image_frame = _show_animation_frame;
  2444.     gui_show_transparent_animated_image_frame = _show_transparent_animation_frame;
  2445.     gui_lock_double_buffer = UI_lock_double_buffer;
  2446.     gui_unlock_double_buffer = UI_unlock_double_buffer;
  2447.     gui_BLT_double_buffer = UI_BLT_double_buffer;
  2448.     /* Bear 040227 - init gui golbal variable */
  2449.     /* declare at wgui.c */
  2450.     MMI_status_bar_height = MMI_STATUS_BAR_HEIGHT;
  2451. #ifdef __MMI_SCREEN_ROTATE__
  2452.     /* 
  2453.      * NOTE: not all basic definitions of UI components has rotated value
  2454.      * because we do not support rotation of all category screens in current design.
  2455.      */
  2456.     if (mmi_frm_is_screen_width_height_swapped())
  2457.     {
  2458.         MMI_content_x = MMI_ROTATED_CONTENT_X;
  2459.         MMI_content_y = MMI_ROTATED_CONTENT_Y;
  2460.         MMI_content_height = MMI_ROTATED_CONTENT_HEIGHT;
  2461.         MMI_content_width = MMI_ROTATED_CONTENT_WIDTH;
  2462.     }
  2463.     else
  2464. #endif /* __MMI_SCREEN_ROTATE__ */ 
  2465.     {
  2466.         MMI_content_x = MMI_CONTENT_X;
  2467.         MMI_content_y = MMI_CONTENT_Y;
  2468.         MMI_content_height = MMI_CONTENT_HEIGHT;
  2469.         MMI_content_width = MMI_CONTENT_WIDTH;
  2470.     }
  2471.     /* declare at wgui_categories.c */
  2472.     MMI_matrix_bar_height = MMI_MATRIX_BAR_HEIGHT;
  2473.     MMI_matrix_bar_x = MMI_MATRIX_BAR_X;
  2474.     MMI_matrix_bar_y = MMI_MATRIX_BAR_Y;
  2475.     MMI_matrix_bar_width = MMI_MATRIX_BAR_WIDTH;
  2476. #ifdef __MMI_SCREEN_ROTATE__
  2477.     if (mmi_frm_is_screen_width_height_swapped())
  2478.     {
  2479.         MMI_title_height = MMI_ROTATED_TITLE_HEIGHT;
  2480.         MMI_title_width = MMI_ROTATED_TITLE_WIDTH;
  2481.         MMI_title_x = MMI_ROTATED_TITLE_X;
  2482.         MMI_title_y = MMI_ROTATED_TITLE_Y;
  2483.     }
  2484.     else
  2485. #endif /* __MMI_SCREEN_ROTATE__ */ 
  2486.     {
  2487.         MMI_title_height = MMI_TITLE_HEIGHT;
  2488.         MMI_title_width = MMI_TITLE_WIDTH;
  2489.         MMI_title_x = MMI_TITLE_X;
  2490.         MMI_title_y = MMI_TITLE_Y;
  2491.     }
  2492.     MMI_button_bar_height = MMI_BUTTON_BAR_HEIGHT;
  2493. #ifdef __MMI_SCREEN_ROTATE__
  2494.     if (mmi_frm_is_screen_width_height_swapped())
  2495.     {
  2496.         MMI_pop_up_dialog_x = MMI_ROTATED_POP_UP_DIALOG_X;
  2497.         MMI_pop_up_dialog_y = MMI_ROTATED_POP_UP_DIALOG_Y;
  2498.         MMI_pop_up_dialog_width = MMI_ROTATED_POP_UP_DIALOG_WIDTH;
  2499.         MMI_pop_up_dialog_height = MMI_ROTATED_POP_UP_DIALOG_HEIGHT;
  2500.         MMI_pop_up_dialog_full_height = MMI_ROTATED_POP_UP_DIALOG_FULL_HEIGHT;
  2501.     }
  2502.     else
  2503. #endif /* __MMI_SCREEN_ROTATE__ */ 
  2504.     {
  2505.         MMI_pop_up_dialog_x = MMI_POP_UP_DIALOG_X;
  2506.         MMI_pop_up_dialog_y = MMI_POP_UP_DIALOG_Y;
  2507.         MMI_pop_up_dialog_width = MMI_POP_UP_DIALOG_WIDTH;
  2508.         MMI_pop_up_dialog_height = MMI_POP_UP_DIALOG_HEIGHT;
  2509.         MMI_pop_up_dialog_full_height = MMI_POP_UP_DIALOG_FULL_HEIGHT;
  2510.     }
  2511.     /* declare at wgui_inputs.c */
  2512.     MMI_multitap_x = MMI_MULTITAP_X;
  2513.     MMI_multitap_y = MMI_MULTITAP_Y;
  2514.     MMI_multitap_width = MMI_MULTITAP_WIDTH;
  2515.     MMI_multitap_height = MMI_MULTITAP_HEIGHT;
  2516.     MMI_singleline_inputbox_x = MMI_SINGLELINE_INPUTBOX_X;
  2517.     MMI_singleline_inputbox_y = MMI_SINGLELINE_INPUTBOX_Y;
  2518.     MMI_singleline_inputbox_width = MMI_SINGLELINE_INPUTBOX_WIDTH;
  2519.     MMI_singleline_inputbox_height = MMI_SINGLELINE_INPUTBOX_HEIGHT;
  2520.     MMI_multiline_inputbox_x = MMI_MULTILINE_INPUTBOX_X;
  2521.     MMI_multiline_inputbox_y = MMI_MULTILINE_INPUTBOX_Y;
  2522.     MMI_multiline_inputbox_width = MMI_MULTILINE_INPUTBOX_WIDTH;
  2523.     MMI_multiline_inputbox_height = MMI_MULTILINE_INPUTBOX_HEIGHT;
  2524.     MMI_general_inputbox_x = MMI_GENERAL_INPUTBOX_X;
  2525.     MMI_general_inputbox_y = MMI_GENERAL_INPUTBOX_Y;
  2526.     MMI_general_inputbox_width = MMI_GENERAL_INPUTBOX_WIDTH;
  2527.     MMI_general_inputbox_height = MMI_GENERAL_INPUTBOX_HEIGHT;
  2528.     MMI_menuitem_height = MMI_MENUITEM_HEIGHT;
  2529.     /* declare at wgui_status_icons.h */
  2530.     MMI_status_icon_bars[0].x = 0;                          /* x */
  2531.     MMI_status_icon_bars[0].y = 0;                          /* y */
  2532.     MMI_status_icon_bars[0].flags = 0;                      /* FLAGS */
  2533.     MMI_status_icon_bars[0].x1 = 0;                         /* x1 */
  2534.     MMI_status_icon_bars[0].y1 = 0;                         /* y1 */
  2535.     MMI_status_icon_bars[0].x2 = UI_device_width - 1;       /* x2 */
  2536.     MMI_status_icon_bars[0].y2 = MMI_STATUS_BAR_HEIGHT - 1; /* y2 */
  2537.     MMI_status_icon_bars[0].group_ID = 0;                   /* GROUP */
  2538.     MMI_status_icon_bars[0].n_icons = 0;                    /* N_ICONS */
  2539.     MMI_status_icon_bars[0].icon_list = MMI_status_icons_list1; /* ICON_LIST */
  2540.     MMI_status_icon_bars[0].graphics_context = &main_LCD_device_bitmap; /* LCD CONTEXT */
  2541.     MMI_status_icon_bars[0].layer_buffer= NULL;             /* LAYER BUFFER */ //061506 double buffer
  2542.     MMI_status_icon_bars[0].layer_handle= GDI_ERROR_HANDLE; /* LAYER HANDLE */ //061506 double buffer
  2543.     MMI_status_icon_bars[1].x = UI_device_width - 17;   /* x */
  2544.     MMI_status_icon_bars[1].y = 16;                     /* y */
  2545.     MMI_status_icon_bars[1].flags = 0;                  /* FLAGS */
  2546.     MMI_status_icon_bars[1].x1 = UI_device_width - 18;  /* x1 */
  2547.     MMI_status_icon_bars[1].y1 = 16;                    /* y1 */
  2548.     MMI_status_icon_bars[1].x2 = UI_device_width - 1;   /* x2 */
  2549.     MMI_status_icon_bars[1].y2 = 80;                    /* y2 */
  2550.     MMI_status_icon_bars[1].group_ID = 0;               /* GROUP */
  2551.     MMI_status_icon_bars[1].n_icons = 0;                /* N_ICONS */
  2552.     MMI_status_icon_bars[1].icon_list = MMI_status_icons_list2; /* ICON_LIST */
  2553.     MMI_status_icon_bars[1].graphics_context = &main_LCD_device_bitmap; /* LCD CONTEXT */
  2554.     MMI_status_icon_bars[1].layer_buffer= NULL;             /* LAYER BUFFER */ //061506 double buffer
  2555.     MMI_status_icon_bars[1].layer_handle= GDI_ERROR_HANDLE; /* LAYER HANDLE */ //061506 double buffer
  2556.     MMI_status_icon_bars[2].x = 0;          /* x */
  2557.     MMI_status_icon_bars[2].y = 0;          /* y */
  2558.     MMI_status_icon_bars[2].flags = 0;      /* FLAGS */
  2559.     MMI_status_icon_bars[2].x1 = 0;         /* x1 */
  2560.     MMI_status_icon_bars[2].y1 = 0;         /* y1 */
  2561.     MMI_status_icon_bars[2].x2 = 48 - 1;    /* x2 */
  2562.     MMI_status_icon_bars[2].y2 = 14;        /* y2 */
  2563.     MMI_status_icon_bars[2].group_ID = 0;   /* GROUP */
  2564.     MMI_status_icon_bars[2].n_icons = 0;    /* N_ICONS */
  2565.     MMI_status_icon_bars[2].icon_list = MMI_status_icons_list3; /* ICON_LIST */
  2566.     MMI_status_icon_bars[2].graphics_context = &sub_LCD_device_bitmap;  /* LCD CONTEXT */
  2567.     MMI_status_icon_bars[2].layer_buffer= NULL;             /* LAYER BUFFER */ //061506 double buffer
  2568.     MMI_status_icon_bars[2].layer_handle= GDI_ERROR_HANDLE; /* LAYER HANDLE */ //061506 double buffer
  2569.     /* PMT VIKAS START 20050707 */
  2570. #ifdef __MMI_UI_DALMATIAN_SOFTKEYS__
  2571.     pixtel_shuffle_draw_background = shuffle_draw_white;    /* Common background filler */
  2572. #endif 
  2573. #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
  2574.     line_draw = 1;
  2575.     inline_bottom_line_draw = 0;
  2576. #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */ 
  2577.     /* PMT VIKAS END 20050707 */
  2578. }
  2579. /*****************************************************************************
  2580.  * FUNCTION
  2581.  *  InitDebugPrint
  2582.  * DESCRIPTION
  2583.  *  
  2584.  * PARAMETERS
  2585.  *  void
  2586.  * RETURNS
  2587.  *  void
  2588.  *****************************************************************************/
  2589. void InitDebugPrint(void)
  2590. {
  2591.     /*----------------------------------------------------------------*/
  2592.     /* Local Variables                                                */
  2593.     /*----------------------------------------------------------------*/
  2594.     static BOOL is_debug_print_init = FALSE;
  2595.     /*----------------------------------------------------------------*/
  2596.     /* Code Body                                                      */
  2597.     /*----------------------------------------------------------------*/
  2598.     if (!is_debug_print_init)
  2599.     {
  2600.         gdi_handle base_handle;
  2601.         /* init graphic library. including lcd and all drawing related modules */
  2602.         gdi_init();
  2603.         setup_UI_wrappers();
  2604.         gdi_layer_get_base_handle(&base_handle);
  2605.         gdi_layer_set_active(base_handle);
  2606.         gdi_layer_clear(GDI_COLOR_WHITE);
  2607.         gdi_layer_reset_clip();
  2608.         gdi_layer_reset_text_clip();
  2609.         is_debug_print_init = TRUE;
  2610.     }
  2611. }
  2612. extern U32 ShowDebugString(S32 x, S32 y, stFontAttribute Font, U8 *String, S32 len, U32 LineHeight, U32 Bordered);
  2613. /*****************************************************************************
  2614.  * FUNCTION
  2615.  *  DebugPrint
  2616.  * DESCRIPTION
  2617.  *  
  2618.  * PARAMETERS
  2619.  *  x       [IN]        
  2620.  *  y       [IN]        
  2621.  *  s       [?]         
  2622.  * RETURNS
  2623.  *  void
  2624.  *****************************************************************************/
  2625. void DebugPrint(U8 x, U8 y, S8 *s)
  2626. {
  2627.     /*----------------------------------------------------------------*/
  2628.     /* Local Variables                                                */
  2629.     /*----------------------------------------------------------------*/
  2630. #define DEBUG_CHAR_COUNT (256)
  2631.     S8 buffer[(DEBUG_CHAR_COUNT + 1) * ENCODING_LENGTH];
  2632.     stFontAttribute debug_font = {0, 0, 0, SMALL_FONT, 0, 0};
  2633.     /*----------------------------------------------------------------*/
  2634.     /* Code Body                                                      */
  2635.     /*----------------------------------------------------------------*/
  2636. #ifdef MMI_ON_HARDWARE_P
  2637.     custom_cfg_gpio_set_level(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
  2638. #endif 
  2639.     InitDebugPrint();
  2640.     /* flattern all layer content to base layer */
  2641.     gdi_layer_flatten_previous_to_base();
  2642.     /* set base layer as active layer */
  2643.     gdi_layer_set_active(GDI_LAYER_MAIN_BASE_LAYER_HANDLE);
  2644.     
  2645.     /* init font setting */
  2646.     UI_set_font(&debug_font);
  2647.     UI_set_text_color(UI_color(0, 0, 0));
  2648.     UI_set_text_border_color(UI_color(255, 255, 255));
  2649.     memset(buffer, 0, (DEBUG_CHAR_COUNT + 1) * ENCODING_LENGTH);
  2650.     AnsiiNToUnicodeString((PS8) buffer, s, DEBUG_CHAR_COUNT);
  2651.     UI_move_text_cursor(x, y);
  2652.     /* UI_print_text((UI_string_type)buffer); */
  2653.     UI_set_current_text_color(UI_text_color);
  2654.     ShowDebugString(UI_text_x, UI_text_y, *UI_font, (U8*) buffer, -1, UI_text_height, 1);
  2655.     gdi_layer_debug_blt();
  2656. }
  2657. #ifdef MMI_ON_HARDWARE_P
  2658. /*****************************************************************************
  2659.  * FUNCTION
  2660.  *  MMISWChangeWarning
  2661.  * DESCRIPTION
  2662.  *  
  2663.  * PARAMETERS
  2664.  *  type            [IN]        
  2665.  *  space           [IN]        
  2666.  *  codeversion     [IN]        
  2667.  *  diskversion     [IN]        
  2668.  * RETURNS
  2669.  *  void
  2670.  *****************************************************************************/
  2671. void MMISWChangeWarning(kal_uint8 type, kal_uint32 space, kal_uint8 const *codeversion, kal_uint8 const *diskversion)
  2672. {
  2673.     /*----------------------------------------------------------------*/
  2674.     /* Local Variables                                                */
  2675.     /*----------------------------------------------------------------*/
  2676. #if !defined(__L1_STANDALONE__) && !defined(EMPTY_MMI)
  2677.     kal_uint8 dspl_text[80];
  2678.     /*----------------------------------------------------------------*/
  2679.     /* Code Body                                                      */
  2680.     /*----------------------------------------------------------------*/
  2681.     InitDebugPrint();
  2682.     kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2683.     sprintf((char*)dspl_text, "SW Change:n");
  2684.     DebugPrint(0, 10, (S8*) dspl_text);
  2685.     kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2686.     sprintf((char*)dspl_text, " From: %sn", diskversion);
  2687.     DebugPrint(0, 20, (S8*) dspl_text);
  2688.     kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2689.     sprintf((char*)dspl_text, " To:    %sn", codeversion);
  2690.     DebugPrint(0, 30, (S8*) dspl_text);
  2691.     if (type == 0)
  2692.     {
  2693.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2694.         sprintf((char*)dspl_text, "Err: Lack of space:n");
  2695.         DebugPrint(0, 40, (S8*) dspl_text);
  2696.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2697.         sprintf((char*)dspl_text, " %d bytes needed.n", space);
  2698.         DebugPrint(0, 50, (S8*) dspl_text);
  2699.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2700.         sprintf((char*)dspl_text, "Fix:Delete from USER.n");
  2701.         DebugPrint(0, 60, (S8*) dspl_text);
  2702.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2703.         sprintf((char*)dspl_text, "SW Change aborted.n");
  2704.         DebugPrint(0, 70, (S8*) dspl_text);
  2705.     }
  2706.     else
  2707.     {
  2708.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2709.         sprintf((char*)dspl_text, "Err: Critical changes.n");
  2710.         DebugPrint(0, 40, (S8*) dspl_text);
  2711.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2712.         sprintf((char*)dspl_text, "Fix:Backup please.n");
  2713.         DebugPrint(0, 50, (S8*) dspl_text);
  2714.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2715.         sprintf((char*)dspl_text, "SW change aborted.n");
  2716.         DebugPrint(0, 60, (S8*) dspl_text);
  2717.     }
  2718. #endif /* !defined(__L1_STANDALONE__) && !defined(EMPTY_MMI) */ 
  2719. }
  2720. #endif /* MMI_ON_HARDWARE_P */ 
  2721. /* MTK modified by Lisen 11/30/2003 */
  2722. #ifdef MMI_ON_HARDWARE_P
  2723. /*****************************************************************************
  2724.  * FUNCTION
  2725.  *  MMIResourceMismatchWarning
  2726.  * DESCRIPTION
  2727.  *  
  2728.  * PARAMETERS
  2729.  *  errType         [IN]        
  2730.  *  errResType      [IN]        
  2731.  *  codeversion     [IN]        
  2732.  *  resversion      [IN]        
  2733.  * RETURNS
  2734.  *  void
  2735.  *****************************************************************************/
  2736. void MMIResourceMismatchWarning(
  2737.         kal_int8 errType,
  2738.         kal_int8 errResType,
  2739.         kal_uint8 const *codeversion,
  2740.         kal_uint8 const *resversion)
  2741. {
  2742.     /*----------------------------------------------------------------*/
  2743.     /* Local Variables                                                */
  2744.     /*----------------------------------------------------------------*/
  2745. #if !defined(__L1_STANDALONE__) && !defined(EMPTY_MMI)
  2746.     kal_uint8 dspl_text[80];
  2747.     /*----------------------------------------------------------------*/
  2748.     /* Code Body                                                      */
  2749.     /*----------------------------------------------------------------*/
  2750.     InitDebugPrint();
  2751.     if (errType < 0)
  2752.     {
  2753.         return;
  2754.     }
  2755.     if (errResType == 0)
  2756.     {
  2757.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2758.         sprintf((char*)dspl_text, "Err: AUDIO Ver:n");
  2759.         DebugPrint(0, 10, (S8*) dspl_text);
  2760.     }
  2761.     else if (errResType == 1)
  2762.     {
  2763.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2764.         sprintf((char*)dspl_text, "Err: IMAGE Ver:n");
  2765.         DebugPrint(0, 10, (S8*) dspl_text);
  2766.     }
  2767.     else if (errResType == 2)
  2768.     {
  2769.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2770.         sprintf((char*)dspl_text, "Err: FONT Ver:n");
  2771.         DebugPrint(0, 10, (S8*) dspl_text);
  2772.     }
  2773.     else
  2774.     {
  2775.         kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2776.         sprintf((char*)dspl_text, "Err: Res Ver:n");
  2777.         DebugPrint(0, 10, (S8*) dspl_text);
  2778.     }
  2779.     kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2780.     sprintf((char*)dspl_text, " %sn", resversion);
  2781.     DebugPrint(0, 20, (S8*) dspl_text);
  2782.     kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2783.     sprintf((char*)dspl_text, " Expected ver#:n");
  2784.     DebugPrint(0, 40, (S8*) dspl_text);
  2785.     kal_mem_set(dspl_text, '', sizeof(dspl_text));
  2786.     sprintf((char*)dspl_text, " %sn", codeversion);
  2787.     DebugPrint(0, 50, (S8*) dspl_text);
  2788.     while (1);
  2789. #endif /* !defined(__L1_STANDALONE__) && !defined(EMPTY_MMI) */ 
  2790. }
  2791. #endif /* MMI_ON_HARDWARE_P */ 
  2792. /* MTK end */
  2793. /*****************************************************************************
  2794.  * FUNCTION
  2795.  *  MMIGetGDIShowFullScreenTime
  2796.  * DESCRIPTION
  2797.  *  
  2798.  * PARAMETERS
  2799.  *  void
  2800.  * RETURNS
  2801.  *  void
  2802.  *****************************************************************************/
  2803. kal_uint32 MMIGetGDIShowFullScreenTime(void)
  2804. {
  2805.     /*----------------------------------------------------------------*/
  2806.     /* Local Variables                                                */
  2807.     /*----------------------------------------------------------------*/
  2808. #if !defined(__L1_STANDALONE__) && !defined(EMPTY_MMI)
  2809.     
  2810.     /*----------------------------------------------------------------*/
  2811.     /* Code Body                                                      */
  2812.     /*----------------------------------------------------------------*/
  2813.     return gdi_image_estimate_show_fullscreen_time();
  2814. #else
  2815.     return 0;
  2816. #endif /* !defined(__L1_STANDALONE__) && !defined(EMPTY_MMI) */ 
  2817. }
  2818. /* Scan disk and display first logo image */
  2819. /*****************************************************************************
  2820.  * FUNCTION
  2821.  *  MMICheckDiskDisplay
  2822.  * DESCRIPTION
  2823.  *  
  2824.  * PARAMETERS
  2825.  *  void
  2826.  * RETURNS
  2827.  *  void
  2828.  *****************************************************************************/
  2829. void MMICheckDiskDisplay(void)
  2830. {
  2831. #ifdef MMI_ON_HARDWARE_P
  2832.     /*----------------------------------------------------------------*/
  2833.     /* Local Variables                                                */
  2834.     /*----------------------------------------------------------------*/
  2835. #if !defined(__L1_STANDALONE__) && !defined(EMPTY_MMI)
  2836.     S32 height, width;
  2837.     S32 x, y;
  2838.     S32 UI_device_width = LCD_WIDTH;
  2839.     S32 UI_device_height = LCD_HEIGHT;
  2840.     static U8 PicHasBeenShown = 0;
  2841.     /*----------------------------------------------------------------*/
  2842.     /* Code Body                                                      */
  2843.     /*----------------------------------------------------------------*/
  2844.     /* 5/1/2004 Lisen Added to avoid screen flash when it is called for several times */
  2845.     if (PicHasBeenShown == 0)
  2846.     {
  2847.         PicHasBeenShown = 1;
  2848.     }
  2849.     else
  2850.     {
  2851.         return;
  2852.     }
  2853.     /* init graphic library. including lcd and all drawing related modules */
  2854.     gdi_init();
  2855.     
  2856. #if defined(__MMI_RESOURCE_ENFB_SUPPORT__)
  2857.     /* 
  2858.      * Init Resource Memory Manamger  for E-NFB
  2859.      */
  2860. mmi_frm_resmem_init();
  2861. #endif /* __MMI_RESOURCE_ENFB_SUPPORT__ */
  2862.     
  2863.     InitDebugPrint();
  2864.     gdi_image_get_dimension_id(IMG_BOOTUP_SCANNING_LOGO, &width, &height);
  2865.     if (width > UI_device_width)
  2866.     {
  2867.         x = 0;
  2868.     }
  2869.     else
  2870.     {
  2871.         x = (UI_device_width >> 1) - (width >> 1);
  2872.     }
  2873.     if (height > UI_device_height)
  2874.     {
  2875.         y = 0;
  2876.     }
  2877.     else
  2878.     {
  2879.         y = (UI_device_height >> 1) - (height >> 1);
  2880.     }
  2881.     gdi_layer_set_clip(0, 0, UI_device_width - 1, UI_device_height - 1);
  2882.     gdi_layer_clear(GDI_COLOR_BLACK);
  2883.     gdi_image_draw_id(x, y, IMG_BOOTUP_SCANNING_LOGO);
  2884.     gdi_layer_blt(GDI_LAYER_MAIN_BASE_LAYER_HANDLE, 0, 0, 0, 0, 0, UI_device_width - 1, UI_device_height - 1);
  2885. #ifdef MMI_ON_HARDWARE_P
  2886.     custom_cfg_gpio_set_level(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
  2887. #endif 
  2888. #endif /* !defined(__L1_STANDALONE__) && !defined(EMPTY_MMI) */ 
  2889. #endif /* MMI_ON_HARDWARE_P */ 
  2890. }
  2891. /* MTK end */
  2892. /* added for BkLight Simulation */
  2893. #ifdef MMI_ON_WIN32
  2894. /*****************************************************************************
  2895.  * FUNCTION
  2896.  *  simulate_lcd_bklight_turn_off
  2897.  * DESCRIPTION
  2898.  *  
  2899.  * PARAMETERS
  2900.  *  void
  2901.  * RETURNS
  2902.  *  void
  2903.  *****************************************************************************/
  2904. void simulate_lcd_bklight_turn_off()
  2905. {
  2906.     /*----------------------------------------------------------------*/
  2907.     /* Local Variables                                                */
  2908.     /*----------------------------------------------------------------*/
  2909.     /*----------------------------------------------------------------*/
  2910.     /* Code Body                                                      */
  2911.     /*----------------------------------------------------------------*/
  2912. }
  2913. /*****************************************************************************
  2914.  * FUNCTION
  2915.  *  simulate_sublcd_bklight_turn_off
  2916.  * DESCRIPTION
  2917.  *  
  2918.  * PARAMETERS
  2919.  *  void
  2920.  * RETURNS
  2921.  *  void
  2922.  *****************************************************************************/
  2923. void simulate_sublcd_bklight_turn_off()
  2924. {
  2925.     /*----------------------------------------------------------------*/
  2926.     /* Local Variables                                                */
  2927.     /*----------------------------------------------------------------*/
  2928.     /*----------------------------------------------------------------*/
  2929.     /* Code Body                                                      */
  2930.     /*----------------------------------------------------------------*/
  2931. }
  2932. /*****************************************************************************
  2933.  * FUNCTION
  2934.  *  simulate_lcd_bklight_turn_on
  2935.  * DESCRIPTION
  2936.  *  
  2937.  * PARAMETERS
  2938.  *  void
  2939.  * RETURNS
  2940.  *  void
  2941.  *****************************************************************************/
  2942. void simulate_lcd_bklight_turn_on()
  2943. {
  2944.     /*----------------------------------------------------------------*/
  2945.     /* Local Variables                                                */
  2946.     /*----------------------------------------------------------------*/
  2947.     /*----------------------------------------------------------------*/
  2948.     /* Code Body                                                      */
  2949.     /*----------------------------------------------------------------*/
  2950. }
  2951. /*****************************************************************************
  2952.  * FUNCTION
  2953.  *  simulate_sublcd_bklight_turn_on
  2954.  * DESCRIPTION
  2955.  *  
  2956.  * PARAMETERS
  2957.  *  void
  2958.  * RETURNS
  2959.  *  void
  2960.  *****************************************************************************/
  2961. void simulate_sublcd_bklight_turn_on()
  2962. {
  2963.     /*----------------------------------------------------------------*/
  2964.     /* Local Variables                                                */
  2965.     /*----------------------------------------------------------------*/
  2966.     /*----------------------------------------------------------------*/
  2967.     /* Code Body                                                      */
  2968.     /*----------------------------------------------------------------*/
  2969. }
  2970. #endif /* MMI_ON_WIN32 */ /* MMI_ON_WIN32//BkLight SImulation Code */
  2971. /* PMT VIKAS START 20050518 */
  2972. /********   Transparency Code  *********************/
  2973. //Added for transparency effect
  2974. //      It will take opacity value in calculation.
  2975. /* PMT VIKAS START 20051217 */
  2976. #if defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__) || defined (__MMI_UI_TRANSPARENT_EFFECT_IN_DALMATIAN_CALENDAR__)     /* 072505 Calvin modified */
  2977. gdi_handle non_default_layer = GDI_LAYER_EMPTY_HANDLE;
  2978. /*****************************************************************************
  2979.  * FUNCTION
  2980.  *  gui_set_transparent_source_layer
  2981.  * DESCRIPTION
  2982.  *  
  2983.  * PARAMETERS
  2984.  *  layer       [IN]        
  2985.  * RETURNS
  2986.  *  void
  2987.  *****************************************************************************/
  2988. void gui_set_transparent_source_layer(gdi_handle layer)
  2989. {
  2990.     /*----------------------------------------------------------------*/
  2991.     /* Local Variables                                                */
  2992.     /*----------------------------------------------------------------*/
  2993.     /*----------------------------------------------------------------*/
  2994.     /* Code Body                                                      */
  2995.     /*----------------------------------------------------------------*/
  2996.     non_default_layer = layer;
  2997. }
  2998. /* 110705 WAP menu Calvin Start */
  2999. /*****************************************************************************
  3000.  * FUNCTION
  3001.  *  gui_get_transparent_source_layer
  3002.  * DESCRIPTION
  3003.  *  
  3004.  * PARAMETERS
  3005.  *  void
  3006.  * RETURNS
  3007.  *  
  3008.  *****************************************************************************/
  3009. gdi_handle gui_get_transparent_source_layer(void)
  3010. {
  3011.     /*----------------------------------------------------------------*/
  3012.     /* Local Variables                                                */
  3013.     /*----------------------------------------------------------------*/
  3014.     /*----------------------------------------------------------------*/
  3015.     /* Code Body                                                      */
  3016.     /*----------------------------------------------------------------*/
  3017.     return non_default_layer;
  3018. }
  3019. /* 110705 WAP menu Calvin End */
  3020. /*****************************************************************************
  3021.  * FUNCTION
  3022.  *  gui_reset_transparent_source_layer
  3023.  * DESCRIPTION
  3024.  *  
  3025.  * PARAMETERS
  3026.  *  void
  3027.  * RETURNS
  3028.  *  void
  3029.  *****************************************************************************/
  3030. void gui_reset_transparent_source_layer(void)
  3031. {
  3032.     /*----------------------------------------------------------------*/
  3033.     /* Local Variables                                                */
  3034.     /*----------------------------------------------------------------*/
  3035.     /*----------------------------------------------------------------*/
  3036.     /* Code Body                                                      */
  3037.     /*----------------------------------------------------------------*/
  3038.     non_default_layer = GDI_LAYER_EMPTY_HANDLE;
  3039. }
  3040. /* PMT VIKAS START 20050630 */
  3041. /*****************************************************************************
  3042.  * FUNCTION
  3043.  *  gui_is_current_transparency_with_multi_layer
  3044.  * DESCRIPTION
  3045.  *  This function returns if multilayer is enabled in transparency effect
  3046.  * PARAMETERS
  3047.  *  void
  3048.  * RETURNS
  3049.  *  TRUE/FALSE
  3050.  *****************************************************************************/
  3051. S32 gui_is_current_transparency_with_multi_layer(void)
  3052. {
  3053.     /*----------------------------------------------------------------*/
  3054.     /* Local Variables                                                */
  3055.     /*----------------------------------------------------------------*/
  3056.     /*----------------------------------------------------------------*/
  3057.     /* Code Body                                                      */
  3058.     /*----------------------------------------------------------------*/
  3059.     return (non_default_layer == GDI_LAYER_EMPTY_HANDLE) ? 0 : 1;
  3060. }
  3061. /* PMT VIKAS END 20050630 */
  3062. /*****************************************************************************
  3063.  * FUNCTION
  3064.  *  gui_fill_transparent_color
  3065.  * DESCRIPTION
  3066.  *  Fill the transparent color rectangle
  3067.  * PARAMETERS
  3068.  *  x1              [IN]        
  3069.  *  y1              [IN]        
  3070.  *  x2              [IN]        
  3071.  *  y2              [IN]        
  3072.  *  c               [IN]        
  3073.  *  start(?)        [IN]        X, start y, end x, end y, color value
  3074.  * RETURNS
  3075.  *  void
  3076.  *****************************************************************************/
  3077. void gui_fill_transparent_color(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  3078. {
  3079.     /*----------------------------------------------------------------*/
  3080.     /* Local Variables                                                */
  3081.     /*----------------------------------------------------------------*/
  3082.     U32 alpha = ((U32) c.alpha) * 255 / 100;
  3083.     /*----------------------------------------------------------------*/
  3084.     /* Code Body                                                      */
  3085.     /*----------------------------------------------------------------*/
  3086.     if (non_default_layer != GDI_LAYER_EMPTY_HANDLE)
  3087.     {
  3088.         gdi_effect_alpha_blending_rect(non_default_layer, x1, y1, x2, y2, alpha, c.r, c.g, c.b);
  3089.     }
  3090.     else
  3091.     {
  3092.         gdi_handle active_layer;
  3093.         gdi_layer_get_active(&active_layer);
  3094.         gdi_effect_alpha_blending_rect(active_layer, x1, y1, x2, y2, alpha, c.r, c.g, c.b);
  3095.     }
  3096. }
  3097. /*****************************************************************************
  3098.  * FUNCTION
  3099.  *  gui_transparent_color_filler
  3100.  * DESCRIPTION
  3101.  *  Choose the color filler
  3102.  * PARAMETERS
  3103.  *  x1              [IN]        
  3104.  *  y1              [IN]        
  3105.  *  x2              [IN]        
  3106.  *  y2              [IN]        
  3107.  *  c               [IN]        
  3108.  *  start(?)        [IN]        X, start y, end x, end y, color value
  3109.  * RETURNS
  3110.  *  void
  3111.  *****************************************************************************/
  3112. void gui_transparent_color_filler(S32 x1, S32 y1, S32 x2, S32 y2, color c)
  3113. {
  3114. #ifdef __MMI_SUBLCD__
  3115.     /*----------------------------------------------------------------*/
  3116.     /* Local Variables                                                */
  3117.     /*----------------------------------------------------------------*/
  3118.     U32 alpha_value;
  3119.     /*----------------------------------------------------------------*/
  3120.     /* Code Body                                                      */
  3121.     /*----------------------------------------------------------------*/
  3122.     if (GDI_LCD->act_handle != GDI_LCD_MAIN_LCD_HANDLE)
  3123.     {
  3124.         alpha_value = ((c.alpha) << 8) / 100;
  3125.         if (256 == alpha_value)
  3126.         {
  3127.             alpha_value = 255;
  3128.         }
  3129.         gdi_draw_solid_rect(x1, y1, x2, y2, gdi_act_color_from_rgb(alpha_value, c.r, c.g, c.b));
  3130.     }
  3131.     else
  3132. #endif /* __MMI_SUBLCD__ */ 
  3133.     {
  3134.     /* 070306 Alpha layer Start */
  3135.     #if __MMI_MAIN_BASE_LAYER_FORMAT__ == GDI_COLOR_FORMAT_32
  3136.         U32 alpha_value;
  3137.     
  3138.         alpha_value = ((c.alpha) << 8) / 100;
  3139.         if (256 == alpha_value)
  3140.         {
  3141.             alpha_value = 255;
  3142.         }
  3143.         gdi_draw_solid_rect(x1, y1, x2, y2, gdi_act_color_from_rgb(alpha_value, c.r, c.g, c.b));
  3144.     #else
  3145.         gui_fill_transparent_color(x1, y1, x2, y2, c);
  3146.     #endif
  3147.     /* 070306 Alpha layer End */
  3148.     }
  3149. }
  3150. #endif /* defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__) || defined (__MMI_UI_TRANSPARENT_EFFECT_IN_DALMATIAN_CALENDAR__) */ 
  3151. /* PMT VIKAS END */