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

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  *   gui_windows.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   Miscellaneous UI components. 
  48.  *
  49.  *   [Popup description]
  50.  *   [Scrolling text]
  51.  *
  52.  * Author:
  53.  * -------
  54.  * -------
  55.  * -------
  56.  * -------
  57.  *
  58.  *============================================================================
  59.  *             HISTORY
  60.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  61.  *------------------------------------------------------------------------------
  62.  * removed!
  63.  *
  64.  * removed!
  65.  * removed!
  66.  * removed!
  67.  *
  68.  * removed!
  69.  * removed!
  70.  * removed!
  71.  *
  72.  * removed!
  73.  * removed!
  74.  * removed!
  75.  *
  76.  * removed!
  77.  * removed!
  78.  * removed!
  79.  *
  80.  * removed!
  81.  * removed!
  82.  * removed!
  83.  *
  84.  * removed!
  85.  * removed!
  86.  * removed!
  87.  *
  88.  * removed!
  89.  * removed!
  90.  * removed!
  91.  *
  92.  * removed!
  93.  * removed!
  94.  * removed!
  95.  *
  96.  * removed!
  97.  * removed!
  98.  * removed!
  99.  *
  100.  * removed!
  101.  * removed!
  102.  * removed!
  103.  *
  104.  *------------------------------------------------------------------------------
  105.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  106.  *============================================================================
  107.  ****************************************************************************/
  108. /**
  109.  * Copyright Notice
  110.  * ?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
  111.  * Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
  112.  *  (It is illegal to remove this copyright notice from this software or any
  113.  *  portion of it)
  114.  */
  115. /**********************************************************************************
  116.    Filename:      gui_windows.c
  117.    Author:        manju
  118.    Date Created:  July-22-2002
  119.    Contains:      PixTel UI routines for User Interface Windows
  120. **********************************************************************************/
  121. #include "MMI_features.h"
  122. #include "gui_windows.h"
  123. #include "gui_themes.h"
  124. /* MTK Elvis for R2L characters */
  125. #include "BIDIDEF.h"
  126. #include "BIDIProt.h"
  127. #include "kal_non_specific_general_types.h"
  128. #include "FS_Type.h"
  129. #include "gdi_include.h"
  130. #include "gdi_image_gif.h"
  131. /* Robin 1208 for Debug */
  132. #include "DebugInitDef.h"
  133. #include "wgui.h"
  134. #include "wgui_categories_MM.h"
  135. /* MTK end */
  136. /* MTK Elvis for R2L characters */
  137. extern BOOL r2lMMIFlag;
  138. /* MTK end */
  139. /* GUI: window title functions               */
  140. UI_window_title_theme *current_window_title_theme = NULL;
  141. /* GUI: Pop up description functions         */
  142. S32 UI_pop_up_description_scroll_time = UI_TEXT_MENUITEM_SCROLL_TIME;
  143. S32 UI_pop_up_description_scroll_size = UI_TEXT_MENUITEM_SCROLL_SIZE;
  144. S32 UI_pop_up_description_scroll_gap = UI_TEXT_MENUITEM_SCROLL_GAP;
  145. S32 UI_pop_up_description_scroll_pause = UI_TEXT_MENUITEM_SCROLL_PAUSE;
  146. UI_pop_up_description_theme *current_pop_up_description_theme = NULL;
  147. /*****************************************************************************
  148.  * FUNCTION
  149.  *  gui_set_pop_up_description_current_theme
  150.  * DESCRIPTION
  151.  *  Applies the current theme for a pop up description
  152.  * PARAMETERS
  153.  *  b       [IN]        Is the pop up description to use
  154.  * RETURNS
  155.  *  void
  156.  *****************************************************************************/
  157. void gui_set_pop_up_description_current_theme(UI_pop_up_description *b)
  158. {
  159.     /*----------------------------------------------------------------*/
  160.     /* Local Variables                                                */
  161.     /*----------------------------------------------------------------*/
  162.     /*----------------------------------------------------------------*/
  163.     /* Code Body                                                      */
  164.     /*----------------------------------------------------------------*/
  165.     b->background_filler = current_pop_up_description_theme->background_filler;
  166.     b->text_color = current_pop_up_description_theme->text_color;
  167.     b->text_font = current_pop_up_description_theme->text_font;
  168. }
  169. /*****************************************************************************
  170.  * FUNCTION
  171.  *  gui_set_pop_up_description_theme
  172.  * DESCRIPTION
  173.  *  Applies the given theme to a pop up description
  174.  * PARAMETERS
  175.  *  b       [IN]        Is the pop up description to use
  176.  *  t       [?]         
  177.  * RETURNS
  178.  *  void
  179.  *****************************************************************************/
  180. void gui_set_pop_up_description_theme(UI_pop_up_description *b, UI_pop_up_description_theme *t)
  181. {
  182.     /*----------------------------------------------------------------*/
  183.     /* Local Variables                                                */
  184.     /*----------------------------------------------------------------*/
  185.     /*----------------------------------------------------------------*/
  186.     /* Code Body                                                      */
  187.     /*----------------------------------------------------------------*/
  188.     b->background_filler = t->background_filler;
  189.     b->text_color = t->text_color;
  190.     b->text_font = t->text_font;
  191. }
  192. /*****************************************************************************
  193.  * FUNCTION
  194.  *  gui_create_pop_up_description
  195.  * DESCRIPTION
  196.  *  Creates a pop up description
  197.  * PARAMETERS
  198.  *  b           [IN]        Is the pop up description (pre-allocated)
  199.  *  x           [IN]        Is the position of the left-top corner of the pop up description
  200.  *  y           [IN]        Is the position of the left-top corner of the pop up description
  201.  *  width       [IN]        Is the width of the pop up description
  202.  *  height      [IN]        Is the height of the pop up description
  203.  * RETURNS
  204.  *  void
  205.  *****************************************************************************/
  206. void gui_create_pop_up_description(UI_pop_up_description *b, S32 x, S32 y, S32 width, S32 height)
  207. {
  208.     /*----------------------------------------------------------------*/
  209.     /* Local Variables                                                */
  210.     /*----------------------------------------------------------------*/
  211.     /*----------------------------------------------------------------*/
  212.     /* Code Body                                                      */
  213.     /*----------------------------------------------------------------*/
  214.     b->x = x;
  215.     b->y = y;
  216.     b->width = width;
  217.     b->height = height;
  218.     b->flags = 0;
  219.     gui_set_pop_up_description_current_theme(b);
  220.     b->text_x = 4;
  221.     b->text_y = 2;
  222.     b->text_width = 0;
  223.     b->scroll_x = 0;
  224.     b->scroll_width = width - 4;
  225.     b->n_strings = 0;
  226. }
  227. /*****************************************************************************
  228.  * FUNCTION
  229.  *  gui_resize_pop_up_description
  230.  * DESCRIPTION
  231.  *  Resizes a pop up description
  232.  * PARAMETERS
  233.  *  b           [IN]        Is the pop up description
  234.  *  width       [IN]        Is the width of the pop up description
  235.  *  height      [IN]        Is the height of the pop up description
  236.  * RETURNS
  237.  *  void
  238.  *****************************************************************************/
  239. void gui_resize_pop_up_description(UI_pop_up_description *b, S32 width, S32 height)
  240. {
  241.     /*----------------------------------------------------------------*/
  242.     /* Local Variables                                                */
  243.     /*----------------------------------------------------------------*/
  244.     /*----------------------------------------------------------------*/
  245.     /* Code Body                                                      */
  246.     /*----------------------------------------------------------------*/
  247.     b->width = width;
  248.     b->height = height;
  249.     b->scroll_x = 0;
  250.     b->scroll_width = width - 4;
  251. }
  252. /*****************************************************************************
  253.  * FUNCTION
  254.  *  gui_move_pop_up_description
  255.  * DESCRIPTION
  256.  *  Moves a pop up description
  257.  * PARAMETERS
  258.  *  b       [IN]        Is the pop up description
  259.  *  x       [IN]        Is the new location
  260.  *  y       [IN]        Is the new location
  261.  * RETURNS
  262.  *  void
  263.  *****************************************************************************/
  264. void gui_move_pop_up_description(UI_pop_up_description *b, S32 x, S32 y)
  265. {
  266.     /*----------------------------------------------------------------*/
  267.     /* Local Variables                                                */
  268.     /*----------------------------------------------------------------*/
  269.     /*----------------------------------------------------------------*/
  270.     /* Code Body                                                      */
  271.     /*----------------------------------------------------------------*/
  272.     b->x = x;
  273.     b->y = y;
  274. }
  275. /*****************************************************************************
  276.  * FUNCTION
  277.  *  gui_set_pop_up_description
  278.  * DESCRIPTION
  279.  *  Moves and resizes the pop up description
  280.  * PARAMETERS
  281.  *  b           [IN]        Is the pop up description
  282.  *  x           [IN]        Is the position of the left-top corner of the pop up description
  283.  *  y           [IN]        Is the position of the left-top corner of the pop up description
  284.  *  width       [IN]        Is the width of the pop up description
  285.  *  height      [IN]        Is the height of the pop up description
  286.  * RETURNS
  287.  *  void
  288.  *****************************************************************************/
  289. void gui_set_pop_up_description(UI_pop_up_description *b, S32 x, S32 y, S32 width, S32 height)
  290. {
  291.     /*----------------------------------------------------------------*/
  292.     /* Local Variables                                                */
  293.     /*----------------------------------------------------------------*/
  294.     /*----------------------------------------------------------------*/
  295.     /* Code Body                                                      */
  296.     /*----------------------------------------------------------------*/
  297.     b->x = x;
  298.     b->y = y;
  299.     b->width = width;
  300.     b->height = height;
  301.     b->scroll_width = width - 4;
  302. }
  303. /*****************************************************************************
  304.  * FUNCTION
  305.  *  gui_set_pop_up_description_n_strings
  306.  * DESCRIPTION
  307.  *  Sets the number of strings to be displayed in the pop up description
  308.  * PARAMETERS
  309.  *  b       [IN]        Is the pop up description
  310.  *  n       [IN]        Is the number of strings
  311.  * RETURNS
  312.  *  void
  313.  *****************************************************************************/
  314. void gui_set_pop_up_description_n_strings(UI_pop_up_description *b, S32 n)
  315. {
  316.     /*----------------------------------------------------------------*/
  317.     /* Local Variables                                                */
  318.     /*----------------------------------------------------------------*/
  319.     /*----------------------------------------------------------------*/
  320.     /* Code Body                                                      */
  321.     /*----------------------------------------------------------------*/
  322.     if (n < 0)
  323.     {
  324.         n = 0;
  325.     }
  326.     if (n > MAX_POP_UP_DESCRIPTION_STRINGS)
  327.     {
  328.         n = MAX_POP_UP_DESCRIPTION_STRINGS;
  329.     }
  330.     b->n_strings = n;
  331. }
  332. /*****************************************************************************
  333.  * FUNCTION
  334.  *  gui_set_pop_up_description_text
  335.  * DESCRIPTION
  336.  *  Sets the text to be displayed for a particular row
  337.  * PARAMETERS
  338.  *  b           [IN]        Is the pop up description
  339.  *  i           [IN]        Is the row index (zero based)
  340.  *  text        [IN]        Is the string
  341.  * RETURNS
  342.  *  void
  343.  *****************************************************************************/
  344. void gui_set_pop_up_description_text(UI_pop_up_description *b, S32 i, UI_string_type text)
  345. {
  346.     /*----------------------------------------------------------------*/
  347.     /* Local Variables                                                */
  348.     /*----------------------------------------------------------------*/
  349.     /*----------------------------------------------------------------*/
  350.     /* Code Body                                                      */
  351.     /*----------------------------------------------------------------*/
  352.     if (i >= 0 && i < b->n_strings)
  353.     {
  354.         b->text_strings[i] = text;
  355.     }
  356. }
  357. /*****************************************************************************
  358.  * FUNCTION
  359.  *  gui_autoresize_pop_up_description
  360.  * DESCRIPTION
  361.  *  Automatically resizes the pop up description based on the text inside it
  362.  * PARAMETERS
  363.  *  b           [IN]        Is the pop up description
  364.  *  width       [IN]        Is the maximum width
  365.  *  height      [IN]        Is the maximum height
  366.  * RETURNS
  367.  *  1 if there is some text in the pop up (Pop up can be displayed)
  368.  *  0 if there is no text in the pop up (Pop up need not be displayed)
  369.  *****************************************************************************/
  370. U8 gui_autoresize_pop_up_description(UI_pop_up_description *b, S32 width, S32 height)
  371. {
  372.     /*----------------------------------------------------------------*/
  373.     /* Local Variables                                                */
  374.     /*----------------------------------------------------------------*/
  375.     S32 i, w, bw = 0, th = 0, h, pw;
  376.     U8 rvalue = 0;
  377.     /*----------------------------------------------------------------*/
  378.     /* Code Body                                                      */
  379.     /*----------------------------------------------------------------*/
  380.     UI_UNUSED_PARAMETER(height);
  381.     if (b->n_strings == 0)
  382.     {
  383.         return (0);
  384.     }
  385.     gui_set_font(b->text_font);
  386.     for (i = 0; i < b->n_strings; i++)
  387.     {
  388.         if (b->text_strings[i] != NULL)
  389.         {
  390.             gui_measure_string(b->text_strings[i], &w, &h);
  391.             th += h;
  392.             if (w > bw)
  393.             {
  394.                 bw = w;
  395.             }
  396.             rvalue = 1;
  397.         }
  398.     }
  399.     b->text_width = bw;
  400.     bw += 8;
  401. #if defined(UI_POPUP_DESCRIPTION_STYLE_3)
  402.     th += 7;
  403. #elif defined(UI_POPUP_DESCRIPTION_STYLE_2)
  404.     th += 5;
  405. #else 
  406.     th += 4;
  407. #endif 
  408.     /* Permissible width is 3/4 of the actual width */
  409.     pw = (width >> 1) + (width >> 2);
  410.     if (bw > pw)
  411.     {
  412.         bw = pw;
  413.     }
  414.     /* if(th>height) th=height; */
  415.     b->width = bw;
  416.     b->height = th;
  417.     b->scroll_width = b->width - 8;
  418.     return (rvalue);
  419. }
  420. /* Text scrolling related functions within the Pop up description */
  421. UI_pop_up_description *GUI_current_pop_up_description = NULL;
  422. U8 GUI_current_pop_up_description_scroll = 0;
  423. U8 GUI_current_pop_up_description_scroll_direction;
  424. S32 GUI_current_pop_up_description_x;
  425. S32 GUI_current_pop_up_description_y;
  426. S32 GUI_current_pop_up_description_scroll_counter = 0;
  427. UI_string_type GUI_current_pop_up_description_scroll_text[MAX_POP_UP_DESCRIPTION_STRINGS];
  428. UI_string_type GUI_current_pop_up_description_scroll_text_end[MAX_POP_UP_DESCRIPTION_STRINGS];
  429. /*****************************************************************************
  430.  * FUNCTION
  431.  *  gui_pop_up_description_scroll_handler
  432.  * DESCRIPTION
  433.  *  
  434.  * PARAMETERS
  435.  *  void
  436.  * RETURNS
  437.  *  void
  438.  *****************************************************************************/
  439. void gui_pop_up_description_scroll_handler(void)
  440. {
  441.     /*----------------------------------------------------------------*/
  442.     /* Local Variables                                                */
  443.     /*----------------------------------------------------------------*/
  444.     U32 flags = GUI_current_pop_up_description->flags;
  445.     /*----------------------------------------------------------------*/
  446.     /* Code Body                                                      */
  447.     /*----------------------------------------------------------------*/
  448.     /* MTK added by JL 031128 for scrolling time can't stop */
  449.     if (GUI_current_pop_up_description_scroll == 0)
  450.     {
  451.         return;
  452.     }
  453.     /* MTK end */
  454.     if (GUI_current_pop_up_description_scroll_counter)
  455.     {
  456.         GUI_current_pop_up_description_scroll_counter--;
  457.     }
  458.     else
  459.     {
  460.     #if(UI_USE_WORD_SCROLLING_TEXT)
  461.         {
  462.             S32 i;
  463.             for (i = 0; i < MAX_POP_UP_DESCRIPTION_STRINGS; i++)
  464.             {
  465.                 GUI_current_pop_up_description_scroll_text[i] = GUI_current_pop_up_description_scroll_text_end[i];
  466.             }
  467.         }
  468.     #else /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  469.         if (flags & UI_POP_UP_DESCRIPTION_MARQUEE_SCROLL)
  470.         {
  471.             GUI_current_pop_up_description->scroll_x -= UI_pop_up_description_scroll_size;
  472.             if (GUI_current_pop_up_description->scroll_x <=
  473.                 (-(GUI_current_pop_up_description->text_width + UI_pop_up_description_scroll_gap)))
  474.             {
  475.                 GUI_current_pop_up_description->scroll_x = 0;
  476.             }
  477.         }
  478.         else
  479.         {
  480.             if (GUI_current_pop_up_description_scroll_direction == 0)
  481.             {
  482.                 GUI_current_pop_up_description->scroll_x -= UI_pop_up_description_scroll_size;
  483.                 if ((GUI_current_pop_up_description->scroll_x + GUI_current_pop_up_description->text_width) <=
  484.                     (GUI_current_pop_up_description->scroll_width))
  485.                 {
  486.                     GUI_current_pop_up_description_scroll_direction = 1;
  487.                     GUI_current_pop_up_description_scroll_counter = UI_pop_up_description_scroll_pause;
  488.                 }
  489.             }
  490.             else if (GUI_current_pop_up_description_scroll_direction == 1)
  491.             {
  492.                 GUI_current_pop_up_description->scroll_x += UI_pop_up_description_scroll_size;
  493.                 if (GUI_current_pop_up_description->scroll_x >= 0)
  494.                 {
  495.                     GUI_current_pop_up_description_scroll_direction = 0;
  496.                     GUI_current_pop_up_description_scroll_counter = UI_pop_up_description_scroll_pause;
  497.                 }
  498.             }
  499.         }
  500.     #endif /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  501.     }
  502.     GUI_current_pop_up_description->flags |= UI_POP_UP_DESCRIPTION_DISPLAY_SCROLL;
  503.     gui_show_pop_up_description((void*)GUI_current_pop_up_description);
  504.     GUI_current_pop_up_description->flags &= ~UI_POP_UP_DESCRIPTION_DISPLAY_SCROLL;
  505. #if(UI_DOUBLE_BUFFER_SUPPORT)
  506.     gui_BLT_double_buffer(
  507.         GUI_current_pop_up_description_x,
  508.         GUI_current_pop_up_description_y,
  509.         GUI_current_pop_up_description_x + GUI_current_pop_up_description->width - 1,
  510.         GUI_current_pop_up_description_y + GUI_current_pop_up_description->height - 1);
  511. #endif /* (UI_DOUBLE_BUFFER_SUPPORT) */ 
  512.     gui_start_timer(UI_pop_up_description_scroll_time, gui_pop_up_description_scroll_handler);
  513. }
  514. #ifdef __MMI_UI_HINT_TOGGLE_TRANSITION__
  515. /*****************************************************************************
  516.  * FUNCTION
  517.  *  gui_pop_up_description_transition_handler
  518.  * DESCRIPTION
  519.  *  
  520.  * PARAMETERS
  521.  *  void
  522.  * RETURNS
  523.  *  void
  524.  *****************************************************************************/
  525. static void gui_pop_up_description_transition_handler(void)
  526. {
  527.     /*----------------------------------------------------------------*/
  528.     /* Local Variables                                                */
  529.     /*----------------------------------------------------------------*/
  530.     /*----------------------------------------------------------------*/
  531.     /* Code Body                                                      */
  532.     /*----------------------------------------------------------------*/
  533.     if (GUI_current_pop_up_description->transition_step > 0)
  534.     {
  535.         gui_lock_double_buffer();
  536.         gui_show_pop_up_description((void*)GUI_current_pop_up_description);
  537.         gui_unlock_double_buffer();
  538.         gui_BLT_double_buffer(
  539.             GUI_current_pop_up_description->x,
  540.             GUI_current_pop_up_description->y,
  541.             GUI_current_pop_up_description->x + GUI_current_pop_up_description->width - 1,
  542.             GUI_current_pop_up_description->y + GUI_current_pop_up_description->height - 1);
  543.         GUI_current_pop_up_description->transition_step--;
  544.         if (GUI_current_pop_up_description->transition_step == 0)
  545.         {
  546.             gui_pop_up_description_start_scroll(GUI_current_pop_up_description);
  547.         }
  548.         else
  549.         {
  550.             gui_start_timer(POPUP_DESCRIPTION_TRANSITION_STEP_TIME, gui_pop_up_description_transition_handler);
  551.         }
  552.     }
  553. }
  554. #endif /* __MMI_UI_HINT_TOGGLE_TRANSITION__ */ 
  555. /*****************************************************************************
  556.  * FUNCTION
  557.  *  gui_pop_up_description_start_scroll
  558.  * DESCRIPTION
  559.  *  
  560.  * PARAMETERS
  561.  *  m       [?]     
  562.  * RETURNS
  563.  *  void
  564.  *****************************************************************************/
  565. void gui_pop_up_description_start_scroll(UI_pop_up_description *m)
  566. {
  567. #ifdef __MMI_UI_HINT_TOGGLE_TRANSITION__
  568.     /*----------------------------------------------------------------*/
  569.     /* Local Variables                                                */
  570.     /*----------------------------------------------------------------*/
  571.     /*----------------------------------------------------------------*/
  572.     /* Code Body                                                      */
  573.     /*----------------------------------------------------------------*/
  574.     if (m->transition_step > 0)
  575.     {
  576.         GUI_current_pop_up_description = m;
  577.         gui_start_timer(UI_pop_up_description_scroll_time, gui_pop_up_description_transition_handler);
  578.     }
  579.     else
  580. #endif /* __MMI_UI_HINT_TOGGLE_TRANSITION__ */ 
  581.     if (m->text_width > m->scroll_width)
  582.     {
  583.     #if(UI_USE_WORD_SCROLLING_TEXT)
  584.         {
  585.             S32 i;
  586.             for (i = 0; i < MAX_POP_UP_DESCRIPTION_STRINGS; i++)
  587.             {
  588.                 GUI_current_pop_up_description_scroll_text[i] = m->text_strings[i];
  589.             }
  590.         }
  591.         GUI_current_pop_up_description = m;
  592.         GUI_current_pop_up_description_x = m->x;
  593.         GUI_current_pop_up_description_y = m->y;
  594.         GUI_current_pop_up_description_scroll = 1;
  595.         GUI_current_pop_up_description_scroll_direction = 0;
  596.         GUI_current_pop_up_description_scroll_counter = UI_pop_up_description_scroll_pause;
  597.         gui_start_timer(UI_pop_up_description_scroll_time, gui_pop_up_description_scroll_handler);
  598.     #else /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  599.         if ((m->flags & UI_POP_UP_DESCRIPTION_MARQUEE_SCROLL) ||
  600.             (m->flags & UI_POP_UP_DESCRIPTION_TWO_DIRECTION_SCROLL))
  601.         {
  602.             GUI_current_pop_up_description = m;
  603.             GUI_current_pop_up_description_x = m->x;
  604.             GUI_current_pop_up_description_y = m->y;
  605.             GUI_current_pop_up_description_scroll = 1;
  606.             GUI_current_pop_up_description_scroll_direction = 0;
  607.             GUI_current_pop_up_description_scroll_counter = UI_pop_up_description_scroll_pause;
  608.             gui_start_timer(UI_pop_up_description_scroll_time, gui_pop_up_description_scroll_handler);
  609.         }
  610.     #endif /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  611.     }
  612.     else
  613.     {
  614.         GUI_current_pop_up_description_scroll = 0;
  615.     }
  616. }
  617. /*****************************************************************************
  618.  * FUNCTION
  619.  *  gui_pop_up_description_stop_scroll
  620.  * DESCRIPTION
  621.  *  
  622.  * PARAMETERS
  623.  *  void
  624.  * RETURNS
  625.  *  void
  626.  *****************************************************************************/
  627. void gui_pop_up_description_stop_scroll(void)
  628. {
  629. #ifdef __MMI_UI_HINT_TOGGLE_TRANSITION__
  630.     /*----------------------------------------------------------------*/
  631.     /* Local Variables                                                */
  632.     /*----------------------------------------------------------------*/
  633.     /*----------------------------------------------------------------*/
  634.     /* Code Body                                                      */
  635.     /*----------------------------------------------------------------*/
  636.     gui_cancel_timer(gui_pop_up_description_transition_handler);
  637.     if (GUI_current_pop_up_description)
  638.     {
  639.         GUI_current_pop_up_description->transition_step = 0;
  640.     }
  641. #endif /* __MMI_UI_HINT_TOGGLE_TRANSITION__ */ 
  642.     if (GUI_current_pop_up_description_scroll)
  643.     {
  644.         GUI_current_pop_up_description->scroll_x = 0;
  645.         gui_cancel_timer(gui_pop_up_description_scroll_handler);
  646.         GUI_current_pop_up_description_scroll = 0;
  647.     }
  648. }
  649. #ifdef __MMI_UI_HINT_TOGGLE_TRANSITION__
  650. /*****************************************************************************
  651.  * FUNCTION
  652.  *  gui_setup_pop_up_description_transition
  653.  * DESCRIPTION
  654.  *  Setup the transition animation of the pop up descriptions
  655.  * PARAMETERS
  656.  *  b       [IN]        Is the pop up description
  657.  * RETURNS
  658.  *  void
  659.  *****************************************************************************/
  660. void gui_setup_pop_up_description_transition(UI_pop_up_description *b)
  661. {
  662.     /*----------------------------------------------------------------*/
  663.     /* Local Variables                                                */
  664.     /*----------------------------------------------------------------*/
  665.     /*----------------------------------------------------------------*/
  666.     /* Code Body                                                      */
  667.     /*----------------------------------------------------------------*/
  668.     b->transition_step = MAX_POP_UP_DESCRIPTION_TRANSITION_STEPS;
  669. }
  670. #endif /* __MMI_UI_HINT_TOGGLE_TRANSITION__ */ 
  671. /*****************************************************************************
  672.  * FUNCTION
  673.  *  gui_show_pop_up_description
  674.  * DESCRIPTION
  675.  *  Displays the pop up description
  676.  * PARAMETERS
  677.  *  b       [IN]        Is the pop up description
  678.  * RETURNS
  679.  *  void
  680.  *****************************************************************************/
  681. void gui_show_pop_up_description(UI_pop_up_description *b)
  682. {
  683.     /*----------------------------------------------------------------*/
  684.     /* Local Variables                                                */
  685.     /*----------------------------------------------------------------*/
  686.     S32 x1, y1, x2, y2;
  687.     S32 text_x, text_y;
  688.     S32 i, sw, sh, text_width;
  689.     color text_color = b->text_color;
  690.     /*----------------------------------------------------------------*/
  691.     /* Code Body                                                      */
  692.     /*----------------------------------------------------------------*/
  693.     x1 = b->x;
  694.     y1 = b->y;
  695.     x2 = x1 + b->width - 1;
  696.     y2 = y1 + b->height - 1;
  697.     /* MTK Elvis for R2L characters */
  698.     if (!r2lMMIFlag)
  699.     {
  700.         text_x = b->text_x + b->scroll_x;
  701.     }
  702.     else
  703.     {
  704.         text_x = b->width - (b->text_x + b->scroll_x);
  705.     }
  706.     /* MTK end */
  707.     text_y = b->text_y;
  708. #ifdef __MMI_UI_HINT_TOGGLE_TRANSITION__
  709.     if (b->transition_step > 0)
  710.     {
  711.         text_color = gui_blend_two_color(
  712.                         text_color,
  713.                         b->background_filler->c,
  714.                         MAX_POP_UP_DESCRIPTION_TRANSITION_STEPS - b->transition_step + (MAX_POP_UP_DESCRIPTION_TRANSITION_STEPS / 3),
  715.                         b->transition_step);
  716.     }
  717. #endif /* __MMI_UI_HINT_TOGGLE_TRANSITION__ */ 
  718. #ifdef UI_POPUP_DESCRIPTION_STYLE_3
  719.     /* Support image in popup description for more flexible theme */
  720.     if ((b->background_filler->flags & UI_FILLED_AREA_MASK_TYPE) != UI_FILLED_AREA_TYPE_BITMAP)
  721.     {
  722.         if (b->flags & UI_POP_UP_DESCRIPTION_ABOVE_MENUITEM)
  723.         {
  724.             b->background_filler->flags = UI_FILLED_AREA_TYPE_CUSTOM_FILL_TYPE2;
  725.         }
  726.         else
  727.         {
  728.             b->background_filler->flags = UI_FILLED_AREA_TYPE_CUSTOM_FILL_TYPE1;
  729.             text_y += 3;
  730.         }
  731.     }
  732. #endif /* UI_POPUP_DESCRIPTION_STYLE_3 */ 
  733.     gui_push_clip();
  734.     gui_set_clip(x1, y1, x2 + 2, y2 + 2);
  735.     gui_draw_filled_area(x1, y1, x2, y2, b->background_filler);
  736.     gui_push_text_clip();
  737.     gui_set_text_clip(x1 + 2, y1 + 2, x2 - 3, y2 - 2);
  738. #if(UI_USE_WORD_SCROLLING_TEXT)
  739.     text_width = x2 - 3 - (x1 + 2) + 1;
  740. #else 
  741.     text_width = b->text_width;
  742. #endif 
  743.     gui_set_text_color(text_color);
  744.     gui_set_font(b->text_font);
  745.     for (i = 0; i < b->n_strings; i++)
  746.     {
  747.         if (b->text_strings[i] != NULL)
  748.         {
  749.             gui_measure_string(b->text_strings[i], &sw, &sh);
  750.             gui_move_text_cursor(x1 + text_x, y1 + text_y);
  751.             gui_set_line_height(sh);
  752.         #if(UI_USE_WORD_SCROLLING_TEXT)
  753.             if (b->flags & UI_POP_UP_DESCRIPTION_DISPLAY_SCROLL)
  754.             {
  755.                 GUI_current_pop_up_description_scroll_text_end[i] = GUI_current_pop_up_description_scroll_text[i];
  756.             }
  757.             else
  758.             {
  759.                 GUI_current_pop_up_description_scroll_text_end[i] = b->text_strings[i];
  760.             }
  761.             if (gui_print_truncated_text2
  762.                 (x1 + text_x, y1 + text_y, text_width, &GUI_current_pop_up_description_scroll_text_end[i]))
  763.             {
  764.                 GUI_current_pop_up_description_scroll_text_end[i] = b->text_strings[i];
  765.             }
  766.         #else /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  767.             gui_print_text(b->text_strings[i]);
  768.             if (b->flags & UI_POP_UP_DESCRIPTION_MARQUEE_SCROLL)
  769.             {
  770.                 /* MTK Elvis for R2L characters */
  771.                 if (r2lMMIFlag)
  772.                 {
  773.                     gui_move_text_cursor(x1 + text_x - (text_width + UI_pop_up_description_scroll_gap), y1 + text_y);
  774.                 }
  775.                 else
  776.                 {
  777.                     gui_move_text_cursor(x1 + text_x + text_width + UI_pop_up_description_scroll_gap, y1 + text_y);
  778.                 }
  779.                 /* MTK end */
  780.                 gui_set_line_height(sh);
  781.                 gui_print_text(b->text_strings[i]);
  782.             }
  783.         #endif /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  784.             text_y += sh;
  785.         }
  786.     }
  787.     gui_pop_text_clip();
  788.     gui_pop_clip();
  789. }
  790. /* Scrolling text object implementation      */
  791. /* Externals for graphics context switching  */
  792. extern bitmap main_LCD_device_bitmap;
  793. extern bitmap sub_LCD_device_bitmap;
  794. void UI_set_main_LCD_graphics_context(void);
  795. void UI_set_sub_LCD_graphics_context(void);
  796. extern bitmap *current_LCD_device_bitmap;
  797. /*****************************************************************************
  798.  * FUNCTION
  799.  *  default_scrolling_text_draw_background
  800.  * DESCRIPTION
  801.  *  
  802.  * PARAMETERS
  803.  *  x1      [IN]        
  804.  *  y1      [IN]        
  805.  *  x2      [IN]        
  806.  *  y2      [IN]        
  807.  * RETURNS
  808.  *  void
  809.  *****************************************************************************/
  810. void default_scrolling_text_draw_background(S32 x1, S32 y1, S32 x2, S32 y2)
  811. {
  812.     /*----------------------------------------------------------------*/
  813.     /* Local Variables                                                */
  814.     /*----------------------------------------------------------------*/
  815.     color c = gui_color(255, 255, 255);
  816.     /*----------------------------------------------------------------*/
  817.     /* Code Body                                                      */
  818.     /*----------------------------------------------------------------*/
  819.     gui_fill_rectangle(x1, y1, x2, y2, c);
  820. }
  821. //micha1111, michaSATc3, #212
  822. //MTK Leo add, set scrolling text to use current text font, or the text height will not be snyc. with object height
  823. extern UI_font_type UI_font;
  824. /*****************************************************************************
  825.  * FUNCTION
  826.  *  gui_create_scrolling_text
  827.  * DESCRIPTION
  828.  *  
  829.  * PARAMETERS
  830.  *  s                   [?]         
  831.  *  x                   [IN]        
  832.  *  y                   [IN]        
  833.  *  width               [IN]        
  834.  *  height              [IN]        
  835.  *  text                [IN]        
  836.  *  timer_callback      [IN]        
  837.  *  draw_background     [IN]        
  838.  *  text_color          [IN]        
  839.  *  border_color        [IN]        
  840.  * RETURNS
  841.  *  void
  842.  *****************************************************************************/
  843. void gui_create_scrolling_text(
  844.         scrolling_text *s,
  845.         S32 x,
  846.         S32 y,
  847.         S32 width,
  848.         S32 height,
  849.         UI_string_type text,
  850.         void (*timer_callback) (void),
  851.         void (*draw_background) (S32 x1, S32 y1, S32 x2, S32 y2),
  852.         color text_color,
  853.         color border_color)
  854. {
  855.     /*----------------------------------------------------------------*/
  856.     /* Local Variables                                                */
  857.     /*----------------------------------------------------------------*/
  858.     /*----------------------------------------------------------------*/
  859.     /* Code Body                                                      */
  860.     /*----------------------------------------------------------------*/
  861.     s->x = x;
  862.     s->y = y;
  863.     s->scroll_x = 0;
  864.     s->width = width;
  865.     s->height = height;
  866.     s->text = text;
  867.     /* micha1111, michaSATc3, #212 */
  868.     s->text_color = text_color;
  869.     s->text_border_color = border_color;
  870.     /* s->text_font=&MMI_default_font; */
  871.     s->text_font = *UI_font;
  872.     s->scroll_size = UI_TEXT_MENUITEM_SCROLL_SIZE;
  873.     s->scroll_gap = UI_TEXT_MENUITEM_SCROLL_GAP;
  874.     s->scroll_pause = UI_TEXT_MENUITEM_SCROLL_PAUSE;
  875.     gui_set_font(&s->text_font);
  876.     gui_measure_string(text, &s->text_width, &s->text_height);
  877.     /*
  878.      * if ( s->width < s->text_width )
  879.      * s->width = s->text_width;
  880.      * if (s->height < s->text_height )
  881.      * s->height = s->text_height;
  882.      */
  883.     s->graphics_context = current_LCD_device_bitmap;
  884.     if (timer_callback == NULL)
  885.     {
  886.         timer_callback = UI_dummy_function;
  887.     }
  888.     s->timer_callback = timer_callback;
  889.     s->scroll_time = UI_TEXT_MENUITEM_SCROLL_TIME;
  890.     s->flags = UI_SCROLLING_TEXT_MARQUEE_SCROLL;
  891.     if (draw_background == NULL)
  892.     {
  893.         draw_background = default_scrolling_text_draw_background;
  894.     }
  895.     s->draw_background = draw_background;
  896. }
  897. /*****************************************************************************
  898.  * FUNCTION
  899.  *  gui_change_scrolling_text
  900.  * DESCRIPTION
  901.  *  
  902.  * PARAMETERS
  903.  *  s           [?]         
  904.  *  text        [IN]        
  905.  * RETURNS
  906.  *  void
  907.  *****************************************************************************/
  908. void gui_change_scrolling_text(scrolling_text *s, UI_string_type text)
  909. {
  910.     /*----------------------------------------------------------------*/
  911.     /* Local Variables                                                */
  912.     /*----------------------------------------------------------------*/
  913.     /*----------------------------------------------------------------*/
  914.     /* Code Body                                                      */
  915.     /*----------------------------------------------------------------*/
  916.     s->text = text;
  917.     gui_set_font(&s->text_font);
  918.     gui_measure_string(text, &s->text_width, &s->text_height);
  919. }
  920. /*****************************************************************************
  921.  * FUNCTION
  922.  *  gui_change_scrolling_text_font
  923.  * DESCRIPTION
  924.  *  
  925.  * PARAMETERS
  926.  *  s           [?]         
  927.  *  font        [IN]        
  928.  * RETURNS
  929.  *  void
  930.  *****************************************************************************/
  931. void gui_change_scrolling_text_font(scrolling_text *s, UI_font_type font)
  932. {
  933.     /*----------------------------------------------------------------*/
  934.     /* Local Variables                                                */
  935.     /*----------------------------------------------------------------*/
  936.     /*----------------------------------------------------------------*/
  937.     /* Code Body                                                      */
  938.     /*----------------------------------------------------------------*/
  939.     s->text_font = *font;
  940.     gui_set_font(&s->text_font);
  941.     gui_measure_string(s->text, &s->text_width, &s->text_height);
  942. }
  943. /*****************************************************************************
  944.  * FUNCTION
  945.  *  gui_redraw_scrolling_text
  946.  * DESCRIPTION
  947.  *  
  948.  * PARAMETERS
  949.  *  s       [?]     
  950.  * RETURNS
  951.  *  void
  952.  *****************************************************************************/
  953. void gui_redraw_scrolling_text(scrolling_text *s)
  954. {
  955.     /*----------------------------------------------------------------*/
  956.     /* Local Variables                                                */
  957.     /*----------------------------------------------------------------*/
  958.     S32 x1, y1, x2, y2, sw, sh;
  959.     S32 cx1, cy1, cx2, cy2;
  960.     bitmap *saved_graphics_context = current_LCD_device_bitmap;
  961.     /*----------------------------------------------------------------*/
  962.     /* Code Body                                                      */
  963.     /*----------------------------------------------------------------*/
  964.     if (s->graphics_context != current_LCD_device_bitmap)
  965.     {
  966.         if (s->graphics_context == &main_LCD_device_bitmap)
  967.         {
  968.             UI_set_main_LCD_graphics_context();
  969.         }
  970.         else if (s->graphics_context == &sub_LCD_device_bitmap)
  971.         {
  972.             UI_set_sub_LCD_graphics_context();
  973.         }
  974.     }
  975.     x1 = s->x;
  976.     y1 = s->y;
  977.     x2 = x1 + s->width - 1;
  978.     y2 = y1 + s->height - 1;
  979.     if (s->flags & UI_SCROLLING_TEXT_BORDERED_TEXT)
  980.     {
  981.         cx1 = x1 - 2;
  982.         cy1 = y1 - 1;
  983.         cx2 = x2 + 2;
  984.         cy2 = y2 + 1;
  985.     }
  986.     else
  987.     {
  988.         cx1 = x1;
  989.         cy1 = y1;
  990.         cx2 = x2;
  991.         cy2 = y2;
  992.     }
  993.     gui_push_clip();
  994.     gui_push_text_clip();
  995.     gui_set_text_clip(cx1, cy1, cx2, cy2);
  996.     gui_set_clip(cx1, cy1, cx2, cy2);
  997.     s->draw_background(cx1, cy1, cx2, cy2);
  998.     gui_set_font(&s->text_font);
  999.     gui_measure_string(s->text, &sw, &sh);
  1000.     if (r2lMMIFlag)
  1001.     {
  1002.         gui_move_text_cursor(s->x + s->scroll_x + s->width, s->y);
  1003.     }
  1004.     else
  1005.     {
  1006.         gui_move_text_cursor(s->x + s->scroll_x, s->y);
  1007.     }
  1008.     gui_set_text_color(s->text_color);
  1009.     gui_set_line_height(sh);
  1010.     if (s->flags & UI_SCROLLING_TEXT_BORDERED_TEXT)
  1011.     {
  1012.         gui_set_text_border_color(s->text_border_color);
  1013.     #if(UI_USE_WORD_SCROLLING_TEXT)
  1014.         if (s->flags & UI_SCROLLING_TEXT_DISPLAY_SCROLL)
  1015.         {
  1016.             s->scroll_text_end = s->scroll_text;
  1017.         }
  1018.         else
  1019.         {
  1020.             s->scroll_text_end = s->text;
  1021.         }
  1022.         if (gui_print_truncated_bordered_text2(s->x + s->scroll_x, s->y, (x2 - x1 + 1), &s->scroll_text_end))
  1023.         {
  1024.             s->scroll_text_end = s->text;
  1025.         }
  1026.     #else /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  1027.         gui_print_bordered_text(s->text);
  1028.         if ((s->flags & UI_SCROLLING_TEXT_MARQUEE_SCROLL) && (s->flags & UI_SCROLLING_TEXT_ENABLE_SCROLL))
  1029.         {
  1030.             /* MTK Elvis for R2L characters */
  1031.             if (r2lMMIFlag)
  1032.             {
  1033.                 gui_move_text_cursor(s->x + s->scroll_x + s->width - (s->text_width + s->scroll_gap), s->y);
  1034.             }
  1035.             else
  1036.             {
  1037.                 gui_move_text_cursor(s->x + s->scroll_x + s->text_width + s->scroll_gap, s->y);
  1038.             }
  1039.             /* MTK end */
  1040.             gui_set_line_height(sh);
  1041.             gui_print_bordered_text(s->text);
  1042.         }
  1043.     #endif /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  1044.     }
  1045.     else
  1046.     {
  1047.     #if(UI_USE_WORD_SCROLLING_TEXT)
  1048.         if (s->flags & UI_SCROLLING_TEXT_DISPLAY_SCROLL)
  1049.         {
  1050.             s->scroll_text_end = s->scroll_text;
  1051.         }
  1052.         else
  1053.         {
  1054.             s->scroll_text_end = s->text;
  1055.         }
  1056.         if (gui_print_truncated_text2(s->x + s->scroll_x, s->y, (x2 - x1 + 1), &s->scroll_text_end))
  1057.         {
  1058.             s->scroll_text_end = s->text;
  1059.         }
  1060.     #else /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  1061.         gui_print_text(s->text);
  1062.         if ((s->flags & UI_SCROLLING_TEXT_MARQUEE_SCROLL) && (s->flags & UI_SCROLLING_TEXT_ENABLE_SCROLL))
  1063.         {
  1064.             /* MTK Elvis for R2L characters */
  1065.             if (r2lMMIFlag)
  1066.             {
  1067.                 gui_move_text_cursor(s->x + s->scroll_x + s->width - (s->text_width + s->scroll_gap), s->y);
  1068.             }
  1069.             else
  1070.             {
  1071.                 gui_move_text_cursor(s->x + s->scroll_x + s->text_width + s->scroll_gap, s->y);
  1072.             }
  1073.             /* MTK end */
  1074.             gui_set_line_height(sh);
  1075.             gui_print_text(s->text);
  1076.         }
  1077.     #endif /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  1078.     }
  1079.     gui_pop_clip();
  1080.     gui_pop_text_clip();
  1081. #if(UI_DOUBLE_BUFFER_SUPPORT)
  1082.     gui_BLT_double_buffer(cx1, cy1, cx2, cy2);
  1083. #endif 
  1084.     if (saved_graphics_context != current_LCD_device_bitmap)
  1085.     {
  1086.         if (saved_graphics_context == &main_LCD_device_bitmap)
  1087.         {
  1088.             UI_set_main_LCD_graphics_context();
  1089.         }
  1090.         else if (saved_graphics_context == &sub_LCD_device_bitmap)
  1091.         {
  1092.             UI_set_sub_LCD_graphics_context();
  1093.         }
  1094.     }
  1095. }
  1096. /*****************************************************************************
  1097.  * FUNCTION
  1098.  *  gui_handle_scrolling_text
  1099.  * DESCRIPTION
  1100.  *  
  1101.  * PARAMETERS
  1102.  *  s       [?]     
  1103.  * RETURNS
  1104.  *  void
  1105.  *****************************************************************************/
  1106. void gui_handle_scrolling_text(scrolling_text *s)
  1107. {
  1108.     /*----------------------------------------------------------------*/
  1109.     /* Local Variables                                                */
  1110.     /*----------------------------------------------------------------*/
  1111.     /*----------------------------------------------------------------*/
  1112.     /* Code Body                                                      */
  1113.     /*----------------------------------------------------------------*/
  1114.     if (s->scroll_counter)
  1115.     {
  1116.         s->scroll_counter--;
  1117.     }
  1118.     else
  1119.     {
  1120.     #if(UI_USE_WORD_SCROLLING_TEXT)
  1121.         s->scroll_text = s->scroll_text_end;
  1122.     #else /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  1123.         if (s->flags & UI_SCROLLING_TEXT_MARQUEE_SCROLL)
  1124.         {
  1125.             if (r2lMMIFlag)
  1126.             {
  1127.                 s->scroll_x += s->scroll_size;
  1128.                 if (s->scroll_x >= (s->text_width + s->scroll_gap))
  1129.                 {
  1130.                     s->scroll_x = 0;
  1131.                 }
  1132.             }
  1133.             else
  1134.             {
  1135.                 s->scroll_x -= s->scroll_size;
  1136.                 if (s->scroll_x <= (-(s->text_width + s->scroll_gap)))
  1137.                 {
  1138.                     s->scroll_x = 0;
  1139.                 }
  1140.             }
  1141.         }
  1142.         else
  1143.         {
  1144.             if (!(s->flags & UI_SCROLLING_TEXT_SCROLL_DIRECTION_RIGHT))
  1145.             {
  1146.                 s->scroll_x -= s->scroll_size;
  1147.                 if ((s->scroll_x + s->text_width) <= (s->width))
  1148.                 {
  1149.                     s->flags |= UI_SCROLLING_TEXT_SCROLL_DIRECTION_RIGHT;
  1150.                     s->scroll_counter = s->scroll_pause;
  1151.                 }
  1152.             }
  1153.             else if (s->flags & UI_SCROLLING_TEXT_SCROLL_DIRECTION_RIGHT)
  1154.             {
  1155.                 s->scroll_x += s->scroll_size;
  1156.                 if (s->scroll_x >= 0)
  1157.                 {
  1158.                     s->flags &= ~UI_SCROLLING_TEXT_SCROLL_DIRECTION_RIGHT;
  1159.                     s->scroll_counter = s->scroll_pause;
  1160.                 }
  1161.             }
  1162.         }
  1163.     #endif /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  1164.         s->flags |= UI_SCROLLING_TEXT_DISPLAY_SCROLL;
  1165.         gui_redraw_scrolling_text(s);
  1166.         s->flags &= ~UI_SCROLLING_TEXT_DISPLAY_SCROLL;
  1167.     }
  1168.     gui_start_timer(s->scroll_time, s->timer_callback);
  1169. }
  1170. /*****************************************************************************
  1171.  * FUNCTION
  1172.  *  gui_scrolling_text_start
  1173.  * DESCRIPTION
  1174.  *  
  1175.  * PARAMETERS
  1176.  *  s       [?]     
  1177.  * RETURNS
  1178.  *  void
  1179.  *****************************************************************************/
  1180. void gui_scrolling_text_start(scrolling_text *s)
  1181. {
  1182.     /*----------------------------------------------------------------*/
  1183.     /* Local Variables                                                */
  1184.     /*----------------------------------------------------------------*/
  1185.     /*----------------------------------------------------------------*/
  1186.     /* Code Body                                                      */
  1187.     /*----------------------------------------------------------------*/
  1188.     if (s->text_width > s->width)
  1189.     {
  1190.         s->scroll_x = 0;
  1191.     #if(UI_USE_WORD_SCROLLING_TEXT)
  1192.         s->scroll_text = s->text;
  1193.         s->flags |= UI_SCROLLING_TEXT_ENABLE_SCROLL;
  1194.         s->flags &= ~UI_SCROLLING_TEXT_SCROLL_DIRECTION_RIGHT;
  1195.         s->scroll_counter = s->scroll_pause;
  1196.         gui_start_timer(s->scroll_time, s->timer_callback);
  1197.     #else /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  1198.         if ((s->flags & UI_SCROLLING_TEXT_MARQUEE_SCROLL) || (s->flags & UI_SCROLLING_TEXT_TWO_DIRECTION_SCROLL))
  1199.         {
  1200.             s->flags |= UI_SCROLLING_TEXT_ENABLE_SCROLL;
  1201.             s->flags &= ~UI_SCROLLING_TEXT_SCROLL_DIRECTION_RIGHT;
  1202.             s->scroll_counter = s->scroll_pause;
  1203.             gui_start_timer(s->scroll_time, s->timer_callback);
  1204.         }
  1205.     #endif /* (UI_USE_WORD_SCROLLING_TEXT) */ 
  1206.     }
  1207. }
  1208. /*****************************************************************************
  1209.  * FUNCTION
  1210.  *  gui_scrolling_text_stop
  1211.  * DESCRIPTION
  1212.  *  
  1213.  * PARAMETERS
  1214.  *  s       [?]     
  1215.  * RETURNS
  1216.  *  void
  1217.  *****************************************************************************/
  1218. void gui_scrolling_text_stop(scrolling_text *s)
  1219. {
  1220.     /*----------------------------------------------------------------*/
  1221.     /* Local Variables                                                */
  1222.     /*----------------------------------------------------------------*/
  1223.     /*----------------------------------------------------------------*/
  1224.     /* Code Body                                                      */
  1225.     /*----------------------------------------------------------------*/
  1226.     if (s->flags & UI_SCROLLING_TEXT_ENABLE_SCROLL)
  1227.     {
  1228.         gui_cancel_timer(s->timer_callback);
  1229.         s->flags &= ~UI_SCROLLING_TEXT_ENABLE_SCROLL;
  1230.     }
  1231. }
  1232. /*****************************************************************************
  1233.  * FUNCTION
  1234.  *  gui_show_scrolling_text
  1235.  * DESCRIPTION
  1236.  *  
  1237.  * PARAMETERS
  1238.  *  s       [?]     
  1239.  * RETURNS
  1240.  *  void
  1241.  *****************************************************************************/
  1242. void gui_show_scrolling_text(scrolling_text *s)
  1243. {
  1244.     /*----------------------------------------------------------------*/
  1245.     /* Local Variables                                                */
  1246.     /*----------------------------------------------------------------*/
  1247.     /*----------------------------------------------------------------*/
  1248.     /* Code Body                                                      */
  1249.     /*----------------------------------------------------------------*/
  1250.     gui_redraw_scrolling_text(s);
  1251.     gui_scrolling_text_start(s);
  1252. }
  1253. /* GUI multiple layer support utility */
  1254. #ifdef __GDI_MEMORY_PROFILE_2__
  1255. #include "lcd_if.h"
  1256. #include "gdi_include.h"
  1257. #include "wgui_categories_util.h"
  1258. extern gdi_handle wgui_layer_1;
  1259. extern gdi_handle wgui_base_layer;
  1260. static S32 gui_image_frame_idx = 0;
  1261. static S32 gui_image_frame_count = 0;
  1262. static S32 gui_image_offset_x, gui_image_offset_y;
  1263. static S32 gui_image_clip_x1, gui_image_clip_y1, gui_image_clip_x2, gui_image_clip_y2;
  1264. static S32 gui_image_id;
  1265. gdi_handle gui_image_layer;
  1266. static U8 gdi_transparent_value;
  1267. #define GUI_OPACITY_SECOND_LAYER    60
  1268. #define GUI_OPACITY_BASED_LAYER  200
  1269. extern void PhnsetWallpaperBadFileCallBack(U16 imgID);
  1270. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  1271. /*****************************************************************************
  1272.  * FUNCTION
  1273.  *  gui_layer_show_animation
  1274.  * DESCRIPTION
  1275.  *  
  1276.  * PARAMETERS
  1277.  *  void
  1278.  * RETURNS
  1279.  *  void
  1280.  *****************************************************************************/
  1281. void gui_layer_show_animation(void)
  1282. {
  1283. #ifdef __GDI_MEMORY_PROFILE_2__
  1284.     /*----------------------------------------------------------------*/
  1285.     /* Local Variables                                                */
  1286.     /*----------------------------------------------------------------*/
  1287.     GDI_HANDLE gdi_base_layer_hdlr;
  1288.     /*----------------------------------------------------------------*/
  1289.     /* Code Body                                                      */
  1290.     /*----------------------------------------------------------------*/
  1291.     /* GDI_HANDLE gui_animation; */
  1292.     gui_image_frame_idx = gui_image_frame_idx + 1;
  1293.     if ((gui_image_frame_idx) >= gui_image_frame_count)
  1294.     {
  1295.         gui_image_frame_idx = 0;
  1296.     }
  1297.     if (gui_is_entry_new_screen() == MMI_TRUE)
  1298.     {
  1299.         return; /* to avoid twice entry while time exipred */
  1300.     }
  1301.     /* dispaly wallpaper */
  1302.     gdi_layer_set_active(gui_image_layer);
  1303.     gdi_layer_lock_frame_buffer();
  1304.     gdi_layer_push_clip();
  1305.     gdi_layer_reset_clip();
  1306.     gui_draw_filled_area(0, 0, UI_device_width - 1, UI_device_height - 1, current_MMI_theme->general_background_filler);
  1307.     gdi_layer_pop_clip();
  1308.     gdi_layer_push_clip();
  1309.     gdi_layer_set_clip(gui_image_clip_x1, gui_image_clip_y1, gui_image_clip_x2, gui_image_clip_y2);
  1310.     gdi_layer_set_opacity(TRUE, gdi_transparent_value);
  1311.     /* gdi_image_draw_animation_single_frame_id(gui_image_offset_x, gui_image_offset_y, gui_image_id, gui_image_frame_idx); */
  1312.     gdi_image_draw_animation(gui_image_offset_x, gui_image_offset_y, get_image((U16) gui_image_id), NULL);
  1313.     gdi_layer_pop_clip();
  1314.     gdi_layer_unlock_frame_buffer();
  1315.     gdi_layer_restore_base_active();
  1316.     gdi_layer_get_base_handle(&gdi_base_layer_hdlr);
  1317.     gdi_layer_set_blt_layer(gui_image_layer, gdi_base_layer_hdlr, 0, 0);
  1318.     gdi_layer_blt_previous(gui_image_clip_x1, gui_image_clip_y1, gui_image_clip_x2, gui_image_clip_y2);
  1319.     /* restore to base layer */
  1320.     /* gdi_layer_restore_base_active(); */
  1321. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  1322. }
  1323. extern S32 cat33_n_frames;
  1324. /* 092005 draw_wallpaper Calvin Start */
  1325. extern S32 cat33_image_x;
  1326. extern S32 cat33_image_y;
  1327. extern S32 cat33_image_width;
  1328. extern S32 cat33_image_height;
  1329. /* 092005 draw_wallpaper Calvin End */
  1330. /*****************************************************************************
  1331.  * FUNCTION
  1332.  *  gui_layer_show_animation_ID
  1333.  * DESCRIPTION
  1334.  *  
  1335.  * PARAMETERS
  1336.  *  gui_show_layer      [IN]        
  1337.  *  trans_value         [IN]        
  1338.  *  frame_idx           [?]         
  1339.  *  image_id            [IN]        
  1340.  *  x1                  [IN]        
  1341.  *  y1                  [IN]        
  1342.  *  x2                  [IN]        
  1343.  *  y2                  [IN]        
  1344.  *  image_x1            [IN]        
  1345.  *  image_y1            [IN]        
  1346.  * RETURNS
  1347.  *  void
  1348.  *****************************************************************************/
  1349. void gui_layer_show_animation_ID(
  1350.         S32 gui_show_layer,
  1351.         U8 trans_value,
  1352.         S32 *frame_idx,
  1353.         U16 image_id,
  1354.         S32 x1,
  1355.         S32 y1,
  1356.         S32 x2,
  1357.         S32 y2,
  1358.         S32 image_x1,
  1359.         S32 image_y1)
  1360. {
  1361. #ifdef __GDI_MEMORY_PROFILE_2__
  1362.     /*----------------------------------------------------------------*/
  1363.     /* Local Variables                                                */
  1364.     /*----------------------------------------------------------------*/
  1365.     /*----------------------------------------------------------------*/
  1366.     /* Code Body                                                      */
  1367.     /*----------------------------------------------------------------*/
  1368.     gui_image_frame_count = cat33_n_frames;
  1369.     gui_image_frame_idx = *frame_idx;
  1370.     gui_image_clip_x1 = x1;
  1371.     gui_image_clip_y1 = y1;
  1372.     gui_image_clip_x2 = x2;
  1373.     gui_image_clip_y2 = y2;
  1374.     gui_image_offset_x = image_x1;
  1375.     gui_image_offset_y = image_y1;
  1376.     gui_image_id = image_id;
  1377.     gui_image_layer = gui_show_layer;
  1378.     gdi_transparent_value = trans_value;
  1379.     gui_layer_show_animation();
  1380. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  1381. }
  1382. /*****************************************************************************
  1383.  * FUNCTION
  1384.  *  gui_layer_show_animation_file
  1385.  * DESCRIPTION
  1386.  *  
  1387.  * PARAMETERS
  1388.  *  gui_show_layer      [IN]        
  1389.  *  trans_value         [IN]        
  1390.  *  frame_idx           [?]         
  1391.  *  file_name           [?]         
  1392.  *  x1                  [IN]        
  1393.  *  y1                  [IN]        
  1394.  *  x2                  [IN]        
  1395.  *  y2                  [IN]        
  1396.  *  image_x1            [IN]        
  1397.  *  image_y1            [IN]        
  1398.  * RETURNS
  1399.  *  void
  1400.  *****************************************************************************/
  1401. void gui_layer_show_animation_file(
  1402.         S32 gui_show_layer,
  1403.         U8 trans_value,
  1404.         S32 *frame_idx,
  1405.         S8 *file_name,
  1406.         S32 x1,
  1407.         S32 y1,
  1408.         S32 x2,
  1409.         S32 y2,
  1410.         S32 image_x1,
  1411.         S32 image_y1)
  1412. {
  1413. #ifdef __GDI_MEMORY_PROFILE_2__
  1414.     /*----------------------------------------------------------------*/
  1415.     /* Local Variables                                                */
  1416.     /*----------------------------------------------------------------*/
  1417.     GDI_HANDLE gdi_base_layer_hdlr;
  1418.     /*----------------------------------------------------------------*/
  1419.     /* Code Body                                                      */
  1420.     /*----------------------------------------------------------------*/
  1421.     /* U16 gui_image_frame_no; */
  1422.     if (gui_is_entry_new_screen() == MMI_TRUE)
  1423.     {
  1424.         return; /* to avoid twice entry while time exipred */
  1425.     }
  1426.     /* dispaly wallpaper */
  1427.     gdi_layer_set_active(gui_show_layer);
  1428.     gdi_layer_lock_frame_buffer();
  1429.     gdi_layer_push_clip();
  1430.     gdi_layer_reset_clip();
  1431.     gui_draw_filled_area(0, 0, UI_device_width - 1, UI_device_height - 1, current_MMI_theme->general_background_filler);
  1432.     gdi_layer_pop_clip();
  1433.     gdi_layer_push_clip();
  1434.     gdi_layer_set_clip(x1, y1, x2, y2);
  1435.     gdi_layer_set_opacity(TRUE, trans_value);
  1436.     {
  1437.         /* 092005 draw_wallpaper Calvin Start */
  1438.     #if 0
  1439. /* under construction !*/
  1440. /* under construction !*/
  1441. /* under construction !*/
  1442. /* under construction !*/
  1443. /* under construction !*/
  1444. /* under construction !*/
  1445. #if defined(ENABLE_ANIMATED_WALLPAPERS)
  1446. /* under construction !*/
  1447. #else
  1448. /* under construction !*/
  1449. #endif
  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.     #else /* 0 */ 
  1504.         S32 offset_x = 0;
  1505.         S32 offset_y = 0;
  1506.         S32 disp_height, disp_width;
  1507.         GDI_RESULT ret;
  1508.         disp_width = x2 - x1 + 1;
  1509.         disp_height = y2 - y1 + 1;
  1510.         gdi_image_get_dimension_file(file_name, &cat33_image_width, &cat33_image_height);
  1511.         if ((disp_width >= cat33_image_width) && (disp_height >= cat33_image_height))   /* image can be displayed entirely */
  1512.         {
  1513.             /* align preview window at the center of screen */
  1514.             offset_x = (disp_width - cat33_image_width) >> 1;
  1515.             offset_y = (disp_height - cat33_image_height) >> 1;
  1516.         #if defined(ENABLE_ANIMATED_WALLPAPERS)
  1517.             ret = gdi_image_draw_animation_file(offset_x, offset_y, (PS8) file_name, NULL);
  1518.         #else 
  1519.             ret = gdi_image_draw_file(offset_x, offset_y, (PS8) file_name);
  1520.         #endif 
  1521.         }
  1522.         else    /* image is larger than screen size */
  1523.         {
  1524.             S32 resized_offset_x;
  1525.             S32 resized_offset_y;
  1526.             S32 resized_width;
  1527.             S32 resized_height;
  1528.             gdi_image_util_fit_bbox(
  1529.                 disp_width,
  1530.                 disp_height,
  1531.                 cat33_image_width,
  1532.                 cat33_image_height,
  1533.                 &resized_offset_x,
  1534.                 &resized_offset_y,
  1535.                 &resized_width,
  1536.                 &resized_height);
  1537.             /* for images of other formats, try to set center alignment */
  1538.         #if defined(ENABLE_ANIMATED_WALLPAPERS)
  1539.             ret = gdi_image_draw_animation_resized_file(
  1540.                     resized_offset_x,
  1541.                     resized_offset_y,
  1542.                     resized_width,
  1543.                     resized_height,
  1544.                     (PS8) file_name,
  1545.                     NULL);
  1546.         #else /* defined(ENABLE_ANIMATED_WALLPAPERS) */ 
  1547.             ret = gdi_image_draw_resized_file(
  1548.                     resized_offset_x,
  1549.                     resized_offset_y,
  1550.                     resized_width,
  1551.                     resized_height,
  1552.                     (PS8) file_name);
  1553.         #endif /* defined(ENABLE_ANIMATED_WALLPAPERS) */ 
  1554.         }
  1555.         if (ret < 0 && ret != GDI_GIF_ERR_OUT_OF_CLIP_REGION && ret != GDI_BMP_ERR_OUT_OF_CLIP_REGION)
  1556.         {
  1557.             PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "draw_wallpaper():[$$$]GDI_RESULT:%d[$$$]n", ret));
  1558.             PhnsetWallpaperBadFileCallBack(0);
  1559.         }
  1560.     #endif /* 0 */ 
  1561.         /* 092005 draw_wallpaper Calvin End */
  1562.     }
  1563.     gdi_layer_pop_clip();
  1564.     gdi_layer_unlock_frame_buffer();
  1565.     gdi_layer_restore_base_active();
  1566.     gdi_layer_get_base_handle(&gdi_base_layer_hdlr);
  1567.     gdi_layer_set_blt_layer(gui_show_layer, gdi_base_layer_hdlr, 0, 0);
  1568. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  1569. }
  1570. /*****************************************************************************
  1571.  * FUNCTION
  1572.  *  gui_free_multilayer_screen
  1573.  * DESCRIPTION
  1574.  *  
  1575.  * PARAMETERS
  1576.  *  void
  1577.  * RETURNS
  1578.  *  void
  1579.  *****************************************************************************/
  1580. void gui_free_multilayer_screen(void)
  1581. {
  1582. #ifdef __GDI_MEMORY_PROFILE_2__
  1583.     /*----------------------------------------------------------------*/
  1584.     /* Local Variables                                                */
  1585.     /*----------------------------------------------------------------*/
  1586.     /*----------------------------------------------------------------*/
  1587.     /* Code Body                                                      */
  1588.     /*----------------------------------------------------------------*/
  1589.     gdi_image_stop_animation_all();
  1590.     gui_cancel_timer(gui_layer_show_animation);
  1591.     /* flatten layers & free another layer */
  1592.     if (wgui_layer_1 != GDI_LAYER_EMPTY_HANDLE)
  1593.     {
  1594.         gdi_layer_flatten_to_base(wgui_layer_1, wgui_base_layer, 0, 0);
  1595.         gdi_layer_free(wgui_layer_1);
  1596.         wgui_layer_1 = GDI_LAYER_EMPTY_HANDLE;
  1597.     }
  1598.     gdi_layer_set_opacity(FALSE, 255);
  1599.     /* restore base to no transparent */
  1600.     gdi_layer_restore_base_active();
  1601.     gdi_layer_multi_layer_disable();
  1602. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  1603. }
  1604. /*****************************************************************************
  1605.  * FUNCTION
  1606.  *  gui_layer_transparent
  1607.  * DESCRIPTION
  1608.  *  
  1609.  * PARAMETERS
  1610.  *  gui_show_layer      [IN]        
  1611.  *  trans_value         [IN]        
  1612.  *  x1                  [IN]        
  1613.  *  y1                  [IN]        
  1614.  *  x2                  [IN]        
  1615.  *  y2                  [IN]        
  1616.  * RETURNS
  1617.  *  void
  1618.  *****************************************************************************/
  1619. void gui_layer_transparent(S32 gui_show_layer, U8 trans_value, S32 x1, S32 y1, S32 x2, S32 y2)
  1620. {
  1621. #ifdef __GDI_MEMORY_PROFILE_2__
  1622.     /*----------------------------------------------------------------*/
  1623.     /* Local Variables                                                */
  1624.     /*----------------------------------------------------------------*/
  1625.     /*----------------------------------------------------------------*/
  1626.     /* Code Body                                                      */
  1627.     /*----------------------------------------------------------------*/
  1628.     /* gdi_layer_get_base_handle(&wgui_base_layer); */
  1629.     gdi_layer_set_active(gui_show_layer);
  1630.     gdi_layer_set_source_key(TRUE, GDI_COLOR_BLUE);
  1631.     gdi_layer_set_opacity(TRUE, trans_value);
  1632.     gdi_layer_push_clip();
  1633.     gdi_layer_set_clip(x1, y1, x2, y2);
  1634.     gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_BLUE);
  1635.     gdi_layer_pop_clip();
  1636. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  1637. }
  1638. static U8 mmi_ui_is_screen_changed = MMI_TRUE;
  1639. /*****************************************************************************
  1640.  * FUNCTION
  1641.  *  gui_set_entry_new_screen
  1642.  * DESCRIPTION
  1643.  *  
  1644.  * PARAMETERS
  1645.  *  new_entry       [IN]        
  1646.  * RETURNS
  1647.  *  void
  1648.  *****************************************************************************/
  1649. void gui_set_entry_new_screen(U8 new_entry)
  1650. {
  1651.     /*----------------------------------------------------------------*/
  1652.     /* Local Variables                                                */
  1653.     /*----------------------------------------------------------------*/
  1654.     /*----------------------------------------------------------------*/
  1655.     /* Code Body                                                      */
  1656.     /*----------------------------------------------------------------*/
  1657.     mmi_ui_is_screen_changed = new_entry;
  1658. }
  1659. /*****************************************************************************
  1660.  * FUNCTION
  1661.  *  gui_is_entry_new_screen
  1662.  * DESCRIPTION
  1663.  *  
  1664.  * PARAMETERS
  1665.  *  void
  1666.  * RETURNS
  1667.  *  
  1668.  *****************************************************************************/
  1669. U8 gui_is_entry_new_screen(void)
  1670. {
  1671.     /*----------------------------------------------------------------*/
  1672.     /* Local Variables                                                */
  1673.     /*----------------------------------------------------------------*/
  1674.     /*----------------------------------------------------------------*/
  1675.     /* Code Body                                                      */
  1676.     /*----------------------------------------------------------------*/
  1677.     return mmi_ui_is_screen_changed;
  1678. }
  1679. #ifdef __GDI_MEMORY_PROFILE_2__
  1680. static S32 mmi_ui_multilayer_mask = UI_MUL_ALL_ON;
  1681. #else 
  1682. static S32 mmi_ui_multilayer_mask = UI_MUL_ALL_OFF;
  1683. #endif 
  1684. /*****************************************************************************
  1685.  * FUNCTION
  1686.  *  gui_set_multilayer_mask
  1687.  * DESCRIPTION
  1688.  *  
  1689.  * PARAMETERS
  1690.  *  in_multilayer_mask      [IN]        
  1691.  * RETURNS
  1692.  *  void
  1693.  *****************************************************************************/
  1694. void gui_set_multilayer_mask(S32 in_multilayer_mask)
  1695. {
  1696.     /*----------------------------------------------------------------*/
  1697.     /* Local Variables                                                */
  1698.     /*----------------------------------------------------------------*/
  1699.     /*----------------------------------------------------------------*/
  1700.     /* Code Body                                                      */
  1701.     /*----------------------------------------------------------------*/
  1702.     mmi_ui_multilayer_mask = in_multilayer_mask;
  1703. }
  1704. /*****************************************************************************
  1705.  * FUNCTION
  1706.  *  gui_get_multilayer_mask
  1707.  * DESCRIPTION
  1708.  *  
  1709.  * PARAMETERS
  1710.  *  void
  1711.  * RETURNS
  1712.  *  
  1713.  *****************************************************************************/
  1714. U16 gui_get_multilayer_mask(void)
  1715. {
  1716.     /*----------------------------------------------------------------*/
  1717.     /* Local Variables                                                */
  1718.     /*----------------------------------------------------------------*/
  1719.     /*----------------------------------------------------------------*/
  1720.     /* Code Body                                                      */
  1721.     /*----------------------------------------------------------------*/
  1722.     return mmi_ui_multilayer_mask;
  1723. }
  1724. /* Touch Panel - Utility functions for waiting longtap animation */
  1725. /* Typical longpress events comes after 0.3~0.6 sec. However,  we wait about 1~2 seconds 
  1726.    before entering fullscreen editor of inline menu. To indicate that it is waiting for a long period, 
  1727.    we display animation on pen down position.  Before the animation is finished, user can abort it 
  1728.    by moving away the pen or pen up. */
  1729. #ifdef __MMI_TOUCH_SCREEN__
  1730. static gui_wait_longpress_enum g_mmi_gui_wait_longpress_state = GUI_WAIT_LONGPRESS_UNDECIDED;
  1731. static mmi_pen_point_struct g_mmi_gui_wait_longpress_pen_origin_pos;
  1732. static S16 g_mmi_gui_wait_longpress_animation_frame;
  1733. static S16 g_mmi_gui_wait_longpress_animation_x;
  1734. static S16 g_mmi_gui_wait_longpress_animation_y;
  1735. static S16 g_mmi_gui_wait_longpress_animation_width;
  1736. static S16 g_mmi_gui_wait_longpress_animation_height;
  1737. static U8 g_mmi_gui_wait_longpress_layer_data[GUI_WAIT_LONGPRESS_CACHE_SIZE];
  1738. static gdi_handle *g_mmi_gui_wait_longpress_layer_p = NULL;
  1739. /*****************************************************************************
  1740.  * FUNCTION
  1741.  *  gui_wait_longpress_animation_handler
  1742.  * DESCRIPTION
  1743.  *  
  1744.  * PARAMETERS
  1745.  *  void
  1746.  * RETURNS
  1747.  *  void
  1748.  *****************************************************************************/
  1749. static void gui_wait_longpress_animation_handler(void)
  1750. {
  1751.     /*----------------------------------------------------------------*/
  1752.     /* Local Variables                                                */
  1753.     /*----------------------------------------------------------------*/
  1754.     GDI_RESULT ret;
  1755.     /*----------------------------------------------------------------*/
  1756.     /* Code Body                                                      */
  1757.     /*----------------------------------------------------------------*/
  1758.     MMI_ASSERT(g_mmi_gui_wait_longpress_layer_p);
  1759.     gdi_layer_push_and_set_active(*g_mmi_gui_wait_longpress_layer_p);
  1760.     gdi_layer_lock_frame_buffer();
  1761.     gdi_layer_reset_clip();
  1762.     /* Draw frame */
  1763.     gdi_draw_solid_rect(
  1764.         0,
  1765.         0,
  1766.         g_mmi_gui_wait_longpress_animation_width - 1,
  1767.         g_mmi_gui_wait_longpress_animation_height - 1,
  1768.         GDI_COLOR_TRANSPARENT);
  1769.     ret = gdi_image_draw_animation_single_frame_id(
  1770.             0,
  1771.             0,
  1772.             IMG_PEN_WAITING_LONGPRESS,
  1773.             g_mmi_gui_wait_longpress_animation_frame++);
  1774.     gdi_layer_unlock_frame_buffer();
  1775.     gdi_layer_pop_and_restore_active();
  1776.     gdi_layer_blt_previous(
  1777.         g_mmi_gui_wait_longpress_animation_x,
  1778.         g_mmi_gui_wait_longpress_animation_y,
  1779.         g_mmi_gui_wait_longpress_animation_x + g_mmi_gui_wait_longpress_animation_width - 1,
  1780.         g_mmi_gui_wait_longpress_animation_y + g_mmi_gui_wait_longpress_animation_height - 1);
  1781.     if (ret == GDI_IMAGE_SUCCEED)
  1782.     {
  1783.         gui_start_timer(gdi_image_get_animation_delay(), gui_wait_longpress_animation_handler);
  1784.     }
  1785.     else    /* Including error or GDI_GIF_LAST_FRAME */
  1786.     {
  1787.         /* Just change the state. The actions is triggered by gui_pen_wait_longpress() later */
  1788.         MMI_DBG_ASSERT(g_mmi_gui_wait_longpress_state == GUI_WAIT_LONGPRESS_ANIMATING);
  1789.         g_mmi_gui_wait_longpress_state = GUI_WAIT_LONGPRESS_ANIMATION_FINISHED;
  1790.     }
  1791. }
  1792. /*****************************************************************************
  1793.  * FUNCTION
  1794.  *  gui_wait_longpress_start_animation
  1795.  * DESCRIPTION
  1796.  *  
  1797.  * PARAMETERS
  1798.  *  x       [IN]        
  1799.  *  y       [IN]        
  1800.  * RETURNS
  1801.  *  void
  1802.  *****************************************************************************/
  1803. static void gui_wait_longpress_start_animation(S32 x, S32 y)
  1804. {
  1805.     /*----------------------------------------------------------------*/
  1806.     /* Local Variables                                                */
  1807.     /*----------------------------------------------------------------*/
  1808.     S32 iw, ih;
  1809.     /*----------------------------------------------------------------*/
  1810.     /* Code Body                                                      */
  1811.     /*----------------------------------------------------------------*/
  1812.     gui_measure_image((PU8) GetImage(IMG_PEN_WAITING_LONGPRESS), &iw, &ih);
  1813.     x -= (iw >> 1);
  1814.     y -= (ih >> 1);
  1815.     if (x < 0)
  1816.     {
  1817.         x = 0;
  1818.     }
  1819.     if (y < 0)
  1820.     {
  1821.         y = 0;
  1822.     }
  1823.     g_mmi_gui_wait_longpress_animation_frame = 0;
  1824.     g_mmi_gui_wait_longpress_animation_x = x;
  1825.     g_mmi_gui_wait_longpress_animation_y = y;
  1826.     g_mmi_gui_wait_longpress_animation_width = iw;
  1827.     g_mmi_gui_wait_longpress_animation_height = ih;
  1828.     if (x + iw >= UI_device_width)
  1829.     {
  1830.         g_mmi_gui_wait_longpress_animation_width = UI_device_width - x;
  1831.     }
  1832.     if (y + ih >= UI_device_height)
  1833.     {
  1834.         g_mmi_gui_wait_longpress_animation_height = UI_device_height - y;
  1835.     }
  1836.     if (g_mmi_gui_wait_longpress_layer_p == NULL)
  1837.     {
  1838.         MMI_ASSERT(((iw * ih * gdi_layer_get_bit_per_pixel() + 7) >> 3) <= GUI_WAIT_LONGPRESS_CACHE_SIZE);
  1839.         dm_create_layer_using_outside_memory(
  1840.             x,
  1841.             y,
  1842.             iw, /* full image width */
  1843.             ih, /* full image height */
  1844.             &g_mmi_gui_wait_longpress_layer_p,
  1845.             g_mmi_gui_wait_longpress_layer_data,
  1846.             GUI_WAIT_LONGPRESS_CACHE_SIZE,
  1847.             DM_LAYER_TOP);
  1848.         gdi_layer_push_and_set_active(*g_mmi_gui_wait_longpress_layer_p);
  1849.         gdi_layer_set_source_key(TRUE, GDI_COLOR_TRANSPARENT);
  1850.         gdi_layer_pop_and_restore_active();
  1851.     }
  1852.     else
  1853.     {
  1854.         gdi_layer_push_and_set_active(*g_mmi_gui_wait_longpress_layer_p);
  1855.         gdi_layer_set_position(x, y);
  1856.         gdi_layer_pop_and_restore_active();
  1857.     }
  1858.     /* Because gui_wait_longpress_animation_handler() might  change g_mmi_gui_wait_longpress_state.
  1859.        Start a quick timer to execute it asynchronously */
  1860.     gui_start_timer(10, gui_wait_longpress_animation_handler);
  1861. }
  1862. /*****************************************************************************
  1863.  * FUNCTION
  1864.  *  gui_wait_longpress_stop_animation
  1865.  * DESCRIPTION
  1866.  *  
  1867.  * PARAMETERS
  1868.  *  void
  1869.  * RETURNS
  1870.  *  void
  1871.  *****************************************************************************/
  1872. static void gui_wait_longpress_stop_animation(void)
  1873. {
  1874.     /*----------------------------------------------------------------*/
  1875.     /* Local Variables                                                */
  1876.     /*----------------------------------------------------------------*/
  1877.     /*----------------------------------------------------------------*/
  1878.     /* Code Body                                                      */
  1879.     /*----------------------------------------------------------------*/
  1880.     gui_cancel_timer(gui_wait_longpress_animation_handler);
  1881. }
  1882. /*****************************************************************************
  1883.  * FUNCTION
  1884.  *  gui_wait_longpress_hide_animation
  1885.  * DESCRIPTION
  1886.  *  
  1887.  * PARAMETERS
  1888.  *  void
  1889.  * RETURNS
  1890.  *  void
  1891.  *****************************************************************************/
  1892. static void gui_wait_longpress_hide_animation(void)
  1893. {
  1894.     /*----------------------------------------------------------------*/
  1895.     /* Local Variables                                                */
  1896.     /*----------------------------------------------------------------*/
  1897.     /*----------------------------------------------------------------*/
  1898.     /* Code Body                                                      */
  1899.     /*----------------------------------------------------------------*/
  1900.     if (g_mmi_gui_wait_longpress_layer_p != NULL)
  1901.     {
  1902.         gdi_layer_push_and_set_active(*g_mmi_gui_wait_longpress_layer_p);
  1903.         gdi_layer_lock_frame_buffer();
  1904.         gdi_layer_reset_clip();
  1905.         gdi_draw_solid_rect(
  1906.             0,
  1907.             0,
  1908.             g_mmi_gui_wait_longpress_animation_width - 1,
  1909.             g_mmi_gui_wait_longpress_animation_height - 1,
  1910.             GDI_COLOR_TRANSPARENT);
  1911.         gdi_layer_unlock_frame_buffer();
  1912.         gdi_layer_pop_and_restore_active();
  1913.         gdi_layer_blt_previous(
  1914.             g_mmi_gui_wait_longpress_animation_x,
  1915.             g_mmi_gui_wait_longpress_animation_y,
  1916.             g_mmi_gui_wait_longpress_animation_x + g_mmi_gui_wait_longpress_animation_width - 1,
  1917.             g_mmi_gui_wait_longpress_animation_y + g_mmi_gui_wait_longpress_animation_height - 1);
  1918.     }
  1919. }
  1920. /* Called when screen is switched */
  1921. /*****************************************************************************
  1922.  * FUNCTION
  1923.  *  gui_pen_reset_waiting_longpress
  1924.  * DESCRIPTION
  1925.  *  
  1926.  * PARAMETERS
  1927.  *  void
  1928.  * RETURNS
  1929.  *  void
  1930.  *****************************************************************************/
  1931. static void gui_pen_reset_waiting_longpress(void)
  1932. {
  1933.     /*----------------------------------------------------------------*/
  1934.     /* Local Variables                                                */
  1935.     /*----------------------------------------------------------------*/
  1936.     /*----------------------------------------------------------------*/
  1937.     /* Code Body                                                      */
  1938.     /*----------------------------------------------------------------*/
  1939.     gui_wait_longpress_stop_animation();
  1940.     g_mmi_gui_wait_longpress_layer_p = NULL;
  1941.     g_mmi_gui_wait_longpress_state = GUI_WAIT_LONGPRESS_UNDECIDED;
  1942. }
  1943. /*****************************************************************************
  1944.  * FUNCTION
  1945.  *  gui_pen_wait_longpress
  1946.  * DESCRIPTION
  1947.  *  
  1948.  * PARAMETERS
  1949.  *  pen_event       [IN]        
  1950.  *  x               [IN]        
  1951.  *  y               [IN]        
  1952.  * RETURNS
  1953.  *  
  1954.  *****************************************************************************/
  1955. gui_wait_longpress_enum gui_pen_wait_longpress(mmi_pen_event_type_enum pen_event, S16 x, S16 y)
  1956. {
  1957.     /*----------------------------------------------------------------*/
  1958.     /* Local Variables                                                */
  1959.     /*----------------------------------------------------------------*/
  1960.     /*----------------------------------------------------------------*/
  1961.     /* Code Body                                                      */
  1962.     /*----------------------------------------------------------------*/
  1963.     /* Register GUI clean up hook */
  1964.     gui_add_cleanup_hook(gui_pen_reset_waiting_longpress);
  1965.     if (pen_event == MMI_PEN_EVENT_DOWN)
  1966.     {
  1967.         g_mmi_gui_wait_longpress_state = GUI_WAIT_LONGPRESS_UNDECIDED;
  1968.     }
  1969.     switch (g_mmi_gui_wait_longpress_state)
  1970.     {
  1971.         case GUI_WAIT_LONGPRESS_INVALID:
  1972.             break;
  1973.         case GUI_WAIT_LONGPRESS_UNDECIDED:
  1974.             if (pen_event == MMI_PEN_EVENT_DOWN)
  1975.             {
  1976.                 g_mmi_gui_wait_longpress_pen_origin_pos.x = x;
  1977.                 g_mmi_gui_wait_longpress_pen_origin_pos.y = y;
  1978.             }
  1979.             else if (pen_event == MMI_PEN_EVENT_LONG_TAP)
  1980.             {
  1981.                 /* MMI_PEN_EVENT_LONG_TAP only occurs on pen down position */
  1982.                 g_mmi_gui_wait_longpress_pen_origin_pos.x = x;
  1983.                 g_mmi_gui_wait_longpress_pen_origin_pos.y = y;
  1984.                 gui_wait_longpress_start_animation(x, y);
  1985.                 g_mmi_gui_wait_longpress_state = GUI_WAIT_LONGPRESS_ANIMATING;
  1986.             }
  1987.             else if (PEN_ABS(x, g_mmi_gui_wait_longpress_pen_origin_pos.x) +
  1988.                      PEN_ABS(y, g_mmi_gui_wait_longpress_pen_origin_pos.y) > GUI_WAIT_LONGPRESS_MAX_DISTANCE)
  1989.             {
  1990.                 g_mmi_gui_wait_longpress_state = GUI_WAIT_LONGPRESS_INVALID;
  1991.             }
  1992.             break;
  1993.         case GUI_WAIT_LONGPRESS_ANIMATING:
  1994.             if (pen_event == MMI_PEN_EVENT_UP ||
  1995.                 pen_event == MMI_PEN_EVENT_ABORT ||
  1996.                 (PEN_ABS(x, g_mmi_gui_wait_longpress_pen_origin_pos.x) +
  1997.                  PEN_ABS(y, g_mmi_gui_wait_longpress_pen_origin_pos.y) > GUI_WAIT_LONGPRESS_MAX_DISTANCE))
  1998.             {
  1999.                 gui_wait_longpress_stop_animation();
  2000.                 gui_wait_longpress_hide_animation();
  2001.                 g_mmi_gui_wait_longpress_state = GUI_WAIT_LONGPRESS_INVALID;
  2002.             }
  2003.             break;
  2004.         case GUI_WAIT_LONGPRESS_ANIMATION_FINISHED:
  2005.             gui_wait_longpress_stop_animation();
  2006.             gui_wait_longpress_hide_animation();
  2007.             g_mmi_gui_wait_longpress_state = GUI_WAIT_LONGPRESS_READY;
  2008.             break;
  2009.         case GUI_WAIT_LONGPRESS_READY:
  2010.             /* Return ready only one time */
  2011.             g_mmi_gui_wait_longpress_state = GUI_WAIT_LONGPRESS_INVALID;
  2012.             break;
  2013.         default:
  2014.             MMI_ASSERT(0);
  2015.             break;
  2016.     }
  2017.     return g_mmi_gui_wait_longpress_state;
  2018. }
  2019. #endif /* __MMI_TOUCH_SCREEN__ */