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

MTK

开发平台:

C/C++

  1. /* To use this flag, turn ON EMS_DISPLAY_SPECIAL_CHARACTERS also (outside this file)   */
  2. #define MULTILINE_INPUTBOX_DISPLAY_SPECIAL_CHARACTERS       0
  3. #define MULTILINE_INPUTBOX_USE_GSM_EXTENDED                 1
  4. #if(MULTILINE_INPUTBOX_DISPLAY_SPECIAL_CHARACTERS)
  5. extern const U8 EMS_CR_display_character[];
  6. extern const U8 EMS_LF_display_character[];
  7. extern const U8 EMS_ESC_display_character[];
  8. #endif /* (MULTILINE_INPUTBOX_DISPLAY_SPECIAL_CHARACTERS) */ 
  9. UI_character_type multi_line_input_box_break_characters[] = { ' ',
  10.     /*
  11.      * '.',
  12.      * ',',
  13.      * '\',
  14.      * '/',
  15.      * '-',
  16.      * ':',
  17.      * ';',
  18.      * '?',
  19.      * '!',
  20.      * '|',
  21.      * '+',
  22.      * '=',
  23.      * '_',
  24.      */
  25.     'n'
  26. };
  27. /* Linear search. Should be improved to something else   */
  28. #define UI_MULTI_LINE_INPUT_BOX_BREAK_CHARACTER(c,flag)                                               
  29.       {  S32 _ii_;                                                                                    
  30.          flag=0;                                                                                      
  31.          for(_ii_=0;_ii_<UI_MULTI_LINE_INPUT_BOX_NUMBER_OF_BREAK_CHARACTERS;_ii_++)                   
  32.          {  if((UI_character_type)c==(UI_character_type)multi_line_input_box_break_characters[_ii_])  
  33.             {  flag=1;                                                                                
  34.                break;                                                                                 
  35.             }                                                                                         
  36.          }                                                                                            
  37.       }
  38. #define UI_MULTI_LINE_INPUT_BOX_SPACE_CHARACTER(c) (((UI_character_type)(c)==(UI_character_type)' ')?(1):(0))
  39. /* Basic Latin,Latin 1,Latin Extended A, Latin Extended B */
  40. /* Cyrillic */
  41. /* Latin Extended Additional  */
  42. /* Combining Marks  */
  43. /* Basic Arabic  */
  44. /* Arabic Presentation Forms-A */
  45. /* Arabic Presentation Forms-B */
  46. #define UI_MULTI_LINE_INPUT_BOX_ALPHABETIC_CHARACTER(c)                                                              
  47.    ((((UI_character_type)(c)<=(UI_character_type)0x0240) ||                                                          
  48.    ( ((UI_character_type)(c)>=(UI_character_type)0x0400) && ((UI_character_type)(c)<=(UI_character_type)0x04FF) ) || 
  49.    ( ((UI_character_type)(c)>=(UI_character_type)0x1E00) && ((UI_character_type)(c)<=(UI_character_type)0x1EFF) ) || 
  50.    ( ((UI_character_type)(c)>=(UI_character_type)0x0300) && ((UI_character_type)(c)<=(UI_character_type)0x036F) ) || 
  51.    ( ((UI_character_type)(c)>=(UI_character_type)0x0621) && ((UI_character_type)(c)<=(UI_character_type)0x0653) ) || 
  52.    ( ((UI_character_type)(c)>=(UI_character_type)0xFB50) && ((UI_character_type)(c)<=(UI_character_type)0xFDFF) ) || 
  53.    ( ((UI_character_type)(c)>=(UI_character_type)0xFE70) && ((UI_character_type)(c)<=(UI_character_type)0xFEFF) ) )?(1):(0))
  54. #define UI_MULTI_LINE_INPUT_BOX_MOVE_TEXT_CURSOR(x,y)                                        
  55.       {                                                                                      
  56.          UI_text_x=x;                                                                        
  57.          UI_text_y=y;                                                                        
  58.       }
  59. #define UI_MULTI_LINE_INPUT_BOX_SET_TEXT_COLOR(c)                                            
  60.       {                                                                                      
  61.          UI_text_color=c;                                                                    
  62.       }
  63. #define UI_MULTI_LINE_INPUT_BOX_DRAW_CURSOR(x,y,height,c)                                       
  64.       {                                                                                         
  65.          gui_fill_rectangle((x)-1,( y),(x),(y)+(height)-1,c);                                   
  66.       }
  67. #define MULTI_LINE_INPUT_BOX_CHARACTER_WIDTH_CACHE_SIZE  ((UI_device_width)>>1)
  68. #define UI_TEST_GRP_SEP_CHARACTER(c)            (((UI_character_type)(c)==(UI_character_type)0x1D)?(1):(0))
  69. #define UI_TEST_FILE_SEP_CHARACTER(c)           (((UI_character_type)(c)==(UI_character_type)0x1C)?(1):(0))
  70. #define UI_TEST_SENDER_TRUNCATE_SEP_CHARACTER(c)   (((UI_character_type)(c)==(UI_character_type)0x1E)?(1):(0))
  71. #define UI_TEST_RECEIVER_TRUNCATE_SEP_CHARACTER(c)  (((UI_character_type)(c)==(UI_character_type)0x1F)?(1):(0))
  72. /*****************************************************************************
  73.  * FUNCTION
  74.  *  gui_multi_line_input_box_show_cursor
  75.  * DESCRIPTION
  76.  *  show cursor of  multiline input box
  77.  * PARAMETERS
  78.  *  b           [IN]        Is the multi-line inputbox object
  79.  *  x           [IN]        
  80.  *  y           [IN]        
  81.  *  height      [IN]        
  82.  *  clip_x1     [IN]        
  83.  *  clip_y1     [IN]        
  84.  *  clip_x2     [IN]        
  85.  *  clip_y2     [IN]        
  86.  * RETURNS
  87.  *  void
  88.  *****************************************************************************/
  89. /* MTK Elvis to fix the cursor clip issue */
  90. #if 0
  91. /* under construction !*/
  92. /* under construction !*/
  93. /* under construction !*/
  94. /* under construction !*/
  95. /* under construction !*/
  96. #if(UI_BLINKING_CURSOR_SUPPORT)
  97. /* under construction !*/
  98. #else
  99. /* under construction !*/
  100. #endif
  101. /* under construction !*/
  102. #endif /* 0 */ 
  103. void gui_multi_line_input_box_show_cursor(
  104.         multi_line_input_box *b,
  105.         S32 x,
  106.         S32 y,
  107.         S32 height,
  108.         S32 clip_x1,
  109.         S32 clip_y1,
  110.         S32 clip_x2,
  111.         S32 clip_y2)
  112. {
  113.     /*----------------------------------------------------------------*/
  114.     /* Local Variables                                                */
  115.     /*----------------------------------------------------------------*/
  116.     color c = b->cursor_color;
  117.     /*----------------------------------------------------------------*/
  118.     /* Code Body                                                      */
  119.     /*----------------------------------------------------------------*/
  120.     /* W06.06 Fix Cursor Clipping issue when storing cursor area to bmp */
  121.     gdi_layer_push_clip();
  122.     gdi_layer_set_clip(clip_x1, clip_y1, clip_x2, clip_y2);
  123.     if (x > clip_x2)
  124.     {
  125.         x = clip_x2;
  126.     }
  127.     x--;
  128.     if (x < clip_x1)
  129.     {
  130.         x = clip_x1;
  131.     }
  132.     if (y < clip_y1)
  133.     {
  134.         height -= (clip_y1 - y);
  135.         y = clip_y1 + 1;
  136.     }
  137.     if ((y + height - 1) > clip_y2)
  138.     {
  139.         height -= (y + height - 1) - clip_y2;
  140.     }
  141. #if(UI_BLINKING_CURSOR_SUPPORT)
  142.     UI_inputbox_show_cursor(x, y, x + 1, y + height - 1, c);
  143. #else 
  144.     gui_fill_rectangle(x, y, x + 1, y + height - 1, c);
  145. #endif 
  146.     gdi_layer_pop_clip();
  147. }
  148. /* MTK end */
  149. /*****************************************************************************
  150.  * FUNCTION
  151.  *  gui_set_multi_line_input_box_current_theme
  152.  * DESCRIPTION
  153.  *  Applies the current theme to the multi-line inputbox
  154.  * PARAMETERS
  155.  *  b       [IN]        Is the multi-line inputbox object
  156.  * RETURNS
  157.  *  void
  158.  *****************************************************************************/
  159. void gui_set_multi_line_input_box_current_theme(multi_line_input_box *b)
  160. {
  161.     /*----------------------------------------------------------------*/
  162.     /* Local Variables                                                */
  163.     /*----------------------------------------------------------------*/
  164.     /*----------------------------------------------------------------*/
  165.     /* Code Body                                                      */
  166.     /*----------------------------------------------------------------*/
  167.     b->normal_filler = current_multi_line_input_box_theme->normal_filler;
  168.     b->disabled_filler = current_multi_line_input_box_theme->disabled_filler;
  169.     b->focussed_filler = current_multi_line_input_box_theme->selected_filler;
  170.     b->text_filler = NULL;  /* Disabled by default */
  171.     b->special_text_color = current_multi_line_input_box_theme->special_text_color;
  172.     b->normal_text_color = current_multi_line_input_box_theme->normal_text_color;
  173.     b->disabled_text_color = current_multi_line_input_box_theme->disabled_text_color;
  174.     b->focussed_text_color = current_multi_line_input_box_theme->selected_text_color;
  175.     b->selector_color = current_multi_line_input_box_theme->selection_color;
  176.     b->selected_text_color = current_multi_line_input_box_theme->selection_text_color;
  177.     b->cursor_color = current_multi_line_input_box_theme->cursor_color;
  178.     b->text_font = current_multi_line_input_box_theme->text_font;
  179.     b->mask_character = current_multi_line_input_box_theme->mask_character;
  180.     b->text_gap = current_multi_line_input_box_theme->text_gap;
  181.     b->flags |= current_multi_line_input_box_theme->flags;
  182. }
  183. /*****************************************************************************
  184.  * FUNCTION
  185.  *  gui_set_multi_line_input_box_theme
  186.  * DESCRIPTION
  187.  *  Applies the given theme to the multi-line inputbox
  188.  * PARAMETERS
  189.  *  b       [IN]        Is the multi-line inputbox object
  190.  *  t       [?]         
  191.  * RETURNS
  192.  *  void
  193.  *****************************************************************************/
  194. void gui_set_multi_line_input_box_theme(multi_line_input_box *b, UI_multi_line_input_box_theme *t)
  195. {
  196.     /*----------------------------------------------------------------*/
  197.     /* Local Variables                                                */
  198.     /*----------------------------------------------------------------*/
  199.     /*----------------------------------------------------------------*/
  200.     /* Code Body                                                      */
  201.     /*----------------------------------------------------------------*/
  202.     b->normal_filler = t->normal_filler;
  203.     b->disabled_filler = t->disabled_filler;
  204.     b->focussed_filler = t->selected_filler;
  205.     b->text_filler = NULL;  /* Disabled by default */
  206.     b->special_text_color = t->special_text_color;
  207.     b->normal_text_color = t->normal_text_color;
  208.     b->disabled_text_color = t->disabled_text_color;
  209.     b->focussed_text_color = t->selected_text_color;
  210.     b->boundary_color = t->boundary_color;
  211.     b->selector_color = t->selection_color;
  212.     b->selected_text_color = t->selection_text_color;
  213.     b->cursor_color = t->cursor_color;
  214.     b->text_font = t->text_font;
  215.     b->text_gap = t->text_gap;
  216.     b->mask_character = t->mask_character;
  217.     b->flags |= t->flags;
  218. }
  219. /*****************************************************************************
  220.  * FUNCTION
  221.  *  gui_multi_line_input_box_clear
  222.  * DESCRIPTION
  223.  *  Initilize the multi-line inputbox to default
  224.  * PARAMETERS
  225.  *  b       [IN]        Is the multi-line inputbox object
  226.  * RETURNS
  227.  *  void
  228.  *****************************************************************************/
  229. void gui_multi_line_input_box_clear(multi_line_input_box *b)
  230. {
  231.     /*----------------------------------------------------------------*/
  232.     /* Local Variables                                                */
  233.     /*----------------------------------------------------------------*/
  234.     /*----------------------------------------------------------------*/
  235.     /* Code Body                                                      */
  236.     /*----------------------------------------------------------------*/
  237.     if (b->text == NULL)
  238.     {
  239.         b->text_length = 0;
  240.         b->allocated_length = 0;
  241.         b->available_length = 0;
  242.         return;
  243.     }
  244.     else
  245.     {
  246.         b->text[0] = '';
  247.         b->text[1] = 0;
  248.         b->text_length = 2;
  249.     }
  250.     b->cursor_p = b->text;
  251.     b->last_position_p = b->text;
  252.     b->UCS2_count = 0;
  253.     b->GSM_ext_count = 0;
  254.     if (b->flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  255.     {
  256.         b->available_length = b->allocated_length;
  257.     }
  258. }
  259. /*****************************************************************************
  260.  * FUNCTION
  261.  *  gui_create_multi_line_input_box
  262.  * DESCRIPTION
  263.  *  Creates a multi-line inputbox object
  264.  *  Starts with an empty string
  265.  *  
  266.  *  See also gui_destroy_multi_line_input_box()
  267.  * PARAMETERS
  268.  *  b           [IN]        Is the multi-line inputbox object   (pre-allocated)
  269.  *  x           [IN]        Is the left-top corner
  270.  *  y           [IN]        Is the left-top corner
  271.  *  width       [IN]        Is the width of the multi-line inputbox
  272.  *  height      [IN]        Is the height of the multi-line inputbox
  273.  *  length      [IN]        Is the length of the buffer         (auto-allocated)
  274.  * RETURNS
  275.  *  void
  276.  *****************************************************************************/
  277. void gui_create_multi_line_input_box(multi_line_input_box *b, S32 x, S32 y, S32 width, S32 height, U32 length)
  278. {
  279.     /*----------------------------------------------------------------*/
  280.     /* Local Variables                                                */
  281.     /*----------------------------------------------------------------*/
  282.     /*----------------------------------------------------------------*/
  283.     /* Code Body                                                      */
  284.     /*----------------------------------------------------------------*/
  285.     b->x = x;
  286.     b->y = y;
  287.     b->width = width;
  288.     b->height = height;
  289.     b->text = (UI_buffer_type) gui_malloc(length * sizeof(UI_character_type));
  290.     b->allocated_length = length;
  291.     b->available_length = length;
  292.     gui_multi_line_input_box_clear(b);  /* show multi line input box to defualt values */
  293.     b->flags = 0;
  294.     b->UCS2_count = 0;
  295.     b->GSM_ext_count = 0;
  296.     b->editor_changed = 0;              /* Gurinder - Variable Added In MultiLine Inputbox */
  297.     b->cursor_p = b->text;
  298.     b->n_lines = 0;
  299.     b->cursor_line_position_counter = 0;
  300.     b->cursor_x = 0;
  301.     b->cursor_y = 0;
  302.     b->text_offset_x = 0;
  303.     b->text_offset_y = 0;
  304.     /* set theme of multiline input box */
  305.     gui_set_multi_line_input_box_current_theme(b);
  306.     b->text_x = 2 + b->text_gap;
  307.     b->text_y = 2;
  308.     b->text_x2_gap_width = 0;
  309.     b->edit_width = b->width - (b->text_x + b->text_x2_gap_width);
  310.     b->edit_height = b->height - (b->text_y * 2);
  311.     b->overflow_callback = UI_dummy_function;
  312.     b->change_callback = UI_dummy_function;
  313.     b->validation_callback = UI_dummy_validation_function;
  314.     /* create vertial scroll bar */
  315.     gui_create_vertical_scrollbar(
  316.         &b->vbar,
  317.         b->x + b->width - current_multi_line_input_box_theme->vbar_width - 1,
  318.         b->y + 1,
  319.         current_multi_line_input_box_theme->vbar_width,
  320.         b->height - 2);
  321.     if (!(b->flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR))
  322.     {
  323.         b->edit_width -= b->vbar.width;
  324.     }
  325.     b->min_text_height = 0;
  326.     b->max_empty_text_height = 0;
  327.     b->min_line_height = 0;
  328.     b->header_height = 0;
  329.     b->footer_height = 0;
  330.     gui_multi_line_input_box_register_infobar_callback(b,NULL,NULL,0);
  331.     b->header_callback = NULL;
  332.     b->footer_callback = NULL;
  333.     b->icon_callback = NULL;
  334.     b->change_event_handler = NULL;
  335. #ifdef __MMI_TOUCH_SCREEN__
  336.     b->pen_scroll_delay_time = 0;
  337.     b->pen_scroll_after_delay = -1;
  338.     memset(&(b->pen_state), 0, sizeof(gui_multi_line_input_box_pen_state_struct));
  339. #endif /* __MMI_TOUCH_SCREEN__ */ 
  340. }
  341. /*****************************************************************************
  342.  * FUNCTION
  343.  *  gui_create_multi_line_input_box_use_buffer
  344.  * DESCRIPTION
  345.  *  Creates a multi-line inputbox object with a user specifed buffer
  346.  *  Starts with an empty string
  347.  * PARAMETERS
  348.  *  b           [IN]        Is the multi-line inputbox object   (pre-allocated)
  349.  *  x           [IN]        Is the left-top corner
  350.  *  y           [IN]        Is the left-top corner
  351.  *  width       [IN]        Is the width of the multi-line inputbox
  352.  *  height      [IN]        Is the height of the multi-line inputbox
  353.  *  buffer      [IN]        Is a pointer to the text buffer to use (pre-allocated)
  354.  *  length      [IN]        Is the length of the buffer
  355.  * RETURNS
  356.  *  void
  357.  *****************************************************************************/
  358. void gui_create_multi_line_input_box_use_buffer(
  359.         multi_line_input_box *b,
  360.         S32 x,
  361.         S32 y,
  362.         S32 width,
  363.         S32 height,
  364.         UI_string_type buffer,
  365.         S32 length)
  366. {
  367.     /*----------------------------------------------------------------*/
  368.     /* Local Variables                                                */
  369.     /*----------------------------------------------------------------*/
  370.     /*----------------------------------------------------------------*/
  371.     /* Code Body                                                      */
  372.     /*----------------------------------------------------------------*/
  373.     b->x = x;
  374.     b->y = y;
  375.     b->width = width;
  376.     b->height = height;
  377.     b->text = (UI_buffer_type) buffer;
  378.     b->allocated_length = length;
  379.     b->available_length = length;
  380.     b->flags = 0;
  381.     gui_multi_line_input_box_clear(b);
  382.     b->UCS2_count = 0;
  383.     b->GSM_ext_count = 0;
  384.     b->editor_changed = 0;  /* Justin WCSS editor */
  385.     b->cursor_p = b->text;
  386.     b->n_lines = 0;
  387.     b->cursor_line_position_counter = 0;
  388.     b->cursor_x = 0;
  389.     b->cursor_y = 0;
  390.     b->text_offset_x = 0;
  391.     b->text_offset_y = 0;
  392.     /* set theme of multiline input box */
  393.     gui_set_multi_line_input_box_current_theme(b);
  394.     b->text_x = 2 + b->text_gap;
  395.     b->text_y = 2;
  396.     b->text_x2_gap_width = 0;
  397.     b->edit_width = b->width - (b->text_x + b->text_x2_gap_width);
  398.     b->edit_height = b->height - (b->text_y * 2);
  399.     b->overflow_callback = UI_dummy_function;
  400.     b->change_callback = UI_dummy_function;
  401.     b->validation_callback = UI_dummy_validation_function;
  402.     /* create vertical scroll  bar */
  403.     gui_create_vertical_scrollbar(
  404.         &b->vbar,
  405.         b->x + b->width - current_multi_line_input_box_theme->vbar_width - 1,
  406.         b->y + 1,
  407.         current_multi_line_input_box_theme->vbar_width,
  408.         b->height - 2);
  409.     if (!(b->flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR))
  410.     {
  411.         b->edit_width -= b->vbar.width;
  412.     }
  413.     b->min_text_height = 0;
  414.     b->max_empty_text_height = 0;
  415.     b->min_line_height = 0;
  416.     b->header_height = 0;
  417.     b->footer_height = 0;
  418.     gui_multi_line_input_box_register_infobar_callback(b,NULL,NULL,0);
  419.     b->header_callback = NULL;
  420.     b->footer_callback = NULL;
  421.     b->icon_callback = NULL;
  422.     b->change_event_handler = NULL;
  423. #ifdef __MMI_TOUCH_SCREEN__
  424.     b->pen_scroll_delay_time = 0;
  425.     b->pen_scroll_after_delay = -1;
  426.     memset(&(b->pen_state), 0, sizeof(gui_multi_line_input_box_pen_state_struct));
  427. #endif /* __MMI_TOUCH_SCREEN__ */ 
  428. }
  429. /*****************************************************************************
  430.  * FUNCTION
  431.  *  gui_create_multi_line_input_box_set_buffer
  432.  * DESCRIPTION
  433.  *  Creates a multi-line inputbox object,
  434.  *  Starts with a given string and allows the user to edit it.
  435.  * PARAMETERS
  436.  *  b                   [IN]        Is the multi-line inputbox object   (pre-allocated)
  437.  *  x                   [IN]        Is the left-top corner
  438.  *  y                   [IN]        Is the left-top corner
  439.  *  width               [IN]        Is the width of the multi-line inputbox
  440.  *  height              [IN]        Is the height of the multi-line inputbox
  441.  *  buffer              [IN]        Is the buffer to use          (pre-allocated)
  442.  *  length              [IN]        Is the length of the buffer         (buffer size)
  443.  *  text_length         [IN]        Is the number of characters in the text
  444.  *  edit_position       [IN]        Is the start position of the cursor
  445.  *  Note(?)             [IN]        The buffer should contain a valid string.
  446.  * RETURNS
  447.  *  void
  448.  *****************************************************************************/
  449. void gui_create_multi_line_input_box_set_buffer(
  450.         multi_line_input_box *b,
  451.         S32 x,
  452.         S32 y,
  453.         S32 width,
  454.         S32 height,
  455.         UI_string_type buffer,
  456.         S32 length,
  457.         S32 text_length,
  458.         S32 edit_position)
  459. {
  460.     /*----------------------------------------------------------------*/
  461.     /* Local Variables                                                */
  462.     /*----------------------------------------------------------------*/
  463.     S32 i;
  464.     /* MTK Elvis to init this parameter */
  465.     UI_character_type dummy_c = '';
  466.     /* MTK end */
  467.     UI_buffer_type text;
  468.     /*----------------------------------------------------------------*/
  469.     /* Code Body                                                      */
  470.     /*----------------------------------------------------------------*/
  471.     b->x = x;
  472.     b->y = y;
  473.     b->width = width;
  474.     b->height = height;
  475.     b->text = (UI_buffer_type) buffer;
  476.     b->allocated_length = length;
  477.     b->available_length = length;
  478.     b->text_length = text_length;
  479.     b->flags = 0;
  480.     b->ext_flags = 0;
  481.     b->UCS2_count = 0;
  482.     b->GSM_ext_count = 0;
  483.     b->editor_changed = 0;  /* Justin WCSS editor */
  484.     b->n_lines = 0;
  485.     b->cursor_line_position_counter = 0;
  486.     b->cursor_x = 0;
  487.     b->cursor_y = 0;
  488.     b->text_offset_x = 0;
  489.     b->text_offset_y = 0;
  490.     b->cursor_p = b->text;
  491.     
  492.     b->show_action_flag = 1;
  493.     
  494.     if (b->text != NULL)
  495.     {
  496.         text = b->text;
  497.         UI_STRING_GET_NEXT_CHARACTER(text, dummy_c);
  498.         text = b->text;
  499.         for (i = 0; i < edit_position; i++)
  500.         {
  501.             UI_STRING_GET_NEXT_CHARACTER(text, dummy_c);
  502.             UI_TEST_UCS2_INCREMENT_COUNT(dummy_c, b->UCS2_count);
  503.             if (UI_STRING_END_OF_STRING_CHARACTER(dummy_c))
  504.             {
  505.                 break;
  506.             }
  507.             if (UI_TEST_GSM_EXTENDED(dummy_c))
  508.             {
  509.                 b->GSM_ext_count++;
  510.             }
  511.         }
  512.         b->cursor_p = text;
  513.         for (i = edit_position; !UI_STRING_END_OF_STRING_CHARACTER(dummy_c); i++)
  514.         {
  515.             UI_STRING_GET_NEXT_CHARACTER(text, dummy_c);
  516.             UI_TEST_UCS2_INCREMENT_COUNT(dummy_c, b->UCS2_count);
  517.             if (UI_TEST_GSM_EXTENDED(dummy_c))
  518.             {
  519.                 b->GSM_ext_count++;
  520.             }
  521.         }
  522.         b->last_position_p = b->cursor_p;
  523.     }
  524.     /* set theme of multiline input bx */
  525.     gui_set_multi_line_input_box_current_theme(b);
  526.     b->text_x = 2 + b->text_gap;
  527.     b->text_y = 2;
  528.     b->text_x2_gap_width = 0;
  529.     b->edit_width = b->width - (b->text_x + b->text_x2_gap_width);
  530.     b->edit_height = b->height - (b->text_y * 2);
  531.     b->overflow_callback = UI_dummy_function;
  532.     b->change_callback = UI_dummy_function;
  533.     b->validation_callback = UI_dummy_validation_function;
  534.     if (!(b->flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR))
  535.     {
  536.         gui_create_vertical_scrollbar(
  537.             &b->vbar,
  538.             b->x + b->width - current_multi_line_input_box_theme->vbar_width - 1,
  539.             b->y + 1,
  540.             current_multi_line_input_box_theme->vbar_width,
  541.             b->height - 2);
  542.         b->edit_width -= b->vbar.width;
  543.     }
  544.     b->min_text_height = 0;
  545.     b->max_empty_text_height = 0;
  546.     b->min_line_height = 0;
  547.     b->header_height = 0;
  548.     b->footer_height = 0;
  549.     gui_multi_line_input_box_register_infobar_callback(b,NULL,NULL,0);
  550.     b->header_callback = NULL;
  551.     b->footer_callback = NULL;
  552.     b->icon_callback = NULL;
  553.     b->change_event_handler = NULL;
  554.     
  555.     /* barcode */
  556.     b->current_hilite_idx = 0;
  557.     b->curr_hilite_text_offset_y = 0;
  558.     b->hilite_list = NULL;
  559.     b->hilite_cb = NULL;
  560. #ifdef __MMI_TOUCH_SCREEN__
  561.     b->pen_scroll_delay_time = 0;
  562.     b->pen_scroll_after_delay = -1;
  563.     memset(&(b->pen_state), 0, sizeof(gui_multi_line_input_box_pen_state_struct));
  564. #endif /* __MMI_TOUCH_SCREEN__ */ 
  565. #if defined(__UI_PAGING_IN_MULTILINE_EDITOR__)
  566.     b->last_page_flag = 0;
  567. #endif 
  568. }
  569. //Gurinder - 5/5/2004 Inline Multiline Box History Control
  570. //Duplicate Function With No Position Reset.
  571. /*****************************************************************************
  572.  * FUNCTION
  573.  *  gui_create_multi_line_input_box_set_buffer_no_text_reset
  574.  * DESCRIPTION
  575.  *  
  576.  * PARAMETERS
  577.  *  b                   [?]         
  578.  *  x                   [IN]        
  579.  *  y                   [IN]        
  580.  *  width               [IN]        
  581.  *  height              [IN]        
  582.  *  buffer              [IN]        
  583.  *  length              [IN]        
  584.  *  text_length         [IN]        
  585.  *  edit_position       [IN]        
  586.  * RETURNS
  587.  *  void
  588.  *****************************************************************************/
  589. void gui_create_multi_line_input_box_set_buffer_no_text_reset(
  590.         multi_line_input_box *b,
  591.         S32 x,
  592.         S32 y,
  593.         S32 width,
  594.         S32 height,
  595.         UI_string_type buffer,
  596.         S32 length,
  597.         S32 text_length,
  598.         S32 edit_position)
  599. {
  600.     /*----------------------------------------------------------------*/
  601.     /* Local Variables                                                */
  602.     /*----------------------------------------------------------------*/
  603.     S32 i;
  604.     UI_character_type dummy_c = 0;
  605.     UI_buffer_type text;
  606.     /*----------------------------------------------------------------*/
  607.     /* Code Body                                                      */
  608.     /*----------------------------------------------------------------*/
  609.     b->x = x;
  610.     b->y = y;
  611.     b->width = width;
  612.     b->height = height;
  613.     b->text = (UI_buffer_type) buffer;
  614.     b->allocated_length = length;
  615.     b->available_length = length;
  616.     b->text_length = text_length;
  617.     b->flags = 0;
  618.     b->UCS2_count = 0;
  619.     b->GSM_ext_count = 0;
  620.     b->cursor_p = b->text;
  621.     if (b->text != NULL)
  622.     {
  623.         text = b->text;
  624.         for (i = 0; i < edit_position; i++)
  625.         {
  626.             UI_STRING_GET_NEXT_CHARACTER(text, dummy_c);
  627.             UI_TEST_UCS2_INCREMENT_COUNT(dummy_c, b->UCS2_count);
  628.             if (UI_STRING_END_OF_STRING_CHARACTER(dummy_c))
  629.             {
  630.                 break;
  631.             }
  632.             if (UI_TEST_GSM_EXTENDED(dummy_c))
  633.             {
  634.                 b->GSM_ext_count++;
  635.             }
  636.         }
  637.         b->cursor_p = text;
  638.         for (i = edit_position; !UI_STRING_END_OF_STRING_CHARACTER(dummy_c); i++)
  639.         {
  640.             UI_STRING_GET_NEXT_CHARACTER(text, dummy_c);
  641.             UI_TEST_UCS2_INCREMENT_COUNT(dummy_c, b->UCS2_count);
  642.             if (UI_TEST_GSM_EXTENDED(dummy_c))
  643.             {
  644.                 b->GSM_ext_count++;
  645.             }
  646.         }
  647.         b->last_position_p = b->cursor_p;
  648.     }
  649.     /* set theme of multiline input bx */
  650.     gui_set_multi_line_input_box_current_theme(b);
  651.     b->text_x = 2 + b->text_gap;
  652.     b->text_y = 2;
  653.     b->text_x2_gap_width = 0;
  654.     b->edit_width = b->width - (b->text_x + b->text_x2_gap_width);
  655.     b->edit_height = b->height - (b->text_y * 2);
  656.     b->overflow_callback = UI_dummy_function;
  657.     b->change_callback = UI_dummy_function;
  658.     b->validation_callback = UI_dummy_validation_function;
  659.     gui_create_vertical_scrollbar(
  660.         &b->vbar,
  661.         b->x + b->width - current_multi_line_input_box_theme->vbar_width - 1,
  662.         b->y + 1,
  663.         current_multi_line_input_box_theme->vbar_width,
  664.         b->height - 2);
  665.     if (!(b->flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR))
  666.     {
  667.         b->edit_width -= b->vbar.width;
  668.     }
  669.     b->min_text_height = 0;
  670.     b->max_empty_text_height = 0;
  671.     b->min_line_height = 0;
  672.     b->header_height = 0;
  673.     b->footer_height = 0;
  674.     gui_multi_line_input_box_register_infobar_callback(b,NULL,NULL,0);
  675.     b->header_callback = NULL;
  676.     b->footer_callback = NULL;
  677.     b->icon_callback = NULL;
  678.     b->change_event_handler = NULL;
  679. #ifdef __MMI_TOUCH_SCREEN__
  680.     b->pen_scroll_delay_time = 0;
  681.     b->pen_scroll_after_delay = -1;
  682.     memset(&(b->pen_state), 0, sizeof(gui_multi_line_input_box_pen_state_struct));
  683. #endif /* __MMI_TOUCH_SCREEN__ */ 
  684. }
  685. /*****************************************************************************
  686.  * FUNCTION
  687.  *  gui_move_multi_line_input_box
  688.  * DESCRIPTION
  689.  *  Moves a multi-line input box
  690.  * PARAMETERS
  691.  *  b       [IN]        Is the multi-line inputbox object
  692.  *  x       [IN]        Is the new position (left-top corner)
  693.  *  y       [IN]        Is the new position (left-top corner)
  694.  * RETURNS
  695.  *  void
  696.  *****************************************************************************/
  697. void gui_move_multi_line_input_box(multi_line_input_box *b, S32 x, S32 y)
  698. {
  699.     /*----------------------------------------------------------------*/
  700.     /* Local Variables                                                */
  701.     /*----------------------------------------------------------------*/
  702.     /*----------------------------------------------------------------*/
  703.     /* Code Body                                                      */
  704.     /*----------------------------------------------------------------*/
  705.     b->x = x;
  706.     b->y = y;
  707.     gui_move_vertical_scrollbar(&b->vbar, b->x + b->width - b->vbar.width, b->y + 1);
  708. }
  709. /*****************************************************************************
  710.  * FUNCTION
  711.  *  gui_resize_multi_line_input_box
  712.  * DESCRIPTION
  713.  *  Moves a multi-line input box
  714.  * PARAMETERS
  715.  *  b           [IN]        Is the multi-line inputbox object
  716.  *  width       [IN]        
  717.  *  height      [IN]        
  718.  *  x(?)        [IN]        Is the new position (left-top corner)
  719.  *  y(?)        [IN]        Is the new position (left-top corner)
  720.  * RETURNS
  721.  *  void
  722.  *****************************************************************************/
  723. void gui_resize_multi_line_input_box(multi_line_input_box *b, S32 width, S32 height)
  724. {
  725.     /*----------------------------------------------------------------*/
  726.     /* Local Variables                                                */
  727.     /*----------------------------------------------------------------*/
  728.     /*----------------------------------------------------------------*/
  729.     /* Code Body                                                      */
  730.     /*----------------------------------------------------------------*/
  731.     b->width = width;
  732.     b->height = height;
  733.     b->edit_width = b->width - (b->text_x + b->text_x2_gap_width);
  734.     b->edit_height = b->height - (b->text_y * 2);
  735.     gui_move_vertical_scrollbar(&b->vbar, b->x + b->width - b->vbar.width - 1, b->y + 1);
  736.     gui_resize_vertical_scrollbar(&b->vbar, b->vbar.width, b->height - 2);
  737.     if (!(b->flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR))
  738.     {
  739.         b->edit_width -= b->vbar.width;
  740.     }
  741.     b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  742.     gui_show_multi_line_input_box(b);   /* show multiline input box */
  743.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  744. }
  745. /*****************************************************************************
  746.  * FUNCTION
  747.  *  gui_multi_line_input_box_test_overflow
  748.  * DESCRIPTION
  749.  *  check for overflow of multiline input box
  750.  * PARAMETERS
  751.  *  b       [IN]        Is the multi-line inputbox object
  752.  * RETURNS
  753.  *  byte
  754.  *****************************************************************************/
  755. U8 gui_multi_line_input_box_test_overflow(multi_line_input_box *b)
  756. {
  757.     /*----------------------------------------------------------------*/
  758.     /* Local Variables                                                */
  759.     /*----------------------------------------------------------------*/
  760.     /*----------------------------------------------------------------*/
  761.     /* Code Body                                                      */
  762.     /*----------------------------------------------------------------*/
  763.     if ((b->last_position_p - b->text) >= (b->available_length))
  764.     {
  765.         return (1);
  766.     }
  767.     return (0);
  768. }
  769. /*****************************************************************************
  770.  * FUNCTION
  771.  *  gui_multi_line_input_box_test_first_position
  772.  * DESCRIPTION
  773.  *  check forif cursor is at first position of  multiline input box
  774.  * PARAMETERS
  775.  *  b       [IN]        Is the multi-line inputbox object
  776.  * RETURNS
  777.  *  byte
  778.  *****************************************************************************/
  779. U8 gui_multi_line_input_box_test_first_position(multi_line_input_box *b)
  780. {
  781.     /*----------------------------------------------------------------*/
  782.     /* Local Variables                                                */
  783.     /*----------------------------------------------------------------*/
  784.     /*----------------------------------------------------------------*/
  785.     /* Code Body                                                      */
  786.     /*----------------------------------------------------------------*/
  787.     if (b->cursor_p == b->text)
  788.     {
  789.         return (1);
  790.     }
  791.     return (0);
  792. }
  793. /*****************************************************************************
  794.  * FUNCTION
  795.  *  gui_multi_line_input_box_test_last_position
  796.  * DESCRIPTION
  797.  *  check forif cursor is at last  position of  multiline input box
  798.  * PARAMETERS
  799.  *  b       [IN]        Is the multi-line inputbox object
  800.  * RETURNS
  801.  *  byte
  802.  *****************************************************************************/
  803. U8 gui_multi_line_input_box_test_last_position(multi_line_input_box *b)
  804. {
  805.     /*----------------------------------------------------------------*/
  806.     /* Local Variables                                                */
  807.     /*----------------------------------------------------------------*/
  808.     UI_character_type dummy_c = 0;
  809.     UI_buffer_type current_text_p = b->cursor_p;
  810.     /*----------------------------------------------------------------*/
  811.     /* Code Body                                                      */
  812.     /*----------------------------------------------------------------*/
  813.     UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
  814.     UI_UNUSED_PARAMETER(dummy_c);
  815.     if (current_text_p == b->last_position_p)
  816.     {
  817.         return (1);
  818.     }
  819.     return (0);
  820. }
  821. /*****************************************************************************
  822.  * FUNCTION
  823.  *  gui_multi_line_input_box_test_last_position_overflow
  824.  * DESCRIPTION
  825.  *  check forif cursor is at last  position of  multiline input box
  826.  * PARAMETERS
  827.  *  b       [IN]        Is the multi-line inputbox object
  828.  * RETURNS
  829.  *  byte
  830.  *****************************************************************************/
  831. U8 gui_multi_line_input_box_test_last_position_overflow(multi_line_input_box *b)
  832. {
  833.     /*----------------------------------------------------------------*/
  834.     /* Local Variables                                                */
  835.     /*----------------------------------------------------------------*/
  836.     U8 flag1 = 0;
  837.     U8 flag2 = 0;
  838.     UI_character_type dummy_c = 0;
  839.     UI_buffer_type current_text_p = b->cursor_p;
  840.     /*----------------------------------------------------------------*/
  841.     /* Code Body                                                      */
  842.     /*----------------------------------------------------------------*/
  843.     UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
  844.     UI_UNUSED_PARAMETER(dummy_c);
  845.     if (current_text_p == b->last_position_p)
  846.     {
  847.         flag1 = 1;
  848.     }
  849.     if ((b->last_position_p - b->text) >= (b->available_length))
  850.     {
  851.         flag2 = 1;
  852.     }
  853.     if (flag1 && flag2)
  854.     {
  855.         return (1);
  856.     }
  857.     return (0);
  858. }
  859. /*****************************************************************************
  860.  * FUNCTION
  861.  *  gui_multi_line_input_box_get_text_length
  862.  * DESCRIPTION
  863.  *  return the text length of multiline input box
  864.  * PARAMETERS
  865.  *  b       [IN]        Is the multi-line inputbox object
  866.  * RETURNS
  867.  *  byte
  868.  *****************************************************************************/
  869. S32 gui_multi_line_input_box_get_text_length(multi_line_input_box *b)
  870. {
  871.     /*----------------------------------------------------------------*/
  872.     /* Local Variables                                                */
  873.     /*----------------------------------------------------------------*/
  874.     /*----------------------------------------------------------------*/
  875.     /* Code Body                                                      */
  876.     /*----------------------------------------------------------------*/
  877.     return (((b->text_length) >> 1) - 1);
  878. }
  879. #if defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__)
  880. /****************WCSS Related Functions***********************/
  881. /* Cursor position previously set by WCSS editor.
  882.    This variable is used to avoid unnecessary input method switching 
  883.    when cursor is not moved. */
  884. static UI_buffer_type WCSS_cursor_pos = NULL;
  885. extern U8 *cat115buffer;
  886. extern void change_input_mode(void);
  887. extern void (*inputbox_change_mode) (void);
  888. extern void change_multiline_inputbox_input_mode(void);
  889. /* Set # Key Depeding Upon The Value Of Status Parameter. */
  890. /*****************************************************************************
  891.  * FUNCTION
  892.  *  gui_set_WCSS_input_method_change_handler
  893.  * DESCRIPTION
  894.  *  
  895.  * PARAMETERS
  896.  *  status      [IN]        
  897.  * RETURNS
  898.  *  void
  899.  *****************************************************************************/
  900. static void gui_set_WCSS_input_method_change_handler(U8 status)
  901. {
  902.     /*----------------------------------------------------------------*/
  903.     /* Local Variables                                                */
  904.     /*----------------------------------------------------------------*/
  905.     /*----------------------------------------------------------------*/
  906.     /* Code Body                                                      */
  907.     /*----------------------------------------------------------------*/
  908.     if (status)
  909.     {
  910.         SetKeyHandler(wgui_handle_inputbox_change_input_mode, KEY_POUND, KEY_EVENT_DOWN);
  911.         inputbox_change_mode = change_multiline_inputbox_input_mode;
  912.     }
  913.     else
  914.     {
  915.         SetKeyHandler(UI_dummy_function, KEY_POUND, KEY_EVENT_DOWN);
  916.         inputbox_change_mode = UI_dummy_function;
  917.     }
  918. }
  919. /*****************************************************************************
  920.  * FUNCTION
  921.  *  gui_reset_WCSS_cursor_position
  922.  * DESCRIPTION
  923.  *  
  924.  * PARAMETERS
  925.  *  void
  926.  * RETURNS
  927.  *  void
  928.  *****************************************************************************/
  929. void gui_reset_WCSS_cursor_position(void)
  930. {
  931.     /*----------------------------------------------------------------*/
  932.     /* Local Variables                                                */
  933.     /*----------------------------------------------------------------*/
  934.     /*----------------------------------------------------------------*/
  935.     /* Code Body                                                      */
  936.     /*----------------------------------------------------------------*/
  937.     WCSS_cursor_pos = NULL;
  938. }
  939. /* Change the input method on cursor movement. */
  940. /*****************************************************************************
  941.  * FUNCTION
  942.  *  gui_change_WCSS_input_method
  943.  * DESCRIPTION
  944.  *  
  945.  * PARAMETERS
  946.  *  b       [?]     
  947.  * RETURNS
  948.  *  void
  949.  *****************************************************************************/
  950. void gui_change_WCSS_input_method(multi_line_input_box *b)
  951. {
  952.     /*----------------------------------------------------------------*/
  953.     /* Local Variables                                                */
  954.     /*----------------------------------------------------------------*/
  955.     /*----------------------------------------------------------------*/
  956.     /* Code Body                                                      */
  957.     /*----------------------------------------------------------------*/
  958.     if (!(b->flags & UI_MULTI_LINE_WCSS_INPUT_BOX_ENABLE))
  959.     {
  960.         return;
  961.     }
  962.     /* Prevent gui_show_multi_line_input_box() invokes this function recursively */
  963.     WCSS_input_change_enable = 0;
  964.     while (WCSS_cursor_pos != b->cursor_p &&
  965.            (b->cursor_p - b->text) < (b->allocated_length - 2) /* out-of-edit area */ )
  966.     {
  967.         U16 temp_var;
  968.         U8 input_method;
  969.         UI_buffer_type prv_cursor_pos = WCSS_cursor_pos;
  970.         temp_var = ((b->cursor_p - b->text) >> 1);
  971.         /* If c appears in the head of input format */
  972.         if (temp_var == 0)
  973.         {
  974.             while (cat115buffer[temp_var] == 0xFF)
  975.             {
  976.                 gui_multi_line_input_box_next(b);
  977.                 temp_var = ((b->cursor_p - b->text) >> 1);
  978.             }
  979.         }
  980.         /* Set WCSS_cursor_pos if input mode is chaged here */
  981.         if (MMI_active_multitap == -1 || WCSS_Esc_Char)
  982.         {
  983.             WCSS_cursor_pos = b->cursor_p;
  984.         }
  985.         if (cat115buffer[temp_var] == 0xFF)
  986.         {
  987.             if (MMI_active_multitap == -1 || WCSS_Esc_Char)
  988.             {
  989.                 /* It always invokes gui_change_WCSS_input_method again (recursive) */
  990.                 if (prv_cursor_pos > b->cursor_p)
  991.                 {
  992.                     gui_multi_line_input_box_previous(b);
  993.                 }
  994.                 else
  995.                 {
  996.                     gui_multi_line_input_box_next(b);
  997.                 }
  998.             }
  999.             else
  1000.             {
  1001.                 break;
  1002.             }
  1003.         }
  1004. temp_var = ((b->cursor_p - b->text) >> 1);
  1005.         input_method = cat115buffer[temp_var] & 0x1F;
  1006.         if (MMI_active_multitap == -1 || WCSS_Esc_Char)
  1007.         {
  1008.             /* If switch from 'm' to 'm', do not switch input method automatically. */
  1009.             if (!(cat115buffer[temp_var] & PIXTEL_UI_ALL_INPUT_METHODS_ALLOWED) ||
  1010.                 !prv_cursor_pos ||
  1011.                 !(cat115buffer[(prv_cursor_pos - b->text) >> 1] & PIXTEL_UI_ALL_INPUT_METHODS_ALLOWED))
  1012.             {
  1013.                 /* If entry category115 from history (prv_cursor_pos = WCSS_cursor_pos was set to NULL), 
  1014.                    we should not change the input method according the WCSS input format string to
  1015.                    keep the previous input method in history */
  1016.                 if (prv_cursor_pos /* not first time in category screen */  ||
  1017.                     is_fisrt_entry_WCSS_editor /* input method was not set in history */ )
  1018.                 {
  1019.                     if (MMI_current_input_mode != (input_method & (~PIXTEL_UI_WCSS_STAR_INPUT)))
  1020.                     {
  1021.                         MMI_current_input_mode = input_method & (~PIXTEL_UI_WCSS_STAR_INPUT);
  1022.                         change_multiline_inputbox_mode(MMI_current_input_mode);
  1023.                         set_MMI_current_input_type();
  1024.                         change_multiline_information_bar_input_method();
  1025.                     }
  1026.                 }
  1027.                 is_fisrt_entry_WCSS_editor = MMI_FALSE;
  1028.                 /* Fix for 'N'. */
  1029.                 if (MMI_current_input_type == INPUT_TYPE_NUMERIC_CHANGEABLE)
  1030.                 {
  1031.                     ClearKeyHandler(KEY_STAR, KEY_EVENT_UP);
  1032.                     ClearKeyHandler(KEY_STAR, KEY_EVENT_DOWN);
  1033.                     /* Tricky. set_MMI_current_input_type() change INPUT_MODE_123 to INPUT_TYPE_NUMERIC_CHANGEABLE */
  1034.                     MMI_current_input_type = INPUT_TYPE_NUMERIC;
  1035.                 }
  1036.             }
  1037.             if (((input_method & 0xFF) == INPUT_MODE_MULTITAP_UPPERCASE_ABC || (input_method & 0xFF) == INPUT_MODE_MULTITAP_LOWERCASE_ABC) && cat115buffer[temp_var] & PIXTEL_UI_ALL_INPUT_METHODS_ALLOWED)     /* 'm' and 'M', not 'x' or 'X' */
  1038.             {
  1039.                 MMI_allow_only_english_input_modes = 1; /* Only support english input */
  1040.                 gui_set_WCSS_input_method_change_handler(1);
  1041.             }
  1042.             else
  1043.             {
  1044.                 gui_set_WCSS_input_method_change_handler(0);
  1045.             }
  1046.             WCSS_Esc_Char = 0;
  1047.         }
  1048.         if (cat115buffer[((b->cursor_p - b->text) >> 1)] != 0xFF)
  1049.         {
  1050.             break;
  1051.         }
  1052.     }
  1053. /* hjf: set again because cursor position is changed */
  1054.     if (MMI_active_multitap == -1 || WCSS_Esc_Char)
  1055. WCSS_cursor_pos = b->cursor_p;
  1056.     WCSS_input_change_enable = 1;
  1057. }
  1058. /*****************************************************************************
  1059.  * FUNCTION
  1060.  *  gui_WCSS_check_next_multitap_input
  1061.  * DESCRIPTION
  1062.  *  
  1063.  * PARAMETERS
  1064.  *  b       [?]     
  1065.  * RETURNS
  1066.  *  
  1067.  *****************************************************************************/
  1068. U8 gui_WCSS_check_next_multitap_input(multi_line_input_box *b)
  1069. {
  1070.     /*----------------------------------------------------------------*/
  1071.     /* Local Variables                                                */
  1072.     /*----------------------------------------------------------------*/
  1073.     U16 temp_var;
  1074.     U8 input_method;
  1075.     /*----------------------------------------------------------------*/
  1076.     /* Code Body                                                      */
  1077.     /*----------------------------------------------------------------*/
  1078.     temp_var = ((b->cursor_p - b->text) >> 1);
  1079.     while (cat115buffer[temp_var] == 0xFF)
  1080.     {
  1081.         temp_var++;
  1082.     }
  1083.     input_method = cat115buffer[temp_var] & 0x1F;
  1084.     if (input_method == INPUT_MODE_123 || input_method == INPUT_MODE_123_SYMBOLS)       /* Add Here Other Input Method For Which Multitap is not require. */
  1085.     {
  1086.         return 0;
  1087.     }
  1088.     else
  1089.     {
  1090.         return 1;
  1091.     }
  1092. }
  1093. //Wrapper function for WCSS_input_change_enable Variable use to Enable Input Method Change
  1094. //While deleting the characters.
  1095. /*****************************************************************************
  1096.  * FUNCTION
  1097.  *  gui_WCSS_input_method_change_enable
  1098.  * DESCRIPTION
  1099.  *  
  1100.  * PARAMETERS
  1101.  *  void
  1102.  * RETURNS
  1103.  *  
  1104.  *****************************************************************************/
  1105. U8 gui_WCSS_input_method_change_enable(void)
  1106. {
  1107.     /*----------------------------------------------------------------*/
  1108.     /* Local Variables                                                */
  1109.     /*----------------------------------------------------------------*/
  1110.     /*----------------------------------------------------------------*/
  1111.     /* Code Body                                                      */
  1112.     /*----------------------------------------------------------------*/
  1113.     return WCSS_input_change_enable;
  1114. }
  1115. /****************************WCSS Related Functions**************************/
  1116. #endif /* defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__) */ 
  1117. /* Set The Editor Chnaged Variable To True On Contents Change. */
  1118. /*****************************************************************************
  1119.  * FUNCTION
  1120.  *  gui_multi_line_input_box_change
  1121.  * DESCRIPTION
  1122.  *  
  1123.  * PARAMETERS
  1124.  *  b       [?]     
  1125.  * RETURNS
  1126.  *  void
  1127.  *****************************************************************************/
  1128. void gui_multi_line_input_box_change(multi_line_input_box *b)
  1129. {
  1130.     /*----------------------------------------------------------------*/
  1131.     /* Local Variables                                                */
  1132.     /*----------------------------------------------------------------*/
  1133.     /*----------------------------------------------------------------*/
  1134.     /* Code Body                                                      */
  1135.     /*----------------------------------------------------------------*/
  1136.     b->editor_changed = 1;
  1137. }
  1138. /* bar code */
  1139. /*****************************************************************************
  1140.  * FUNCTION
  1141.  *  gui_multi_line_input_box_go_to_hilite
  1142.  * DESCRIPTION
  1143.  *  
  1144.  * PARAMETERS
  1145.  *  b           [?]         
  1146.  *  idx         [IN]        
  1147.  *  by_pen      [IN]        
  1148.  * RETURNS
  1149.  *  void
  1150.  *****************************************************************************/
  1151. void gui_multi_line_input_box_go_to_hilite(multi_line_input_box *b, U16 idx, MMI_BOOL need_scroll_to_pos)
  1152. {
  1153.     /*----------------------------------------------------------------*/
  1154.     /* Local Variables                                                */
  1155.     /*----------------------------------------------------------------*/
  1156.     /*----------------------------------------------------------------*/
  1157.     /* Code Body                                                      */
  1158.     /*----------------------------------------------------------------*/
  1159.     if (idx <= b->hilite_str_number - 1)
  1160.     {
  1161.         b->highlight_start_position = (UI_buffer_type) (b->hilite_list[idx].str_addr);
  1162.         b->highlight_end_position = (UI_buffer_type) (b->hilite_list[idx].str_addr + b->hilite_list[idx].length * 2);
  1163.     }
  1164.     b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1165.     gui_show_multi_line_input_box(b);   /* show multiline input box */
  1166.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1167. if (need_scroll_to_pos)
  1168.     {
  1169.         if(b->text_height > b->edit_height)
  1170.         {
  1171. S32 highy = -b->curr_hilite_text_offset_y;
  1172. S32 oy = -b->text_offset_y;
  1173.          //b->text_offset_y = b->curr_hilite_text_offset_y;
  1174. // check if highlight begin is above the windows begin
  1175. if( highy < oy) 
  1176. {
  1177. // move window begin to highlight begin
  1178. b->text_offset_y = b->curr_hilite_text_offset_y;
  1179. }
  1180. // check if highlight end is below the window end
  1181. else if(oy+b->edit_height < highy + b->max_line_height*2)
  1182. {
  1183. // move window begin to the hightlight end - window height
  1184. b->text_offset_y = - ( highy + b->max_line_height*2 -b->edit_height);
  1185. }
  1186.         }
  1187.     }
  1188.     gui_show_multi_line_input_box(b);
  1189.     gui_BLT_double_buffer(b->x, b->y, b->x + b->width, b->y + b->height);
  1190.     b->hilite_cb(b->current_hilite_idx);
  1191. }
  1192. /*****************************************************************************
  1193.  * FUNCTION
  1194.  *  gui_multi_line_input_box_go_to_pre_hilite
  1195.  * DESCRIPTION
  1196.  *  
  1197.  * PARAMETERS
  1198.  *  b       [?]     
  1199.  * RETURNS
  1200.  *  void
  1201.  *****************************************************************************/
  1202. void gui_multi_line_input_box_go_to_pre_hilite(multi_line_input_box *b)
  1203. {
  1204.     /*----------------------------------------------------------------*/
  1205.     /* Local Variables                                                */
  1206.     /*----------------------------------------------------------------*/
  1207.     /*----------------------------------------------------------------*/
  1208.     /* Code Body                                                      */
  1209.     /*----------------------------------------------------------------*/
  1210.     if (b->current_hilite_idx > 0)
  1211.     {
  1212.         b->current_hilite_idx--;
  1213.         b->highlight_start_position = (UI_buffer_type) (b->hilite_list[b->current_hilite_idx].str_addr);
  1214.         b->highlight_end_position =
  1215.             (UI_buffer_type) (b->hilite_list[b->current_hilite_idx].str_addr +
  1216.                               b->hilite_list[b->current_hilite_idx].length * 2);
  1217.     }
  1218.     b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1219.     gui_show_multi_line_input_box(b);   /* show multiline input box */
  1220.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1221.     if(b->text_height > b->edit_height)
  1222.     {
  1223.      b->text_offset_y = b->curr_hilite_text_offset_y;
  1224.     }
  1225.     gui_show_multi_line_input_box(b);
  1226.     gui_BLT_double_buffer(b->x, b->y, b->x + b->width, b->y + b->height);
  1227.     b->hilite_cb(b->current_hilite_idx);
  1228. }
  1229. /*****************************************************************************
  1230.  * FUNCTION
  1231.  *  gui_multi_line_input_box_go_to_next_hilite
  1232.  * DESCRIPTION
  1233.  *  
  1234.  * PARAMETERS
  1235.  *  b       [?]     
  1236.  * RETURNS
  1237.  *  void
  1238.  *****************************************************************************/
  1239. void gui_multi_line_input_box_go_to_next_hilite(multi_line_input_box *b)
  1240. {
  1241.     /*----------------------------------------------------------------*/
  1242.     /* Local Variables                                                */
  1243.     /*----------------------------------------------------------------*/
  1244.     /*----------------------------------------------------------------*/
  1245.     /* Code Body                                                      */
  1246.     /*----------------------------------------------------------------*/
  1247.     if (b->current_hilite_idx < b->hilite_str_number - 1)
  1248.     {
  1249.         b->current_hilite_idx++;
  1250.         b->highlight_start_position = (UI_buffer_type) (b->hilite_list[b->current_hilite_idx].str_addr);
  1251.         b->highlight_end_position =
  1252.             (UI_buffer_type) (b->hilite_list[b->current_hilite_idx].str_addr +
  1253.                               b->hilite_list[b->current_hilite_idx].length * 2);
  1254.     }
  1255.     b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1256.     gui_show_multi_line_input_box(b);   /* show multiline input box */
  1257.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1258.     if(b->text_height > b->edit_height)
  1259.     {
  1260.      b->text_offset_y = b->curr_hilite_text_offset_y;
  1261.     }
  1262.     gui_show_multi_line_input_box(b);
  1263.     gui_BLT_double_buffer(b->x, b->y, b->x + b->width, b->y + b->height);
  1264.     b->hilite_cb(b->current_hilite_idx);
  1265. }
  1266. /*****************************************************************************
  1267.  * FUNCTION
  1268.  *  gui_multi_line_input_box_is_pos_inside_hilite_ext
  1269.  * DESCRIPTION
  1270.  *  
  1271.  * PARAMETERS
  1272.  *  b               [?]         
  1273.  *  current_pos     [IN]        
  1274.  *  hilite_idx      [?]         
  1275.  * RETURNS
  1276.  *  
  1277.  *****************************************************************************/
  1278. MMI_BOOL gui_multi_line_input_box_is_pos_inside_hilite_ext(
  1279.             multi_line_input_box *b,
  1280.             UI_buffer_type current_pos,
  1281.             U16 *hilite_idx)
  1282. {
  1283.     /*----------------------------------------------------------------*/
  1284.     /* Local Variables                                                */
  1285.     /*----------------------------------------------------------------*/
  1286.     U16 hilite_no = b->hilite_str_number;
  1287.     U16 i = 0;
  1288.     /*----------------------------------------------------------------*/
  1289.     /* Code Body                                                      */
  1290.     /*----------------------------------------------------------------*/
  1291.     for (i = 0; i < hilite_no; i++)
  1292.     {
  1293.         if (((S8*)current_pos >= b->hilite_list[i].str_addr) &&
  1294.             ((S8*)current_pos < b->hilite_list[i].str_addr + b->hilite_list[i].length * 2))
  1295.         {
  1296.             *hilite_idx = i;
  1297.             return MMI_TRUE;
  1298.         }
  1299.     }
  1300.     return MMI_FALSE;
  1301. }
  1302. /*****************************************************************************
  1303.  * FUNCTION
  1304.  *  gui_multi_line_input_box_is_pos_inside_hilite
  1305.  * DESCRIPTION
  1306.  *  
  1307.  * PARAMETERS
  1308.  *  b               [?]         
  1309.  *  current_pos     [IN]        
  1310.  * RETURNS
  1311.  *  
  1312.  *****************************************************************************/
  1313. MMI_BOOL gui_multi_line_input_box_is_pos_inside_hilite(multi_line_input_box *b, UI_buffer_type current_pos)
  1314. {
  1315.     /*----------------------------------------------------------------*/
  1316.     /* Local Variables                                                */
  1317.     /*----------------------------------------------------------------*/
  1318.     U16 hilite_idx = 0;
  1319.     /*----------------------------------------------------------------*/
  1320.     /* Code Body                                                      */
  1321.     /*----------------------------------------------------------------*/
  1322.     return (gui_multi_line_input_box_is_pos_inside_hilite_ext(b, current_pos, &hilite_idx));
  1323. }
  1324. /*****************************************************************************
  1325.  * FUNCTION
  1326.  *  gui_multi_line_input_box_is_pen_down_in_hilite
  1327.  * DESCRIPTION
  1328.  *  
  1329.  * PARAMETERS
  1330.  *  b       [?]     
  1331.  * RETURNS
  1332.  *  
  1333.  *****************************************************************************/
  1334. MMI_BOOL gui_multi_line_input_box_is_pen_down_in_hilite(multi_line_input_box *b)
  1335. {
  1336.     /*----------------------------------------------------------------*/
  1337.     /* Local Variables                                                */
  1338.     /*----------------------------------------------------------------*/
  1339.     UI_buffer_type current_pos = b->cursor_p;
  1340.     U16 idx = 0;
  1341.     /*----------------------------------------------------------------*/
  1342.     /* Code Body                                                      */
  1343.     /*----------------------------------------------------------------*/
  1344.     if (gui_multi_line_input_box_is_pos_inside_hilite_ext(b, current_pos, &idx))
  1345.     {
  1346.         b->current_hilite_idx = idx;
  1347.         return MMI_TRUE;
  1348.     }
  1349.     else
  1350.     {
  1351.         return MMI_FALSE;
  1352.     }
  1353. }
  1354. /***Ritesh started here***/
  1355. #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  1356. /*****************************************************************************
  1357.  * FUNCTION
  1358.  *  gui_paging_multi_line_input_box_get_next_page_callback
  1359.  * DESCRIPTION
  1360.  *  callback function for demand of next page by multiline editor
  1361.  * PARAMETERS
  1362.  *  b       [IN]        (instance of multi_line_input_box)
  1363.  * RETURNS
  1364.  *  void
  1365.  *****************************************************************************/
  1366. void gui_paging_multi_line_input_box_get_next_page_callback(multi_line_input_box *b)
  1367. {
  1368.     /*----------------------------------------------------------------*/
  1369.     /* Local Variables                                                */
  1370.     /*----------------------------------------------------------------*/
  1371.     U8 page_index;
  1372.     /*----------------------------------------------------------------*/
  1373.     /* Code Body                                                      */
  1374.     /*----------------------------------------------------------------*/
  1375.     memcpy(b->text, b->page_details[PAGE_ZERO].shared_data, b->page_details[PAGE_ZERO].shared_no_of_bytes);
  1376.     for (page_index = 0; page_index < GUI_NO_OF_PAGES - 1; page_index++)
  1377.     {
  1378.         memcpy(
  1379.             b->text + (GUI_PAGE_SIZE_IN_UCS2 * page_index) + b->page_details[PAGE_ZERO].shared_no_of_bytes,
  1380.             b->text + b->previous_shared_bytes + (GUI_PAGE_SIZE_IN_UCS2 * (page_index + 1)),
  1381.             GUI_PAGE_SIZE_IN_UCS2);
  1382.     }
  1383.     b->previous_shared_bytes = b->page_details[PAGE_ZERO].shared_no_of_bytes;
  1384.     b->start_id++;
  1385.     b->end_id++;
  1386.     b->page_details[PAGE_ZERO].page_id = b->start_id;
  1387.     gui_paging_multiline_input_box_get_page(
  1388.         b->end_id,
  1389.         b->end_id,
  1390.         b->text + (GUI_PAGE_SIZE_IN_UCS2 * PAGE_THREE) + b->page_details[PAGE_ZERO].shared_no_of_bytes);
  1391.     show_multiline_inputbox_no_draw();
  1392. }
  1393. /*****************************************************************************
  1394.  * FUNCTION
  1395.  *  gui_paging_multi_line_input_box_get_previous_page_callback
  1396.  * DESCRIPTION
  1397.  *  callback function for previous page
  1398.  * PARAMETERS
  1399.  *  b       [IN]        (instance of multi_line_input_box)
  1400.  * RETURNS
  1401.  *  void
  1402.  *****************************************************************************/
  1403. void gui_paging_multi_line_input_box_get_previous_page_callback(multi_line_input_box *b)
  1404. {
  1405.     /*----------------------------------------------------------------*/
  1406.     /* Local Variables                                                */
  1407.     /*----------------------------------------------------------------*/
  1408.     U8 page_index;
  1409.     /*----------------------------------------------------------------*/
  1410.     /* Code Body                                                      */
  1411.     /*----------------------------------------------------------------*/
  1412.     if (b->page_details[0].page_id > 0)
  1413.     {
  1414.         b->page_zero_prev_height = b->page_details[PAGE_ZERO].page_height;
  1415.         for (page_index = GUI_NO_OF_PAGES - 1; page_index != 0; page_index--)
  1416.         {
  1417.             memcpy(
  1418.                 b->text + (GUI_PAGE_SIZE_IN_UCS2 * page_index) + b->previous_shared_bytes,
  1419.                 b->text + (b->previous_shared_bytes * ENCODING_LENGTH) + (GUI_PAGE_SIZE_IN_UCS2 * (page_index - 1)),
  1420.                 GUI_PAGE_SIZE_IN_UCS2 - b->previous_shared_bytes);
  1421.             memcpy(
  1422.                 b->text + (GUI_PAGE_SIZE_IN_UCS2 * page_index),
  1423.                 b->text + (GUI_PAGE_SIZE_IN_UCS2 * (page_index - 1)) + b->previous_shared_bytes,
  1424.                 b->previous_shared_bytes);
  1425.         }
  1426.         gui_paging_multiline_input_box_get_page(b->start_id - 1, b->start_id - 1, b->text);
  1427.         b->previous_shared_bytes = 0;
  1428.         show_multiline_inputbox_no_draw();
  1429.         b->start_id--;
  1430.         b->end_id--;
  1431.     }
  1432. }
  1433. #endif /* __UI_PAGING_IN_MULTILINE_EDITOR__ */ 
  1434. /***** ritesh ended here*****/
  1435. /*****************************************************************************
  1436.  * FUNCTION
  1437.  *  gui_show_multi_line_input_box
  1438.  * DESCRIPTION
  1439.  *  Displays the multi-line inputbox
  1440.  * PARAMETERS
  1441.  *  b       [IN]        Is the multi-line inputbox object
  1442.  * RETURNS
  1443.  *  void
  1444.  *****************************************************************************/
  1445. extern U8 EMS_object_width_cache[];
  1446. extern U8 EMS_object_height_cache[];
  1447. extern U16 EMS_object_str_cache[];
  1448. /* Gurinder - Extern Decleration - 15/4/2004 */
  1449. extern void (*wgui_inline_edit_DONE_function) (void);
  1450. //START FARHAD PMT 20050211
  1451. //START TARUN PMT 20050128
  1452. //#ifdef __MMI_HINDI_ALG__
  1453. //extern BOOL cancelWidth;
  1454. //#endif
  1455. //END TARUN PMT 20050128
  1456. //END FARHAD PMT 20050211
  1457. //MTK modify for stacked character
  1458. //START PMTFARHAD  20050224
  1459. #if defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__)
  1460. extern S32 HINDI_PRESENT;
  1461. extern S32 ARABIC_PRESENT;
  1462. #endif /* defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__) */ 
  1463. /* END PMTFARHAD  20050224 */
  1464. void gui_show_multi_line_input_box(multi_line_input_box *b)
  1465. {
  1466.     gui_show_multi_line_input_box_ext(b, (-1), (-1));
  1467. }
  1468. /*****************************************************************************
  1469.  * FUNCTION
  1470.  *  gui_show_multi_line_input_box_ext
  1471.  * DESCRIPTION
  1472.  *  
  1473.  * PARAMETERS
  1474.  *  b               [?]         
  1475.  *  move_to_x       [IN]        
  1476.  *  move_to_y       [IN]        
  1477.  * RETURNS
  1478.  *  void
  1479.  *****************************************************************************/
  1480. void gui_show_multi_line_input_box_ext(multi_line_input_box *b, S32 move_to_x, S32 move_to_y)
  1481. {
  1482.     /*----------------------------------------------------------------*/
  1483.     /* Local Variables                                                */
  1484.     /*----------------------------------------------------------------*/
  1485.     S32 x1, y1;                                     /* x1,y1 -> left-top corner of the editor windows */
  1486.     S32 x2, y2;                                     /* x2,y2 -> right-bottom of the editor windows */
  1487.     UI_buffer_type current_text_p, line_start_text_p, line_break_text_p;
  1488.     UI_buffer_type previous_line_start_text_p, previous_text_p = NULL;
  1489.     UI_buffer_type current_cursor_p = b->cursor_p;  /* points to the character at which the cursor is positioned */
  1490.     UI_buffer_type previous_cursor_p = b->cursor_p;
  1491. pBOOL is_cursor_show = MMI_FALSE; //hjf , to avoid cursor to display two place. for BIDI, some case will cause two cursor
  1492.     S32 character_width = 0, character_height;
  1493.     UI_character_type current_character = 0, pre2_character = 0, pre_character = 0, dummy_c = 0;
  1494.     S32 text_gap = b->text_gap;
  1495.     S32 tx = 0, ty, xx, yy, temp_d;
  1496.     color selector_color = b->selector_color;
  1497.     color selected_text_color = b->selected_text_color;
  1498. S32 reserve_line_height_for_hilite; // hjf, using in barcode
  1499.     S32 current_line_width, previous_line_width;
  1500.     S32 current_line_height=0, previous_line_height, saved_line_height = 1;
  1501.     S32 current_line_character_counter = 0;
  1502.     S32 current_line_break_character_counter;
  1503.     U8 done = 0;
  1504.     S32 edit_width, edit_height;
  1505.     U8 *character_widths_cache = EMS_object_width_cache;
  1506.     U8 *character_heights_cache = EMS_object_height_cache;
  1507.     U16 *character_str_cache = EMS_object_str_cache;
  1508.     U32 flags = b->flags;
  1509.     U8 break_character_flag;
  1510.     S32 line_counter = 0;
  1511.     U8 multitap_flag = 0;
  1512.     U8 overwrite_flag = 0;
  1513.     S32 set_cursor_flag = 0;
  1514.     UI_buffer_type temp_text_p;
  1515.     U8 next_line_found_flag = 0;
  1516.     S32 mask_character_width = 0, mask_character_height;
  1517.     U8 word_highlight = 0;
  1518.     S32 xtx, yty = 0;
  1519.     S32 l_clip = 0;
  1520.     PMT_BIDI_TYPES default_direction = BIDI_L;
  1521.     S32 vbar_x = 0, vbar_button_x = 0;
  1522.     gui_input_richtext_struct rich_text;
  1523. #if defined(__UI_PAGING_IN_MULTILINE_EDITOR__)
  1524.     U8 shared_data_count, check_flag = 0;
  1525. #endif 
  1526.     /* PMT LANGUAGE START 20051221 */
  1527. #if defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__)
  1528.     U16 unicode = 0;
  1529.     U16 clFill = 0;
  1530. #endif /* defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__) */ 
  1531.     //PMT LANGUAGE END 20051221     
  1532.     //MTK Arabic connectivity issue
  1533. #if defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__
  1534.     UI_buffer_type temp_p;
  1535.     UI_character_type next_char = 0;
  1536.     S32 nLen;
  1537. #endif /* defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__ */ 
  1538.     /* MTK end */
  1539.     /* PMT VIKAS START 20050707 */
  1540. #ifdef __MMI_UI_DALMATIAN_EDITOR__
  1541.     S32 image_width, image_height;
  1542. #endif 
  1543.     /* PMT VIKAS END 20050707 */
  1544. #ifdef __MMI_BIDI_ALG__
  1545.     U16 logical_cur_pos;
  1546.     U8 *temp_text_pt;
  1547.     U8 *temp_cursor_p;
  1548.     U8 *temp_pre_cursor_p;
  1549.     U16 visual_str_len;
  1550.     U16 visual_cur_pos;
  1551.     U16 logical_hilight_start;
  1552.     U16 logical_hilight_end;
  1553.     U16 visual_hilight_start;
  1554.     U16 visual_hilight_end;
  1555.     UI_buffer_type temp_hilight_start;
  1556.     UI_buffer_type temp_hilight_end;
  1557.     PMT_BIDI_TYPES default_line_direction = BIDI_L;
  1558.     pBOOL reverse_flag;
  1559.     S32 num_char;
  1560.     U32 iCount;
  1561.     pBOOL arabic_char_flag = MMI_FALSE;
  1562.     U8 lastest_char_type;
  1563.     UI_character_type test_current_character;
  1564.     /* PMT NO_AR_SL_DU START 20050909 */
  1565.     S32 text_len;
  1566.     PU8 ptr_text_buffer;
  1567.     pBOOL BIDI_done_flag = MMI_FALSE;
  1568.     UI_buffer_type saved_current_text_p;
  1569.     /* MTK begin chat issue 2005.10.27 */
  1570. #ifdef __MMI_MESSAGES_CHAT__
  1571.     pBOOL Show_Chat_NickName = MMI_FALSE;
  1572. #endif 
  1573.     /* MTK End */
  1574. #endif /* __MMI_BIDI_ALG__ */ 
  1575.     BOOL draw_separator;    /* Used by UI_MULTI_LINE_INPUT_BOX_DRAW_SEPARATOR */
  1576.     /* MTK for Chinese Characters Display */
  1577.     U8 break_flag;
  1578.     /* MTK end */
  1579.     S32 current_cluster_width = 0;
  1580. #ifdef __MMI_HINDI_ALG__
  1581.     U16 disp_cluster[MAX_EDITOR_DISP_LEN];
  1582.     /* START FARHAD PMT 20050211 */
  1583.     PU8 temp_hindi_cursor_p = b->text;
  1584.     /* END FARHAD PMT 20050211 */
  1585.     S32 cluster_width = 0;
  1586.     S32 cursor_width = 0;
  1587.     PU8 move_cursor_prev_p = b->text;
  1588.     PU8 move_cursor_curr_p = b->text;
  1589.     PU8 move_cursor_disp_prev_p = b->text;
  1590.     PU8 move_cursor_disp_curr_p = b->text;
  1591.     S32 skip_moves = 1;         /* for skipping by cluster */
  1592.     S32 saved_skip_moves = 1;
  1593.     S32 display_skip_moves = 1; /* for skipping by cluster while display */
  1594.     S32 saved_display_skip_moves = 0;
  1595.     S32 hindi_cluster_counter;
  1596.     UI_buffer_type hindi_line_brk_p;
  1597.     S32 cluster_width_filler[50];
  1598.     S32 cluster_filler_count = 0;
  1599. #endif /* __MMI_HINDI_ALG__ */ 
  1600. /****** ritesh started here****/
  1601. #if defined(__UI_PAGING_IN_MULTILINE_EDITOR__)
  1602.     U8 count_flag = 0; /*jump_to_offset_flag = 0;*/
  1603.     S32 total_page_height = 0;  /* ritesh */
  1604.     S32 char_count = 0;
  1605.     U8 page_index = 0;
  1606. #endif /* defined(__UI_PAGING_IN_MULTILINE_EDITOR__) */ 
  1607. /***** ritesh ended here****/
  1608. #if defined(__MMI_LANG_VIETNAMESE__)
  1609.     /* U16 next_unicode = 0; */
  1610.     viet_tone_mark tone_mark = VIET_TONE_NONE;
  1611.     viet_vowel_letter viet_vowel = VIET_VOWEL_NONE;
  1612. #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  1613.     /*----------------------------------------------------------------*/
  1614.     /* Code Body                                                      */
  1615.     /*----------------------------------------------------------------*/
  1616.     /* PMT RAKESH START 20061006 */
  1617. #if defined __MMI_HINDI_ALG__
  1618.     overwrite_current_language_for_hindi_rules_based_on_input_method();
  1619. #endif 
  1620.     /* PMT RAKESH END 20061006 */   
  1621. #if defined(__UI_PAGING_IN_MULTILINE_EDITOR__)
  1622.     b->edit_height_displayed_lines = 0; /* ritesh */
  1623. #endif 
  1624.     
  1625. if(b->hilite_cb)
  1626. reserve_line_height_for_hilite = 1;
  1627. else
  1628. reserve_line_height_for_hilite = 0;
  1629. #if defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__)
  1630.     HINDI_PRESENT = 0;
  1631.     ARABIC_PRESENT = 0;
  1632.     while ((b->text[clFill] != '' || b->text[clFill + 1] != '') && !HINDI_PRESENT)
  1633.     {
  1634.         unicode = b->text[clFill];
  1635.         unicode |= (b->text[clFill + 1] << 8);
  1636.         if (UI_HINDI_CHARACTER_UCS2_RANGE(unicode))
  1637.         {
  1638.             HINDI_PRESENT = 1;
  1639.             ARABIC_PRESENT = 0;
  1640.         }
  1641.         else if (IS_ARABIC_CHARACTER(unicode))
  1642.         {
  1643.             ARABIC_PRESENT = 1;
  1644.             HINDI_PRESENT = 0;
  1645.         }
  1646.         clFill += 2;
  1647.         clFill += 2;
  1648.     }
  1649. #endif /* defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__) */ 
  1650. #if defined (__MMI_LANG_ARABIC__) || defined (__MMI_LANG_PERSIAN__)
  1651.     if ((b->text_length / ENCODING_LENGTH) - 1 != 0)
  1652.     {
  1653.         if (!(b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE || (b->flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW)))
  1654.         {
  1655.             pfnUnicodeStrncpy((S8*) shaping_str, (const S8*)b->text, (b->text_length / ENCODING_LENGTH) - 1);
  1656.             unshaped_text_len = text_len = (b->text_length / 2) - 1;
  1657. OrgToSha[text_len] = 0xffff;
  1658.         #ifdef __MMI_ZI__
  1659.         #ifdef __MMI_ZI_V7__
  1660.         #if defined(__MMI_ZI_ARABIC__) && defined(__MMI_ZI_PERSIAN__)
  1661.             ZiStringShapeEx(ZI8_LANG_FA, (U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);      /* 19 is the Arabic id */
  1662.         #elif defined(__MMI_ZI_PERSIAN__)
  1663.             ZiStringShapeEx(ZI8_LANG_FA, (U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);      /* 19 is the Arabic id */
  1664.         #elif defined(__MMI_ZI_ARABIC__)
  1665.             ZiStringShapeEx(ZI8_LANG_AR, (U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);      /* 19 is the Arabic id */
  1666.         #endif 
  1667.         #else /* __MMI_ZI_V7__ */ 
  1668.             ArabicStringShape2((U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);
  1669.         #endif /* __MMI_ZI_V7__ */ 
  1670.         #else /* __MMI_ZI__ */ 
  1671.             ArabicShapeEngine2((U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);
  1672.         #endif /* __MMI_ZI__ */ 
  1673.         }
  1674.         else
  1675.         {
  1676.             pfnUnicodeStrncpy((S8*) shaping_str, (const S8*)b->text, (b->text_length / ENCODING_LENGTH) - 1);
  1677.             unshaped_text_len = text_len = (b->text_length / 2) - 1;
  1678. OrgToSha[text_len] = 0xffff;
  1679.         #ifdef __MMI_ZI__
  1680.         #ifdef __MMI_ZI_V7__
  1681.         #if defined(__MMI_ZI_ARABIC__) && defined(__MMI_ZI_PERSIAN__)
  1682.             ZiStringShapeEx(ZI8_LANG_FA, (U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);      /* 19 is the Arabic id */
  1683.         #elif defined(__MMI_ZI_PERSIAN__)
  1684.             ZiStringShapeEx(ZI8_LANG_FA, (U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);      /* 19 is the Arabic id */
  1685.         #elif defined(__MMI_ZI_ARABIC__)
  1686.             ZiStringShapeEx(ZI8_LANG_AR, (U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);      /* 19 is the Arabic id */
  1687.         #endif 
  1688.         #else /* __MMI_ZI_V7__ */ 
  1689.             ArabicStringShape2((U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);
  1690.         #endif /* __MMI_ZI_V7__ */ 
  1691.         #else /* __MMI_ZI__ */ 
  1692.             ArabicShapeEngine2((U16*) & text_len, (U16*) shaping_str, (U16*) OrgToSha, NULL);
  1693.         #endif /* __MMI_ZI__ */ 
  1694.         #ifdef __MMI_HINDI_ALG__
  1695.             move_cursor_prev_p = b->text;
  1696.             move_cursor_curr_p = b->text;
  1697.             move_cursor_disp_prev_p = b->text;
  1698.             move_cursor_disp_curr_p = b->text;
  1699.         #endif /* __MMI_HINDI_ALG__ */ 
  1700.         }
  1701.     }
  1702. #endif /* defined (__MMI_LANG_ARABIC__) || defined (__MMI_LANG_PERSIAN__) */ 
  1703.     /* #if defined __MMI_LANG_HINDI__  && defined __MMI_LANG_ARABIC__
  1704.        U16 unicode       =  0;
  1705.        U16 clFill        =  0;
  1706.        HINDI_PRESENT     =  0;
  1707.        ARABIC_PRESENT    =  0;
  1708.        while( (b->text[clFill] != '' || b->text[clFill+1] != '') && !HINDI_PRESENT )
  1709.        {
  1710.        unicode  =   b->text[clFill];
  1711.        unicode  |= (b->text[clFill+1]<<8);
  1712.        if(UI_HINDI_CHARACTER_UCS2_RANGE(unicode))
  1713.        {
  1714.        HINDI_PRESENT     =  1;
  1715.        ARABIC_PRESENT    =  0;
  1716.        }
  1717.        clFill+=2;
  1718.        }
  1719.        #endif */
  1720.     //PMT LANGUAGE END 20051221
  1721.     //END PMTFARHAD  20050224
  1722.     /* Current implementation does not support icon_callback on overwrite mode */
  1723.     MMI_DBG_ASSERT(!(flags & UI_MULTI_LINE_INPUT_BOX_OVERWRITE_MODE) || !b->icon_callback);
  1724.     /* Setup rich text context */
  1725.     MMI_DBG_ASSERT((flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE) || !(flags & UI_MULTI_LINE_INPUT_BOX_RICHTEXT));
  1726.     rich_text.default_color = rich_text.curr_color = b->normal_text_color;
  1727.     /* USAT */
  1728.     rich_text.default_text_bg_color = rich_text.curr_text_bg_color = gui_richtext_default_text_bg_color;
  1729.     rich_text.draw_text_bg_color = 0;
  1730.     if (flags & UI_MULTI_LINE_INPUT_BOX_CENTER_JUSTIFY)
  1731.     {
  1732.         rich_text.default_alignment = GUI_INPUT_ALIGN_CENTER;
  1733.     }
  1734.     else if (flags & UI_MULTI_LINE_INPUT_BOX_RIGHT_JUSTIFY)
  1735.     {
  1736.         rich_text.default_alignment = GUI_INPUT_ALIGN_RIGHT;
  1737.     }
  1738.     else
  1739.     {
  1740.         rich_text.default_alignment = GUI_INPUT_ALIGN_LEFT;
  1741.     }
  1742.     rich_text.curr_alignment = rich_text.default_alignment;
  1743.     rich_text.line_begin_font = rich_text.curr_font = *b->text_font;
  1744.     rich_text.line_begin_border = rich_text.curr_border = 0;
  1745.     /* USAT */
  1746.     rich_text.line_begin_strikethrough = rich_text.curr_strikethrough = 0;
  1747.     rich_text.more_line_spacing = 0;
  1748.     rich_text.line_separator = 0;
  1749.     /* Setup runtime variables */
  1750.     if (r2lMMIFlag)
  1751.     {
  1752.         if (b->flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR)
  1753.         {
  1754.             x1 = b->x;
  1755.         }
  1756.         else if (b->flags & UI_MULTI_LINE_INPUT_BOX_AUTO_DISABLE_SCROLLBAR)
  1757.         {
  1758.             if (b->vbar.scale < b->vbar.range)
  1759.             {
  1760.                 x1 = b->x + b->vbar.width;//hjf it should not  - 5;
  1761.             }
  1762.             else
  1763.             {
  1764.                 x1 = b->x;
  1765.             }
  1766.         }
  1767.         else
  1768.         {
  1769.             x1 = b->x + b->vbar.width;//hjf it should not - 5;
  1770.         }
  1771.     }
  1772.     else
  1773.     {
  1774.         x1 = b->x;
  1775.     }
  1776.     y1 = b->y;
  1777.     x2 = b->x + b->width - 1;   /* b->width contains the width of vbar */
  1778.     y2 = y1 + b->height - 1;
  1779.     edit_width = b->edit_width;
  1780.     edit_height = b->edit_height;
  1781.     if (((-1) != move_to_x) || ((-1) != move_to_y))
  1782.     {
  1783.         flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1784.     }
  1785. #ifdef __MMI_HINDI_ALG__
  1786.     memset(disp_cluster, 0, sizeof(disp_cluster));
  1787. #endif 
  1788. #if defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__)
  1789.     /*
  1790.      * Evertime the cursor position is changed, GUI will invoke the current function,
  1791.      * there is no other place to hook it cleanly.
  1792.      * However, it's protected by the flag UI_MULTI_LINE_WCSS_INPUT_BOX_ENABLE
  1793.      */
  1794.     if (b->flags & UI_MULTI_LINE_WCSS_INPUT_BOX_ENABLE && gui_WCSS_input_method_change_enable())
  1795.     {
  1796.         /* gui_change_WCSS_input_method() will change cursor position */
  1797.         gui_change_WCSS_input_method(b);
  1798.         current_cursor_p = b->cursor_p;
  1799.         previous_cursor_p = b->cursor_p;
  1800.     }
  1801. #endif /* defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__) */ /* MMI_WCSS_INPUT_FORMAT_SUPPORT_ */
  1802.     /* Pixtel - Gurinder 2/4/6 - Use Auto Scrollbar if current multi line box is Inscreen */
  1803. #if defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__)
  1804.     if (MMI_multi_line_inputbox_present)
  1805.     {
  1806.         b->flags |= UI_MULTI_LINE_INPUT_BOX_AUTO_DISABLE_SCROLLBAR;
  1807.         b->flags |= UI_MULTI_LINE_INPUT_BOX_INSIDE_INLINE_MENU;
  1808.         l_clip = y2 - (MMI_content_height + MMI_content_y - 1);
  1809.         if (l_clip < 0)
  1810.         {
  1811.             l_clip = 0;
  1812.         }
  1813.     }
  1814. #endif /* defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__) */ 
  1815.     if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))    /* If not disable draw then do it.. */
  1816.     {
  1817.         UI_filled_area f;
  1818.         S32 l_height = 0;
  1819.         if (flags & UI_MULTI_LINE_INPUT_BOX_STATE_FOCUSSED)
  1820.         {
  1821.             f = *b->focussed_filler;
  1822.             rich_text.default_color = rich_text.curr_color = b->focussed_text_color;
  1823.         }
  1824.         else if (flags & UI_MULTI_LINE_INPUT_BOX_STATE_DISABLED)
  1825.         {
  1826.             f = *b->disabled_filler;
  1827.             rich_text.default_color = rich_text.curr_color = b->disabled_text_color;
  1828.         }
  1829.         else
  1830.         {
  1831.             f = *b->normal_filler;
  1832.             rich_text.default_color = rich_text.curr_color = b->normal_text_color;
  1833.         }
  1834.     #if defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__)
  1835.         if (MMI_multi_line_inputbox_present == 1)
  1836.         {
  1837.             /* Inline Multiline Edit Infobar Height Change. - Gurinder - 12/5/2004 */
  1838.             l_height = INFORMATION_BAR_HEIGHT + 2;
  1839.             /* Gurinder 7/14/2004 - Inscreen Multiline Title Enable/Disable */
  1840.         #if(!INSCREEN_MUTLILINE_TITLE_ENABLE)
  1841.             if (b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE)
  1842.             {
  1843.                 l_height = 0;
  1844.             }
  1845.         #endif /* (!INSCREEN_MUTLILINE_TITLE_ENABLE) */ 
  1846.         }
  1847.     #endif /* defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__) */ 
  1848.         gui_push_clip();
  1849.         if (flags & UI_MULTI_LINE_INPUT_BOX_USE_PRESET_CLIPPING)
  1850.         {
  1851.             gui_set_clip_preset(b->x, y1 - l_height, x2 + 2, y2 + 2 - l_clip);
  1852.         }
  1853.         else
  1854.         {
  1855.             /* MTK Terry instead y2+1-l_clip with y2-l_clip for overlap soft key area */
  1856.             gui_set_clip(b->x, y1 - l_height, x2 + 2, y2 - l_clip);
  1857.         }
  1858.         if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_BACKGROUND))      /* if not disable background then do .. */
  1859.         {
  1860.             if (!(flags & UI_MULTI_LINE_INPUT_BOX_INCLUDE_INFO_AREA))   /* if not include info_area then do .. */
  1861.             {
  1862.                 /* Draw standard background filler */
  1863.                 /* 070405 Calvin Start */
  1864.                 if (r2lMMIFlag)
  1865.                 {
  1866.                     if ((wgui_is_wallpaper_on_bottom() == MMI_TRUE) &&
  1867.                         (flags & UI_MULTI_LINE_INPUT_BOX_TRANSPARENT_BACKGROUND))
  1868.                     {
  1869.                         gdi_draw_solid_rect(b->x, y1 - l_height, x2 /* +b->vbar.width */ , y2, GDI_COLOR_TRANSPARENT);
  1870.                     }
  1871.                     else
  1872.                     {
  1873.                         gui_draw_filled_area(b->x, y1 - l_height, x2 /* +b->vbar.width */ , y2, &f);
  1874.                     }
  1875.                 }
  1876.                 else
  1877.                 {
  1878.                     if ((wgui_is_wallpaper_on_bottom() == MMI_TRUE) &&
  1879.                         (flags & UI_MULTI_LINE_INPUT_BOX_TRANSPARENT_BACKGROUND))
  1880.                     {
  1881.                         gdi_draw_solid_rect(x1, y1 - l_height, x2, y2, GDI_COLOR_TRANSPARENT);
  1882.                     }
  1883.                     else
  1884.                     {
  1885.                         gui_draw_filled_area(x1, y1 - l_height, x2, y2, &f);
  1886.                     }
  1887.                 }
  1888.                 /* 070405 Calvin End */
  1889.                 /*
  1890.                  * Draw b->text_filler for text area only.
  1891.                  * (typically when b->header_height or b->footer_callback is non-zero)
  1892.                  */
  1893.                 if (b->text_filler)
  1894.                 {
  1895.                     /*
  1896.                      * This filler can only be used in View Mode such that b->text_height can be pre-computed
  1897.                      * * at the first time in something like show_multiline_inputbox_no_draw().
  1898.                      */
  1899.                     S32 text_border_y1, text_border_y2;
  1900.                     MMI_DBG_ASSERT((flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE) != 0 && l_clip == 0);
  1901.                     text_border_y1 = y1 + b->text_y + b->text_offset_y + b->header_height - 1;
  1902.                     text_border_y2 = y1 + b->text_y + b->text_offset_y + b->text_height - b->footer_height;
  1903.                     /* If text_height is large, we should shrink the filling area */
  1904.                     if (text_border_y1 < 0)
  1905.                     {
  1906.                         text_border_y1 = 0;
  1907.                     }
  1908.                     if (text_border_y2 >= UI_device_height)
  1909.                     {
  1910.                         text_border_y2 = UI_device_height - 1;
  1911.                     }
  1912.                     gui_push_clip();
  1913.                     if ((f.flags & UI_FILLED_AREA_DOUBLE_BORDER) == UI_FILLED_AREA_DOUBLE_BORDER)
  1914.                     {
  1915.                         gui_set_clip(x1 + 2, y1 + 2, x2 - 2, y2 - 2);
  1916.                     }
  1917.                     else if (f.flags & UI_FILLED_AREA_BORDER)
  1918.                     {
  1919.                         gui_set_clip(x1 + 1, y1 + 1, x2 - 1, y2 - 1);
  1920.                     }
  1921.                     gui_draw_filled_area(
  1922.                         x1 + b->text_x + b->text_offset_x - 1,
  1923.                         text_border_y1,
  1924.                         x1 + b->text_x + b->text_offset_x + b->edit_width,
  1925.                         text_border_y2,
  1926.                         b->text_filler);
  1927.                     gui_pop_clip();
  1928.                 }
  1929.             }
  1930.             else    /* if including info_area then do .. */
  1931.             {
  1932.                 gui_set_clip(b->x, y1 - wgui_inputbox_information_bar_height - l_height, x2, y2 - l_clip);
  1933.                 f.flags = UI_FILLED_AREA_TYPE_BITMAP;
  1934.                 f.b = get_image(WGUI_VOLUME_LEVEL1);    /* test */
  1935.                 /* 070405 Calvin Start */
  1936.                 if ((wgui_is_wallpaper_on_bottom() == MMI_TRUE) &&
  1937.                     (flags & UI_MULTI_LINE_INPUT_BOX_TRANSPARENT_BACKGROUND))
  1938.                 {
  1939.                     gdi_draw_solid_rect(
  1940.                         b->x,
  1941.                         y1 - wgui_inputbox_information_bar_height - l_height,
  1942.                         x2,
  1943.                         y2,
  1944.                         GDI_COLOR_TRANSPARENT);
  1945.                 }
  1946.                 else
  1947.                 {
  1948.                     gui_draw_filled_area(b->x, y1 - wgui_inputbox_information_bar_height - l_height, x2, y2, &f);
  1949.                 }
  1950.                 /* 070405 Calvin End */
  1951.                 if (r2lMMIFlag)
  1952.                 {
  1953.                     gui_draw_rectangle(b->x, y1 - l_height, x2 /* +b->vbar.width */ , y2, b->boundary_color);
  1954.                 }
  1955.                 else
  1956.                 {
  1957.                     gui_draw_rectangle(x1, y1 - l_height, x2, y2, b->boundary_color);
  1958.                 }
  1959.                 if (flags & UI_MULTI_LINE_INPUT_BOX_USE_PRESET_CLIPPING)
  1960.                 {
  1961.                     gui_set_clip_preset(x1, y1 - l_height, x2 + 2, y2 + 2 - l_clip);
  1962.                 }
  1963.                 else
  1964.                 {
  1965.                     gui_set_clip(x1, y1 - l_height, x2 + 2, y2 + 2 - l_clip);
  1966.                 }
  1967.             }
  1968.         }
  1969.     #if defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__)
  1970.         if (MMI_multi_line_inputbox_present)
  1971.         {
  1972.             /* Gurinder 6/5/2004 - Show Information Bar / Caption String */
  1973.             if (!(b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE))
  1974.             {
  1975.                 //Show Information Bar
  1976.                 //START TARUN PMT 20040927  ADDED : Check the flag before redrawing the info bar
  1977.                 if (wgui_inputbox_information_flag)
  1978.                 {
  1979.                     wgui_redraw_input_information_bar();
  1980.                 }
  1981.                 /* END TARUN PMT 20040927 */
  1982.             }
  1983.         #if(INSCREEN_MUTLILINE_TITLE_ENABLE)
  1984.             /* Gurinder 7/14/2004 - Inscreen Multiline Title Enable/Disable */
  1985.             else
  1986.             {
  1987.                 /* Show Signature Text.... */
  1988.                 gui_draw_inscreen_multi_line_input_box_title(x1, y1 - l_height + 1, x2 - 2, y1 - 1);
  1989.             }
  1990.         #endif /* (INSCREEN_MUTLILINE_TITLE_ENABLE) */ 
  1991.         }
  1992.     #endif /* defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__) */ 
  1993.     }
  1994. #ifdef __MMI_BIDI_ALG__
  1995.     if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) && (((b->text_length >> 1) - 1) != 0))
  1996.     {
  1997.         bidi_get_char_type(b->text, (U8*) & default_direction);
  1998.         if (default_direction == BIDI_R || default_direction == AL)
  1999.         {
  2000.             default_direction = BIDI_R;
  2001.         }
  2002.         else
  2003.         {
  2004.             default_direction = BIDI_L;
  2005.         }
  2006.         for (iCount = 0; iCount < (U32) ((b->text_length >> 1) - 1); iCount++)
  2007.         {
  2008.             bidi_get_char_type((U8*) (b->text + iCount * ENCODING_LENGTH), (U8*) & lastest_char_type);
  2009.             if ((lastest_char_type == AL) || (lastest_char_type == AN) || (lastest_char_type == BIDI_R))
  2010.             {
  2011.                 arabic_char_flag = MMI_TRUE;
  2012.                 break;
  2013.             }
  2014.         }
  2015.         if (arabic_char_flag)
  2016.         {
  2017.             /* 
  2018.              * Tricky: icon is not supported in Arabic because text order is rearranged.
  2019.              * Set icon_callback to NULL to disable icon in cursor movement, delete character, and display.
  2020.              * Otherwise, we have to modify BIDI to support 'icon_callback'.
  2021.              */
  2022.             b->icon_callback = NULL;
  2023.         }
  2024.     }
  2025. #endif /* __MMI_BIDI_ALG__ */ 
  2026. //hjf recalculate the x boundary
  2027.     if (!(flags & UI_EMS_INPUT_BOX_DISABLE_SCROLLBAR))
  2028.     {
  2029.         x2 -= b->vbar.width;
  2030.     }
  2031.     edit_width = (x2 - x1 - 2);
  2032.     if (b->text != NULL)
  2033.     {
  2034.         /* START PMTFARHAD 20050224 */
  2035.     #if defined __MMI_LANG_HINDI__ && (defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__)
  2036.         PMT_BIDI_TYPES temp_default_direction = BIDI_L;
  2037.         temp_default_direction = default_direction;
  2038.         bidi_get_char_type(b->text, (U8*) & default_direction);
  2039.         if ((default_direction == AL) || (default_direction == AN) || (default_direction == BIDI_R))
  2040.         {
  2041.             ARABIC_PRESENT = 1;
  2042.         }
  2043.         default_direction = temp_default_direction;
  2044.     #endif /* defined __MMI_LANG_HINDI__ && defined __MMI_LANG_ARABIC__ */ 
  2045.         /* END PMTFARHAD 20050224 */
  2046.     #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  2047.         if (b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_VIEW_PAGING_MODE)
  2048.         {
  2049.             switch (b->font_style)
  2050.             {
  2051.                 case FONT_DEFAULT:
  2052.                     rich_text.curr_font.italic = rich_text.curr_font.bold = 0;
  2053.                     break;
  2054.                 case FONT_BOLD:
  2055.                     rich_text.curr_font.bold = 1;
  2056.                     rich_text.curr_font.italic = 0;
  2057.                     break;
  2058.                 case FONT_ITALIC:
  2059.                     rich_text.curr_font.italic = 1;
  2060.                     rich_text.curr_font.bold = 0;
  2061.                     break;
  2062.             }
  2063.         }
  2064.     #endif /* __UI_PAGING_IN_MULTILINE_EDITOR__ */ 
  2065.         gui_set_font(&rich_text.curr_font); /* set text font */
  2066.         previous_line_height = character_height = gui_get_character_height();
  2067.         if (b->min_line_height > previous_line_height)
  2068.         {
  2069.             previous_line_height = character_height = b->min_line_height;
  2070.         }
  2071.         if (flags & UI_MULTI_LINE_INPUT_BOX_MASK_CHARACTERS)
  2072.         {
  2073.             gui_measure_character(b->mask_character, &mask_character_width, &mask_character_height);
  2074.         }
  2075.         /* Setup clipping for text and icon */
  2076.         if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))    /* if not disable draw then do ... */
  2077.         {
  2078.             UI_filled_area f;
  2079.             S32 clip_x1, clip_y1, clip_x2, clip_y2;
  2080.             U32 chk_flags;
  2081.             if (flags & UI_MULTI_LINE_INPUT_BOX_STATE_FOCUSSED)
  2082.             {
  2083.                 f = *b->focussed_filler;
  2084.             }
  2085.             else if (flags & UI_MULTI_LINE_INPUT_BOX_STATE_DISABLED)
  2086.             {
  2087.                 f = *b->disabled_filler;
  2088.             }
  2089.             else
  2090.             {
  2091.                 f = *b->normal_filler;
  2092.             }
  2093.             chk_flags = f.flags;
  2094.             /* Clipping is poped after the editor has finished drawing */
  2095.             gui_push_text_clip();
  2096.             gui_push_clip();
  2097.             if ((chk_flags & UI_FILLED_AREA_DOUBLE_BORDER) == UI_FILLED_AREA_DOUBLE_BORDER)
  2098.             {
  2099.                 clip_x1 = x1 + 2;
  2100.                 clip_y1 = y1 + 2;
  2101.                 clip_x2 = x2 - 2;
  2102.                 clip_y2 = y2 - ((l_clip > 2) ? l_clip : 2);
  2103.             }
  2104.             else if (chk_flags & UI_FILLED_AREA_BORDER)
  2105.             {
  2106.                 clip_x1 = x1 + 1;
  2107.                 clip_y1 = y1 + 1;
  2108.                 clip_x2 = x2 - 1;
  2109.                 clip_y2 = y2 - ((l_clip > 1) ? l_clip : 1);
  2110.             }
  2111.             else
  2112.             {
  2113.                 clip_x1 = x1;
  2114.                 clip_y1 = y1;
  2115.                 clip_x2 = x2;
  2116.                 clip_y2 = y2 - l_clip;
  2117.             }
  2118.             if (flags & UI_MULTI_LINE_INPUT_BOX_USE_PRESET_CLIPPING)
  2119.             {
  2120.                 gui_set_text_clip_preset(clip_x1, clip_y1, clip_x2, clip_y2);
  2121.                 gui_set_clip_preset(clip_x1, clip_y1, clip_x2, clip_y2);
  2122.             }
  2123.             else
  2124.             {
  2125.                 gui_set_text_clip(clip_x1, clip_y1, clip_x2, clip_y2);
  2126.                 gui_set_clip(clip_x1, clip_y1, clip_x2, clip_y2);
  2127.             }
  2128.         }
  2129.         if (previous_cursor_p != b->text)
  2130.         {
  2131.             UI_STRING_GET_PREVIOUS_CHARACTER(previous_cursor_p, dummy_c);
  2132.         }
  2133.         previous_line_start_text_p = line_start_text_p = b->text;
  2134.         if (flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP)
  2135.         {
  2136.         #ifdef __MMI_BIDI_ALG__
  2137.             if (arabic_char_flag)
  2138.             {
  2139.                 multitap_flag = 0;
  2140.             }
  2141.             else
  2142.         #endif /* __MMI_BIDI_ALG__ */ 
  2143.                 multitap_flag = 1;
  2144.         }
  2145.         if (flags & UI_MULTI_LINE_INPUT_BOX_OVERWRITE_MODE)
  2146.         {
  2147.             overwrite_flag = 1;
  2148.         }
  2149.         xx = x1 + b->text_x + b->text_offset_x;
  2150.         yy = y1 + b->text_y + b->text_offset_y;
  2151.         ty = b->header_height;
  2152.         b->max_line_height = 0;
  2153.     #if defined(__MMI_LANG_VIETNAMESE__)
  2154.         /* W05.38 Fix Viet Tone Cursor Moving Issue */
  2155.         if ((flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) && (((b->text_length >> 1) - 1) != 0))
  2156.         {
  2157.             UI_buffer_type temp_cursor_p = b->cursor_p;
  2158.             UI_character_type temp_tone, temp_vowel;
  2159.             UI_STRING_GET_NEXT_CHARACTER(temp_cursor_p, temp_tone);
  2160.             if ((temp_tone >= 0x0300) && (temp_tone <= 0x0323))
  2161.             {
  2162.                 temp_cursor_p = b->cursor_p;
  2163.                 UI_STRING_GET_PREVIOUS_CHARACTER(temp_cursor_p, temp_vowel);    /* get next character */
  2164.                 viet_vowel = mmi_viet_vowel_letter(temp_vowel);
  2165.                 if (VIET_VOWEL_NONE != viet_vowel)
  2166.                 {
  2167.                     tone_mark = mmi_viet_tone_mark(temp_tone);
  2168.                     if (VIET_TONE_NONE != tone_mark)
  2169.                     {
  2170.                         dummy_c = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  2171.                         UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  2172.                     }
  2173.                 }
  2174.             }
  2175.         }
  2176.     #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  2177.         /* Fix cursor position if it's inside a control sequence of an icon */
  2178.         if ((flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) &&
  2179.             !(flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE) && b->icon_callback)
  2180.         {
  2181.             UI_buffer_type temp_cursor_p = b->cursor_p;
  2182.             UI_buffer_type new_cursor_p = NULL;
  2183.             S32 pre_char_cnt, fit_char_cnt;
  2184.             for (pre_char_cnt = 1; pre_char_cnt <= MMI_MULTILINE_ICON_MAX_STRING_LEN; pre_char_cnt++)
  2185.             {
  2186.                 temp_cursor_p -= 2;
  2187.                 if (temp_cursor_p < b->text)
  2188.                 {
  2189.                     break;
  2190.                 }
  2191.                 if ((fit_char_cnt = b->icon_callback(temp_cursor_p, MMI_FALSE, NULL, NULL, 0, 0)) > 0)
  2192.                 {
  2193.                     if (fit_char_cnt > pre_char_cnt)
  2194.                     {
  2195.                         new_cursor_p = temp_cursor_p + fit_char_cnt * 2;
  2196.                         break;
  2197.                     }
  2198.                 }
  2199.             }
  2200.             if (new_cursor_p)
  2201.             {
  2202.                 current_cursor_p = previous_cursor_p = b->cursor_p = new_cursor_p;
  2203.             }
  2204.         }
  2205.          
  2206.         while (!done && (edit_width >= 0))   /* Compute line by line */
  2207.         {
  2208.             /* number of characters consumed by b->icon_callback */
  2209.             S32 char_cnt_for_control_seq = 0;
  2210.         #ifdef __MMI_HINDI_ALG__
  2211.             S32 idx = 0;
  2212.         #endif 
  2213.             /* Restore the text_gap and line spacing */
  2214.             text_gap = b->text_gap;
  2215.             rich_text.more_line_spacing = 0;
  2216.             rich_text.line_separator = 0;
  2217.             previous_line_width = current_line_width = 0;
  2218.         #ifdef __MMI_HINDI_ALG__
  2219.             saved_skip_moves = skip_moves = 1;
  2220.         #endif 
  2221.             current_cluster_width = 0;
  2222.         #ifdef __MMI_HINDI_ALG__
  2223.             cluster_filler_count = 0;
  2224.         #endif 
  2225.             previous_line_height = current_line_height = gui_get_character_height() + 1;
  2226.             if (b->min_line_height > current_line_height)
  2227.             {
  2228.                 previous_line_height = current_line_height = b->min_line_height;
  2229.             }
  2230.             current_line_character_counter = 0;
  2231.             current_line_break_character_counter = 0;
  2232.             /* MTK for Chinese Characters Display */
  2233.             break_flag = 0;
  2234.             /* MTK end */
  2235.             previous_text_p = line_break_text_p = current_text_p = line_start_text_p;
  2236.         #ifdef __MMI_HINDI_ALG__
  2237.             move_cursor_prev_p = line_start_text_p; /* TARUN 20041122 */
  2238.         #endif 
  2239.             draw_separator = FALSE;
  2240.             /*
  2241.              * Backup the font at the beginning of line
  2242.              * Alignment is setup in the first pass only, and color is set in the second pass only.
  2243.              */
  2244.             rich_text.line_begin_font = rich_text.curr_font;
  2245.             rich_text.line_begin_border = rich_text.curr_border;
  2246.             /* USAT */
  2247.             rich_text.line_begin_strikethrough = rich_text.curr_strikethrough;
  2248.             /* First pass. Determine the line positions */
  2249.             while (current_line_width < (edit_width - 1) 
  2250.             && current_line_character_counter< 128 ) // because EMS_object_height_cache[128]
  2251.             {
  2252.                 previous_text_p = current_text_p;
  2253.             #ifdef __MMI_HINDI_ALG__
  2254.                 /* only one movement first time */
  2255.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_show_multi_line_input_box:[skip_moves] :%d",
  2256.                                      skip_moves));
  2257.                 while (skip_moves--)
  2258.             #endif /* __MMI_HINDI_ALG__ */ 
  2259.                 {
  2260.                     UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);    /* get next character */
  2261.                 }
  2262.                  /* MTK Arabic connectivity issue */
  2263.             #if defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__
  2264. //??hjf this part should check the shaped chars not original data
  2265.                 temp_p = current_text_p;
  2266.                 UI_STRING_GET_NEXT_CHARACTER(temp_p, next_char);
  2267.                 if (IS_ARABIC_CHARACTER(current_character) && IS_ARABIC_CHARACTER(next_char))
  2268.                 {
  2269.                     text_gap = 0;
  2270.                 }
  2271.                 else
  2272.                 {
  2273.                     text_gap = b->text_gap;
  2274.                 }
  2275.             #endif /* defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__ */ 
  2276.                 /* MTK end */
  2277.                 /* W06.09 Touch Screen With Keypad V1 */
  2278.             #if defined(__MMI_FULL_SCREEN_EDITOR__) || defined(__MMI_TOUCH_SCREEN__)
  2279.                 /* MTK Terry for password display for __MMI_FULL_SCREEN_EDITOR__ */
  2280.                 if (flags & UI_MULTI_LINE_INPUT_BOX_MASK_CHARACTERS)
  2281.                 {
  2282.                     if ((flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP) && (previous_text_p == previous_cursor_p))
  2283.                     {
  2284.                         gui_measure_character(current_character, &mask_character_width, &mask_character_height);
  2285.                     }
  2286.                     else
  2287.                     {
  2288.                         gui_measure_character(b->mask_character, &mask_character_width, &mask_character_height);
  2289.                     }
  2290.                 }
  2291.             #endif /* defined(__MMI_FULL_SCREEN_EDITOR__) || defined(__MMI_TOUCH_SCREEN__) */ 
  2292.             #if defined(__MMI_LANG_VIETNAMESE__)
  2293.                 if ((current_character > 0x0040) && (current_character < 0x01B1))
  2294.                 {
  2295.                     UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);      /* get next character */
  2296.                     tone_mark = mmi_viet_tone_mark(dummy_c);
  2297.                     if (VIET_TONE_NONE != tone_mark)
  2298.                     {
  2299.                         viet_vowel = mmi_viet_vowel_letter(current_character);
  2300.                         if (VIET_VOWEL_NONE != viet_vowel)
  2301.                         {
  2302.                             current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  2303.                         }
  2304.                         else
  2305.                         {
  2306.                             UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, dummy_c);
  2307.                         }
  2308.                     }
  2309.                     else
  2310.                     {
  2311.                         UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, dummy_c);
  2312.                     }
  2313.                 }
  2314.             #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  2315.             #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
  2316.                 if (IS_ARABIC_CHARACTER(current_character))
  2317.                 {
  2318.                     U32 idx = (current_text_p - b->text) / 2 - 1;
  2319.                     U32 ligature_move = 0;
  2320.                     UI_character_type dummy_c_arabic = 0;
  2321.                     current_character = (UI_character_type) shaping_str[OrgToSha[idx]];
  2322.                     while (idx < unshaped_text_len - 1)
  2323.                     {
  2324.                         if (OrgToSha[idx] == OrgToSha[idx + 1])
  2325.                         {
  2326.                             ligature_move++;
  2327.                         }
  2328.                         else
  2329.                         {
  2330.                             break;
  2331.                         }
  2332.                         idx++;
  2333.                     }
  2334.                     while (ligature_move > 0)
  2335.                     {
  2336.                         UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
  2337.                         /* previous_text_p+=2; */
  2338.                         ligature_move--;
  2339.                     }
  2340.                 }
  2341.             #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */ 
  2342.                 if ((flags & UI_MULTI_LINE_INPUT_BOX_DRAW_SEPARATOR) && UI_TEST_ESC_CHARACTER(current_character))
  2343.                 {
  2344.                     /* START TARUN PMT 20050128 */
  2345.                 #ifdef __MMI_HINDI_ALG__
  2346.                     skip_moves = 1; /* If not required to move cursor ,char count should be incremented */
  2347.                 #endif 
  2348.                     /* END TARUN PMT 20050128 */
  2349.                     current_cluster_width = 0;
  2350.                 #ifdef __MMI_BIDI_ALG__
  2351.                     if (arabic_char_flag)
  2352.                     {
  2353.                         character_height = gui_get_character_height() + 3;
  2354.                     }
  2355.                     else
  2356.                 #endif /* __MMI_BIDI_ALG__ */ 
  2357.                         character_height = gui_get_character_height() + 2;      /* reserve one more pixel */
  2358.                     draw_separator = TRUE;
  2359.                 }
  2360.                 else
  2361.             #if(MULTILINE_INPUTBOX_DISPLAY_SPECIAL_CHARACTERS)
  2362.                 if (UI_TEST_CR_CHARACTER(current_character) ||
  2363.                         UI_TEST_LF_CHARACTER(current_character) || UI_TEST_ESC_CHARACTER(current_character))
  2364.                 {
  2365.                     /* START TARUN PMT 20050128 */
  2366.                 #ifdef __MMI_HINDI_ALG__
  2367.                     skip_moves = 1;             /* If not required to move cursor ,char count should be incremented */
  2368.                 #endif 
  2369.                     /* END TARUN PMT 20050128 */
  2370.                     current_cluster_width = 10; /* TARUN 20041122 */
  2371.                     character_height = 10;
  2372.                 }
  2373.                 else
  2374.                 {
  2375.             #endif /* (MULTILINE_INPUTBOX_DISPLAY_SPECIAL_CHARACTERS) */ 
  2376.                 #if(MULTILINE_INPUTBOX_USE_CRLF_COMBINATION)
  2377.                     if (UI_TEST_CR_CHARACTER(current_character) && UI_TEST_LF_CHARACTER(*current_text_p))
  2378.                     {
  2379.                         /* START TARUN PMT 20050128 */
  2380.                     #ifdef __MMI_HINDI_ALG__
  2381.                         skip_moves = 1;             /* If not required to move cursor ,char count should be incremented */
  2382.                     #endif 
  2383.                         /* END TARUN PMT 20050128 */
  2384.                         current_cluster_width = 0;  /* TARUN 20041122 */
  2385.                         character_height = gui_get_character_height();
  2386.                     }
  2387.                     else
  2388.                 #endif /* (MULTILINE_INPUTBOX_USE_CRLF_COMBINATION) */ 
  2389.                     if (flags & UI_MULTI_LINE_INPUT_BOX_MASK_CHARACTERS)
  2390.                     {
  2391.                         /* START TARUN PMT 20050128 */
  2392.                     #ifdef __MMI_HINDI_ALG__
  2393.                         skip_moves = 1; /* If not required to move cursor ,char count should be incremented */
  2394.                     #endif 
  2395.                         /* END TARUN PMT 20050128 */
  2396.                         current_cluster_width = mask_character_width;   /* TARUN 20041122 */
  2397.                         character_height = mask_character_height;
  2398.                     }
  2399.                     else if (char_cnt_for_control_seq > 0)
  2400.                     {
  2401.                     #ifdef __MMI_HINDI_ALG__
  2402.                         skip_moves = 1; /* If not required to move cursor ,char count should be incremented */
  2403.                     #endif 
  2404.                         text_gap = 0;
  2405.                         current_cluster_width = 0;
  2406.                     character_height = character_heights_cache[current_line_character_counter-1]; /* hjf should reuse last char's height */
  2407.                     }
  2408.                     else if ((flags & UI_MULTI_LINE_INPUT_BOX_RICHTEXT) && GUI_INPUT_IS_MARKER(current_character))
  2409.                     {
  2410.                         BOOL change_font = MMI_FALSE;
  2411.                         text_gap = 0;
  2412.                         current_cluster_width = 0;
  2413.                         /* We do not want to assign 'current_line_height' because we might change to small font */
  2414.                         character_height = 1;
  2415.                     #ifdef __MMI_HINDI_ALG__
  2416.                         skip_moves = 1; /* If not required to move cursor ,char count should be incremented */
  2417.                     #endif 
  2418.                         switch (current_character)
  2419.                         {
  2420.                             case GUI_INPUT_MARKER_RESET_ALL:
  2421.                                 /* Reset font format and alignment (no color) */
  2422.                                 rich_text.curr_alignment = rich_text.default_alignment;
  2423.                                 rich_text.curr_font = *b->text_font;
  2424.                                 rich_text.curr_border = 0;
  2425.                                 /* USAT */
  2426.                                 rich_text.curr_strikethrough = 0;
  2427.                                 rich_text.more_line_spacing = 0;
  2428.                                 rich_text.line_separator = 0;
  2429.                                 change_font = MMI_TRUE;
  2430.                                 break;
  2431.                             case GUI_INPUT_MARKER_RESET_PARAGRAPH:
  2432.                                 rich_text.curr_alignment = rich_text.default_alignment;
  2433.                                 rich_text.more_line_spacing = 0;
  2434.                                 rich_text.line_separator = 0;
  2435.                                 break;
  2436.                             case GUI_INPUT_MARKER_RESET_FORMAT:
  2437.                                 rich_text.curr_font = *b->text_font;
  2438.                                 rich_text.curr_border = 0;
  2439.                                 /* USAT */
  2440.                                 rich_text.curr_strikethrough = 0;
  2441.                                 change_font = MMI_TRUE;
  2442.                                 break;
  2443.                             case GUI_INPUT_MARKER_RESET_COLOR:
  2444.                                 /* Do not change color because characters is not drawn in the first pass */
  2445.                                 break;
  2446.                             default:
  2447.                                 /* UAT */
  2448.                                 if ((current_character >= GUI_INPUT_MARKER_W3C_COLOR_BEGIN &&
  2449.                                      current_character <= GUI_INPUT_MARKER_W3C_COLOR_END) ||
  2450.                                     (current_character >= GUI_INPUT_MARKER_COLOR_BEGIN &&
  2451.                                      current_character <= GUI_INPUT_MARKER_COLOR_END) ||
  2452.                                     (current_character >= GUI_INPUT_MARKER_W3C_BORDER_COLOR_BEGIN &&
  2453.                                      current_character <= GUI_INPUT_MARKER_W3C_BORDER_COLOR_END) ||
  2454.                                     (current_character >= GUI_INPUT_MARKER_BORDER_COLOR_BEGIN &&
  2455.                                      current_character <= GUI_INPUT_MARKER_BORDER_COLOR_END) ||
  2456.                                     (current_character >= GUI_INPUT_MARKER_TEXT_BACKGROUND_COLOR_BEGIN &&
  2457.                                      current_character <= GUI_INPUT_MARKER_TEXT_BACKGROUND_COLOR_END))
  2458.                                 {
  2459.                                     /* Do not change color because characters is not drawn in the first pass */
  2460.                                 }
  2461.                                 else if (GUI_INPUT_IS_FORMAT_MARKER(current_character))
  2462.                                 {
  2463.                                     if (GUI_INPUT_CHECK_FORMAT_MARKER(current_character, GUI_INPUT_MARKER_BOLD))
  2464.                                     {
  2465.                                         rich_text.curr_font.bold = 1;
  2466.                                         change_font = MMI_TRUE;
  2467.                                     }
  2468.                                     if (GUI_INPUT_CHECK_FORMAT_MARKER(current_character, GUI_INPUT_MARKER_ITALIC))
  2469.                                     {
  2470.                                         rich_text.curr_font.italic = 1;
  2471.                                         change_font = MMI_TRUE;
  2472.                                     }
  2473.                                     if (GUI_INPUT_CHECK_FORMAT_MARKER(current_character, GUI_INPUT_MARKER_UNDERLINE))
  2474.                                     {
  2475.                                         rich_text.curr_font.underline = 1;
  2476.                                         change_font = MMI_TRUE;
  2477.                                     }
  2478.                                     /* USAT */
  2479.                                     if (GUI_INPUT_CHECK_FORMAT_MARKER
  2480.                                         (current_character, GUI_INPUT_MARKER_STRIKETHROUGH))
  2481.                                     {
  2482.                                         rich_text.curr_strikethrough = 1;
  2483.                                     }
  2484.                                     if (GUI_INPUT_CHECK_FORMAT_MARKER(current_character, GUI_INPUT_MARKER_BORDER))
  2485.                                     {
  2486.                                         /* We do not increase font size for bordered font because text gap is already enlarged */
  2487.                                         rich_text.curr_border = 1;
  2488.                                     }
  2489.                                     if (GUI_INPUT_CHECK_SIZE_MARKER(current_character, GUI_INPUT_MARKER_SMALL))
  2490.                                     {
  2491.                                         rich_text.curr_font.size = SMALL_FONT;
  2492.                                         change_font = MMI_TRUE;
  2493.                                     }
  2494.                                     else if (GUI_INPUT_CHECK_SIZE_MARKER(current_character, GUI_INPUT_MARKER_MEDIUM))
  2495.                                     {
  2496.                                         rich_text.curr_font.size = MEDIUM_FONT;
  2497.                                         change_font = MMI_TRUE;
  2498.                                     }
  2499.                                     else if (GUI_INPUT_CHECK_SIZE_MARKER(current_character, GUI_INPUT_MARKER_LARGE))
  2500.                                     {
  2501.                                         rich_text.curr_font.size = LARGE_FONT;
  2502.                                         change_font = MMI_TRUE;
  2503.                                     }
  2504.                                 }
  2505.                                 else if (GUI_INPUT_IS_PARAGRAPH_MARKER(current_character))
  2506.                                 {
  2507.                                     if (GUI_INPUT_CHECK_ALIGN_MARKER(current_character, GUI_INPUT_MARKER_ALIGN_LEFT))
  2508.                                     {
  2509.                                         rich_text.curr_alignment = GUI_INPUT_ALIGN_LEFT;
  2510.                                     }
  2511.                                     else if (GUI_INPUT_CHECK_ALIGN_MARKER
  2512.                                              (current_character, GUI_INPUT_MARKER_ALIGN_CENTER))
  2513.                                     {
  2514.                                         rich_text.curr_alignment = GUI_INPUT_ALIGN_CENTER;
  2515.                                     }
  2516.                                     else if (GUI_INPUT_CHECK_ALIGN_MARKER
  2517.                                              (current_character, GUI_INPUT_MARKER_ALIGN_RIGHT))
  2518.                                     {
  2519.                                         rich_text.curr_alignment = GUI_INPUT_ALIGN_RIGHT;
  2520.                                     }
  2521.                                     if (GUI_INPUT_CHECK_LINE_SPACING_MARKER
  2522.                                         (current_character, GUI_INPUT_MARKER_LINE_SPACING_1))
  2523.                                     {
  2524.                                         rich_text.more_line_spacing = 1;
  2525.                                     }
  2526.                                     else if (GUI_INPUT_CHECK_LINE_SPACING_MARKER
  2527.                                              (current_character, GUI_INPUT_MARKER_LINE_SPACING_2))
  2528.                                     {
  2529.                                         rich_text.more_line_spacing = 2;
  2530.                                     }
  2531.                                     else if (GUI_INPUT_CHECK_LINE_SPACING_MARKER
  2532.                                              (current_character, GUI_INPUT_MARKER_LINE_SPACING_3))
  2533.                                     {
  2534.                                         rich_text.more_line_spacing = 3;
  2535.                                     }
  2536.                                     else if (GUI_INPUT_CHECK_LINE_SPACING_MARKER
  2537.                                              (current_character, GUI_INPUT_MARKER_LINE_SPACING_4))
  2538.                                     {
  2539.                                         rich_text.more_line_spacing = 4;
  2540.                                     }
  2541.                                     else if (GUI_INPUT_CHECK_LINE_SPACING_MARKER
  2542.                                              (current_character, GUI_INPUT_MARKER_LINE_SPACING_5))
  2543.                                     {
  2544.                                         rich_text.more_line_spacing = 5;
  2545.                                     }
  2546.                                     else if (GUI_INPUT_CHECK_LINE_SPACING_MARKER
  2547.                                              (current_character, GUI_INPUT_MARKER_LINE_SPACING_6))
  2548.                                     {
  2549.                                         rich_text.more_line_spacing = 6;
  2550.                                     }
  2551.                                     else if (GUI_INPUT_CHECK_LINE_SPACING_MARKER
  2552.                                              (current_character, GUI_INPUT_MARKER_LINE_SPACING_7))
  2553.                                     {
  2554.                                         rich_text.more_line_spacing = 7;
  2555.                                     }
  2556.                                     if (GUI_INPUT_CHECK_PARAGRAPH_MARKER
  2557.                                         (current_character, GUI_INPUT_MARKER_LINE_SEPARATOR))
  2558.                                     {
  2559.                                         rich_text.line_separator = 1;
  2560.                                     }
  2561.                                     /* Reserve minimum line spacing for line separator */
  2562.                                     if (rich_text.line_separator && rich_text.more_line_spacing < 3)
  2563.                                     {
  2564.                                         rich_text.more_line_spacing = 3;
  2565.                                     }
  2566.                                 }
  2567.                                 break;
  2568.                         }
  2569.                         if (change_font)
  2570.                         {
  2571.                             gui_set_font(&rich_text.curr_font);
  2572.                         }
  2573.                     }
  2574.                     else if (b->icon_callback &&
  2575.                              (char_cnt_for_control_seq =
  2576.                               b->icon_callback(
  2577.                                     previous_text_p,
  2578.                                     MMI_FALSE,
  2579.                                     &current_cluster_width,
  2580.                                     &character_height,
  2581.                                     0,
  2582.                                     0)) > 0)
  2583.                     {
  2584.                     #ifdef __MMI_HINDI_ALG__
  2585.                         skip_moves = 1; /* If not required to move cursor ,char count should be incremented */
  2586.                     #endif 
  2587.                     }
  2588.                     else
  2589.                     {
  2590.                     #ifdef __MMI_HINDI_ALG__
  2591.                         /* MTK Terry for Cursor Height Issue */
  2592.                         if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  2593.                         {
  2594.                             character_height = gui_get_character_height();
  2595.                         }
  2596.                         else
  2597.                         {
  2598.                             gui_measure_character(current_character, &current_cluster_width, &character_height);
  2599.                         }
  2600.                     #else /* __MMI_HINDI_ALG__ */ 
  2601.                         gui_measure_character(current_character, &current_cluster_width, &character_height);
  2602.                     #endif /* __MMI_HINDI_ALG__ */ 
  2603.                         if (!RequireToMoveCursor(pre_character, current_character))
  2604.                         {
  2605.                             current_cluster_width = 0;
  2606.                         #ifdef __MMI_HINDI_ALG__
  2607.                             skip_moves = 1; /* If not required to move cursor ,char count should be incremented */
  2608.                             /* START TARUN PMT 20050128 */