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

MTK

开发平台:

C/C++

  1.                             move_cursor_prev_p += 2;
  2.                             /* END TARUN PMT 20050128 */
  3.                         #endif /* __MMI_HINDI_ALG__ */ 
  4.                         }
  5.                     #ifdef __MMI_HINDI_ALG__
  6.                         else
  7.                         {
  8.                             /* Move pointer by the cluster width */
  9.                             //Performance issue
  10.                             //move_cursor_curr_p = hf_get_next_cluster_p((PU16)b->text,move_cursor_prev_p);
  11.                             move_cursor_curr_p = hf_get_next_cluster_p(move_cursor_prev_p, move_cursor_prev_p);
  12.                             skip_moves = move_cursor_curr_p - move_cursor_prev_p;       /* Number of moves */
  13.                             if (skip_moves <= 0)    /* Not Required Now 20041228 */
  14.                             {
  15.                                 skip_moves = 1; /* At least 1 */
  16.                             }
  17.                             else
  18.                             {
  19.                                 skip_moves = skip_moves >> 1;
  20.                             }
  21.                             saved_skip_moves = skip_moves;  /* Save moves to skip the current_text_p also */
  22.                             /* Calculate the width of current cluster as well as english character */
  23.                             /* current_cluster_width = hf_size_of_current_cluster((PU16)b->text,move_cursor_curr_p,0); */
  24.                             current_cluster_width = hf_size_of_current_cluster(move_cursor_prev_p, move_cursor_curr_p, 0);
  25.                             PRINT_INFORMATION_2((MMI_TRACE_INFO,
  26.                                                  "pixtel_UI_show_multi_line_input_box:[current_cluster_width] :%d",
  27.                                                  current_cluster_width));
  28.                             if (current_cluster_width + current_line_width >= edit_width)
  29.                             {
  30.                                 previous_text_p = move_cursor_prev_p;
  31.                             }
  32.                             move_cursor_prev_p = move_cursor_curr_p;
  33.                         }
  34.                     #endif /* __MMI_HINDI_ALG__ */ 
  35.                         /* 120104 Calvin added */
  36.                     #ifdef __MMI_MESSAGES_CHAT__
  37.                         if(b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_CHAT_ICON_DISPLAY)
  38.                         {
  39.                             if (UI_TEST_GRP_SEP_CHARACTER(current_character))
  40.                             {
  41.                                 gdi_image_get_dimension(
  42.                                     (U8*) GetImage(CHAT_LOCAL_IMG),
  43.                                     &current_cluster_width,
  44.                                     &character_height);
  45.                             }
  46.                             else if (UI_TEST_FILE_SEP_CHARACTER(current_character))
  47.                             {
  48.                                 gdi_image_get_dimension(
  49.                                     (U8*) GetImage(CHAT_REMOTE_IMG),
  50.                                     &current_cluster_width,
  51.                                     &character_height);
  52.                             }
  53.                             else if (UI_TEST_SENDER_TRUNCATE_SEP_CHARACTER(current_character))
  54.                             {
  55.                                 gdi_image_get_dimension(
  56.                                     (U8*) GetImage(CHAT_SENDER_TRUNCATE_IMG),
  57.                                     &current_cluster_width,
  58.                                     &character_height);
  59.                             }
  60.                             else if (UI_TEST_RECEIVER_TRUNCATE_SEP_CHARACTER(current_character))
  61.                             {
  62.                                 gdi_image_get_dimension(
  63.                                     (U8*) GetImage(CHAT_RECEIVER_TRUNCATE_IMG),
  64.                                     &current_cluster_width,
  65.                                     &character_height);
  66.                             }
  67.                         }
  68.                     #endif /* __MMI_MESSAGES_CHAT__ */ 
  69.                         /* Calvin end */
  70.                     }
  71.                     if (UI_TEST_LF_CHARACTER(current_character) || UI_TEST_CR_CHARACTER(current_character))
  72.                     {
  73.                         current_cluster_width = 0;
  74.                     }
  75.                 #if(MULTILINE_INPUTBOX_DISPLAY_SPECIAL_CHARACTERS)
  76.                 }
  77.                 #endif 
  78.                 if (UI_STRING_END_OF_STRING_CHARACTER(current_character) ||
  79.                     UI_STRING_LINE_BREAK_CHARACTER(current_character))
  80.                 {
  81.                     current_cluster_width = 0;
  82.                 }
  83.             #ifdef __MMI_HINDI_ALG__  //??hjf it should not need this compile option, and HINDI should also cached!
  84.                 if (!UI_HINDI_CHARACTER_UCS2_RANGE(current_character) && !(UI_STRING_END_OF_STRING_CHARACTER(current_character)))       /* bakshi */
  85.             #endif 
  86.                 {
  87.                     character_str_cache[current_line_character_counter] = (U16) current_character;
  88.                     character_widths_cache[current_line_character_counter] = (U8) current_cluster_width;        /* TARUN 20041122 */
  89.                 #ifdef __MMI_BIDI_ALG__
  90.                     if (arabic_char_flag)
  91.                     {
  92.                         character_heights_cache[current_line_character_counter] = (U8) gui_get_character_height() + 2;
  93.                     }
  94.                     else
  95.                 #endif /* __MMI_BIDI_ALG__ */ 
  96.                         character_heights_cache[current_line_character_counter] = (U8) character_height;
  97.                 }
  98.                 if (RequireToMoveCursor(pre_character, current_character))
  99.                 {
  100.                 #ifdef __MMI_HINDI_ALG__
  101.                     /* To stop the unwanted text to be added in cuurent_line_width */
  102.                     if (!UI_STRING_END_OF_STRING_CHARACTER(current_character))
  103.                     {
  104.                         /* Calculate the width for the whole string as well as single english char */
  105.                         if (current_cluster_width != 0)
  106.                         {
  107.                             current_line_width += current_cluster_width + text_gap;     /* text_gap added by TARUN 20041123 */
  108.                         }
  109.                     }
  110.                     else
  111.                     {
  112.                         current_line_width += text_gap * 2;
  113.                     }
  114.                     PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_show_multi_line_input_box:[current_line_width] :%d",
  115.                                          current_line_width));
  116.                     if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  117.                     {
  118.                         hindi_cluster_counter = current_line_character_counter; /* TARUN 20041123 */
  119.                         while (saved_skip_moves--)
  120.                         {
  121.                             character_widths_cache[hindi_cluster_counter] = 0;
  122.                             character_heights_cache[hindi_cluster_counter] = (U8) character_height;
  123.                             hindi_cluster_counter++;
  124.                         }
  125.                         /* START TARUN 20050107 */
  126.                         cluster_width_filler[cluster_filler_count] = current_cluster_width;
  127.                         /* END TARUN 20050107 */
  128.                     }
  129.                 #else /* __MMI_HINDI_ALG__ */ 
  130.                     if (current_cluster_width != 0)
  131.                     {
  132.                         current_line_width += current_cluster_width + text_gap;
  133.                     }
  134.                     /* MTK Terry for cursor overlap scroll bar */
  135.                     if (UI_STRING_END_OF_STRING_CHARACTER(current_character))
  136.                     {
  137.                         current_line_width += text_gap;
  138.                     }
  139.                 #endif /* __MMI_HINDI_ALG__ */ 
  140.                 }
  141.                 else
  142.                 {
  143.                     current_line_width += current_cluster_width /* +text_gap */ ;       /* TARUN 20041122 */
  144.                 }
  145.                 pre2_character = pre_character;
  146.                 pre_character = current_character;
  147.                 /* MTK end */
  148.             #ifdef __MMI_HINDI_ALG__
  149.                 current_line_character_counter += skip_moves;
  150.                 /* START TARUN 20050107 */
  151.                 cluster_filler_count++;
  152.                 /* END TARUN 20050107 */
  153.             #else /* __MMI_HINDI_ALG__ */ 
  154.                 current_line_character_counter++;
  155.             #endif /* __MMI_HINDI_ALG__ */ 
  156.                 if (char_cnt_for_control_seq == 0 && !(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_WRAPPING_BY_WORD))
  157.                 {
  158.                     UI_MULTI_LINE_INPUT_BOX_BREAK_CHARACTER(current_character, break_character_flag);
  159.                 }
  160.                 else
  161.                 {
  162.                     break_character_flag = 0;
  163.                 }
  164.                 /* MTK Terry For the last character of the line is 0x20 and the cursor moving will be incorrect */
  165.                 if ((!break_character_flag || current_character == 0x20) && (current_line_width > edit_width - 1))
  166.                 {
  167.                     /* Get rid of infinite loop If editor width is smaller than one character. */
  168.                     if (current_line_character_counter == 1)
  169.                     {
  170.                         done = 1;
  171.                     }
  172.                     break;
  173.                 }
  174.                 saved_line_height = current_line_height;
  175.     /*hjf character height + 1 if bigger then current line height */
  176.                 if((character_height + rich_text.more_line_spacing +reserve_line_height_for_hilite + 1) > current_line_height)
  177.                 {
  178.                     current_line_height = character_height + rich_text.more_line_spacing + reserve_line_height_for_hilite +1;
  179.                 }
  180.                 if (UI_STRING_END_OF_STRING_CHARACTER(current_character))
  181.                 {
  182.                     current_line_break_character_counter = current_line_character_counter;
  183.                     line_break_text_p = current_text_p;
  184.                     b->last_position_p = current_text_p;
  185.                     previous_line_width = current_line_width - current_cluster_width - text_gap;
  186.                     previous_line_height = saved_line_height;
  187.                     done = 1;
  188.                     break;
  189.                 }
  190.                 else if (UI_STRING_LINE_BREAK_CHARACTER(current_character))
  191.                 {
  192.                     current_line_break_character_counter = current_line_character_counter;
  193.                     line_break_text_p = current_text_p;
  194.                     previous_line_width = current_line_width - current_cluster_width - text_gap;
  195.                     previous_line_height = saved_line_height;
  196.                     break;
  197.                 }
  198.                 else
  199.                 {
  200.                     if (break_character_flag)
  201.                     {
  202.                         current_line_break_character_counter = current_line_character_counter;
  203.                         line_break_text_p = current_text_p;
  204.                         if (UI_MULTI_LINE_INPUT_BOX_SPACE_CHARACTER(current_character))
  205.                         {
  206.                             previous_line_width = current_line_width - current_cluster_width - text_gap;
  207.                             previous_line_height = saved_line_height;
  208.                             /* MTK for Chinese Characters Display */
  209.                             break_flag = 1;
  210.                             /* MTK end */
  211.                         }
  212.                         else
  213.                         {
  214.                             previous_line_width = current_line_width;
  215.                             previous_line_height = current_line_height;
  216.                         }
  217.                     }
  218.                     /* MTK for Chinese Characters Display */
  219.                 #ifdef __MMI_HINDI_ALG__
  220.                     /* Hindi Word wrapping issue */
  221.                     if (!UI_MULTI_LINE_INPUT_BOX_ALPHABETIC_CHARACTER(current_character) &&
  222.                         !((flags & UI_MULTI_LINE_INPUT_BOX_RICHTEXT) &&
  223.                           GUI_INPUT_IS_MARKER(current_character)) &&
  224.                         (1 == break_flag) && (!UI_HINDI_CHARACTER_UCS2_RANGE(current_character)))
  225.                 #else /* __MMI_HINDI_ALG__ */ 
  226.                     if (!UI_MULTI_LINE_INPUT_BOX_ALPHABETIC_CHARACTER(current_character) &&
  227.                         !((flags & UI_MULTI_LINE_INPUT_BOX_RICHTEXT) && GUI_INPUT_IS_MARKER(current_character)) &&
  228.                         (1 == break_flag))
  229.                 #endif /* __MMI_HINDI_ALG__ */ 
  230.                     {
  231.                         current_line_break_character_counter = 0;
  232.                     }
  233.                     /* MTK end */
  234.                 }
  235.                 if (char_cnt_for_control_seq > 0)
  236.                 {
  237.                     char_cnt_for_control_seq--;
  238.                 }
  239.             }
  240.             if ((current_line_break_character_counter == 0) && (current_line_character_counter > 0))
  241.             {
  242.             #ifdef __MMI_HINDI_ALG__
  243.                 PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_show_multi_line_input_box:NEW LINE  "));
  244.                 current_line_break_character_counter = current_line_character_counter - skip_moves;
  245.             #else /* __MMI_HINDI_ALG__ */ 
  246.                 current_line_break_character_counter = current_line_character_counter - 1;
  247.             #endif /* __MMI_HINDI_ALG__ */ 
  248.                 line_break_text_p = previous_text_p;
  249.                 previous_line_width = current_line_width - current_cluster_width - text_gap;
  250.                 previous_line_height = saved_line_height;
  251.             }
  252.             /* Second pass. Display the entire line            */
  253.             pre2_character = 0;
  254.             pre_character = 0;
  255.         #ifdef __MMI_HINDI_ALG__
  256.             cluster_filler_count = 0;
  257.             //START FARHAD PMT 20050211
  258.             // move_cursor_disp_prev_p= b->text;
  259.             b->last_position_p = current_text_p;
  260.             /* END FARHAD PMT 20050211 */
  261.         #endif /* __MMI_HINDI_ALG__ */ 
  262.             current_line_character_counter = 0;
  263.         #ifdef __MMI_BIDI_ALG__
  264.             saved_current_text_p = current_text_p;
  265.         #endif 
  266.             current_text_p = line_start_text_p;
  267.             current_line_height = previous_line_height;
  268.             tx = 0;
  269.             /* Restore the font at the beginning of line  */
  270.             rich_text.curr_font = rich_text.line_begin_font;
  271.             rich_text.curr_border = rich_text.line_begin_border;
  272.             /* USAT */
  273.             rich_text.curr_strikethrough = rich_text.line_begin_strikethrough;
  274.             gui_set_font(&rich_text.curr_font);
  275.    /***ritesh is adding code for page height concept from here***/
  276.         #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  277.             if (b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_VIEW_PAGING_MODE)
  278.             {
  279.          /** to determine the height of the currently displayed window.if condition is taken here to get the current **/
  280.                 if (total_page_height >= -(b->text_offset_y) &&
  281.                     b->edit_height_displayed_lines + current_line_height <= edit_height)
  282.                 {
  283.                     if (total_page_height == -b->text_offset_y)
  284.                     {
  285.                         if (b->text_offset_y == 0)
  286.                         {
  287.                             b->text_offset = 0; /* text_count :offset of the character where text_offset_y is currently pointing.char_count variable is needed when application exit. */
  288.                         }
  289.                         else
  290.                         {
  291.                             b->text_offset = char_count;
  292.                         }
  293.                     }
  294.                     if (total_page_height > -b->text_offset_y &&
  295.                         total_page_height - (-b->text_offset_y) < current_line_height)
  296.                     {
  297.                         b->text_offset = char_count;
  298.                     }
  299.                     total_page_height += current_line_height;
  300.                     b->edit_height_displayed_lines += current_line_height;
  301.                 }
  302.                 else
  303.                 {
  304.                     total_page_height += current_line_height;
  305.                 }
  306.                 char_count += current_line_break_character_counter;     /* for every line ,char_count is incermented by the no of containing in that line */
  307.                 /* if concerned application wants to show the text from the particular offset then this offset value is copied into 
  308.                    page_offset element of the multiline structure.According to this text_offset_y is calculated.This page_offset is compared against char_count to get text_offset_y */
  309.                 if (b->page_offset >= char_count || b->jump_offset_from_app >= char_count)
  310.                 {
  311.                     b->text_offset_y -= current_line_height;
  312. b->text_offset = char_count;
  313.                 }
  314.                 /*
  315.                  * this condition is tested for the 1st page.
  316.                  * "b->previous_shared_bytes" is considered to be the part of the page at 0th index in the buffer.it is needed to maintain the height of page 
  317.                  * available in the buffer.height of page is also dependent on the shared_bytes with next or previous page.
  318.                  * In case of next page entry,the page at 0th index will be out from the buffer and the page next to the removed one will come to 0th index and so on
  319.                  * 
  320.                  * check_flag: check_flag is needed to prevent the body of every if should be executed once.
  321.                  * 
  322.                  * page_size=512 bytes.if char_count>=512 then it should go through the if condition and set the check_flag to 1. 
  323.                  */
  324.                 if (char_count >= (GUI_PAGE_SIZE + (b->previous_shared_bytes / ENCODING_LENGTH)) && check_flag == 0)
  325.                 {
  326.                     /* if shared bytes is zero. previous_shared_bytes is the bytes which is shared between page at 0th and 1st index in the buffer** */
  327.                     if ((shared_data_count =
  328.                          char_count % (GUI_PAGE_SIZE + (b->previous_shared_bytes / ENCODING_LENGTH))) == 0)
  329.                     {
  330.                         b->page_details[PAGE_ZERO].page_id = b->start_id;
  331.                         b->page_details[PAGE_ZERO].page_height = total_page_height;
  332.                         b->page_details[PAGE_ZERO].shared_no_of_bytes = 0;
  333.                     }
  334.                     else
  335.                     {
  336.                         memcpy(
  337.                             b->page_details[PAGE_ZERO].shared_data,
  338.                             b->text + (GUI_PAGE_SIZE + (b->previous_shared_bytes / ENCODING_LENGTH) - current_line_break_character_counter + shared_data_count) * ENCODING_LENGTH,
  339.                             (current_line_break_character_counter - shared_data_count) * ENCODING_LENGTH);
  340.                         b->page_details[PAGE_ZERO].page_id = b->start_id;
  341.                         b->page_details[PAGE_ZERO].page_height = total_page_height - current_line_height;
  342.                         b->page_details[PAGE_ZERO].shared_no_of_bytes =
  343.                             (current_line_break_character_counter - shared_data_count) * ENCODING_LENGTH;
  344.                     }
  345.                     check_flag = 1;
  346.                 }
  347.                 /*
  348.                  * 2nd page details calculation:
  349.                  * GUI_PAGE_SIZE=512 bytes.if char_count>=GUI_PAGE_SIZE*2 then it should go through the if condition and set the check_flag to 2. 
  350.                  */
  351.                 else if (char_count >= GUI_PAGE_SIZE * 2 && check_flag == 1)
  352.                 {
  353.                     if ((shared_data_count = char_count % (GUI_PAGE_SIZE * 2)) == 0)
  354.                     {
  355.                         b->page_details[PAGE_ONE].page_id = b->start_id + 1;
  356.                         b->page_details[PAGE_ONE].page_height =
  357.                             total_page_height - b->page_details[PAGE_ZERO].page_height;
  358.                         b->page_details[PAGE_ONE].shared_no_of_bytes = 0;
  359.                     }
  360.                     else
  361.                     {
  362.                         memcpy(
  363.                             b->page_details[PAGE_ONE].shared_data,
  364.                             b->text + ((GUI_PAGE_SIZE * 2) - current_line_break_character_counter + shared_data_count) * ENCODING_LENGTH,
  365.                             (current_line_break_character_counter - shared_data_count) * ENCODING_LENGTH);
  366.                         b->page_details[PAGE_ONE].page_id = b->start_id + 1;
  367.                         b->page_details[PAGE_ONE].page_height =
  368.                             total_page_height - b->page_details[PAGE_ZERO].page_height - current_line_height;
  369.                         b->page_details[PAGE_ONE].shared_no_of_bytes =
  370.                             (current_line_break_character_counter - shared_data_count) * ENCODING_LENGTH;
  371.                     }
  372.                     check_flag = 2;
  373.                 }
  374.                 /*
  375.                  * 3rd page details calculation: 
  376.                  * GUI_PAGE_SIZE=512 bytes.if char_count>=GUI_PAGE_SIZE*3 then it should go through the if condition and set the check_flag to 3. 
  377.                  */
  378.                 else if (char_count >= GUI_PAGE_SIZE * 3 && check_flag == 2)
  379.                 {
  380.                     if ((shared_data_count = char_count % (GUI_PAGE_SIZE * 3)) == 0)
  381.                     {
  382.                         b->page_details[PAGE_TWO].page_id = b->start_id + 2;
  383.                         b->page_details[PAGE_TWO].page_height =
  384.                             total_page_height - b->page_details[PAGE_ONE].page_height -
  385.                             b->page_details[PAGE_ZERO].page_height;
  386.                         b->page_details[PAGE_TWO].shared_no_of_bytes = 0;
  387.                     }
  388.                     else
  389.                     {
  390.                         memcpy(
  391.                             b->page_details[PAGE_TWO].shared_data,
  392.                             b->text + ((GUI_PAGE_SIZE * 3) - current_line_break_character_counter + shared_data_count) * ENCODING_LENGTH,
  393.                             (current_line_break_character_counter - shared_data_count) * ENCODING_LENGTH);
  394.                         b->page_details[PAGE_TWO].page_id = b->start_id + 2;
  395.                         b->page_details[PAGE_TWO].page_height =
  396.                             total_page_height - b->page_details[page_index + 1].page_height -
  397.                             b->page_details[page_index + 0].page_height + current_line_height;
  398.                         b->page_details[PAGE_TWO].shared_no_of_bytes =
  399.                             (current_line_break_character_counter - shared_data_count) * ENCODING_LENGTH;
  400.                     }
  401.                     check_flag = 3;
  402.                 }
  403.                 /*
  404.                  * 4th page details calculation: 
  405.                  * GUI_PAGE_SIZE=512 bytes.if char_count>=GUI_PAGE_SIZE*4 then it should go through the if coditon. 
  406.                  */
  407.                 else if ((char_count >= GUI_PAGE_SIZE * 3 /* && count_flag==0 */ ) && check_flag == 3)
  408.                 {
  409.                     /* count_flag=1; */
  410.                     b->page_details[PAGE_THREE].shared_no_of_bytes = 0;
  411.                     b->page_details[PAGE_THREE].page_id = b->start_id + 3;
  412.                     b->page_details[PAGE_THREE].page_height =
  413.                         total_page_height - b->page_details[page_index + PAGE_TWO].page_height -
  414.                         b->page_details[page_index + PAGE_ONE].page_height - b->page_details[page_index +
  415.                                                                                              PAGE_ZERO].page_height;
  416.                 }
  417.             }
  418.         #endif /* __UI_PAGING_IN_MULTILINE_EDITOR__ */ 
  419.    /****ritesh has ended****/
  420.             if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))
  421.             {
  422.                 if (rich_text.curr_alignment == GUI_INPUT_ALIGN_CENTER)
  423.                 {
  424.                     temp_text_p = current_text_p;
  425.                     UI_STRING_GET_NEXT_CHARACTER(temp_text_p, current_character);
  426.                 #if defined(__MMI_LANG_VIETNAMESE__)
  427.                     if ((current_character > 0x0040) && (current_character < 0x01B1))
  428.                     {
  429.                         //next_unicode = String[2];
  430.                         //next_unicode |= (String[3]<<8);
  431.                         UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);  /* get next character */
  432.                         tone_mark = mmi_viet_tone_mark(dummy_c);
  433.                         if (VIET_TONE_NONE != tone_mark)
  434.                         {
  435.                             viet_vowel = mmi_viet_vowel_letter(current_character);
  436.                             if (VIET_VOWEL_NONE != viet_vowel)
  437.                             {
  438.                                 current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  439.                             }
  440.                             else
  441.                             {
  442.                                 UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, dummy_c);
  443.                             }
  444.                         }
  445.                         else
  446.                         {
  447.                             UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, dummy_c);
  448.                         }
  449.                     }
  450.                 #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  451.                     if (UI_MULTI_LINE_INPUT_BOX_SPACE_CHARACTER(current_character))
  452.                     {
  453.                         /* MTK Terry for Center Align when the beginning of the line is space */
  454.                         //previous_line_width-=(character_widths_cache[current_line_character_counter]+text_gap); 
  455.                         //UI_STRING_GET_NEXT_CHARACTER(current_text_p,dummy_c);
  456.                         //current_line_character_counter++;
  457.                         //current_line_break_character_counter--;
  458.                     }
  459.                     if (default_direction == BIDI_R)
  460.                     {
  461.                         tx = ((edit_width >> 1) + (previous_line_width >> 1));
  462.                         if (tx < 0)
  463.                         {
  464.                             tx = 0;
  465.                         }
  466.                         if (tx > edit_width)
  467.                         {
  468.                             tx = edit_width - 1;
  469.                         }
  470.                     }
  471.                     else
  472.                     {
  473.                         tx = ((edit_width >> 1) - (previous_line_width >> 1));
  474.                         if (tx < 0)
  475.                         {
  476.                             tx = 0;
  477.                         }
  478.                     }
  479.                 }
  480.                 else if (rich_text.curr_alignment == GUI_INPUT_ALIGN_RIGHT)
  481.                 {
  482.                     if (default_direction == BIDI_R)
  483.                     {
  484.                         tx = edit_width - 1;
  485.                         if (tx < 0)
  486.                         {
  487.                             tx = 0;
  488.                         }
  489.                         if (tx > edit_width)
  490.                         {
  491.                             tx = edit_width - 1;
  492.                         }
  493.                     }
  494.                     else
  495.                     {
  496.                         tx = edit_width - previous_line_width;
  497.                         if (tx < 0)
  498.                         {
  499.                             tx = 0;
  500.                         }
  501.                     }
  502.                 }
  503.                 else
  504.                 {
  505.                     if (default_direction == BIDI_R)
  506.                     {
  507.                         tx = edit_width - 1;
  508.                     }
  509.                     else
  510.                     {
  511.                         tx = 0;
  512.                     }
  513.                 }
  514.             }
  515.         #ifdef __MMI_HINDI_ALG__
  516.             cluster_width = 0;
  517.             cursor_width = 0;
  518.         #endif /* __MMI_HINDI_ALG__ */ 
  519.             char_cnt_for_control_seq = 0;
  520.         #ifdef __MMI_BIDI_ALG__
  521.             if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) && arabic_char_flag)
  522.             {
  523.                 U16 i = 0;
  524.                 U16 k = (saved_current_text_p - line_start_text_p) / 2 - 1;
  525.                 U16 j = (line_start_text_p - b->text) / 2;
  526.                 U16 ligature_count = 0;
  527.                 i += j;
  528.                 k += j;
  529.                 while (i < k)
  530.                 {
  531.                     if (OrgToSha[i] == OrgToSha[i + 1])
  532.                     {
  533.                         if (i - 1 >= 0)
  534.                         {
  535.                             if (OrgToSha[i - 1] != OrgToSha[i])
  536.                             {
  537.                                 ligature_count++;
  538.                             }
  539.                         }
  540.                         else
  541.                         {
  542.                             ligature_count++;
  543.                         }
  544.                     }
  545.                     i++;
  546.                 }
  547.                 num_char = current_line_break_character_counter + ligature_count;
  548.                 MMI_ASSERT(!(num_char > ((MAX_NUM_OF_CHAR_FOR_EACH_LINE >> 1) - 1)));
  549.                 /* bidi_get_char_type(b->text, (U8 *)&default_direction); */
  550.                 if (b->cursor_p < current_text_p)
  551.                 {
  552.                     logical_cur_pos = 0xFFFF;
  553.                 }
  554.                 else if (((b->cursor_p - current_text_p) / ENCODING_LENGTH) > (num_char))
  555.                 {
  556.                     logical_cur_pos = 0xFFFF;
  557.                 }
  558.                 else
  559.                 {
  560.                     logical_cur_pos = (b->cursor_p - current_text_p) / ENCODING_LENGTH;
  561.                 }
  562.                 /* to get the last character unicode of previous line */
  563.                 if (line_counter == 0)
  564.                 {
  565.                     pfnEncodingSchemeToUnicode(
  566.                         &test_current_character,
  567.                         (current_text_p + num_char * ENCODING_LENGTH - ENCODING_LENGTH));//hjf should use num_char to fetch the last char
  568.                 }
  569.                 else
  570.                 {
  571.                     pfnEncodingSchemeToUnicode(&test_current_character, (current_text_p - ENCODING_LENGTH));
  572.                 }
  573. //hjf, cursor already be show
  574. if(is_cursor_show)
  575.                         logical_cur_pos = 0xFFFF;
  576.                 //hjfif ((line_counter == 0 && logical_cur_pos == current_line_break_character_counter))
  577.                 //hjf{
  578.                 //hjf    if (UI_STRING_LINE_BREAK_CHARACTER(test_current_character) || test_current_character == 0x20)
  579.                 //hjf    {
  580.                 //hjf        logical_cur_pos = 0xFFFF;
  581.                 //hjf    }
  582.                 //hjf}
  583.                 //if cursor pointer is at the last char of current line, it will cause that logical_cur_pos is zero at the next line
  584.                 //this check is to avoid that cursor displayed at both previous line and current line
  585. //hjf it should be the same process as english mode
  586.                 //hjfelse if ((line_counter != 0 && logical_cur_pos == 0))
  587.                 //hjf{
  588.                 //hjf    if (!UI_STRING_LINE_BREAK_CHARACTER(test_current_character))
  589.                 //hjf    {
  590.                 //hjf        logical_cur_pos = 0xFFFF;
  591.                 //hjf    }
  592.                 //hjf}
  593.                 //if last char of current line is n, cursor shall displayed at next line instead of current line.
  594.                 //if(UI_STRING_LINE_BREAK_CHARACTER(test_current_character))
  595.                 //     logical_cur_pos = 0xFFFF;
  596.             #if 0
  597. /* under construction !*/
  598. /* under construction !*/
  599. /* under construction !*/
  600. /* under construction !*/
  601. /* under construction !*/
  602. /* under construction !*/
  603. /* under construction !*/
  604. /* under construction !*/
  605. /* under construction !*/
  606. /* under construction !*/
  607. /* under construction !*/
  608. /* under construction !*/
  609. /* under construction !*/
  610. /* under construction !*/
  611. /* under construction !*/
  612. /* under construction !*/
  613. /* under construction !*/
  614. /* under construction !*/
  615. /* under construction !*/
  616. /* under construction !*/
  617. /* under construction !*/
  618. /* under construction !*/
  619. /* under construction !*/
  620.             #endif /* 0 */ 
  621.                 {
  622.                     logical_hilight_start = 0;
  623.                     logical_hilight_end = 0;
  624.                 }
  625.                 bidi_get_char_type(current_text_p, (U8*) & default_line_direction);
  626.                 if (default_line_direction == BIDI_R || default_line_direction == AL)
  627.                 {
  628.                     default_line_direction = BIDI_R;
  629.                 }
  630.                 else
  631.                 {
  632.                     default_line_direction = BIDI_L;
  633.                 }
  634.                 if (default_direction == BIDI_R && default_line_direction == BIDI_R)
  635.                 {
  636.                     reverse_flag = MMI_TRUE;
  637.                 }
  638.                 else if (default_direction == BIDI_R && default_line_direction == BIDI_L)
  639.                 {
  640.                     reverse_flag = MMI_TRUE;
  641.                 }
  642.                 else if (default_direction == BIDI_L && default_line_direction == BIDI_R)
  643.                 {
  644.                     reverse_flag = MMI_FALSE;
  645.                 }
  646.                 else if (default_direction == BIDI_L && default_line_direction == BIDI_L)
  647.                 {
  648.                     reverse_flag = MMI_FALSE;
  649.                 }
  650.                 /* MTK begin chat issue 2005.10.27 */
  651.             #ifdef __MMI_MESSAGES_CHAT__
  652.                 if(b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_CHAT_ICON_DISPLAY)
  653.                     {
  654.                     UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  655.                     UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, dummy_c);
  656.                     if (UI_TEST_GRP_SEP_CHARACTER(current_character) ||
  657.                         UI_TEST_FILE_SEP_CHARACTER(current_character) ||
  658.                         UI_TEST_SENDER_TRUNCATE_SEP_CHARACTER(current_character) ||
  659.                         UI_TEST_RECEIVER_TRUNCATE_SEP_CHARACTER(current_character))
  660.                     {
  661.                         Show_Chat_NickName = MMI_TRUE;
  662.                         current_text_p += 2;
  663.                         num_char -= 1;
  664.                     }
  665.                 }
  666.             #endif /* __MMI_MESSAGES_CHAT__ */ 
  667.                 /* MTK End */
  668.                 bidi_main(
  669.                     current_text_p,
  670.                     (U16) num_char,
  671.                     logical_cur_pos,
  672.                     visual_str,
  673.                     &visual_str_len,
  674.                     &visual_cur_pos,
  675.                     reverse_flag,
  676.                     MMI_bidi_input_type,
  677.                     logical_hilight_start,
  678.                     logical_hilight_end,
  679.                     &visual_hilight_start,
  680.                     &visual_hilight_end);
  681.                 /* MTK begin chat issue 2005.10.27 */
  682.             #ifdef __MMI_MESSAGES_CHAT__
  683.                 if(b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_CHAT_ICON_DISPLAY)
  684.                 {
  685.                     if (Show_Chat_NickName)
  686.                     {
  687.                         current_text_p -= 2;
  688.                         pTemp = visual_str_chat;
  689.                         UI_STRING_INSERT_CHARACTER(pTemp, current_character);
  690.                         memcpy(visual_str_chat + 2, visual_str, (pfnUnicodeStrlen((S8*) visual_str)) * ENCODING_LENGTH);
  691.                         memcpy(visual_str, visual_str_chat, MAX_TEXT_LENGTH * BIDI_ENCODING_LENGTH);
  692.                         Show_Chat_NickName = MMI_FALSE;
  693.                     }
  694.                 }
  695.             #endif /* __MMI_MESSAGES_CHAT__ */ 
  696.                 /* MTK End */
  697.                 temp_text_pt = current_text_p;
  698.                 current_text_p = visual_str;
  699.                 temp_cursor_p = current_cursor_p;
  700.                 temp_pre_cursor_p = previous_cursor_p;
  701.                 if (visual_cur_pos != 0xFFFF)
  702.                 {
  703.                     current_cursor_p = previous_cursor_p = current_text_p + (visual_cur_pos) * ENCODING_LENGTH;
  704.                     /* previous_cursor_p = current_cursor_p - ENCODING_LENGTH; */
  705.                     if (previous_cursor_p != current_text_p)
  706.                     {
  707.                         UI_STRING_GET_PREVIOUS_CHARACTER(previous_cursor_p, dummy_c);
  708.                     }
  709.                 }
  710.                 //if (default_line_direction == BIDI_L ||
  711.                 //   (default_direction == BIDI_L && default_line_direction == BIDI_R))
  712. if(arabic_char_flag)
  713.                 {
  714.                     MMI_ASSERT(visual_str_len<128);
  715.                     memcpy(shaping_str1, visual_str, visual_str_len * 2);
  716. OrgToSha1[visual_str_len] = 0xffff;
  717.                 #ifdef __MMI_ZI__
  718.                 #ifdef __MMI_ZI_V7__
  719.                 #if defined(__MMI_ZI_ARABIC__) && defined(__MMI_ZI_PERSIAN__)
  720.                     ZiStringShapeEx(ZI8_LANG_FA, (U16*) & visual_str_len, (U16*) shaping_str1, (U16*) OrgToSha1, NULL);        /* 19 is the Arabic id */
  721.                 #elif defined(__MMI_ZI_PERSIAN__)
  722.                     ZiStringShapeEx(ZI8_LANG_FA, (U16*) & visual_str_len, (U16*) shaping_str1, (U16*) OrgToSha1, NULL);        /* 19 is the Arabic id */
  723.                 #elif defined(__MMI_ZI_ARABIC__)
  724.                     ZiStringShapeEx(ZI8_LANG_AR, (U16*) & visual_str_len, (U16*) shaping_str1, (U16*) OrgToSha1, NULL);        /* 19 is the Arabic id */
  725.                 #endif 
  726.                 #else /* __MMI_ZI_V7__ */ 
  727.                     ArabicStringShape2((U16*) & visual_str_len, (U16*) shaping_str1, (U16*) OrgToSha1, NULL);
  728.                 #endif /* __MMI_ZI_V7__ */ 
  729.                 #else /* __MMI_ZI__ */ 
  730.                     ArabicShapeEngine2((U16*) & visual_str_len, (U16*) shaping_str1, (U16*) OrgToSha1, NULL);
  731.                 #endif /* __MMI_ZI__ */ 
  732.                 }
  733.                 BIDI_done_flag = MMI_TRUE;
  734.             #if 0
  735. /* under construction !*/
  736. /* under construction !*/
  737. /* under construction !*/
  738. /* under construction !*/
  739. /* under construction !*/
  740. /* under construction !*/
  741. /* under construction !*/
  742. /* under construction !*/
  743. /* under construction !*/
  744. /* under construction !*/
  745. /* under construction !*/
  746. /* under construction !*/
  747. /* under construction !*/
  748. /* under construction !*/
  749. /* under construction !*/
  750. /* under construction !*/
  751. /* under construction !*/
  752. /* under construction !*/
  753. /* under construction !*/
  754. /* under construction !*/
  755. /* under construction !*/
  756. /* under construction !*/
  757. /* under construction !*/
  758. /* under construction !*/
  759.             #endif /* 0 */ 
  760.             }
  761.         #endif /* __MMI_BIDI_ALG__ */ 
  762.             while (current_line_break_character_counter)
  763.             {
  764.                 previous_text_p = current_text_p;
  765.                 /* PMT FARHAD START 20050708 */
  766.             #ifdef __MMI_HINDI_ALG__
  767.                 temp_hindi_cursor_p = current_text_p;
  768.             #endif 
  769.                 /* PMT FARHAD START 20050708 */
  770.                 if (flags & UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT)
  771.                 {
  772.                 #ifdef __MMI_BIDI_ALG__
  773.                     if (arabic_char_flag)
  774.                     {
  775.                         word_highlight = 0;
  776.                     }
  777.                     else
  778.                 #endif /* __MMI_BIDI_ALG__ */ 
  779.                     if (current_text_p == b->highlight_start_position)
  780.                     {
  781.                        /* barcode */
  782.                         int temp_y = ty;
  783.                         word_highlight = 1;
  784.                         if (b->hilite_cb != NULL)
  785.                         {
  786.                             b->curr_hilite_text_offset_y = -temp_y;
  787.                             if(b->hilite_str_number == 0)
  788.                             {
  789.                                 word_highlight = 0;
  790.                             }
  791.                         }
  792.                     }
  793.                 #ifdef __MMI_BIDI_ALG__
  794.                     if (arabic_char_flag)
  795.                     {
  796.                         word_highlight = 0;
  797.                     }
  798.                     else
  799.                 #endif /* __MMI_BIDI_ALG__ */ 
  800.                     if (current_text_p == b->highlight_end_position)
  801.                     {
  802.                         word_highlight = 0;
  803.                     }
  804.                 }
  805.                 UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);        /* get next character */
  806.             #if defined(__MMI_LANG_VIETNAMESE__)
  807.                 if ((current_character > 0x0040) && (current_character < 0x01B1))
  808.                 {
  809.                     //next_unicode = String[2];
  810.                     //next_unicode |= (String[3]<<8);
  811.                     UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);      /* get next character */
  812.                     tone_mark = mmi_viet_tone_mark(dummy_c);
  813.                     if (VIET_TONE_NONE != tone_mark)
  814.                     {
  815.                         viet_vowel = mmi_viet_vowel_letter(current_character);
  816.                         if (VIET_VOWEL_NONE != viet_vowel)
  817.                         {
  818.                             current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  819.                         }
  820.                         else
  821.                         {
  822.                             UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, dummy_c);
  823.                         }
  824.                     }
  825.                     else
  826.                     {
  827.                         UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, dummy_c);
  828.                     }
  829.                 }
  830.             #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  831.             #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
  832.                 if (IS_ARABIC_CHARACTER(current_character))
  833.                 {
  834.                     U32 idx = 0;
  835.                     U32 ligature_move = 0;
  836.                     UI_character_type dummy_c_arabic = 0;
  837.                     if (BIDI_done_flag)
  838.                     {
  839.                         idx = (current_text_p - visual_str) / 2 - 1;
  840.                     }
  841.                     else
  842.                     {
  843.                         idx = (current_text_p - b->text) / 2 - 1;
  844.                     }
  845. //                    if (default_line_direction != BIDI_L && default_direction != BIDI_L)
  846. //                    {
  847. //                        idx += (line_start_text_p - b->text) / 2;
  848. //                    }
  849.                     current_character = (UI_character_type) shaping_str1[OrgToSha1[idx]];
  850.                     while (idx < unshaped_text_len - 1)
  851.                     {
  852.                         if (OrgToSha1[idx] == OrgToSha1[idx + 1])
  853.                         {
  854.                             ligature_move++;
  855.                         }
  856.                         else
  857.                         {
  858.                             break;
  859.                         }
  860.                         idx++;
  861.                     }
  862.                     while (ligature_move > 0)
  863.                     {
  864.                         UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
  865.                         ligature_move--;
  866.                     }
  867.                 }
  868.             #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */ 
  869.             #ifdef __MMI_BIDI_ALG__
  870.                 if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) && arabic_char_flag)
  871.                 {
  872.                     S32 e = current_line_character_counter + current_line_break_character_counter -1;
  873.                     S32 i;
  874.                     static S32 p=0,n=0;
  875.                     
  876.                     if(current_line_character_counter == 0) {p=e;n=0;}
  877.                         
  878.                     for(i=0;i<=e;i++)
  879.                     {
  880.                         if(character_str_cache[p]==current_character) break;
  881.                         if(character_str_cache[n]==current_character) {p=n;break;}
  882.                         if( (--p) <0) p = e;
  883.                         if( (++n) >e) n = 0;
  884.                     }
  885. if(i <= e)
  886. {
  887. character_width = character_widths_cache[p];
  888. character_height = character_heights_cache[p];
  889. }
  890. else
  891. {
  892. gui_measure_character(current_character, &character_width, &character_height);
  893. }
  894.                 }
  895.                 else
  896.             #endif /* __MMI_BIDI_ALG__ */ 
  897.                 {
  898. character_width = character_widths_cache[current_line_character_counter];       /* +text_gap; manju: Dec-11-2003 */
  899. character_height = character_heights_cache[current_line_character_counter];
  900.                 }
  901.             #ifdef __MMI_HINDI_ALG__
  902.                 if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))   /* space shud have been added in the Hindi range */
  903.                 {
  904.                     if (move_cursor_disp_prev_p <= (b->last_position_p))        /* tarun1 */
  905.                     {
  906.                         /* move_cursor_disp_curr_p = hf_get_next_cluster_p((PU16)b->text,move_cursor_disp_prev_p); */
  907.                         move_cursor_disp_curr_p = hf_get_next_cluster_p(move_cursor_disp_prev_p, move_cursor_disp_prev_p);
  908.                         display_skip_moves = move_cursor_disp_curr_p - move_cursor_disp_prev_p;
  909.                         display_skip_moves = display_skip_moves >> 1;
  910.                     #if 0
  911. /* under construction !*/
  912.                     #else /* 0 */ 
  913.                         cluster_width = cursor_width = cluster_width_filler[cluster_filler_count];
  914.                     #endif /* 0 */ 
  915.                         PRINT_INFORMATION_2((MMI_TRACE_INFO, "pixtel_UI_show_cursor_width[cursor_width]:%d  ",
  916.                                              cursor_width));
  917.                         move_cursor_disp_prev_p = move_cursor_disp_curr_p;
  918.                         saved_display_skip_moves = display_skip_moves;
  919.                         display_skip_moves--;
  920.                         for (idx = 0; idx < display_skip_moves; idx++)
  921.                         {
  922.                             UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);    /* get next character */
  923.                         }
  924.                     }
  925.                 }
  926.                 else
  927.                 {
  928.                     move_cursor_disp_prev_p += 2;
  929.                     saved_display_skip_moves = 1;
  930.                 }
  931.             #endif /* __MMI_HINDI_ALG__ */ 
  932.                 if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))
  933.                 {
  934.                     /* MTK Elvis for R2L characters */
  935.                     if (default_direction == BIDI_L)
  936.                     {
  937.                         xtx = xx + tx;
  938.                         yty = yy + ty;
  939.                     }
  940.                     else
  941.                     {
  942.                         /* START FARHAD PMT 20050211 */
  943.                     #ifdef __MMI_HINDI_ALG__
  944.                         if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  945.                         {
  946.                             /* tx-= (cluster_width+text_gap); */
  947.                             tx -= cluster_width;
  948.                         }
  949.                         else
  950.                     #endif /* __MMI_HINDI_ALG__ */ 
  951.                         {
  952.                             /* MTK Arabic connectivity issue */
  953.                             
  954.                         #if defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__
  955.                             
  956.                             if (IS_ARABIC_CHARACTER(current_character))
  957.                             {
  958.                                 tx -= character_width;
  959.                             }
  960.                             else
  961.                         #endif /* defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__ */ 
  962.                                 /* MTK end */
  963.                                 tx -= (character_width + text_gap);
  964.                         }
  965.                         /* END FARHAD PMT 20050211 */
  966.                         xtx = xx + tx;
  967.                         yty = yy + ty;
  968.                     }
  969.                     /* MTK end */
  970.                 #if(MULTILINE_INPUTBOX_DISPLAY_WHOLE_LINES)
  971.                     /* MTK Terry for speed up Editor by only display the characters in the display area */
  972.                     /* MTK Terry for show the last line in the display area even it can't display whole line */
  973.                     if ((((-1) == move_to_x) || ((-1) == move_to_y)) &&
  974.                         ((!(flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE) && (yty >= y1 - current_line_height) &&
  975.                           ((yty - current_line_height) <= y2)) || ((flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE) &&
  976.                                                                    ((yty /* +current_line_height */ ) <= y2)
  977.                                                                    /* START TARUN PMT 20041002 No need to check it */
  978.                 #ifndef MMI_HALF_LINE_MARQUEE_SCROLLING_ENABLE
  979.                                                                    && (yty >= y1)
  980.                 #endif 
  981.                                                                    /* END TARUN PMT 20041002 */
  982.                          )))
  983.                     {
  984.                 #endif /* (MULTILINE_INPUTBOX_DISPLAY_WHOLE_LINES) */ 
  985.                         UI_MULTI_LINE_INPUT_BOX_SET_TEXT_COLOR(rich_text.curr_color);
  986.                         if (word_highlight || (multitap_flag && (previous_text_p == previous_cursor_p)))
  987.                         {
  988.                         #ifdef __MMI_HINDI_ALG__
  989.                             if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  990.                             {
  991.                                 /* PMT START 17082006 */
  992.                                 if (MMI_current_input_mode == INPUT_MODE_SMART_HINDI)
  993.                                 {
  994.                                     if (!UI_HINDI_CHARACTER_UCS2_RANGE(pre_character))
  995.                                     {
  996.                                         gui_fill_rectangle(
  997.                                             xtx - 1,
  998.                                             yty,
  999.                                             xtx + cluster_width + 1,
  1000.                                             yty + current_line_height - 1,
  1001.                                             selector_color);
  1002.                                     }
  1003.                                     else
  1004.                                     {
  1005.                                         gui_fill_rectangle(
  1006.                                             xtx + 1,
  1007.                                             yty,
  1008.                                             xtx + cluster_width + 1,
  1009.                                             yty + current_line_height - 1,
  1010.                                             selector_color);
  1011.                                     }
  1012.                                 }
  1013.                                 else
  1014.                                 {
  1015.                                     gui_fill_rectangle(
  1016.                                         xtx - 1,
  1017.                                         yty,
  1018.                                         xtx + cluster_width - 1,
  1019.                                         yty + current_line_height - 1,
  1020.                                         selector_color);
  1021.                                 }
  1022.                             }
  1023.                             else
  1024.                                 /* PMT END 17082006 */
  1025.                         #endif /* __MMI_HINDI_ALG__ */ 
  1026.                             {
  1027.                                 gui_fill_rectangle(
  1028.                                     xtx,
  1029.                                     yty,
  1030.                                     xtx + character_width,
  1031.                                     yty + current_line_height - 1,
  1032.                                     selector_color);
  1033.                             }
  1034.                             UI_MULTI_LINE_INPUT_BOX_SET_TEXT_COLOR(selected_text_color);        /* set text color */
  1035.                         }
  1036.                         if (previous_text_p == current_cursor_p)
  1037.                         {
  1038.                             if (overwrite_flag && !multitap_flag)
  1039.                             {
  1040.                                 gui_fill_rectangle(
  1041.                                     xtx,
  1042.                                     yty,
  1043.                                     xtx + character_width - 1,
  1044.                                     yty + current_line_height - 1,
  1045.                                     selector_color);
  1046.                                 UI_MULTI_LINE_INPUT_BOX_SET_TEXT_COLOR(selected_text_color);
  1047.                             }
  1048.                         }
  1049.                         if (flags & UI_MULTI_LINE_INPUT_BOX_DRAW_UNDERLINE)     /* Prevent text and underline connected together */
  1050.                         {
  1051.                             UI_MULTI_LINE_INPUT_BOX_MOVE_TEXT_CURSOR(
  1052.                                 xtx,
  1053.                                 yty + current_line_height - character_height - 2);
  1054.                         }
  1055.                         else
  1056.                         {
  1057.                             UI_MULTI_LINE_INPUT_BOX_MOVE_TEXT_CURSOR(xtx, yty + current_line_height - character_height - reserve_line_height_for_hilite);
  1058.                         }
  1059.                     #if(MULTILINE_INPUTBOX_DISPLAY_SPECIAL_CHARACTERS)
  1060.                         if (UI_TEST_CR_CHARACTER(current_character))
  1061.                         {
  1062.                             gui_show_transparent_image(
  1063.                                 xtx,
  1064.                                 current_line_height - character_height + yty,
  1065.                                 (PU8) EMS_CR_display_character,
  1066.                                 0);
  1067.                         }
  1068.                         else if (UI_TEST_LF_CHARACTER(current_character))
  1069.                         {
  1070.                             gui_show_transparent_image(
  1071.                                 xtx,
  1072.                                 current_line_height - character_height + yty,
  1073.                                 (PU8) EMS_LF_display_character,
  1074.                                 0);
  1075.                         }
  1076.                         else if (UI_TEST_ESC_CHARACTER(current_character))
  1077.                         {
  1078.                             gui_show_transparent_image(
  1079.                                 xtx,
  1080.                                 current_line_height - character_height + yty,
  1081.                                 (PU8) EMS_ESC_display_character,
  1082.                                 0);
  1083.                         }
  1084.                         else
  1085.                     #endif /* (MULTILINE_INPUTBOX_DISPLAY_SPECIAL_CHARACTERS) */ 
  1086.                         if (char_cnt_for_control_seq > 0)
  1087.                         {
  1088.                             /* Dummy */
  1089.                         }
  1090.                         else if ((flags & UI_MULTI_LINE_INPUT_BOX_RICHTEXT) && GUI_INPUT_IS_MARKER(current_character))
  1091.                         {
  1092.                             BOOL change_font = MMI_FALSE;
  1093.                             BOOL change_color = MMI_FALSE;
  1094.                             switch (current_character)
  1095.                             {
  1096.                                     /* Alignment is handled in the first pass */
  1097.                                 case GUI_INPUT_MARKER_RESET_ALL:
  1098.                                     /* Reset font format and color (no paragraph) */
  1099.                                     rich_text.curr_font = *b->text_font;
  1100.                                     rich_text.curr_border = 0;
  1101.                                     /* USAT */
  1102.                                     rich_text.curr_strikethrough = 0;
  1103.                                     rich_text.curr_text_bg_color = rich_text.default_text_bg_color;
  1104.                                     rich_text.draw_text_bg_color = 0;
  1105.                                     rich_text.curr_color = rich_text.default_color;
  1106.                                     change_font = MMI_TRUE;
  1107.                                     change_color = MMI_TRUE;
  1108.                                     break;
  1109.                                 case GUI_INPUT_MARKER_RESET_PARAGRAPH:
  1110.                                     /* Paragraph handled in the first pass */
  1111.                                     break;
  1112.                                 case GUI_INPUT_MARKER_RESET_FORMAT:
  1113.                                     rich_text.curr_font = *b->text_font;
  1114.                                     rich_text.curr_border = 0;
  1115.                                     /* USAT */
  1116.                                     rich_text.curr_strikethrough = 0;
  1117.                                     change_font = MMI_TRUE;
  1118.                                     break;
  1119.                                 case GUI_INPUT_MARKER_RESET_COLOR:
  1120.                                     rich_text.curr_color = rich_text.default_color;
  1121.                                     /* USAT */
  1122.                                     rich_text.curr_text_bg_color = rich_text.default_text_bg_color;
  1123.                                     rich_text.draw_text_bg_color = 0;
  1124.                                     change_color = MMI_TRUE;
  1125.                                     break;
  1126.                                 default:
  1127.                                     if (current_character >= GUI_INPUT_MARKER_COLOR_BEGIN &&
  1128.                                         current_character <= GUI_INPUT_MARKER_COLOR_END)
  1129.                                     {
  1130.                                         if (current_character - GUI_INPUT_MARKER_COLOR_BEGIN < MAX_GUI_INPUT_COLOR)
  1131.                                         {
  1132.                                             rich_text.curr_color =
  1133.                                                 g_mmi_gui_input_format_color_table[current_character -
  1134.                                                                                    GUI_INPUT_MARKER_COLOR_BEGIN];
  1135.                                             change_color = MMI_TRUE;
  1136.                                         }
  1137.                                     }
  1138.                                     else if (current_character >= GUI_INPUT_MARKER_W3C_COLOR_BEGIN &&
  1139.                                              current_character <= GUI_INPUT_MARKER_W3C_COLOR_END)
  1140.                                     {
  1141.                                         if (current_character - GUI_INPUT_MARKER_W3C_COLOR_BEGIN <
  1142.                                             MAX_GUI_INPUT_W3C_COLOR)
  1143.                                         {
  1144.                                             rich_text.curr_color =
  1145.                                                 g_mmi_gui_input_format_w3c_color_table[current_character -
  1146.                                                                                        GUI_INPUT_MARKER_W3C_COLOR_BEGIN];
  1147.                                             change_color = MMI_TRUE;
  1148.                                         }
  1149.                                     }
  1150.                                     /* USAT */
  1151.                                     else if (current_character >= GUI_INPUT_MARKER_TEXT_BACKGROUND_COLOR_BEGIN &&
  1152.                                              current_character <= GUI_INPUT_MARKER_TEXT_BACKGROUND_COLOR_END)
  1153.                                     {
  1154.                                         if (current_character - GUI_INPUT_MARKER_TEXT_BACKGROUND_COLOR_BEGIN <
  1155.                                             MAX_GUI_INPUT_W3C_TEXT_BG_COLOR)
  1156.                                         {
  1157.                                             rich_text.curr_text_bg_color =
  1158.                                                 g_mmi_gui_input_format_w3c_text_background_color_table[current_character
  1159.                                                                                                        -
  1160.                                                                                                        GUI_INPUT_MARKER_TEXT_BACKGROUND_COLOR_BEGIN];
  1161.                                             rich_text.draw_text_bg_color = 1;
  1162.                                         }
  1163.                                     }
  1164.                                     if (current_character >= GUI_INPUT_MARKER_BORDER_COLOR_BEGIN &&
  1165.                                         current_character <= GUI_INPUT_MARKER_BORDER_COLOR_END)
  1166.                                     {
  1167.                                         if (current_character - GUI_INPUT_MARKER_BORDER_COLOR_BEGIN <
  1168.                                             MAX_GUI_INPUT_COLOR)
  1169.                                         {
  1170.                                             gui_set_text_border_color(g_mmi_gui_input_format_color_table
  1171.                                                                       [current_character -
  1172.                                                                        GUI_INPUT_MARKER_BORDER_COLOR_BEGIN]);
  1173.                                         }
  1174.                                     }
  1175.                                     else if (current_character >= GUI_INPUT_MARKER_W3C_BORDER_COLOR_BEGIN &&
  1176.                                              current_character <= GUI_INPUT_MARKER_W3C_BORDER_COLOR_END)
  1177.                                     {
  1178.                                         if (current_character - GUI_INPUT_MARKER_W3C_BORDER_COLOR_BEGIN <
  1179.                                             MAX_GUI_INPUT_W3C_COLOR)
  1180.                                         {
  1181.                                             gui_set_text_border_color(g_mmi_gui_input_format_w3c_color_table
  1182.                                                                       [current_character -
  1183.                                                                        GUI_INPUT_MARKER_W3C_BORDER_COLOR_BEGIN]);
  1184.                                         }
  1185.                                     }
  1186.                                     else if (GUI_INPUT_IS_FORMAT_MARKER(current_character))
  1187.                                     {
  1188.                                         if (GUI_INPUT_CHECK_FORMAT_MARKER(current_character, GUI_INPUT_MARKER_BOLD))
  1189.                                         {
  1190.                                             rich_text.curr_font.bold = 1;
  1191.                                             change_font = MMI_TRUE;
  1192.                                         }
  1193.                                         if (GUI_INPUT_CHECK_FORMAT_MARKER(current_character, GUI_INPUT_MARKER_ITALIC))
  1194.                                         {
  1195.                                             rich_text.curr_font.italic = 1;
  1196.                                             change_font = MMI_TRUE;
  1197.                                         }
  1198.                                         if (GUI_INPUT_CHECK_FORMAT_MARKER
  1199.                                             (current_character, GUI_INPUT_MARKER_UNDERLINE))
  1200.                                         {
  1201.                                             rich_text.curr_font.underline = 1;
  1202.                                             change_font = MMI_TRUE;
  1203.                                         }
  1204.                                         /* USAT */
  1205.                                         if (GUI_INPUT_CHECK_FORMAT_MARKER
  1206.                                             (current_character, GUI_INPUT_MARKER_STRIKETHROUGH))
  1207.                                         {
  1208.                                             rich_text.curr_strikethrough = 1;
  1209.                                         }
  1210.                                         if (GUI_INPUT_CHECK_FORMAT_MARKER(current_character, GUI_INPUT_MARKER_BORDER))
  1211.                                         {
  1212.                                             /* We do not increase font size for bordered font because text gap is already enlarged */
  1213.                                             rich_text.curr_border = 1;
  1214.                                         }
  1215.                                         if (GUI_INPUT_CHECK_SIZE_MARKER(current_character, GUI_INPUT_MARKER_SMALL))
  1216.                                         {
  1217.                                             rich_text.curr_font.size = SMALL_FONT;
  1218.                                             change_font = MMI_TRUE;
  1219.                                         }
  1220.                                         else if (GUI_INPUT_CHECK_SIZE_MARKER
  1221.                                                  (current_character, GUI_INPUT_MARKER_MEDIUM))
  1222.                                         {
  1223.                                             rich_text.curr_font.size = MEDIUM_FONT;
  1224.                                             change_font = MMI_TRUE;
  1225.                                         }
  1226.                                         else if (GUI_INPUT_CHECK_SIZE_MARKER(current_character, GUI_INPUT_MARKER_LARGE))
  1227.                                         {
  1228.                                             rich_text.curr_font.size = LARGE_FONT;
  1229.                                             change_font = MMI_TRUE;
  1230.                                         }
  1231.                                     }
  1232.                                     /* Paragraph handled in the first pass */
  1233.                                     break;
  1234.                             }
  1235.                             if (change_font)
  1236.                             {
  1237.                                 gui_set_font(&rich_text.curr_font);
  1238.                             }
  1239.                             if (change_color)
  1240.                             {
  1241.                                 UI_MULTI_LINE_INPUT_BOX_SET_TEXT_COLOR(rich_text.curr_color);
  1242.                             }
  1243.                         }
  1244.                         else if (b->icon_callback &&
  1245.                                  (char_cnt_for_control_seq =
  1246.                                   b->icon_callback(
  1247.                                         previous_text_p,
  1248.                                         MMI_TRUE,
  1249.                                         NULL,
  1250.                                         NULL,
  1251.                                         xtx,
  1252.                                         /* current_line_height-character_height+ */ yty)) > 0)
  1253.                         {
  1254.                             /* Dummy */
  1255.                         }
  1256.                         else
  1257.                     #ifdef __MMI_MESSAGES_CHAT__
  1258.                         if ((b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_CHAT_ICON_DISPLAY) && UI_TEST_GRP_SEP_CHARACTER(current_character))
  1259.                         {
  1260.                             /* For Chat Buddy Icon - Gurinder - 15/4/2004 */
  1261.                             gui_show_transparent_image(
  1262.                                 xtx,
  1263.                                 current_line_height - character_height + yty,
  1264.                                 (PU8) GetImage(CHAT_LOCAL_IMG),
  1265.                                 0);
  1266.                         #ifdef __MMI_BIDI_ALG__
  1267.                             if (arabic_char_flag == MMI_TRUE)
  1268.                             {
  1269.                                 tx += character_width;
  1270.                                 current_line_width += character_width;
  1271.                             }
  1272.                         #endif /* __MMI_BIDI_ALG__ */ 
  1273.                         }
  1274.                         else if ((b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_CHAT_ICON_DISPLAY) && UI_TEST_FILE_SEP_CHARACTER(current_character))
  1275.                         {
  1276.                             /* For Chat Buddy Icon - Gurinder - 15/4/2004 */
  1277.                             gui_show_transparent_image(
  1278.                                 xtx,
  1279.                                 current_line_height - character_height + yty,
  1280.                                 (PU8) GetImage(CHAT_REMOTE_IMG),
  1281.                                 0);
  1282.                         #ifdef __MMI_BIDI_ALG__
  1283.                             if (arabic_char_flag == MMI_TRUE)
  1284.                             {
  1285.                                 tx += character_width;
  1286.                                 current_line_width += character_width;
  1287.                             }
  1288.                         #endif /* __MMI_BIDI_ALG__ */ 
  1289.                         }
  1290.                         else if ((b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_CHAT_ICON_DISPLAY) && UI_TEST_SENDER_TRUNCATE_SEP_CHARACTER(current_character))
  1291.                         {
  1292.                             gui_show_transparent_image(
  1293.                                 xtx,
  1294.                                 current_line_height - character_height + yty,
  1295.                                 (PU8) GetImage(CHAT_SENDER_TRUNCATE_IMG),
  1296.                                 0);
  1297.                         #ifdef __MMI_BIDI_ALG__
  1298.                             if (arabic_char_flag == MMI_TRUE)
  1299.                             {
  1300.                                 tx += character_width;
  1301.                                 current_line_width += character_width;
  1302.                             }
  1303.                         #endif /* __MMI_BIDI_ALG__ */ 
  1304.                         }
  1305.                         else if ((b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_CHAT_ICON_DISPLAY) && UI_TEST_RECEIVER_TRUNCATE_SEP_CHARACTER(current_character))
  1306.                         {
  1307.                             gui_show_transparent_image(
  1308.                                 xtx,
  1309.                                 current_line_height - character_height + yty,
  1310.                                 (PU8) GetImage(CHAT_RECEIVER_TRUNCATE_IMG),
  1311.                                 0);
  1312.                         #ifdef __MMI_BIDI_ALG__
  1313.                             if (arabic_char_flag == MMI_TRUE)
  1314.                             {
  1315.                                 tx += character_width;
  1316.                                 current_line_width += character_width;
  1317.                             }
  1318.                         #endif /* __MMI_BIDI_ALG__ */ 
  1319.                         }
  1320.                         else
  1321.                     #endif /* __MMI_MESSAGES_CHAT__ */ 
  1322.                         if (!(UI_STRING_END_OF_STRING_CHARACTER(current_character) ||
  1323.                                   UI_TEST_LF_CHARACTER(current_character) ||
  1324.                                   UI_TEST_CR_CHARACTER(current_character) || UI_TEST_ESC_CHARACTER(current_character)))
  1325.                         {
  1326.                         #ifdef __MMI_HINDI_ALG__
  1327.                             PU8 prev_temp_cursor_p;
  1328.                         #endif
  1329.                         
  1330.                             /* USAT */
  1331.                             if (rich_text.draw_text_bg_color)
  1332.                             {
  1333.                                 UI_fill_rectangle(
  1334.                                     xtx,
  1335.                                     yty - 1,
  1336.                                     xtx + character_width,
  1337.                                     yty + current_line_height /* character_height */ - 1,
  1338.                                     rich_text.curr_text_bg_color);
  1339.                             }
  1340.                            if((b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_TRUNCATE_CONTENT) && (flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR))
  1341.                            {
  1342.                                if(b->text_height > b->edit_height)
  1343.                                {
  1344.                                    if(yty + current_line_height * 2 > y2)
  1345.                                    {
  1346.       UI_character_type next_char;
  1347.   {
  1348.   UI_buffer_type tmp = current_text_p;
  1349.       UI_STRING_GET_NEXT_CHARACTER(tmp,next_char);
  1350.   }
  1351.                                       if(current_line_break_character_counter == 1 
  1352.       || UI_TEST_LF_CHARACTER(next_char)
  1353.   || UI_TEST_CR_CHARACTER(next_char))
  1354.                                       {
  1355.                                          gui_move_text_cursor(UI_text_x,UI_text_y);
  1356.                                          gui_print_character((UI_character_type)'.');
  1357.                                          gui_move_text_cursor(UI_text_x+3,UI_text_y);
  1358.                                          gui_print_character((UI_character_type)'.');
  1359.                                          gui_move_text_cursor(UI_text_x+3,UI_text_y);
  1360.                                          gui_print_character((UI_character_type)'.');
  1361.                                          done = 1;
  1362.                                          break;
  1363.                                       }
  1364.                                    }
  1365.                                 }
  1366.                             }
  1367.                         #ifdef __MMI_HINDI_ALG__
  1368.                             /* START FARHAD PMT 20050211 */
  1369.                             if (temp_hindi_cursor_p == (b->last_position_p))    /* tarun2 don't go further after whole string */
  1370.                             {
  1371.                                 goto enddisp;
  1372.                             }
  1373.                             {
  1374.                                 prev_temp_cursor_p = temp_hindi_cursor_p;
  1375.                                 temp_hindi_cursor_p = hf_get_next_cluster_p(temp_hindi_cursor_p, temp_hindi_cursor_p);
  1376.                             }
  1377.                             if (flags & UI_MULTI_LINE_INPUT_BOX_MASK_CHARACTERS)
  1378.                             {
  1379.                                 /* W06.09 Touch Screen With Keypad V1 */
  1380.                             #if defined(__MMI_FULL_SCREEN_EDITOR__) || defined(__MMI_TOUCH_SCREEN__)
  1381.                                 /* MTK Terry for password display for __MMI_FULL_SCREEN_EDITOR__ */
  1382.                                 if ((flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP) &&
  1383.                                     (previous_text_p == previous_cursor_p))
  1384.                                 {
  1385.                                     gui_print_character(current_character);
  1386.                                 }
  1387.                                 else
  1388.                             #endif /* defined(__MMI_FULL_SCREEN_EDITOR__) || defined(__MMI_TOUCH_SCREEN__) */ 
  1389.                                 {
  1390.                                     gui_print_character(b->mask_character);
  1391.                                 }
  1392.                             }
  1393.                             /* for getting the current cluster for display */
  1394.                             else if (hf_get_current_cluster(prev_temp_cursor_p, temp_hindi_cursor_p, disp_cluster))
  1395.                                 /* END FARHAD PMT 20050211 */
  1396.                             {
  1397.                                 S32 disp_multi_clust_len = pfnUnicodeStrlen((PS8) disp_cluster);
  1398.                                 MMI_ASSERT(!(disp_multi_clust_len > MAX_EDITOR_DISP_LEN));
  1399.                                 UI_text_height = character_height;
  1400.                                 /* To avoid rule appln in showstring */
  1401.                                 hf_disable_hindi_rules_parsing();
  1402.                                 hf_padding_value(0);
  1403.                                 /* START TARUN PMT 20050128 */
  1404.                                 UI_set_current_text_color(UI_text_color);
  1405.                                 if (!UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  1406.                                 {
  1407.                                     cancelWidth = 1;
  1408.                                     ShowString(
  1409.                                         UI_text_x,
  1410.                                         UI_text_y,
  1411.                                         *UI_font,
  1412.                                         0,
  1413.                                         (U8*) (disp_cluster),
  1414.                                         UI_text_height);
  1415.                                     cancelWidth = 0;
  1416.                                 }
  1417.                                 else
  1418.                                 {
  1419.                                     cancelWidth = 1;
  1420.                                     ShowString(
  1421.                                         UI_text_x,
  1422.                                         UI_text_y,
  1423.                                         *UI_font,
  1424.                                         0,
  1425.                                         (U8*) (disp_cluster),
  1426.                                         UI_text_height);
  1427.                                     cancelWidth = 0;
  1428.                                 }
  1429.                                 //END TARUN PMT 20050128
  1430.                                 //Open it again
  1431.                                 hf_enable_hindi_rules_parsing();
  1432.                                 hf_padding_def_value();
  1433.                             }
  1434.                             else
  1435.                             {
  1436.                                 if (rich_text.curr_border)
  1437.                                 {
  1438.                                     gui_print_bordered_stacked_character(
  1439.                                         current_character,
  1440.                                         pre2_character,
  1441.                                         pre_character);
  1442.                                 }
  1443.                                 else
  1444.                                 {
  1445.                                     gui_print_stacked_character(current_character, pre2_character, pre_character);
  1446.                                 }
  1447.                             }
  1448.                           enddisp:
  1449.                             memset(disp_cluster, 0, sizeof(disp_cluster));
  1450.                         #else /* __MMI_HINDI_ALG__ */ 
  1451.                             if (flags & UI_MULTI_LINE_INPUT_BOX_MASK_CHARACTERS)
  1452.                             {
  1453.                                 /* W06.09 Touch Screen With Keypad V1 */
  1454.                             #if defined(__MMI_FULL_SCREEN_EDITOR__) || defined(__MMI_TOUCH_SCREEN__)
  1455.                                 /* MTK Terry for password display for __MMI_FULL_SCREEN_EDITOR__ */
  1456.                                 if ((flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP) &&
  1457.                                     (previous_text_p == previous_cursor_p))
  1458.                                 {
  1459.                                     //VIKAS 20060120 PMT START
  1460.                                     //gui_print_character(current_character);
  1461.                                     gui_print_stacked_character(current_character, pre2_character, pre_character);
  1462.                                     /* VIKAS 20060120 PMT END */
  1463.                                 }
  1464.                                 else
  1465.                             #endif /* defined(__MMI_FULL_SCREEN_EDITOR__) || defined(__MMI_TOUCH_SCREEN__) */ 
  1466.                                 {
  1467.                                     //VIKAS 20060120 PMT START
  1468.                                     //gui_print_character(b->mask_character);
  1469.                                     gui_print_stacked_character(b->mask_character, pre2_character, pre_character);
  1470.                                     /* VIKAS 20060120 PMT END */
  1471.                                 }
  1472.                             }
  1473.                             else
  1474.                             {
  1475.                                 if (rich_text.curr_border)
  1476.                                 {
  1477.                                     gui_print_bordered_stacked_character(
  1478.                                         current_character,
  1479.                                         pre2_character,
  1480.                                         pre_character);
  1481.                                 }
  1482.                                 else
  1483.                                 {
  1484.                                     gui_print_stacked_character(current_character, pre2_character, pre_character);
  1485.                                 }
  1486.                                 /* USAT */
  1487.                                 if (rich_text.curr_strikethrough)
  1488.                                 {
  1489.                                     UI_draw_horizontal_line(
  1490.                                         xtx,
  1491.                                         xtx + character_width - 1,
  1492.                                         yty + (current_line_height >> 1),
  1493.                                         gui_richtext_strikethrough_color);
  1494.                                 }
  1495.                                 /* barcode */
  1496.                                 if (b->hilite_cb != NULL)
  1497.                                 {
  1498.                                     if (gui_multi_line_input_box_is_pos_inside_hilite(b, current_text_p - 2))
  1499.                                     {
  1500.                                         UI_draw_horizontal_line(
  1501.                                             xtx,
  1502.                                             xtx + character_width,
  1503.                                             yty + current_line_height -1 ,
  1504.                                             gui_hilite_underline_color);
  1505.                                     }
  1506.                                 }
  1507.                             }
  1508.                         #endif /* __MMI_HINDI_ALG__ */ 
  1509.                         }
  1510.                     #ifdef __MMI_HINDI_ALG__
  1511.                         else
  1512.                         {
  1513.                             /* START FARHAD PMT 20050211 */
  1514.                             temp_hindi_cursor_p += 2;
  1515.                             /* END FARHAD PMT 20050211 */
  1516.                         }
  1517.                     #endif /* __MMI_HINDI_ALG__ */ 
  1518.                         if ((previous_text_p == current_cursor_p) &&
  1519.                             !(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW))
  1520.                         {
  1521.                             S32 BX2,BY2;
  1522. //hjf x2 already - vbar width, 
  1523.                                 BX2 = x2;
  1524.                             BY2 = y2-2;
  1525. is_cursor_show = MMI_TRUE; // hjf, to record the cursor is be show
  1526.                             /* gui_multi_line_input_box_show_cursor(b,xtx,yty,current_line_height,x1,x2-b->vbar.width); */
  1527.                         #ifdef __MMI_HINDI_ALG__
  1528.                             if (UI_HINDI_CHARACTER_UCS2_RANGE(pre_character))
  1529.                             {
  1530.                                 xtx -= cluster_width;
  1531.                                 xtx += cursor_width;
  1532.                             }
  1533.                         #endif /* __MMI_HINDI_ALG__ */ 
  1534.                             /* For every multiline input box the value remains as y1-2 */
  1535.                             if (default_direction != BIDI_L)
  1536.                             {
  1537.                                 if (g_mmi_wgui_halfline_marquee_scroll_enable)
  1538.                                 {
  1539.                                     gui_multi_line_input_box_show_cursor(
  1540.                                         b,
  1541.                                         xtx + character_width,
  1542.                                         y1,
  1543.                                         current_line_height,
  1544.                                         x1,
  1545.                                         y1,
  1546.                                         BX2,
  1547.                                         BY2);
  1548.                                 }
  1549.                                 else
  1550.                                 {
  1551.                                     if (flags & UI_MULTI_LINE_INPUT_BOX_DRAW_UNDERLINE)
  1552.                                     {
  1553.                                         gui_multi_line_input_box_show_cursor(
  1554.                                             b,
  1555.                                             xtx + character_width,
  1556.                                             yty,
  1557.                                             current_line_height - 2,
  1558.                                             x1,
  1559.                                             y1,
  1560.                                             BX2,
  1561.                                             BY2);
  1562.                                     }
  1563.                                     else
  1564.                                     {
  1565.                                         gui_multi_line_input_box_show_cursor(
  1566.                                             b,
  1567.                                             xtx + character_width,
  1568.                                             yty,
  1569.                                             current_line_height,
  1570.                                             x1,
  1571.                                             y1,
  1572.                                             BX2,
  1573.                                             BY2);
  1574.                                     }
  1575.                                 }
  1576.                             }
  1577.                             else
  1578.                             {
  1579.                                 if (g_mmi_wgui_halfline_marquee_scroll_enable)
  1580.                                 {
  1581.                                     gui_multi_line_input_box_show_cursor(
  1582.                                         b,
  1583.                                         xtx,
  1584.                                         y1 + 2,
  1585.                                         current_line_height,
  1586.                                         x1,
  1587.                                         y1,
  1588.                                         BX2,
  1589.                                         BY2);
  1590.                                 }
  1591.                                 else
  1592.                                 {
  1593.                                     if (flags & UI_MULTI_LINE_INPUT_BOX_DRAW_UNDERLINE)
  1594.                                     {
  1595.                                         gui_multi_line_input_box_show_cursor(
  1596.                                             b,
  1597.                                             xtx,
  1598.                                             yty,
  1599.                                             current_line_height - 2,
  1600.                                             x1,
  1601.                                             y1,
  1602.                                             BX2,
  1603.                                             BY2);
  1604.                                     }
  1605.                                     else
  1606.                                     {
  1607.                                         gui_multi_line_input_box_show_cursor(
  1608.                                             b,
  1609.                                             xtx,
  1610.                                             yty,
  1611.                                             current_line_height,
  1612.                                             x1,
  1613.                                             y1,
  1614.                                             BX2,
  1615.                                             BY2);
  1616.                                     }
  1617.                                 }
  1618.                             }
  1619.                         }
  1620.                     #if(MULTILINE_INPUTBOX_DISPLAY_WHOLE_LINES)
  1621.                     }
  1622.                     #endif 
  1623.                     if (default_direction == BIDI_L)
  1624.                     {
  1625.                         if (RequireToMoveCursor(pre_character, current_character))
  1626.                         {
  1627.                         #ifdef __MMI_HINDI_ALG__
  1628.                             if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  1629.                             {
  1630.                                 tx += cluster_width;
  1631.                             }
  1632.                             else
  1633.                         #endif /* __MMI_HINDI_ALG__ */ 
  1634.                             {
  1635.                                 /* MTK Arabic connectivity issue */
  1636.                                 
  1637.                             #if defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__
  1638.                                 
  1639.                                 if (IS_ARABIC_CHARACTER(current_character))
  1640.                                 {
  1641.                                     tx += character_width;
  1642.                                 }
  1643.                                 else
  1644.                             #endif /* defined __MMI_LANG_ARABIC__ || defined __MMI_LANG_PERSIAN__ */ 
  1645.                                     /* MTK end */
  1646.                                     tx += character_width + text_gap;
  1647.                             }
  1648.                         }
  1649.                         else
  1650.                         {
  1651.                             tx += character_width /* +text_gap */ ;
  1652.                         }
  1653.                     }
  1654.                     pre2_character = pre_character;
  1655.                     pre_character = current_character;
  1656.                 }
  1657.                 if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))
  1658.                 {
  1659.                     if ((((-1) == move_to_x) || ((-1) == move_to_y)))
  1660.                     {
  1661.                         if (previous_text_p == current_cursor_p)
  1662.                         {
  1663.                             b->cursor_line_position_counter = current_line_character_counter;
  1664.                             b->line_before_cursor_line_p = previous_line_start_text_p;
  1665.                             b->cursor_line_p = line_start_text_p;
  1666.                             b->cursor_x = tx;
  1667.                             b->cursor_y = ty;
  1668.                         }
  1669.                     }
  1670.                     else
  1671.                     {
  1672.                         if (((tx + b->x) > move_to_x) && ((ty + b->y + current_line_height + b->text_offset_y) > move_to_y)
  1673.                             && (!set_cursor_flag))
  1674.                         {
  1675.                             b->cursor_line_position_counter = current_line_character_counter;
  1676.                             b->line_before_cursor_line_p = previous_line_start_text_p;
  1677.                             b->cursor_line_p = line_start_text_p;
  1678.                             b->cursor_x = tx;
  1679.                             b->cursor_y = ty;
  1680.                             b->cursor_p = previous_text_p;
  1681.                             set_cursor_flag = 1;
  1682.                         }
  1683.                         else if (((ty + b->y + current_line_height + b->text_offset_y) > move_to_y) && (!set_cursor_flag) &&
  1684.                                  ((1 == current_line_break_character_counter) || (UI_TEST_CR_CHARACTER(current_character))))
  1685.                         {
  1686.                             b->cursor_line_position_counter = current_line_character_counter;
  1687.                             b->line_before_cursor_line_p = previous_line_start_text_p;
  1688.                             b->cursor_line_p = line_start_text_p;
  1689.                             b->cursor_x = tx;
  1690.                             b->cursor_y = ty;
  1691.                             b->cursor_p = previous_text_p;
  1692.                             set_cursor_flag = 1;
  1693.                         }
  1694.                     }
  1695.                 }
  1696.             #ifdef __MMI_HINDI_ALG__
  1697.                 current_line_break_character_counter -= saved_display_skip_moves;
  1698.                 current_line_character_counter += saved_display_skip_moves;
  1699.                 cluster_filler_count++;
  1700.             #else /* __MMI_HINDI_ALG__ */ 
  1701.                 current_line_break_character_counter--;
  1702.                 current_line_character_counter++;
  1703.             #endif /* __MMI_HINDI_ALG__ */ 
  1704.                 if (char_cnt_for_control_seq > 0)
  1705.                 {
  1706.                     char_cnt_for_control_seq--;
  1707.                 }
  1708.             }
  1709.         #ifdef __MMI_BIDI_ALG__
  1710.             if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) && arabic_char_flag)
  1711.             {
  1712.                 current_text_p = temp_text_pt + (current_text_p - visual_str);
  1713.                 previous_text_p = temp_text_pt + (previous_text_p - visual_str);
  1714.                 current_cursor_p = temp_cursor_p;
  1715.                 previous_cursor_p = temp_pre_cursor_p;
  1716.                 /*
  1717.                  * if(flags & UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT)
  1718.                  * {
  1719.                  * b->highlight_start_position = temp_hilight_start;
  1720.                  * b->highlight_end_position = temp_hilight_end;
  1721.                  * }
  1722.                  */
  1723.             }
  1724.         #endif /* __MMI_BIDI_ALG__ */ 
  1725.             if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) &&
  1726.                 (flags & UI_MULTI_LINE_INPUT_BOX_DRAW_SEPARATOR) && draw_separator)
  1727.             {
  1728.                 static const U8 dotted_line_bitvalues[] = {1, 1, 0, 0};
  1729.             #ifdef __MMI_BIDI_ALG__
  1730.                 if (arabic_char_flag)
  1731.                 {
  1732.                     gdi_draw_line_style(
  1733.                         xx + 5,
  1734.                         yty + current_line_height - 1,
  1735.                         xx + b->edit_width - 1 - 5,
  1736.                         yty + current_line_height - 1,
  1737.                         gdi_act_color_from_rgb(255, 112, 125, 240),
  1738.                         sizeof(dotted_line_bitvalues),
  1739.                         dotted_line_bitvalues);
  1740.                 }
  1741.                 else
  1742.             #endif /* __MMI_BIDI_ALG__ */ 
  1743.                     gdi_draw_line_style(
  1744.                         xx + 5,
  1745.                         yty + current_line_height - 0,
  1746.                         xx + b->edit_width - 1 - 5,
  1747.                         yty + current_line_height - 0,
  1748.                         gdi_act_color_from_rgb(255, 112, 125, 240),
  1749.                         sizeof(dotted_line_bitvalues),
  1750.                         dotted_line_bitvalues);
  1751.             }
  1752.             if (rich_text.line_separator)
  1753.             {
  1754.                 static const U8 line_separator_value[] = {1, 0};
  1755.                 S32 gap = b->edit_width >> 3;
  1756.                 S32 yoffset = (rich_text.more_line_spacing >> 1) + 1;
  1757.                 gdi_draw_line_style(
  1758.                     (S32) xx + gap,
  1759.                     (S32) yty + yoffset,
  1760.                     (S32) xx + b->edit_width - 1 - gap,
  1761.                     (S32) yty + yoffset,
  1762.                     (gdi_color) gdi_act_color_from_rgb(255, rich_text.curr_color.r, rich_text.curr_color.g, rich_text.curr_color.b),
  1763.                     sizeof(line_separator_value),
  1764.                     line_separator_value);
  1765.             }
  1766.             ty += current_line_height;  /* Previously: character_height+text_gap  */
  1767.             if (current_line_height > b->max_line_height)
  1768.             {
  1769.                 b->max_line_height = current_line_height;
  1770.             }
  1771.             if (b->cursor_line_p == previous_line_start_text_p)
  1772.             {
  1773.                 b->line_after_cursor_line_p = line_start_text_p;
  1774.                 b->line_after_cursor_line_last_p = previous_text_p;
  1775.                 next_line_found_flag = 1;
  1776.             }
  1777.             previous_line_start_text_p = line_start_text_p;
  1778.             line_start_text_p = line_break_text_p;
  1779.             if (flags & UI_MULTI_LINE_INPUT_BOX_ONLY_SHOW_FIRST_LINE)
  1780.             {
  1781.                 /* Used by WAP to emulate single line input gadget  */
  1782.                 done = 1;
  1783.             }
  1784.             line_counter++;
  1785.         }
  1786.         if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))
  1787.         if ((((-1) != move_to_x) || ((-1) != move_to_y)) && (!set_cursor_flag))
  1788.         {
  1789.             b->cursor_line_position_counter = current_line_character_counter;
  1790.             b->line_before_cursor_line_p = previous_line_start_text_p;
  1791.             b->cursor_line_p = line_start_text_p;
  1792.             b->cursor_x = tx;
  1793.             b->cursor_y = ty;
  1794.             b->cursor_p = previous_text_p;
  1795.             set_cursor_flag = 1;
  1796.         }
  1797.         /* ty + b->footer_height will become b->text_height */
  1798.         if (b->min_text_height > 0 && ty + b->footer_height < b->min_text_height)
  1799.         {
  1800.             ty = b->min_text_height - b->footer_height;
  1801.         }
  1802.         if (b->max_empty_text_height > 0 && !b->text[0] && !b->text[1])
  1803.         {
  1804.             ty = b->header_height + b->max_empty_text_height;
  1805.         }
  1806.         /* Draw underline */
  1807.         if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) && (flags & UI_MULTI_LINE_INPUT_BOX_DRAW_UNDERLINE))
  1808.         {
  1809.             S32 line_x, line_x2, line_y, line_y_end, line_jump = b->min_line_height;
  1810.             line_y = yy + b->header_height + line_jump - 1;
  1811.             line_y_end = b->y + b->text_y + b->edit_height - 1;
  1812.             if (b->footer_height > 0 && (line_y_end > yy + ty))
  1813.             {
  1814.                 line_y_end = yy + ty;
  1815.             }
  1816.             line_x = b->x + b->text_x;
  1817.             line_x2 = line_x + b->edit_width - 1;
  1818.             line_x++;
  1819.             line_x2--;
  1820.             while (line_y <= line_y_end)
  1821.             {
  1822.                 gdi_draw_line(line_x, line_y, line_x2, line_y, gdi_act_color_from_rgb(255, 112, 125, 240));
  1823.                 line_y += line_jump;
  1824.             }
  1825.         }
  1826.         /* Draw header region */
  1827.         if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) &&
  1828.             b->header_callback && (b->header_height > 0) && (b->text_offset_y + b->header_height > 0))
  1829.         {
  1830.             /* Not overlapped with single-pixel border */
  1831.             b->header_callback(yy, x1 + 1, y1 + 1, x2 - 1, y2 - 1);
  1832.         }
  1833.         /* Draw footer region */
  1834.         if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) &&
  1835.             b->footer_callback && (b->footer_height > 0) && (b->text_offset_y + ty < b->edit_height))
  1836.         {
  1837.             /* Not overlapped with single-pixel border */
  1838.             b->footer_callback(yy + ty, x1 + 1, y1 + 1, x2 - 1, y2 - 1);
  1839.         }
  1840.         if (b->max_line_height > 0)
  1841.         {
  1842.             if (b->text_length == 0)
  1843.             {
  1844.                 b->max_line_height = 0;
  1845.             }
  1846.             else if ((b->text != NULL) && (b->text[0] == 0 && b->text[1] == 0))
  1847.             {
  1848.                 b->max_line_height = 0;
  1849.             }
  1850.         }
  1851.         if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))
  1852.         {
  1853.             gui_pop_text_clip();
  1854.             gui_pop_clip();
  1855.         }
  1856.         if (!next_line_found_flag)
  1857.         {
  1858.             b->line_after_cursor_line_p = b->cursor_line_p;
  1859.         }
  1860.         /* Footer area should be included in b->text_height */
  1861.         ty += b->footer_height;
  1862.         b->text_height = ty;
  1863.         temp_d = b->text_offset_y + ty;
  1864.         /* View mode condition added. Nov-19, TESTFIX   */
  1865.         if (!(b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE) && (flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))
  1866.         {
  1867.             if (temp_d < edit_height)
  1868.             {
  1869.             #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  1870.                 if (GetMessagesCurrScrnID() == SCR_ID_MSG_WRITE)
  1871.                 {
  1872.                     b->text_offset_y += 15;
  1873.                 }
  1874.                 else
  1875.             #endif /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  1876.                     b->text_offset_y += (edit_height - temp_d);
  1877.                 if (b->text_offset_y > 0)
  1878.                 {
  1879.                     b->text_offset_y = 0;
  1880.                 }
  1881.             }
  1882.         }
  1883.         b->n_lines = line_counter;
  1884.     #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  1885.         /* Once text_offset_y value is acheived for the text display from the offset given by the concerned application 
  1886.            then reset the offset value */
  1887.         if (b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_VIEW_PAGING_MODE)
  1888.         {
  1889.             if (b->jump_offset_from_app != 0 && b->search_flag_is_on)
  1890.             {
  1891. /* PMT Start 09_08_06 00071 */
  1892.                 if(((-b->text_offset_y) % b->edit_height_displayed_lines)<b->edit_height_displayed_lines -(current_line_height*2))
  1893.     {
  1894.                     b->text_offset_y += (-b->text_offset_y) % b->edit_height_displayed_lines;
  1895.                 }
  1896. /* PMT End 09_08_06 00071 */
  1897.             }
  1898. //begin steven ebook 
  1899. if(-b->text_offset_y==b->text_height && b->text_height >b->edit_height_displayed_lines)
  1900. {
  1901. b->text_offset_y+=b->edit_height_displayed_lines;
  1902. }
  1903. //end steve ebook
  1904.             b->page_offset = 0;
  1905.             b->jump_offset_from_app = 0;
  1906. /* PMT Start 06_08_06 00071 */
  1907.   if(b->size_of_total_data < GUI_PAGE_SIZE)
  1908.          {
  1909.              gui_set_vertical_scrollbar_scale(&b->vbar, b->edit_height);
  1910.          }
  1911.         else
  1912.          {
  1913.              gui_set_vertical_scrollbar_scale(&b->vbar, 1);
  1914.          }
  1915. /* PMT End 06_08_06 00071 */
  1916.             rich_text.curr_font.bold = rich_text.curr_font.italic = 0;
  1917.         }
  1918.         else
  1919.     #endif /* __UI_PAGING_IN_MULTILINE_EDITOR__ */ 
  1920.         {
  1921.             gui_set_vertical_scrollbar_scale(&b->vbar, b->edit_height);
  1922.             gui_set_vertical_scrollbar_range(&b->vbar, ty);
  1923.             gui_set_vertical_scrollbar_value(&b->vbar, -b->text_offset_y);
  1924.         }
  1925.         /* Set global font to default because rich_text.curr_font is local variable released dynamically. */
  1926.         gui_set_font(b->text_font);
  1927.     }
  1928.     else    /* else of if(b->text != NULL) */
  1929.     {
  1930.         gui_set_vertical_scrollbar_scale(&b->vbar, b->edit_height);
  1931.         gui_set_vertical_scrollbar_range(&b->vbar, 0);
  1932.         gui_set_vertical_scrollbar_value(&b->vbar, 0);
  1933.     }
  1934. #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  1935.     count_flag = 0;                                         /* ritesh */
  1936. #endif 
  1937.     if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))    /* if not disable draw then do .. */
  1938.     {
  1939.         gui_pop_clip();
  1940.         if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR) && (edit_width > 0))
  1941.         {
  1942.             if (flags & UI_MULTI_LINE_INPUT_BOX_AUTO_DISABLE_SCROLLBAR)
  1943.             {
  1944.                 if (b->vbar.scale < b->vbar.range)
  1945.                 {
  1946.                     if (r2lMMIFlag)
  1947.                     {
  1948.                         vbar_x = b->vbar.x;
  1949.                         vbar_button_x = b->vbar.scroll_button.x;
  1950.                         b->vbar.x = b->vbar.x + b->vbar.width - b->width;
  1951.                         b->vbar.scroll_button.x = b->vbar.scroll_button.x + b->vbar.scroll_button.width - b->width;
  1952.                         gui_show_vertical_scrollbar(&b->vbar);
  1953.                     }
  1954.                     else
  1955.                     {
  1956.                         gui_show_vertical_scrollbar(&b->vbar);
  1957.                     }
  1958.                     if (r2lMMIFlag)
  1959.                     {
  1960.                         b->vbar.x = vbar_x;
  1961.                         b->vbar.scroll_button.x = vbar_button_x;
  1962.                     }
  1963.                 }
  1964.             }
  1965.             else
  1966.             {
  1967.                 if (r2lMMIFlag)
  1968.                 {
  1969.                     vbar_x = b->vbar.x;
  1970.                     vbar_button_x = b->vbar.scroll_button.x;
  1971.                     b->vbar.x = b->vbar.x + b->vbar.width - b->width;
  1972.                     b->vbar.scroll_button.x = b->vbar.scroll_button.x + b->vbar.scroll_button.width - b->width;
  1973.                     gui_show_vertical_scrollbar(&b->vbar);
  1974.                 }
  1975.                 else
  1976.                 {
  1977.                     gui_show_vertical_scrollbar(&b->vbar);
  1978.                 }
  1979.                 if (r2lMMIFlag)
  1980.                 {
  1981.                     b->vbar.x = vbar_x;
  1982.                     b->vbar.scroll_button.x = vbar_button_x;
  1983.                 }
  1984.             }
  1985.         }
  1986.         if (((b->flags & UI_MULTI_LINE_INPUT_BOX_AUTO_VERTICAL_SCROLL) ==
  1987.              UI_MULTI_LINE_INPUT_BOX_AUTO_VERTICAL_SCROLL) && !b->vertical_scroll_on)
  1988.         {
  1989.         #if(UI_BLINKING_CURSOR_SUPPORT)
  1990.             StopMyTimer(BLINKING_CURSOR);
  1991.         #endif 
  1992.             gui_cancel_timer(multiline_inputbox_vertical_scroll);
  1993.             gui_start_timer(UI_MULTI_LINE_INIT_SCROLL, multiline_inputbox_vertical_scroll);
  1994.         }
  1995.     }
  1996. #if 0
  1997. #ifdef __MMI_BIDI_ALG__
  1998. /* under construction !*/
  1999. /* under construction !*/
  2000. /* under construction !*/
  2001. /* under construction !*/
  2002. /* under construction !*/
  2003. /* under construction !*/
  2004. /* under construction !*/
  2005. /* under construction !*/
  2006. /* under construction !*/
  2007. /* under construction !*/
  2008. /* under construction !*/
  2009. /* under construction !*/
  2010. /* under construction !*/
  2011. /* under construction !*/
  2012. /* under construction !*/
  2013. /* under construction !*/
  2014. /* under construction !*/
  2015. #endif
  2016. #endif /* 0 */ 
  2017. #ifdef __MMI_BIDI_ALG__
  2018.     UI_UNUSED_PARAMETER(temp_hilight_start);
  2019.     UI_UNUSED_PARAMETER(temp_hilight_end);
  2020. #endif /* __MMI_BIDI_ALG__ */ 
  2021. #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  2022.     if (GetMessagesCurrScrnID() == SCR_ID_MSG_WRITE)
  2023.     {
  2024.         g_nsm_msg_context.UCS2_count = b->UCS2_count;   /* To fix outbox edit bug */
  2025.         g_nsm_msg_context.textlength = b->text_length;
  2026.     }
  2027.     if ((GetExitScrnID() == SCR_ID_MSG_OUTBOX_MSG) && (mmi_nsm_get_msg_type() == PICTURE_MESSAGE))
  2028.     {
  2029.         g_nsm_msg_context.UCS2_count = b->UCS2_count;   /* To fix outbox SEND bug */
  2030.     }
  2031. #endif /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  2032.     /* PMT VIKAS START 20050707 */
  2033. #ifdef __MMI_UI_DALMATIAN_EDITOR__
  2034. if(!(b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_DISABLE_DALMATIAN_EDITOR))
  2035. {
  2036.     if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))//053006 dalmatian editor Calvin
  2037.     {
  2038.         S32 draw_dal_image = 1;
  2039.         if (!(flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW) &&
  2040.             b->header_callback && (b->header_height > 0) && (b->text_offset_y + b->header_height >= 0))
  2041.         {
  2042.             draw_dal_image = 0; /* Not to draw image when image insert in editor. */
  2043.         }
  2044.         /* Draw Dalmatian editor image */
  2045.         if (b->height >= 100)   /* To draw image according to screen size. */
  2046.         {
  2047.             gui_measure_image(get_image(IMG_EDITOR_DALMATIAN), &image_width, &image_height);
  2048.         }
  2049.         else
  2050.         {
  2051.             gui_measure_image(get_image(IMG_EDITOR_DALMATIAN_SMALL), &image_width, &image_height);
  2052.         }
  2053.         //PMT SUKRIT START 20060104
  2054.         //The image will be drawn if the editor height is 25% more than image height
  2055.         if (image_height > (b->height - (image_height >> 2)))
  2056.         {
  2057.             draw_dal_image = 0;
  2058.         }
  2059.         /* PMT SUKRIT END 20060104 */
  2060.         if (draw_dal_image && b->text_length <= 2 && (!(flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE)) &&
  2061.             (0 == b->footer_height))
  2062.         {
  2063.             /* PMT VIKAS START 20050817 */
  2064.             if (b->height >= 100)
  2065.                 if (!r2lMMIFlag)
  2066.                 {
  2067.                     gui_show_image(
  2068.                         (U16) b->x + b->width - (b->vbar.width + image_width + 2),
  2069.                         (U16) b->y + b->height - (image_height + 4),
  2070.                         get_image(IMG_EDITOR_DALMATIAN));
  2071.                 }
  2072.                 else
  2073.                 {
  2074.                     gui_show_image(
  2075.                         (U16) b->x + (b->vbar.width + 2),
  2076.                         (U16) b->y + b->height - (image_height + 4),
  2077.                         get_image(IMG_EDITOR_DALMATIAN));
  2078.                 }
  2079.             else if (!r2lMMIFlag)
  2080.             {
  2081.                 gui_show_image(
  2082.                     (U16) b->x + b->width - (b->vbar.width + image_width + 2),
  2083.                     (U16) b->y + b->height - (image_height + 4),
  2084.                     get_image(IMG_EDITOR_DALMATIAN_SMALL));
  2085.             }
  2086.             else
  2087.             {
  2088.                 gui_show_image(
  2089.                     (U16) b->x + (b->vbar.width + 2),
  2090.                     (U16) b->y + b->height - (image_height + 4),
  2091.                     get_image(IMG_EDITOR_DALMATIAN_SMALL));
  2092.             }
  2093.             /* PMT VIKAS END 20050817 */
  2094.         }
  2095.     }
  2096. }
  2097. #endif /* __MMI_UI_DALMATIAN_EDITOR__ */ 
  2098.     /* PMT VIKAS END 20050707 */
  2099. #if defined(__MMI_SMART_MESSAGE_MT__)
  2100.     if ((GetMessagesCurrScrnID() == SCR_ID_NSM_EDITOR) || ((GetExitScrnID() == SCR_ID_MSG_OUTBOX_MSG) && (mmi_nsm_get_msg_type() == PICTURE_MESSAGE))   /* Update ucs2 flag when entering outbox msg */
  2101.         )
  2102.     {
  2103.         picmsg_text_struct.ucs2_count = b->UCS2_count;
  2104.     }
  2105. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  2106.     //W05.49 Fix cursor in Information Bar Issue
  2107.     //W06.03 Fix cursor issue when adding image in MMS
  2108.     if (!(b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE))/* if not view mode then do .. */
  2109. if(!(b->ext_flags &GUI_MULTI_LINE_INPUT_BOX_DISABLE_FORCE_CURSOR_APPEAR))
  2110. //W06.51 Fix cursor may not update the offset_y if ((flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW))      
  2111.     {
  2112.         if ((b->cursor_y+current_line_height+b->text_offset_y) > edit_height  &&  edit_height > character_height)
  2113.         {
  2114.             b->text_offset_y = -(b->cursor_y+current_line_height - edit_height);
  2115.         }
  2116.         else if ((b->cursor_y + b->text_offset_y) < 0)
  2117.         {
  2118.             b->text_offset_y = -(b->cursor_y);
  2119.         }
  2120.         StopMyTimer(BLINKING_CURSOR);
  2121.     }
  2122.     UI_UNUSED_PARAMETER(dummy_c);
  2123.     /* PMT RAKESH START 20061006 */
  2124. #if defined __MMI_HINDI_ALG__
  2125.     restore_current_language_for_hindi_rules();
  2126. #endif 
  2127.     /* PMT RAKESH END 20061006 */
  2128. }
  2129. /*****************************************************************************
  2130.  * FUNCTION
  2131.  *  gui_destroy_multi_line_input_box
  2132.  * DESCRIPTION
  2133.  *  Destroys the multi-line inputbox
  2134.  *  
  2135.  *  This function only frees the buffer used by the multi-line input box.
  2136.  *  It does not destroy the multi-line inputbox object.
  2137.  * PARAMETERS
  2138.  *  b       [IN]        Is the multi-line inputbox object
  2139.  * RETURNS
  2140.  *  void
  2141.  *****************************************************************************/
  2142. void gui_destroy_multi_line_input_box(multi_line_input_box *b)
  2143. {
  2144.     /*----------------------------------------------------------------*/
  2145.     /* Local Variables                                                */
  2146.     /*----------------------------------------------------------------*/
  2147.     /*----------------------------------------------------------------*/
  2148.     /* Code Body                                                      */
  2149.     /*----------------------------------------------------------------*/
  2150.     gui_free(b->text);
  2151. }
  2152. /*****************************************************************************
  2153.  * FUNCTION
  2154.  *  gui_multi_line_input_box_delete_character
  2155.  * DESCRIPTION
  2156.  *  Deletes a character before the current cursor position (Backspace)
  2157.  * PARAMETERS
  2158.  *  b       [IN]        Is the multi-line inputbox object
  2159.  * RETURNS
  2160.  *  void
  2161.  *****************************************************************************/
  2162. void gui_multi_line_input_box_delete_character(multi_line_input_box *b)
  2163. {
  2164.     /*----------------------------------------------------------------*/
  2165.     /* Local Variables                                                */
  2166.     /*----------------------------------------------------------------*/
  2167.     UI_buffer_type current_text_p;
  2168.     UI_buffer_type previous_text_p;
  2169.     UI_character_type current_character = (UI_character_type) - 1;
  2170.     UI_character_type dummy_c = 0;
  2171. #if defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__)
  2172.     U8 input_mode = 1;
  2173. #endif 
  2174.     /*----------------------------------------------------------------*/
  2175.     /* Code Body                                                      */
  2176.     /*----------------------------------------------------------------*/
  2177.     if(b->change_event_handler)
  2178.     {
  2179. UI_buffer_type tmp_p = b->cursor_p;
  2180. UI_STRING_GET_PREVIOUS_CHARACTER(tmp_p,dummy_c);
  2181.         if(!b->change_event_handler(GUI_MULTI_LINE_INPUT_BOX_DELETE_CHAR,(U16)dummy_c))
  2182.             return;
  2183.     }
  2184.     current_text_p = b->cursor_p;
  2185.     previous_text_p = b->cursor_p;
  2186. #if defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__)
  2187.     WCSS_input_change_enable = 0;
  2188.     if (b->flags & UI_MULTI_LINE_WCSS_INPUT_BOX_ENABLE)
  2189.     {
  2190.         if (b->cursor_p - 2 >= b->text)
  2191.         {
  2192.             UI_buffer_type cursor_p = b->cursor_p;
  2193.             BOOL has_editable_char = MMI_FALSE;
  2194.             while (cursor_p - 2 >= b->text)
  2195.             {
  2196.                 if (cat115buffer[(cursor_p - 2 - b->text) >> 1] != 0xFF)
  2197.                 {
  2198.                     has_editable_char = MMI_TRUE;
  2199.                     break;
  2200.                 }
  2201.                 cursor_p -= 2;
  2202.             }
  2203.             if (!has_editable_char) /* eg. "--nnn" */
  2204.             {
  2205.                 UI_editor_play_tone_cannot_change();
  2206.                 WCSS_input_change_enable = 1;
  2207.                 return;
  2208.             }
  2209.             input_mode = cat115buffer[(b->cursor_p - 2 - b->text) >> 1];
  2210.             while (input_mode == 0xFF && b->cursor_p - 2 >= b->text /* redundant check */ )
  2211.             {
  2212.                 gui_multi_line_input_box_previous(&MMI_multiline_inputbox);
  2213.                 input_mode = cat115buffer[(b->cursor_p - 2 - b->text) >> 1];
  2214.             }
  2215.             current_text_p = b->cursor_p;
  2216.             previous_text_p = b->cursor_p;
  2217.         }
  2218.     }
  2219. #endif /* defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__) */ 
  2220.     if (previous_text_p == b->text)
  2221.     {
  2222.         UI_editor_play_tone_cannot_change();    /* play tone */
  2223.     #if defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__)
  2224.         WCSS_input_change_enable = 1;           /* change back to 1 after returing from this function */
  2225.     #endif 
  2226.         return;
  2227.     }
  2228.     UI_STRING_GET_PREVIOUS_CHARACTER(previous_text_p, dummy_c);
  2229.     if (UI_TEST_GSM_EXTENDED(dummy_c))
  2230.     {
  2231.         if (b->GSM_ext_count > 0)
  2232.         {
  2233.             b->GSM_ext_count--;
  2234.         }
  2235.     }
  2236.     if (b->icon_callback)
  2237.     {
  2238.         /* previous_text_p is the first character to be deleted */
  2239.         S32 cnt, gsm_char_cnt = 0;
  2240.         UI_buffer_type tmp_text_p = previous_text_p;
  2241.         UI_character_type tmp_c;
  2242.         UI_STRING_GET_PREVIOUS_CHARACTER(tmp_text_p, tmp_c);
  2243.         if (UI_TEST_GSM_EXTENDED(tmp_c))
  2244.         {
  2245.             gsm_char_cnt++;
  2246.         }
  2247.         for (cnt = 2; cnt <= MMI_MULTILINE_ICON_MAX_STRING_LEN; cnt++)
  2248.         {
  2249.             if (tmp_text_p < b->text)
  2250.             {
  2251.                 break;
  2252.             }
  2253.             if (cnt == b->icon_callback(tmp_text_p, MMI_FALSE, NULL, NULL, 0, 0))
  2254.             {
  2255.                 /* Delete an icon as character sequence */
  2256.                 previous_text_p = tmp_text_p;
  2257.                 dummy_c = tmp_c;
  2258.                 if (b->GSM_ext_count > gsm_char_cnt)
  2259.                 {
  2260.                     b->GSM_ext_count -= gsm_char_cnt;
  2261.                 }
  2262.                 else
  2263.                 {
  2264.                     b->GSM_ext_count = 0;
  2265.                 }
  2266.                 break;
  2267.             }
  2268.             UI_STRING_GET_PREVIOUS_CHARACTER(tmp_text_p, tmp_c);
  2269.             if (UI_TEST_GSM_EXTENDED(tmp_c))
  2270.             {
  2271.                 gsm_char_cnt++;
  2272.             }
  2273.         }
  2274.     }
  2275. #if(MULTILINE_INPUTBOX_USE_CRLF_COMBINATION)
  2276.     if (UI_TEST_LF_CHARACTER(dummy_c))
  2277.     {
  2278.         UI_STRING_GET_PREVIOUS_CHARACTER(previous_text_p, dummy_c);
  2279.         if (!UI_TEST_CR_CHARACTER(dummy_c)
  2280.         ||  (b->change_event_handler && !b->change_event_handler(GUI_MULTI_LINE_INPUT_BOX_DELETE_CHAR,(U16)dummy_c)))
  2281.         {
  2282.             UI_STRING_GET_NEXT_CHARACTER(previous_text_p, dummy_c);
  2283.         }
  2284.     }
  2285. #endif /* (MULTILINE_INPUTBOX_USE_CRLF_COMBINATION) */ 
  2286. #if defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__)
  2287.     /* If In Non * Mode No Need To Decrease the text_length */
  2288.     if (((b->flags & UI_MULTI_LINE_WCSS_INPUT_BOX_ENABLE) && (input_mode & PIXTEL_UI_WCSS_STAR_INPUT)) ||
  2289.         !(b->flags & UI_MULTI_LINE_WCSS_INPUT_BOX_ENABLE))
  2290.     {
  2291. #endif /* defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__) */ 
  2292.         b->text_length -= ((S32) current_text_p - (S32) previous_text_p);
  2293.         b->cursor_p = previous_text_p;
  2294.         if (b->flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  2295.         {
  2296.             UI_TEST_UCS2_DECREMENT_COUNT_SET_LENGTH(dummy_c, b->UCS2_count, b->allocated_length, b->available_length);
  2297.         }
  2298.         while (!UI_STRING_END_OF_STRING_CHARACTER(current_character))
  2299.         {
  2300.             UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  2301.             UI_STRING_INSERT_CHARACTER(previous_text_p, current_character);     /* insert character */
  2302.         }
  2303.     #if defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__)
  2304.     }   /* if non-WCSS or not in * mode */
  2305.     else if ((b->flags & UI_MULTI_LINE_WCSS_INPUT_BOX_ENABLE) && (!(input_mode & PIXTEL_UI_WCSS_STAR_INPUT)))
  2306.     {
  2307.         b->cursor_p = previous_text_p;
  2308.         if (input_mode & PIXTEL_UI_WCSS_SPACE_DEFAULT_CHARACTER)
  2309.         {
  2310.             current_character = 0x20;   /* ' ' */
  2311.         }
  2312.         else
  2313.         {
  2314.             current_character = 0x30;   /* '0' */
  2315.         }
  2316.         UI_STRING_INSERT_CHARACTER(previous_text_p, current_character);
  2317.     }
  2318.     WCSS_input_change_enable = 1;
  2319.     #endif /* defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__) */ 
  2320.     b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  2321. #ifdef __MMI_HINDI_ALG__
  2322.     if ((b->cursor_p - b->text) >= 4)
  2323.     {
  2324.         UI_buffer_type temp_multi_line_cursor_p;
  2325.         temp_multi_line_cursor_p = b->cursor_p;
  2326.         if ((UI_CHK_CONSONANT(*(temp_multi_line_cursor_p - 4))) && (UI_CHK_CONSONANT(*(temp_multi_line_cursor_p))) &&
  2327.             (*(temp_multi_line_cursor_p - 2) == 0x4d))
  2328.         {
  2329.             U8 skip_after_delete = 0;
  2330.             PU8 first_pos_p = temp_multi_line_cursor_p;
  2331.             PU8 second_pos_p;
  2332.             /* second_pos_p = hf_get_next_cluster_p(b->text,first_pos_p); */
  2333.             second_pos_p = hf_get_next_cluster_p(first_pos_p, first_pos_p);
  2334.             skip_after_delete = second_pos_p - first_pos_p; /* Number of moves */
  2335.             skip_after_delete = skip_after_delete >> 1;
  2336.             while (skip_after_delete--)
  2337.             {
  2338.                 UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  2339.             }
  2340.         }
  2341.     }
  2342. #endif /* __MMI_HINDI_ALG__ */ 
  2343.     
  2344.     if (b->show_action_flag)
  2345.     {
  2346.         gui_show_multi_line_input_box(b);   /* show multiline input box */
  2347.     }
  2348.     
  2349.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  2350. #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  2351.     /* !!! Note : For for Nokia smart message write message screen */
  2352.     if (GetMessagesCurrScrnID() == SCR_ID_MSG_WRITE)
  2353.     {
  2354.         g_nsm_msg_context.UCS2_count = b->UCS2_count;
  2355.         if (g_nsm_msg_context.UCS2_count == 0)
  2356.         {
  2357.             MMI_multiline_inputbox.available_length = mmi_nsm2_get_remaining_len();
  2358.             wgui_inputbox_buffer_size = (MMI_multiline_inputbox.available_length >> 1);
  2359.             wgui_redraw_input_information_bar();
  2360.         }
  2361.         g_nsm_msg_context.textlength = b->text_length;
  2362.     }
  2363. #endif /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  2364. #if defined(__MMI_SMART_MESSAGE_MT__)
  2365.     if (GetMessagesCurrScrnID() == SCR_ID_NSM_EDITOR)
  2366.     {
  2367.         picmsg_text_struct.ucs2_count = b->UCS2_count;
  2368.         if (picmsg_text_struct.ucs2_count == 0)
  2369.         {
  2370.             MMI_multiline_inputbox.available_length = mmi_nsm_get_infobar_maxlen();
  2371.             wgui_inputbox_buffer_size = (MMI_multiline_inputbox.available_length >> 1);
  2372.             wgui_redraw_input_information_bar();
  2373.         }
  2374.     }
  2375. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  2376.     b->validation_callback(b->text, b->cursor_p, (b->text_length >> 1) - 1);
  2377.     b->change_callback();
  2378. }
  2379. /*****************************************************************************
  2380.  * FUNCTION
  2381.  *  gui_multi_line_input_box_delete_all
  2382.  * DESCRIPTION
  2383.  *  Deletes all characters
  2384.  * PARAMETERS
  2385.  *  b       [IN]        Is the multi-line inputbox object
  2386.  * RETURNS
  2387.  *  void
  2388.  *****************************************************************************/
  2389. void gui_multi_line_input_box_delete_all(multi_line_input_box *b)
  2390. {
  2391.     /*----------------------------------------------------------------*/
  2392.     /* Local Variables                                                */
  2393.     /*----------------------------------------------------------------*/
  2394.     UI_character_type c;
  2395.     UI_buffer_type p = b->text;
  2396.     /*----------------------------------------------------------------*/
  2397.     /* Code Body                                                      */
  2398.     /*----------------------------------------------------------------*/
  2399.     UI_STRING_GET_NEXT_CHARACTER(p, c);
  2400.     UI_UNUSED_PARAMETER(c);
  2401.     if(b->change_event_handler)
  2402.     {
  2403.         if(!b->change_event_handler(GUI_MULTI_LINE_INPUT_BOX_DELETEALL,0))
  2404.             return;
  2405.     }
  2406.     
  2407.     gui_multi_line_input_box_clear(b);  /* initilaize multiline box */
  2408.     b->cursor_p = b->text;
  2409.     b->cursor_line_position_counter = 0;
  2410.     b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  2411.     gui_show_multi_line_input_box(b);   /* show multiline input box */
  2412.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  2413.     /* For clear all characters from multiline input box */
  2414. #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  2415.     if (GetMessagesCurrScrnID() == SCR_ID_MSG_WRITE)    /* For nsm2 write message only */
  2416.     {
  2417.         g_nsm_msg_context.UCS2_count = b->UCS2_count;
  2418.         MMI_multiline_inputbox.available_length = mmi_nsm2_get_remaining_len();
  2419.         wgui_inputbox_buffer_size = (MMI_multiline_inputbox.available_length >> 1);
  2420.         if (wgui_inputbox_information_flag)
  2421.         {
  2422.             wgui_redraw_remaining_characters_display();
  2423.         }
  2424.         g_nsm_msg_context.textlength = b->text_length;
  2425.     }
  2426. #endif /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  2427. #if defined(__MMI_SMART_MESSAGE_MT__)
  2428.     if (GetMessagesCurrScrnID() == SCR_ID_NSM_EDITOR)
  2429.     {
  2430.         picmsg_text_struct.ucs2_count = b->UCS2_count;
  2431.         MMI_multiline_inputbox.available_length = mmi_nsm_get_infobar_maxlen();
  2432.         wgui_inputbox_buffer_size = (MMI_multiline_inputbox.available_length >> 1);
  2433.         wgui_redraw_input_information_bar();
  2434.     }
  2435. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  2436.     b->validation_callback(b->text, b->cursor_p, (b->text_length >> 1) - 1);
  2437.     b->change_callback();
  2438. }
  2439. /*****************************************************************************
  2440.  * FUNCTION
  2441.  *  gui_multi_line_input_box_delete_current_character
  2442.  * DESCRIPTION
  2443.  *  Deletes a character at the current cursor position (Delete)
  2444.  * PARAMETERS
  2445.  *  b       [IN]        Is the multi-line inputbox object
  2446.  * RETURNS
  2447.  *  void
  2448.  *****************************************************************************/
  2449. void gui_multi_line_input_box_delete_current_character(multi_line_input_box *b)
  2450. {
  2451.     /*----------------------------------------------------------------*/
  2452.     /* Local Variables                                                */
  2453.     /*----------------------------------------------------------------*/
  2454.     UI_buffer_type current_text_p;
  2455.     UI_buffer_type previous_text_p;
  2456.     UI_character_type current_character = (UI_character_type) - 1;
  2457.     /*----------------------------------------------------------------*/
  2458.     /* Code Body                                                      */
  2459.     /*----------------------------------------------------------------*/
  2460.     current_text_p = b->cursor_p;
  2461.     previous_text_p = b->cursor_p;
  2462.     UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  2463.     if (b->icon_callback)
  2464.     {
  2465.         /* current_text_p is the character next to the last character to be deleted */
  2466.         S32 cnt;
  2467.         if ((cnt = b->icon_callback(previous_text_p, MMI_FALSE, NULL, NULL, 0, 0)) > 0)
  2468.         {
  2469.             /* Delete an icon as character sequence */
  2470.             current_text_p = previous_text_p + ((cnt - 1) << 1);
  2471.             UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  2472.         }
  2473.     }
  2474. #if(MULTILINE_INPUTBOX_USE_CRLF_COMBINATION)
  2475.     if (UI_TEST_CR_CHARACTER(current_character))
  2476.     {
  2477.         UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  2478.         if (!UI_TEST_LF_CHARACTER(current_character)
  2479.         ||  !b->change_event_handler(GUI_MULTI_LINE_INPUT_BOX_DELETE_CHAR,(U16)current_character))
  2480.         {
  2481.             UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, current_character);
  2482.         }
  2483.     }
  2484. #endif /* (MULTILINE_INPUTBOX_USE_CRLF_COMBINATION) */ 
  2485.     if (!UI_STRING_END_OF_STRING_CHARACTER(current_character))
  2486.     {
  2487.         if (UI_TEST_GSM_EXTENDED(current_character))
  2488.         {
  2489.             if (b->GSM_ext_count > 0)
  2490.             {
  2491.                 b->GSM_ext_count--;
  2492.             }
  2493.         }
  2494.         if (b->flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  2495.         {
  2496.             UI_TEST_UCS2_DECREMENT_COUNT_SET_LENGTH(
  2497.                 current_character,
  2498.                 b->UCS2_count,
  2499.                 b->allocated_length,
  2500.                 b->available_length);
  2501.         }
  2502.         while (!UI_STRING_END_OF_STRING_CHARACTER(current_character))
  2503.         {
  2504.             UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  2505.             UI_STRING_INSERT_CHARACTER(previous_text_p, current_character);
  2506.         }
  2507.         b->text_length -= ((S32) current_text_p - (S32) previous_text_p);
  2508.         if (b->flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP)
  2509.         {
  2510.             b->flags &= ~UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP;
  2511.         }
  2512.         b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  2513.         gui_show_multi_line_input_box(b);   /* show multiline input box */
  2514.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  2515.         b->validation_callback(b->text, b->cursor_p, (b->text_length >> 1) - 1);
  2516.         b->change_callback();
  2517.     }
  2518.     else
  2519.     {
  2520.         UI_editor_play_tone_cannot_change();    /* play error tone */
  2521.     }
  2522. }
  2523. /*****************************************************************************
  2524.  * FUNCTION
  2525.  *  gui_multi_line_input_box_insert_character
  2526.  * DESCRIPTION
  2527.  *  Inserts a character at the current cursor position
  2528.  * PARAMETERS
  2529.  *  b       [IN]        Is the multi-line inputbox object
  2530.  *  c       [IN]        Is the character to be inserted
  2531.  * RETURNS
  2532.  *  void
  2533.  *****************************************************************************/
  2534. MMI_BOOL gui_multi_line_input_box_insert_character_internal(multi_line_input_box *b, UI_character_type c)
  2535. {
  2536.     /*----------------------------------------------------------------*/
  2537.     /* Local Variables                                                */
  2538.     /*----------------------------------------------------------------*/
  2539.     UI_buffer_type p1, p2;
  2540.     UI_character_type old_c, dummy_c = 0;
  2541.     U32 b_flags = b->flags;
  2542.     S32 text_length = b->text_length;
  2543.     U8 GSM_extended_flag = 0;
  2544.     /* MTK Terry for 0x81 encoding support for Phone Book */
  2545.     U8 temp_0x81 = 0;
  2546.     /*----------------------------------------------------------------*/
  2547.     /* Code Body                                                      */
  2548.     /*----------------------------------------------------------------*/
  2549.     if(b->change_event_handler)
  2550.     {
  2551.         if(!b->change_event_handler(GUI_MULTI_LINE_INPUT_BOX_INSERT_CHAR,(U16)c))
  2552.             return MMI_FALSE;
  2553.     }
  2554.     
  2555.     /* MTK Terry for 0x81 memory corrupt issue */
  2556.     if (MMI_current_input_ext_type & INPUT_TYPE_EXT_USE_0x81_ENCODING)
  2557.     {
  2558.         temp_0x81 = mmi_phb_convert_to_0x81((S8*) MMI_multiline_inputbox.text, FALSE);
  2559.     }
  2560.     if ((MMI_current_input_ext_type & INPUT_TYPE_EXT_USE_0x81_ENCODING) && (0 != temp_0x81))
  2561.     {
  2562.         if ((text_length >> 1) - 1 >= b->available_length - 3)
  2563.         {
  2564.             UI_editor_play_tone_cannot_insert();    /* play error tone */
  2565.             return MMI_FALSE;
  2566.         }
  2567.     }
  2568.     else
  2569.     {
  2570.         if (b_flags & UI_MULTI_LINE_INPUT_BOX_CHECK_GSM_EXTENDED)
  2571.         {
  2572.             if (UI_TEST_GSM_EXTENDED(c))
  2573.             {
  2574.                 GSM_extended_flag = 1;
  2575.             }
  2576.             if (b->UCS2_count == 0)
  2577.             {
  2578.                 text_length += (b->GSM_ext_count * ENCODING_LENGTH);
  2579.             }
  2580.         }
  2581.         if ((b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH) && (b->UCS2_count == 0) &&
  2582.             UI_TEST_UCS2_CHARACTER(c))
  2583.         {
  2584.             if ((b_flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER) &&
  2585.                 (text_length >= UI_UCS2_STRING_HALF_LENGTH_MINUS_ONE(b->available_length)))
  2586.             {
  2587.                 UI_editor_play_tone_cannot_insert();    /* play error tone */
  2588.                 return MMI_FALSE;
  2589.             }
  2590.             if ((b_flags & UI_MULTI_LINE_INPUT_BOX_FORTY_FOUR_LESS_CHARACTER) &&
  2591.                 (text_length >= UI_UCS2_STRING_HALF_LENGTH_MINUS_FORTYFOUR(b->available_length)))
  2592.             {
  2593.                 UI_editor_play_tone_cannot_insert();    /* play error tone */
  2594.                 return MMI_FALSE;
  2595.             }
  2596.             else if (text_length >= UI_UCS2_STRING_HALF_LENGTH(b->available_length))
  2597.             {
  2598.                 UI_editor_play_tone_cannot_insert();    /* play eror tone */
  2599.                 return MMI_FALSE;
  2600.             }
  2601.         }
  2602.         if (GSM_extended_flag && (text_length >= (b->available_length - ENCODING_LENGTH)))
  2603.         {
  2604.             UI_editor_play_tone_cannot_insert();
  2605.             return MMI_FALSE;
  2606.         }
  2607.     }
  2608.     p1 = p2 = b->cursor_p;
  2609.     if (b_flags & UI_MULTI_LINE_INPUT_BOX_OVERWRITE_MODE)
  2610.     {
  2611.         UI_STRING_GET_NEXT_CHARACTER(p1, old_c);    /* get next character */
  2612.         if ((p1 == b->last_position_p) && (text_length >= b->available_length))
  2613.         {
  2614.             UI_editor_play_tone_cannot_insert();
  2615.             return MMI_FALSE;
  2616.         }
  2617.         if (GSM_extended_flag)
  2618.         {
  2619.             b->GSM_ext_count++;
  2620.         }
  2621.         if (!UI_STRING_END_OF_STRING_CHARACTER(old_c))  /* check for end of string */
  2622.         {
  2623.             UI_STRING_INSERT_CHARACTER(p2, c);
  2624.             if (b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  2625.             {
  2626.                 if (b_flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
  2627.                 {
  2628.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  2629.                         old_c,
  2630.                         c,
  2631.                         b->UCS2_count,
  2632.                         b->allocated_length,
  2633.                         b->available_length);
  2634.                 }
  2635.                 else if (b_flags & UI_MULTI_LINE_INPUT_BOX_FORTY_FOUR_LESS_CHARACTER)
  2636.                 {
  2637.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE3(
  2638.                         old_c,
  2639.                         c,
  2640.                         b->UCS2_count,
  2641.                         b->allocated_length,
  2642.                         b->available_length);
  2643.                 }
  2644.                 else
  2645.                 {
  2646.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  2647.                         old_c,
  2648.                         c,
  2649.                         b->UCS2_count,
  2650.                         b->allocated_length,
  2651.                         b->available_length);
  2652.                 }
  2653.             }
  2654.             b->cursor_p = p2;
  2655.         }
  2656.         else    /* UI_STRING_END_OF_STRING_CHARACTER(old_c) */
  2657.         {
  2658.             p1 = b->cursor_p;
  2659.             UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c); /* get next character */
  2660.             while (!UI_STRING_END_OF_STRING_CHARACTER(c))   /* check for end of string */
  2661.             {
  2662.                 UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  2663.                 UI_STRING_INSERT_CHARACTER(p2, c);
  2664.                 c = old_c;
  2665.             }
  2666.             UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  2667.             if (b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  2668.             {
  2669.                 if (b_flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
  2670.                 {
  2671.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  2672.                         old_c,
  2673.                         c,
  2674.                         b->UCS2_count,
  2675.                         b->allocated_length,
  2676.                         b->available_length);
  2677.                 }
  2678.                 else if (b_flags & UI_MULTI_LINE_INPUT_BOX_FORTY_FOUR_LESS_CHARACTER)
  2679.                 {
  2680.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE3(
  2681.                         old_c,
  2682.                         c,
  2683.                         b->UCS2_count,
  2684.                         b->allocated_length,
  2685.                         b->available_length);
  2686.                 }
  2687.                 else
  2688.                 {
  2689.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  2690.                         old_c,
  2691.                         c,
  2692.                         b->UCS2_count,
  2693.                         b->allocated_length,
  2694.                         b->available_length);
  2695.                 }
  2696.             }
  2697.             b->text_length += ((S32) p2 - (S32) p1);
  2698.         }
  2699.     }
  2700.     else    /* b_flags & UI_MULTI_LINE_INPUT_BOX_OVERWRITE_MODE */
  2701.     {
  2702.         if (text_length >= (b->available_length) &&
  2703.             !((MMI_current_input_ext_type & INPUT_TYPE_EXT_USE_0x81_ENCODING) && (0 != temp_0x81)))