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

MTK

开发平台:

C/C++

  1.                                             ty + line_height - (object_height >> 1),
  2.                                             strikethrough_color);
  3.                                     }
  4.                                 }
  5.                             #ifdef __MMI_HINDI_ALG__
  6.                               end_ems_disp:
  7.                                 memset(disp_ems_cluster, 0, sizeof(disp_ems_cluster));
  8.                             #endif /* __MMI_HINDI_ALG__ */ 
  9.                             #endif /* (EMS_ENABLE_SPECIAL_FONT_DISPLAY) */ /* end of #if(EMS_ENABLE_SPECIAL_FONT_DISPLAY) */
  10.                             }
  11.                         #ifdef __MMI_HINDI_ALG__
  12.                             else
  13.                             {
  14.                                 temp_ems_cursor_p += 2;
  15.                             }
  16.                         #endif /* __MMI_HINDI_ALG__ */ 
  17.                         }
  18.                     }
  19.                     if (!(((-1) != move_to_x) || ((-1) != move_to_y)))
  20.                     {
  21.                         if ((!cursor_displayed_flag) &&
  22.                             (mapped_previous_position.OffsetToText == mapped_cursor_position.OffsetToText))
  23.                         {
  24.                             b->cursor_ax = cursor_ax;
  25.                             b->cursor_ay = cursor_ay;
  26.                             b->cursor_line_height = line_height;
  27.                             b->cursor_line_position = line_object_count;
  28.                             b->current_line = n_lines - 1;
  29.                             if (!disable_draw_flag && !(flags & UI_EMS_INPUT_BOX_DISABLE_CURSOR_DRAW))
  30.                             {
  31.                                 if (default_direction != BIDI_L)
  32.                                 {
  33.                                 #ifdef __MMI_HINDI_ALG__
  34.                                     if (UI_HINDI_CHARACTER_UCS2_RANGE(pre_character))
  35.                                     {
  36.                                         /* PMT START FIX HINDI ISSUES 20060604 */
  37.                                         S32 h, w;
  38.                                         gui_measure_character(pre_character, &w, &h);
  39.                                         tx -= ems_cluster_width;
  40.                                         tx += ems_cursor_width;
  41.                                         gui_show_EMS_input_box_cursor(b, tx + 1 + ems_cluster_width, ty, 0, h, 1);
  42.                                     }
  43.                                     else
  44.                                     {
  45.                                         gui_show_EMS_input_box_cursor(
  46.                                             b,
  47.                                             tx + 1 + ems_cluster_width,
  48.                                             line_height - object_height + ty,
  49.                                             0,
  50.                                             object_height,
  51.                                             1);
  52.                                     }
  53.                                     /* PMT END FIX HINDI ISSUES 20060604 */
  54.                                 #else /* __MMI_HINDI_ALG__ */ 
  55.                                     gui_show_EMS_input_box_cursor(
  56.                                         b,
  57.                                         tx + object_width,
  58.                                         line_height - object_height + ty,
  59.                                         0,
  60.                                         object_height,
  61.                                         1);
  62.                                 #endif /* __MMI_HINDI_ALG__ */ 
  63.                                 }
  64.                                 else
  65.                                 {
  66.                                 #ifdef __MMI_HINDI_ALG__
  67.                                     if (UI_HINDI_CHARACTER_UCS2_RANGE(pre_character))
  68.                                     {
  69.                                         /* PMT START FIX HINDI ISSUES 20060604 */
  70.                                         S32 h, w;
  71.                                         gui_measure_character(pre_character, &w, &h);
  72.                                         tx -= ems_cluster_width;
  73.                                         tx += ems_cursor_width;
  74.                                         gui_show_EMS_input_box_cursor(b, tx + 1, ty, 0, h, 1);
  75.                                     }
  76.                                     else
  77.                                     {
  78.                                         gui_show_EMS_input_box_cursor(
  79.                                             b,
  80.                                             tx + 1,
  81.                                             line_height - object_height + ty,
  82.                                             0,
  83.                                             object_height,
  84.                                             1);
  85.                                     }
  86.                                     /* PMT END FIX HINDI ISSUES 20060604 */
  87.                                 #else /* __MMI_HINDI_ALG__ */ 
  88.                                     gui_show_EMS_input_box_cursor(
  89.                                         b,
  90.                                         tx,
  91.                                         line_height - object_height + ty,
  92.                                         0,
  93.                                         object_height,
  94.                                         1);
  95.                                 #endif /* __MMI_HINDI_ALG__ */ 
  96.                                 }
  97.                             }
  98.                             cursor_displayed_flag = 1;
  99.                         }
  100.                     }
  101.                     else if ((((-1) != move_to_x) || ((-1) != move_to_y)))
  102.                     {
  103.                         if (((tx + b->x + object_width) > move_to_x) &&
  104.                             ((cursor_ay + line_height + b->y + b->display_y + b->header_height) > move_to_y) &&
  105.                             (!set_cursor_flag))
  106.                         {
  107.                             b->cursor_ax = cursor_ax;
  108.                             b->cursor_ay = cursor_ay;
  109.                             b->cursor_line_height = line_height;
  110.                             b->cursor_line_position = line_object_count;
  111.                             b->current_line = n_lines - 1;
  112.                             /* EMS_map_position(data,&previous_position,&(data->CurrentPosition)); */
  113.                             MoveCursorToPosition(data, &previous_position);
  114.                             set_cursor_flag = 1;
  115.                         #if(EMS_USE_ESC_COMBINATION)
  116.                             /* W05.52 Fix Cursor Moviong issue for ESC character */
  117.                             gui_EMS_input_box_back_cursor_for_ESC_character(data, &previous_position);
  118.                         #endif /* (EMS_USE_ESC_COMBINATION) */ 
  119.                         }
  120.                         else if (((cursor_ay + line_height + b->y + b->display_y + b->header_height) > move_to_y) &&
  121.                                  (n_lines < (b->n_lines)) && (!set_cursor_flag) &&
  122.                                  (((line_object_count + 1) >= break_line_object_count) ||
  123.                                   (UI_TEST_CR_CHARACTER(current_character))))
  124.                         {
  125.                             b->cursor_ax = cursor_ax;
  126.                             b->cursor_ay = cursor_ay;
  127.                             b->cursor_line_height = line_height;
  128.                             b->cursor_line_position = line_object_count;
  129.                             b->current_line = n_lines - 1;
  130.                             /* EMS_map_position(data,&previous_position,&(data->CurrentPosition)); */
  131.                             MoveCursorToPosition(data, &previous_position);
  132.                             set_cursor_flag = 1;
  133.                         #if(EMS_USE_ESC_COMBINATION)
  134.                             /* W05.52 Fix Cursor Moviong issue for ESC character */
  135.                             gui_EMS_input_box_back_cursor_for_ESC_character(data, &previous_position);
  136.                         #endif /* (EMS_USE_ESC_COMBINATION) */ 
  137.                         }
  138.                     }
  139.                     /* START FARHAD PMT 20050211 */
  140.                     if (default_direction == BIDI_L)
  141.                     {
  142.                     #ifdef __MMI_HINDI_ALG__
  143.                         if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  144.                         {
  145.                             tx += ems_cluster_width;
  146.                             cursor_ax += ems_cursor_width;
  147.                         }
  148.                         else
  149.                     #endif /* __MMI_HINDI_ALG__ */ 
  150.                         {
  151.                             tx += object_width;
  152.                             cursor_ax += object_width;
  153.                         }
  154.                     }
  155.                 #ifdef __MMI_HINDI_ALG__
  156.                     line_object_count += saved_ems_display_skip_moves;
  157.                     hindi_cache_counter++;
  158.                 #else /* __MMI_HINDI_ALG__ */ 
  159.                     line_object_count++;
  160.                 #endif /* __MMI_HINDI_ALG__ */ 
  161.                     if (text_format_object_count)
  162.                     {
  163.                         text_format_object_count--;
  164.                         if ((text_format_object_count == 0) && (current_position.OffsetToText <= data->textLength))
  165.                         {
  166.                         #ifdef __MMI_MESSAGES_EMS__
  167.                             gui_EMS_input_box_set_text_format(b, &UI_EMS_normal_text_format_object);
  168.                         #else /* __MMI_MESSAGES_EMS__ */ 
  169.                             {
  170.                                 EMS_SET_FONT(&UI_EMS_inputbox_medium_font);
  171.                                 EMS_SET_TEXT_COLOR(UI_EMS_inputbox_text_color);
  172.                                 b->flags &= ~(UI_EMS_INPUT_BOX_CURRENT_ALIGN_LEFT |
  173.                                               UI_EMS_INPUT_BOX_CURRENT_ALIGN_RIGHT |
  174.                                               UI_EMS_INPUT_BOX_CURRENT_ALIGN_CENTER);
  175.                             }
  176.                         #endif /* __MMI_MESSAGES_EMS__ */ 
  177.                             object_height = gui_get_character_height();
  178.                             if (line_object_count == 0)
  179.                             {
  180.                                 line_height = object_height;
  181.                             }
  182.                             current_text_format = &UI_EMS_normal_text_format_object;
  183.                         #if(EMS_ENABLE_SPECIAL_FONT_DISPLAY)
  184.                             if (current_text_format != NULL)
  185.                             {
  186.                                 if (current_text_format->data->text_format.isUnderline == KAL_TRUE)
  187.                                 {
  188.                                     underline_flag = 1;
  189.                                 }
  190.                                 else
  191.                                 {
  192.                                     underline_flag = 0;
  193.                                 }
  194.                                 if (current_text_format->data->text_format.isStrikethrough == KAL_TRUE)
  195.                                 {
  196.                                     strikethrough_flag = 1;
  197.                                 }
  198.                                 else
  199.                                 {
  200.                                     strikethrough_flag = 0;
  201.                                 }
  202.                             }
  203.                         #endif /* (EMS_ENABLE_SPECIAL_FONT_DISPLAY) */ 
  204.                         }
  205.                     }
  206.                     pre2_character = pre_character;
  207.                     pre_character = current_character;
  208.                     break;
  209.                 #ifdef __MMI_MESSAGES_EMS__
  210.                 case 2: /* object */
  211.                     /* MTK Terry for speed up Editor by only display the characters in the display area */
  212.                     if (((ty + line_height) < (y1 + 2)) && ((ty - line_height) > y2))
  213.                     {
  214.                         break;
  215.                     }
  216.                     if (current_object->Type == EMS_TYPE_TEXT_FORMAT)
  217.                     {
  218.                         gui_EMS_input_box_set_text_format(b, current_object);
  219.                         object_height = gui_get_character_height();
  220.                         current_text_format = current_object;
  221.                     #if(EMS_ENABLE_SPECIAL_FONT_DISPLAY)
  222.                         if (current_text_format != NULL)
  223.                         {
  224.                             if (current_text_format->data->text_format.isUnderline == KAL_TRUE)
  225.                             {
  226.                                 underline_flag = 1;
  227.                             }
  228.                             else
  229.                             {
  230.                                 underline_flag = 0;
  231.                             }
  232.                             if (current_text_format->data->text_format.isStrikethrough == KAL_TRUE)
  233.                             {
  234.                                 strikethrough_flag = 1;
  235.                             }
  236.                             else
  237.                             {
  238.                                 strikethrough_flag = 0;
  239.                             }
  240.                         }
  241.                     #endif /* (EMS_ENABLE_SPECIAL_FONT_DISPLAY) */ 
  242.                         text_format_object_count = ((current_object->data->text_format.textLength) >> 1);
  243.                         if (line_object_count == 0)
  244.                         {
  245.                             switch (current_text_format->data->text_format.Alignment)
  246.                             {
  247.                                 case EMS_ALIGN_LEFT:
  248.                                     if (default_direction == BIDI_L)
  249.                                     {
  250.                                         tx = x1 + 2;
  251.                                     }
  252.                                     else
  253.                                     {
  254.                                         tx = x1 + line_width + 2;
  255.                                     }
  256.                                     break;
  257.                                 case EMS_ALIGN_RIGHT:
  258.                                     if (default_direction == BIDI_L)
  259.                                     {
  260.                                         tx = x2 - line_width - 2;
  261.                                     }
  262.                                     else
  263.                                     {
  264.                                         tx = x1 + box_width;
  265.                                     }
  266.                                     break;
  267.                                 case EMS_ALIGN_CENTER:
  268.                                     if (default_direction == BIDI_L)
  269.                                     {
  270.                                         tx = center_x - (line_width >> 1);
  271.                                     }
  272.                                     else
  273.                                     {
  274.                                         tx = center_x + (line_width >> 1);
  275.                                     }
  276.                                     break;
  277.                                 case EMS_ALIGN_LANG_DEP:
  278.                                     if (default_direction == BIDI_L)
  279.                                     {
  280.                                         tx = x1 + 2;
  281.                                     }
  282.                                     else
  283.                                     {
  284.                                         tx = x1 + box_width;
  285.                                     }
  286.                                     break;
  287.                             }
  288.                         }
  289.                     }
  290.                     else
  291.                     {
  292.                         object_width = object_width_cache[line_object_count];
  293.                         object_height = object_height_cache[line_object_count];
  294.                         if (first_object_flag)
  295.                         {
  296.                             if (default_direction == BIDI_L)
  297.                             {
  298.                                 object_width += 1;
  299.                                 tx += 1;
  300.                             }
  301.                             else
  302.                             {
  303.                                 object_width += 1;
  304.                                 tx -= 1;
  305.                             }
  306.                         }
  307.                         else
  308.                         {
  309.                          if(default_direction == BIDI_L)
  310. {
  311. tx += 3;
  312. }                          
  313.                         }
  314.                         if (default_direction == BIDI_R)
  315.                         {
  316.                             tx -= object_width;
  317.                             cursor_ax -= object_width;
  318.                         }
  319.                         /* MTK end */
  320.                         if (!(((-1) != move_to_x) || ((-1) != move_to_y)))
  321.                         {
  322.                             if ((mapped_cursor_position.Object != NULL) &&
  323.                                 (mapped_previous_position.Object != NULL) &&
  324.                                 (mapped_previous_position.OffsetToText == mapped_cursor_position.OffsetToText) &&
  325.                                 (mapped_previous_position.Object == mapped_cursor_position.Object))
  326.                             {
  327.                                 b->cursor_ax = cursor_ax;
  328.                                 b->cursor_ay = cursor_ay;
  329.                                 b->cursor_line_height = line_height;
  330.                                 b->cursor_line_position = line_object_count;
  331.                                 b->current_line = n_lines - 1;
  332.                                 if (!disable_draw_flag)
  333.                                 {
  334.                                     gui_EMS_input_box_display_object(
  335.                                         tx,
  336.                                         line_height - object_height + ty,
  337.                                         current_object,
  338.                                         1);
  339.                                     if (!(flags & UI_EMS_INPUT_BOX_DISABLE_CURSOR_DRAW))
  340.                                     {
  341.                                         /* MTK Terry for EMS Multitap Highlight Issue */
  342.                                         if (overwrite_mode_flag ||
  343.                                             selection_flag && !(flags & UI_EMS_INPUT_BOX_STATE_MULTITAP))
  344.                                         {
  345.                                             S32 rx1, ry1, rx2, ry2;
  346.                                             rx1 = tx;
  347.                                             ry1 = line_height - object_height + ty;
  348.                                             rx2 = rx1 + object_width - 1;
  349.                                             ry2 = ry1 + object_height - 1;
  350.                                             gui_cross_hatch_fill_rectangle(rx1, ry1, rx2, ry2, b->selection_color);
  351.                                         }
  352.                                         if (default_direction != BIDI_L)
  353.                                             /* PMT START MAUI_00223197 */
  354.                                         {
  355.                                         #ifdef __MMI_HINDI_ALG__
  356.                                             if (UI_HINDI_CHARACTER_UCS2_RANGE(pre_character))
  357.                                             {
  358.                                                 S32 h, w;
  359.                                                 gui_measure_character(pre_character, &w, &h);
  360.                                                 gui_show_EMS_input_box_cursor(
  361.                                                     b,
  362.                                                     tx + object_width,
  363.                                                     ty,
  364.                                                     object_width,
  365.                                                     h,
  366.                                                     2);
  367.                                             }
  368.                                             else
  369.                                         #endif /* __MMI_HINDI_ALG__ */ 
  370.                                             {
  371.                                                 /* PMT END MAUI_00223197 */
  372.                                                 gui_show_EMS_input_box_cursor(
  373.                                                     b,
  374.                                                     tx + object_width,
  375.                                                     line_height - object_height + ty,
  376.                                                     object_width,
  377.                                                     object_height,
  378.                                                     2);
  379.                                                 /* PMT START MAUI_00223197 */
  380.                                             }
  381.                                         }
  382.                                         else
  383.                                         {
  384.                                         #ifdef __MMI_HINDI_ALG__
  385.                                             if (UI_HINDI_CHARACTER_UCS2_RANGE(pre_character))
  386.                                             {
  387.                                                 S32 h, w;
  388.                                                 gui_measure_character(pre_character, &w, &h);
  389.                                                 gui_show_EMS_input_box_cursor(b, tx, ty, object_width, h, 2);
  390.                                             }
  391.                                             else
  392.                                         #endif /* __MMI_HINDI_ALG__ */ 
  393.                                             {
  394.                                                 /* PMT END MAUI_00223197 */
  395.                                                 gui_show_EMS_input_box_cursor(
  396.                                                     b,
  397.                                                     tx,
  398.                                                     line_height - object_height + ty,
  399.                                                     object_width,
  400.                                                     object_height,
  401.                                                     2);
  402.                                                 /* PMT START MAUI_00223197 */
  403.                                             }
  404.                                         }
  405.                                     }
  406.                                     else if (EMS_view_mode)
  407.                                     {
  408.                                     #ifdef __MMI_HINDI_ALG__
  409.                                         if (UI_HINDI_CHARACTER_UCS2_RANGE(pre_character))
  410.                                         {
  411.                                             S32 h, w;
  412.                                             gui_measure_character(pre_character, &w, &h);
  413.                                             gui_show_EMS_input_box_cursor(b, tx, ty, object_width, h, 3);
  414.                                         }
  415.                                         else
  416.                                     #endif /* __MMI_HINDI_ALG__ */ 
  417.                                         {
  418.                                             gui_show_EMS_input_box_cursor(
  419.                                                 b,
  420.                                                 tx,
  421.                                                 line_height - object_height + ty,
  422.                                                 object_width,
  423.                                                 object_height,
  424.                                                 3);
  425.                                         }
  426.                                     }
  427.                                     /* PMT END MAUI_00223197 */
  428.                                 }
  429.                                 cursor_displayed_flag = 1;
  430.                             }
  431.                             else if (!disable_draw_flag)
  432.                             {
  433.                                 gui_EMS_input_box_display_object(
  434.                                     tx,
  435.                                     line_height - object_height + ty,
  436.                                     current_object,
  437.                                     0);
  438.                             }
  439.                         }
  440.                         else if ((((-1) != move_to_x) || ((-1) != move_to_y)))
  441.                         {
  442.                             if (((tx + b->x + object_width) > move_to_x) &&
  443.                                 ((cursor_ay + line_height + b->y + b->display_y + b->header_height) > move_to_y) &&
  444.                                 (!set_cursor_flag))
  445.                             {
  446.                                 b->cursor_ax = cursor_ax;
  447.                                 b->cursor_ay = cursor_ay;
  448.                                 b->cursor_line_height = line_height;
  449.                                 b->cursor_line_position = line_object_count;
  450.                                 b->current_line = n_lines - 1;
  451.                                 /* EMS_map_position(data,&previous_position,&(data->CurrentPosition)); */
  452.                                 MoveCursorToPosition(data, &previous_position);
  453.                                 set_cursor_flag = 1;
  454.                             }
  455.                         }
  456.                         if (default_direction == BIDI_L)
  457.                         {
  458.                             tx += object_width;
  459.                             cursor_ax += object_width;
  460.                         }
  461.                         line_object_count++;
  462.                     }
  463.                     current_character = 0;
  464.                     break;
  465.                 #endif /* __MMI_MESSAGES_EMS__ */ 
  466.             }
  467.             first_object_flag = 0;
  468.         }
  469.     #ifdef __MMI_BIDI_ALG__
  470.         if (!(flags & UI_EMS_INPUT_BOX_DISABLE_DRAW) && arabic_char_flag)
  471.         {
  472.             memcpy(data->textBuffer + temp_text_position, temp_text_buffer, visual_str_len * ENCODING_LENGTH);
  473.             mapped_cursor_position.OffsetToText = temp_cursor_position;
  474.         #if 0
  475. /* under construction !*/
  476. /* under construction !*/
  477. /* under construction !*/
  478. /* under construction !*/
  479. /* under construction !*/
  480.         #endif /* 0 */ 
  481.         }
  482.     #endif /* __MMI_BIDI_ALG__ */ 
  483.         line_start_position = current_position;
  484.         if ((current_character == EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER)
  485.     #if(EMS_SHOW_HORIZONTAL_RULE_FOR_NEWLINE)
  486.             || (UI_TEST_LF_CHARACTER(current_character) && (flags & UI_EMS_INPUT_BOX_NEWLINE_DRAW))
  487.     #endif 
  488.             )
  489.         {
  490.             if (!disable_draw_flag)
  491.             {
  492.                 EMS_EDITOR_DRAW_DOTTED_LINE(x1 + 2, x2 - 1, ty + line_height + 2, paragraph_color);
  493.             }
  494.             ty += 4;    /*  4=height of line break horizontal rule display  */
  495.             cursor_ay += 4;
  496.             b->display_height += 4;
  497.         }
  498.         /* START PMT NEERAJ 20050916 */
  499.     #if(EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES)
  500.         else
  501.         {
  502.             if (flags & UI_EMS_INPUT_BOX_ALL_LINE_DRAW)
  503.             {
  504.                 if (!disable_draw_flag)
  505.                 {
  506.                     UI_draw_horizontal_line(x1 + 2, x2 - 1, ty + line_height + 2, gui_color(112, 125, 240));
  507.                     last_line_y = ty + line_height + 2;
  508.                     line_height += 4;
  509.                 }
  510.                 else
  511.                 {
  512.                     line_height += 4;
  513.                 }
  514.             }
  515.         }
  516.     #endif /* (EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES) */ 
  517.         /* END PMT NEERAJ 20050916 */
  518.         line_height += 1;   /*  +1 added for 1 pixel gap between lines */
  519.         ty += line_height;
  520.         cursor_ay += line_height;
  521.         b->display_height += line_height;
  522.     }
  523.     b->n_lines = n_lines;
  524.     /* START PMT NEERAJ 20050916 */
  525. #if(EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES)
  526.     if (flags & UI_EMS_INPUT_BOX_ALL_LINE_DRAW)
  527.     {      
  528.         minimum_line_height = object_height;
  529.         if (!disable_draw_flag)
  530.         {
  531.             while (last_line_y <= y2)
  532.             {
  533.                 last_line_y += minimum_line_height + 5;
  534.                 UI_draw_horizontal_line(x1 + 2, x2 - 1, last_line_y, gui_color(112, 125, 240));
  535.             }
  536. /*            if (EMS_view_mode)
  537.             {
  538.             #if defined(__MMI_MAINLCD_240X320__)
  539.                     if (last_line_y - y2 <= minimum_line_height - 13 && b->display_y != 0)
  540.             #elif defined(__MMI_MAINLCD_128X128__)
  541.                 if (last_line_y - y2 <= minimum_line_height - 12 && b->display_y != 0)
  542.             #else 
  543.                 if (last_line_y - y2 <= minimum_line_height - 11 && b->display_y != 0)
  544.             #endif 
  545.                 {
  546.                     b->display_y -= 3;
  547.                 }
  548.             }*/
  549.         }
  550.     }
  551. #endif /* (EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES) */ 
  552.     /* END PMT NEERAJ 20050916 */
  553.     /* W06.12 cursor_displayed_flag is only used when not moving cusrsor by pen */
  554.     if (!cursor_displayed_flag && ((move_to_x == (-1)) && (move_to_y == (-1))))
  555.     {
  556.         cursor_ay -= (line_height);
  557.         b->cursor_ax = cursor_ax;
  558.         b->cursor_ay = cursor_ay;
  559.         b->cursor_line_height = line_height - 1;
  560.         b->cursor_line_position = line_object_count;
  561.         b->current_line = n_lines - 1;
  562.         if (!disable_draw_flag && !(flags & UI_EMS_INPUT_BOX_DISABLE_CURSOR_DRAW))
  563.         {
  564.             /* START PMT NEERAJ 20050916 */
  565.         #if(EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES)
  566.         #ifdef __MMI_HINDI_ALG__
  567.             if (flags & UI_EMS_INPUT_BOX_ALL_LINE_DRAW)
  568.             {
  569.                 gui_show_EMS_input_box_cursor(b, tx + 1, ty - line_height, 0, line_height - 5, 1);
  570.             }
  571.             else
  572.             {
  573.                 gui_show_EMS_input_box_cursor(b, tx + 1, ty - line_height, 0, line_height - 1, 1);
  574.             }
  575.         #else /* __MMI_HINDI_ALG__ */ 
  576.             if (flags & UI_EMS_INPUT_BOX_ALL_LINE_DRAW)
  577.             {
  578.                 gui_show_EMS_input_box_cursor(b, tx, ty - line_height, 0, line_height - 5, 1);
  579.             }
  580.             else
  581.             {
  582.                 gui_show_EMS_input_box_cursor(b, tx, ty - line_height, 0, line_height - 1, 1);
  583.             }
  584.         #endif /* __MMI_HINDI_ALG__ */ 
  585.         #else /* (EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES) */ 
  586.             /* END PMT NEERAJ 20050916 */
  587.         #ifdef __MMI_HINDI_ALG__
  588.             /* if( UI_HINDI_CHARACTER_UCS2_RANGE(pre_character)) */
  589.             gui_show_EMS_input_box_cursor(b, tx + 1, ty - line_height, 0, line_height - 1, 1);
  590.         #else /* __MMI_HINDI_ALG__ */ 
  591.             gui_show_EMS_input_box_cursor(b, tx, ty - line_height, 0, line_height - 1, 1);
  592.         #endif /* __MMI_HINDI_ALG__ */ 
  593.             /* START PMT NEERAJ 20050916 */
  594.         #endif /* (EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES) */ 
  595.             /* END PMT NEERAJ 20050916 */
  596.         }
  597.         cursor_ay += line_height;
  598.     }
  599.     if ((((-1) != move_to_x) || ((-1) != move_to_y)) && (!set_cursor_flag))
  600.     {
  601.         cursor_ay -= (line_height);
  602.         b->cursor_ax = cursor_ax;
  603.         b->cursor_ay = cursor_ay;
  604.         b->cursor_line_height = line_height - 1;
  605.         b->cursor_line_position = line_object_count;
  606.         b->current_line = n_lines - 1;
  607.         /* EMS_map_position(data,&current_position,&(data->CurrentPosition)); */
  608.         MoveCursorToPosition(data, &current_position);
  609.         //W05.34 Fix warning tone in stylus on the blank area
  610.         //gui_EMS_input_box_next(b);
  611.         cursor_ay += line_height;
  612.     }
  613. #if(EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES)
  614.     /* W06.16 If EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES, the height of the last line is different */
  615.     if ((flags & UI_EMS_INPUT_BOX_ALL_LINE_DRAW) && (b->current_line == (b->n_lines - 1)))
  616.     {
  617.         b->cursor_line_height = line_height;
  618.     }
  619. #endif /* (EMS_SHOW_HORIZONTAL_RULE_FOR_ALL_LINES) */ 
  620.     if (b->saved_cursor_ax == -1)
  621.     {
  622.         b->saved_cursor_ax = b->cursor_ax;
  623.     }
  624.     /* W06.16 Set text format after changing cursor position by pen */
  625.     if ((!EMS_view_mode) && (((-1) != move_to_x) || ((-1) != move_to_y)))
  626.     {
  627.         gui_EMS_input_box_set_text_format_cursor_position(b);
  628.     }
  629.     if (!disable_draw_flag && !(flags & UI_EMS_INPUT_BOX_DISABLE_SCROLLBAR))
  630.     {
  631.         if (flags & UI_EMS_INPUT_BOX_DISPLAY_HEADER)
  632.         {
  633.             gui_set_vertical_scrollbar_scale(&b->vbar, b->height - 2);
  634.             gui_set_vertical_scrollbar_range(&b->vbar, cursor_ay + b->header_height);
  635.             gui_set_vertical_scrollbar_value(&b->vbar, -b->display_y);
  636.         }
  637.         else
  638.         {
  639.             gui_set_vertical_scrollbar_scale(&b->vbar, b->height - 2);
  640.             /* W06.12 Use b->display_height + 2 instead of cursor_ay 
  641.                1.cursor_ay is different when the cusrosr at the last line
  642.                2.(+2)because that the box_height is b->height - 4 in gui_EMS_input_box_locate_cursor */
  643.             gui_set_vertical_scrollbar_range(&b->vbar, b->display_height + 2);
  644.             /* gui_set_vertical_scrollbar_range(    &b->vbar,       cursor_ay               ); */
  645.             gui_set_vertical_scrollbar_value(&b->vbar, -b->display_y);
  646.         }
  647.         if (flags & UI_EMS_INPUT_BOX_AUTO_DISABLE_SCROLLBAR)
  648.         {
  649.             if (b->vbar.scale < b->vbar.range)
  650.             {
  651.                 if (r2lMMIFlag)
  652.                 {
  653.                     vbar_x = b->vbar.x;
  654.                     vbar_button_x = b->vbar.scroll_button.x;
  655.                     b->vbar.x = b->vbar.x + b->vbar.width - b->width;
  656.                     b->vbar.scroll_button.x = b->vbar.scroll_button.x + b->vbar.scroll_button.width - b->width;
  657.                     gui_show_vertical_scrollbar(&b->vbar);
  658.                 }
  659.                 else
  660.                 {
  661.                     gui_show_vertical_scrollbar(&b->vbar);
  662.                 }
  663.                 if (r2lMMIFlag)
  664.                 {
  665.                     b->vbar.x = vbar_x;
  666.                     b->vbar.scroll_button.x = vbar_button_x;
  667.                 }
  668.             }
  669.         }
  670.         else
  671.         {
  672.             if (r2lMMIFlag)
  673.             {
  674.                 vbar_x = b->vbar.x;
  675.                 vbar_button_x = b->vbar.scroll_button.x;
  676.                 b->vbar.x = b->vbar.x + b->vbar.width - b->width;
  677.                 b->vbar.scroll_button.x = b->vbar.scroll_button.x + b->vbar.scroll_button.width - b->width;
  678.                 gui_show_vertical_scrollbar(&b->vbar);
  679.             }
  680.             else
  681.             {
  682.                 gui_show_vertical_scrollbar(&b->vbar);
  683.             }
  684.             if (r2lMMIFlag)
  685.             {
  686.                 b->vbar.x = vbar_x;
  687.                 b->vbar.scroll_button.x = vbar_button_x;
  688.             }
  689.         }
  690.     }
  691.     /* Handle next line, previous line navigation   */
  692.     if (disable_draw_flag)
  693.     {
  694.         if (flags & UI_EMS_INPUT_BOX_PREVIOUS_LINE)
  695.         {
  696.             if (EMS_view_mode)
  697.             {
  698.                 S32 fdl = b->first_displayed_line;
  699.                 EMSPosition new_position;
  700.                 if (data->listHead == NULL)
  701.                 {
  702.                     b->current_line = fdl;
  703.                     if (b->current_line > 0)
  704.                     {
  705.                         b->current_line--;
  706.                     }
  707.                     else
  708.                     {
  709.                         b->cursor_ay = 0;
  710.                     }
  711.                     new_position = b->line_positions[b->current_line];
  712.                     MoveCursorToPosition(data, &new_position);
  713.                 }
  714.                 else
  715.                 {
  716.                     if ((data->CurrentPosition.OffsetToText > 0) || (data->CurrentPosition.Object != NULL))
  717.                     {
  718.                         EMSPosition new_position;
  719.                         U8 flag;
  720.                         U8 done = 0;
  721.                         while (!done)
  722.                         {
  723.                             flag = 0;
  724.                             if (b->current_line > 0)
  725.                             {
  726.                                 flag = 1;
  727.                                 b->current_line--;
  728.                             }
  729.                             else
  730.                             {
  731.                                 b->cursor_ay = 0;
  732.                             }
  733.                             new_position = b->line_positions[b->current_line];
  734.                             if (BackwardCurrentPositionObject(data, &new_position))
  735.                             {
  736.                                 if (flag)
  737.                                 {
  738.                                     b->current_line++;
  739.                                 }
  740.                             }
  741.                             else
  742.                             {
  743.                                 break;
  744.                             }
  745.                             if (b->current_line > 0)
  746.                             {
  747.                                 b->current_line--;
  748.                             }
  749.                             else
  750.                             {
  751.                                 break;
  752.                             }
  753.                             if (b->current_line <= (fdl - 1))
  754.                             {
  755.                                 break;
  756.                             }
  757.                         }
  758.                     }
  759.                 }
  760.             }
  761.             else
  762.             {
  763.                 if (b->current_line > 0)
  764.                 {
  765.                     EMSPosition new_position;
  766.                     S32 object_count = b->cursor_line_position;
  767.                     S32 new_position_object_count;
  768.                     b->current_line--;
  769.                     new_position = b->line_positions[b->current_line];
  770.                     new_position_object_count = b->line_object_counts[b->current_line] - 1;
  771.                     if (object_count > new_position_object_count)
  772.                     {
  773.                         object_count = new_position_object_count;
  774.                     }
  775.                     MoveCursorToPosition(data, &new_position);
  776.                 #if(EMS_ENABLE_GRAPHICAL_CURSOR_MOVEMENT)
  777.                     EMS_move_graphical_cursor(
  778.                         data,
  779.                         b->line_x_positions[b->current_line],
  780.                         b->saved_cursor_ax,
  781.                         new_position_object_count);
  782.                 #else /* (EMS_ENABLE_GRAPHICAL_CURSOR_MOVEMENT) */ 
  783.                     ForwardCurrentPosition(data, (U16) object_count);
  784.                 #endif /* (EMS_ENABLE_GRAPHICAL_CURSOR_MOVEMENT) */ 
  785.                 }
  786.                 else
  787.                 {
  788.                     if (flags & UI_EMS_INPUT_BOX_DISABLE_TONE)
  789.                     {
  790.                         b->flags &= ~UI_EMS_INPUT_BOX_DISABLE_TONE;
  791.                     }
  792.                     else
  793.                     {
  794.                         UI_editor_play_tone_cannot_navigate();
  795.                     }
  796.                 }
  797.             }
  798.             /* MTK Terry for scroll down problem for extension character in EMS_view_mode temp solution */
  799.             if (!EMS_view_mode)
  800.             {
  801.                 EMS_handle_CRLF_navigation(data);
  802.             }
  803.             /* if(!TestFirstPosition(data,&data->CurrentPosition)) */
  804.             gui_EMS_input_box_set_text_format_cursor_position(b);
  805.         }
  806.         else if (flags & UI_EMS_INPUT_BOX_PREVIOUS_OBJECT)
  807.         {
  808.             if (EMS_view_mode && (data->listHead != NULL))
  809.             {
  810.                 if ((data->CurrentPosition.OffsetToText > 0) || (data->CurrentPosition.Object != NULL))
  811.                 {
  812.                     EMSPosition new_position;
  813.                     new_position = b->line_positions[b->current_line];
  814.                     BackwardCurrentPositionSeekObject(data, &new_position);
  815.                 }
  816.             }
  817.         }
  818.         if (flags & UI_EMS_INPUT_BOX_NEXT_LINE)
  819.         {
  820.             if (EMS_view_mode)
  821.             {
  822.                 S32 ldl = b->last_displayed_line;
  823.                 EMSPosition new_position;
  824.                 if (data->listHead == NULL)
  825.                 {
  826.                     b->current_line = ldl;
  827.                     if (b->current_line < (b->n_lines - 1))
  828.                     {
  829.                         b->current_line++;
  830.                     }
  831.                     new_position = b->line_positions[b->current_line];
  832.                     MoveCursorToPosition(data, &new_position);
  833.                 }
  834.                 else
  835.                 {
  836.                     if (!TestLastPosition(data, &data->CurrentPosition))
  837.                     {
  838.                         EMSPosition new_position, old_position;
  839.                         U8 flag;
  840.                         U8 done = 0;
  841.                         while (!done)
  842.                         {
  843.                             flag = 0;
  844.                             if (b->current_line < (b->n_lines - 1))
  845.                             {
  846.                                 flag = 1;
  847.                                 b->current_line++;
  848.                             }
  849.                             new_position = b->line_positions[b->current_line];
  850.                             if (ForwardCurrentPositionObject(data, &new_position))
  851.                             {
  852.                                 if (flag)
  853.                                 {
  854.                                     b->current_line--;
  855.                                 }
  856.                             }
  857.                             else
  858.                             {
  859.                                 break;
  860.                             }
  861.                             flag = 0;
  862.                             if (b->current_line < (b->n_lines - 1))
  863.                             {
  864.                                 new_position = b->line_positions[b->current_line + 1];
  865.                             }
  866.                             else
  867.                             {
  868.                                 new_position.OffsetToText = data->textLength;
  869.                                 new_position.Object = data->listTail;
  870.                                 flag = 1;
  871.                             }
  872.                             old_position = data->CurrentPosition;
  873.                             if (ForwardCurrentPositionObject(data, &new_position))
  874.                             {
  875.                                 if (!flag)
  876.                                 {
  877.                                     MoveCursorToPosition(data, &old_position);
  878.                                 }
  879.                             }
  880.                             else
  881.                             {
  882.                                 break;
  883.                             }
  884.                             if (b->current_line < (b->n_lines - 1))
  885.                             {
  886.                                 b->current_line++;
  887.                             }
  888.                             else
  889.                             {
  890.                                 break;
  891.                             }
  892.                             if (b->current_line >= (ldl + 1))
  893.                             {
  894.                                 break;
  895.                             }
  896.                         }
  897.                     }
  898.                 }
  899.             }
  900.             else
  901.             {
  902.                 if (b->current_line < (b->n_lines - 1))
  903.                 {
  904.                     EMSPosition new_position;
  905.                     S32 object_count = b->cursor_line_position;
  906.                     S32 new_position_object_count;
  907.                     b->current_line++;
  908.                     new_position = b->line_positions[b->current_line];
  909.                     new_position_object_count = b->line_object_counts[b->current_line];
  910.                     if (b->current_line != (b->n_lines - 1))
  911.                     {
  912.                         new_position_object_count -= 1;
  913.                     }
  914.                     if (object_count > new_position_object_count)
  915.                     {
  916.                         object_count = new_position_object_count;
  917.                     }
  918.                     MoveCursorToPosition(data, &new_position);
  919.                 #if(EMS_ENABLE_GRAPHICAL_CURSOR_MOVEMENT)
  920.                     EMS_move_graphical_cursor(
  921.                         data,
  922.                         b->line_x_positions[b->current_line],
  923.                         b->saved_cursor_ax,
  924.                         new_position_object_count);
  925.                 #else /* (EMS_ENABLE_GRAPHICAL_CURSOR_MOVEMENT) */ 
  926.                     ForwardCurrentPosition(data, (U16) object_count);
  927.                 #endif /* (EMS_ENABLE_GRAPHICAL_CURSOR_MOVEMENT) */ 
  928.                 }
  929.                 else
  930.                 {
  931.                     if (flags & UI_EMS_INPUT_BOX_DISABLE_TONE)
  932.                     {
  933.                         b->flags &= ~UI_EMS_INPUT_BOX_DISABLE_TONE;
  934.                     }
  935.                     else
  936.                     {
  937.                         UI_editor_play_tone_cannot_navigate();
  938.                     }
  939.                 }
  940.             }
  941.             /* MTK Terry for scroll down problem for extension character in EMS_view_mode temp solution */
  942.             if (!EMS_view_mode)
  943.             {
  944.                 EMS_handle_CRLF_navigation(data);
  945.             }
  946.             /* if(!TestLastPosition(data,&data->CurrentPosition)) */
  947.             gui_EMS_input_box_set_text_format_cursor_position(b);
  948.         }
  949.         else if (flags & UI_EMS_INPUT_BOX_NEXT_OBJECT)
  950.         {
  951.             if (EMS_view_mode && (data->listHead != NULL))
  952.             {
  953.                 if (!TestLastPosition(data, &data->CurrentPosition))
  954.                 {
  955.                     EMSPosition new_position;
  956.                     if (b->current_line >= (b->n_lines - 1))
  957.                     {
  958.                         new_position.OffsetToText = data->textLength;
  959.                         new_position.Object = data->listTail;
  960.                     }
  961.                     else
  962.                     {
  963.                         new_position = b->line_positions[b->current_line + 1];
  964.                     }
  965.                     ForwardCurrentPositionSeekObject(data, &new_position);
  966.                 }
  967.             }
  968.         }
  969.     }
  970. #if 0
  971. #ifdef __MMI_BIDI_ALG__
  972. /* under construction !*/
  973. /* under construction !*/
  974. /* under construction !*/
  975. /* under construction !*/
  976. /* under construction !*/
  977. /* under construction !*/
  978. /* under construction !*/
  979. /* under construction !*/
  980. /* under construction !*/
  981. /* under construction !*/
  982. /* under construction !*/
  983. /* under construction !*/
  984. /* under construction !*/
  985.   #endif
  986. #endif /* 0 */ 
  987. #ifdef __MMI_BIDI_ALG__
  988.     UI_UNUSED_PARAMETER(temp_hilight_start);
  989.     UI_UNUSED_PARAMETER(temp_hilight_end);
  990.     UI_UNUSED_PARAMETER(temp_text_pt);
  991. #endif /* __MMI_BIDI_ALG__ */ 
  992.     /* PMT RAKESH START 20061006 */
  993. #if defined __MMI_HINDI_ALG__
  994.     restore_current_language_for_hindi_rules();
  995. #endif 
  996.     /* PMT RAKESH END 20061006 */
  997. }
  998. /*****************************************************************************
  999.  * FUNCTION
  1000.  *  gui_EMS_input_box_toggle_insert_mode
  1001.  * DESCRIPTION
  1002.  *  
  1003.  * PARAMETERS
  1004.  *  b       [?]     
  1005.  * RETURNS
  1006.  *  void
  1007.  *****************************************************************************/
  1008. void gui_EMS_input_box_toggle_insert_mode(UI_EMS_input_box *b)
  1009. {
  1010.     /*----------------------------------------------------------------*/
  1011.     /* Local Variables                                                */
  1012.     /*----------------------------------------------------------------*/
  1013.     /*----------------------------------------------------------------*/
  1014.     /* Code Body                                                      */
  1015.     /*----------------------------------------------------------------*/
  1016. #ifdef __MMI_MESSAGES_EMS__
  1017.     EMS_cancel_object_focus();
  1018. #endif 
  1019.     if (b->flags & UI_EMS_INPUT_BOX_OVERWRITE_MODE)
  1020.     {
  1021.         b->flags &= ~UI_EMS_INPUT_BOX_OVERWRITE_MODE;
  1022.     }
  1023.     else
  1024.     {
  1025.         b->flags |= UI_EMS_INPUT_BOX_OVERWRITE_MODE;
  1026.     }
  1027. }
  1028. /*****************************************************************************
  1029.  * FUNCTION
  1030.  *  gui_EMS_input_box_backspace
  1031.  * DESCRIPTION
  1032.  *  
  1033.  * PARAMETERS
  1034.  *  b       [?]     
  1035.  * RETURNS
  1036.  *  void
  1037.  *****************************************************************************/
  1038. void gui_EMS_input_box_backspace(UI_EMS_input_box *b)
  1039. {
  1040.     /*----------------------------------------------------------------*/
  1041.     /* Local Variables                                                */
  1042.     /*----------------------------------------------------------------*/
  1043.     U8 paragraph_text_align_flag = 0;
  1044.     U8 previous_paragraph_text_alignment = EMS_ALIGN_LANG_DEP;
  1045.     EMSPosition current_position;
  1046.     UI_character_type c;
  1047.     EMSObject *o;
  1048.     /*----------------------------------------------------------------*/
  1049.     /* Code Body                                                      */
  1050.     /*----------------------------------------------------------------*/
  1051. #ifdef __MMI_MESSAGES_EMS__
  1052.     EMS_cancel_object_focus();
  1053. #endif 
  1054.     if ((b->data != NULL) && (b->data->listHead != NULL))
  1055.     {
  1056.         current_position = b->data->CurrentPosition;
  1057.         if (gui_EMS_input_box_test_paragraph_start(b, &current_position))
  1058.         {
  1059.             gui_EMS_input_box_get_previous_object(b->data, &current_position, &c, &o);
  1060.             previous_paragraph_text_alignment = gui_EMS_input_box_get_previous_text_alignment(b, &current_position);
  1061.             paragraph_text_align_flag = 1;
  1062.         }
  1063.     }
  1064.     if (gui_EMS_cancel_current_position(b) == 0)
  1065.     {
  1066.         UI_editor_play_tone_cannot_change();
  1067.     }
  1068.     else
  1069.     {
  1070.         
  1071.         if (b->locate_cursor_flag)
  1072.         {
  1073.             gui_EMS_input_box_locate_cursor(b);
  1074.         }
  1075.         
  1076.         gui_EMS_input_box_set_text_format_cursor_position(b);
  1077.         if (paragraph_text_align_flag)
  1078.         {
  1079.             current_position = b->data->CurrentPosition;
  1080.             gui_EMS_input_box_set_paragraph_text_alignment(b, &current_position, previous_paragraph_text_alignment);
  1081.         }
  1082.     }
  1083.     b->saved_cursor_ax = -1;
  1084. }
  1085. /*****************************************************************************
  1086.  * FUNCTION
  1087.  *  gui_EMS_input_box_previous_line
  1088.  * DESCRIPTION
  1089.  *  
  1090.  * PARAMETERS
  1091.  *  b       [?]     
  1092.  * RETURNS
  1093.  *  void
  1094.  *****************************************************************************/
  1095. void gui_EMS_input_box_previous_line(UI_EMS_input_box *b)
  1096. {
  1097.     /*----------------------------------------------------------------*/
  1098.     /* Local Variables                                                */
  1099.     /*----------------------------------------------------------------*/
  1100.     U8 hflag = 0;
  1101.     EMSPosition current_position = b->data->CurrentPosition;
  1102.     /*----------------------------------------------------------------*/
  1103.     /* Code Body                                                      */
  1104.     /*----------------------------------------------------------------*/
  1105. #ifdef __MMI_MESSAGES_EMS__
  1106.     EMS_cancel_object_focus();
  1107. #endif 
  1108. if(b->cursor_ay == 0 && b->display_y <0)
  1109. {
  1110. b->display_y +=20;
  1111. if(b->display_y >0) b->display_y = 0;
  1112. return;
  1113. }
  1114.     b->flags |= (UI_EMS_INPUT_BOX_PREVIOUS_LINE | UI_EMS_INPUT_BOX_DISABLE_DRAW);
  1115.     gui_show_EMS_input_box(b);
  1116.     b->flags &= ~(UI_EMS_INPUT_BOX_PREVIOUS_LINE | UI_EMS_INPUT_BOX_DISABLE_DRAW);
  1117.     if (b->cursor_ay == 0)
  1118.     {
  1119.         hflag = 1;
  1120.     }
  1121.     /* if(!TestFirstPosition(b->data,&current_position)) */
  1122.     gui_EMS_input_box_locate_cursor(b);
  1123.     if ((b->flags & UI_EMS_INPUT_BOX_DISPLAY_HEADER) && hflag
  1124.         && (b->cursor_ay == 0) && (b->display_y != 0) &&
  1125.         (current_position.Object == NULL) /* && TestFirstPosition(b->data,&current_position) */ )
  1126.     {
  1127.         b->flags |= UI_EMS_INPUT_BOX_DISABLE_TONE;
  1128.         b->display_y += EMS_HEADER_SCROLL_SIZE; /* Scroll through header   */
  1129.         if (b->display_y > 0)
  1130.         {
  1131.             b->display_y = 0;
  1132.         }
  1133.     }
  1134. }
  1135. /*****************************************************************************
  1136.  * FUNCTION
  1137.  *  gui_EMS_input_box_next_line
  1138.  * DESCRIPTION
  1139.  *  
  1140.  * PARAMETERS
  1141.  *  b       [?]     
  1142.  * RETURNS
  1143.  *  void
  1144.  *****************************************************************************/
  1145. void gui_EMS_input_box_next_line(UI_EMS_input_box *b)
  1146. {
  1147.     /*----------------------------------------------------------------*/
  1148.     /* Local Variables                                                */
  1149.     /*----------------------------------------------------------------*/
  1150.     /*----------------------------------------------------------------*/
  1151.     /* Code Body                                                      */
  1152.     /*----------------------------------------------------------------*/
  1153. #ifdef __MMI_MESSAGES_EMS__
  1154.     EMS_cancel_object_focus();
  1155. #endif 
  1156.     b->flags |= (UI_EMS_INPUT_BOX_NEXT_LINE | UI_EMS_INPUT_BOX_DISABLE_DRAW);
  1157.     gui_show_EMS_input_box(b);
  1158.     b->flags &= ~(UI_EMS_INPUT_BOX_NEXT_LINE | UI_EMS_INPUT_BOX_DISABLE_DRAW);
  1159.     /* if(!TestLastPosition(b->data,&b->data->CurrentPosition)) */
  1160.     gui_EMS_input_box_locate_cursor(b);
  1161. }
  1162. #ifdef __MMI_MESSAGES_EMS__
  1163. /*****************************************************************************
  1164.  * FUNCTION
  1165.  *  gui_EMS_input_box_view_previous_object
  1166.  * DESCRIPTION
  1167.  *  
  1168.  * PARAMETERS
  1169.  *  b       [?]     
  1170.  * RETURNS
  1171.  *  void
  1172.  *****************************************************************************/
  1173. void gui_EMS_input_box_view_previous_object(UI_EMS_input_box *b)
  1174. {
  1175.     /*----------------------------------------------------------------*/
  1176.     /* Local Variables                                                */
  1177.     /*----------------------------------------------------------------*/
  1178.     /*----------------------------------------------------------------*/
  1179.     /* Code Body                                                      */
  1180.     /*----------------------------------------------------------------*/
  1181.     EMS_cancel_object_focus();
  1182.     b->flags |= (UI_EMS_INPUT_BOX_PREVIOUS_OBJECT | UI_EMS_INPUT_BOX_DISABLE_DRAW);
  1183.     gui_show_EMS_input_box(b);
  1184.     b->flags &= ~(UI_EMS_INPUT_BOX_PREVIOUS_OBJECT | UI_EMS_INPUT_BOX_DISABLE_DRAW);
  1185.     gui_EMS_input_box_locate_cursor(b);
  1186.     b->saved_cursor_ax = -1;
  1187. }
  1188. /*****************************************************************************
  1189.  * FUNCTION
  1190.  *  gui_EMS_input_box_view_next_object
  1191.  * DESCRIPTION
  1192.  *  
  1193.  * PARAMETERS
  1194.  *  b       [?]     
  1195.  * RETURNS
  1196.  *  void
  1197.  *****************************************************************************/
  1198. void gui_EMS_input_box_view_next_object(UI_EMS_input_box *b)
  1199. {
  1200.     /*----------------------------------------------------------------*/
  1201.     /* Local Variables                                                */
  1202.     /*----------------------------------------------------------------*/
  1203.     /*----------------------------------------------------------------*/
  1204.     /* Code Body                                                      */
  1205.     /*----------------------------------------------------------------*/
  1206.     EMS_cancel_object_focus();
  1207.     b->flags |= (UI_EMS_INPUT_BOX_NEXT_OBJECT | UI_EMS_INPUT_BOX_DISABLE_DRAW);
  1208.     gui_show_EMS_input_box(b);
  1209.     b->flags &= ~(UI_EMS_INPUT_BOX_NEXT_OBJECT | UI_EMS_INPUT_BOX_DISABLE_DRAW);
  1210.     gui_EMS_input_box_locate_cursor(b);
  1211.     b->saved_cursor_ax = -1;
  1212. }
  1213. #endif /* __MMI_MESSAGES_EMS__ */ 
  1214. /*****************************************************************************
  1215.  * FUNCTION
  1216.  *  gui_EMS_inputbox_empty
  1217.  * DESCRIPTION
  1218.  *  
  1219.  * PARAMETERS
  1220.  *  b       [?]     
  1221.  * RETURNS
  1222.  *  
  1223.  *****************************************************************************/
  1224. U8 gui_EMS_inputbox_empty(UI_EMS_input_box *b)
  1225. {
  1226.     /*----------------------------------------------------------------*/
  1227.     /* Local Variables                                                */
  1228.     /*----------------------------------------------------------------*/
  1229.     /*----------------------------------------------------------------*/
  1230.     /* Code Body                                                      */
  1231.     /*----------------------------------------------------------------*/
  1232.     if ((b->data->textLength == 0) && (b->data->listHead == NULL))
  1233.     {
  1234.         return (1);
  1235.     }
  1236.     else
  1237.     {
  1238.         return (0);
  1239.     }
  1240. }
  1241. /*****************************************************************************
  1242.  * FUNCTION
  1243.  *  gui_EMS_input_box_highlight_cursor_end
  1244.  * DESCRIPTION
  1245.  *  
  1246.  * PARAMETERS
  1247.  *  b       [?]     
  1248.  * RETURNS
  1249.  *  
  1250.  *****************************************************************************/
  1251. S32 gui_EMS_input_box_highlight_cursor_end(UI_EMS_input_box *b)
  1252. {
  1253.     /*----------------------------------------------------------------*/
  1254.     /* Local Variables                                                */
  1255.     /*----------------------------------------------------------------*/
  1256.     EMSPosition *current_position = &b->data->CurrentPosition;
  1257.     EMSPosition previous_position;
  1258.     EMSPosition saved_current_position = b->data->CurrentPosition;
  1259.     U8 done = 0, bflag;
  1260.     UI_character_type current_character;
  1261.     S32 count = 0;
  1262.     /*----------------------------------------------------------------*/
  1263.     /* Code Body                                                      */
  1264.     /*----------------------------------------------------------------*/
  1265.     /* Move cursor backwards until a break character is encountered   */
  1266.     while (!done)
  1267.     {
  1268.         previous_position = *current_position;
  1269.         if ((current_position->Object != NULL) &&
  1270.             (current_position->Object->OffsetToText == current_position->OffsetToText))
  1271.         {
  1272.             break;
  1273.         }
  1274.         if (current_position->OffsetToText == 0)
  1275.         {
  1276.             break;
  1277.         }
  1278.         if (BackwardCurrentPosition(b->data, 1) != 1)
  1279.         {
  1280.             break;
  1281.         }
  1282.     #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1283.         current_character =
  1284.             b->data->textBuffer[current_position->OffsetToText +
  1285.                                 1] | (b->data->textBuffer[current_position->OffsetToText] << 8);
  1286.     #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1287.         current_character =
  1288.             b->data->textBuffer[current_position->OffsetToText] | (b->data->
  1289.                                                                    textBuffer[current_position->OffsetToText + 1] << 8);
  1290.     #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1291.         count++;
  1292.         UI_EMS_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1293.         if (bflag)
  1294.         {
  1295.             break;
  1296.         }
  1297.     }
  1298.     b->highlight_start_position = previous_position;
  1299.     /* *current_position=saved_current_position; */
  1300.     MoveCursorToPosition(b->data, &saved_current_position);
  1301.     /* Move cursor forwards until a break character is encountered */
  1302. #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1303.     current_character =
  1304.         b->data->textBuffer[current_position->OffsetToText +
  1305.                             1] | (b->data->textBuffer[current_position->OffsetToText] << 8);
  1306. #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1307.     current_character =
  1308.         b->data->textBuffer[current_position->OffsetToText] | (b->data->
  1309.                                                                textBuffer[current_position->OffsetToText + 1] << 8);
  1310. #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1311.     UI_EMS_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1312.     if (b->data->CurrentPosition.OffsetToText >= b->data->textLength)
  1313.     {
  1314.         bflag = 1;
  1315.     }
  1316.     if (bflag)
  1317.     {
  1318.         done = 1;
  1319.         b->flags &= ~UI_EMS_INPUT_BOX_WORD_HIGHLIGHT;
  1320.     }
  1321.     else
  1322.     {
  1323.         done = 0;
  1324.         b->flags |= UI_EMS_INPUT_BOX_WORD_HIGHLIGHT;
  1325.     }
  1326.     while (!done)
  1327.     {
  1328.         if ((current_position->Object != NULL) &&
  1329.             (current_position->Object->OffsetToText == current_position->OffsetToText))
  1330.         {
  1331.             break;
  1332.         }
  1333.         if (current_position->OffsetToText >= b->data->textLength)
  1334.         {
  1335.             break;
  1336.         }
  1337.         if (ForwardCurrentPosition(b->data, 1) != 1)
  1338.         {
  1339.             break;
  1340.         }
  1341.     #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1342.         current_character =
  1343.             b->data->textBuffer[current_position->OffsetToText +
  1344.                                 1] | (b->data->textBuffer[current_position->OffsetToText] << 8);
  1345.     #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1346.         current_character =
  1347.             b->data->textBuffer[current_position->OffsetToText] | (b->data->
  1348.                                                                    textBuffer[current_position->OffsetToText + 1] << 8);
  1349.     #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1350.         count++;
  1351.         UI_EMS_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1352.         if (bflag)
  1353.         {
  1354.             break;
  1355.         }
  1356.     }
  1357.     b->highlight_end_position = *current_position;
  1358.     gui_EMS_input_box_locate_cursor(b);
  1359.     return (count);
  1360. }
  1361. /*****************************************************************************
  1362.  * FUNCTION
  1363.  *  gui_EMS_input_box_highlight_cursor_number
  1364.  * DESCRIPTION
  1365.  *  
  1366.  * PARAMETERS
  1367.  *  b               [?]         
  1368.  *  numOfChar       [IN]        
  1369.  * RETURNS
  1370.  *  
  1371.  *****************************************************************************/
  1372. S32 gui_EMS_input_box_highlight_cursor_number(UI_EMS_input_box *b, S32 numOfChar)
  1373. {
  1374.     /*----------------------------------------------------------------*/
  1375.     /* Local Variables                                                */
  1376.     /*----------------------------------------------------------------*/
  1377.     EMSPosition *current_position = &b->data->CurrentPosition;
  1378.     EMSPosition saved_current_position = b->data->CurrentPosition;
  1379.     U8 bflag;
  1380.     UI_character_type current_character;
  1381.     S32 count = 0, i;
  1382.     /*----------------------------------------------------------------*/
  1383.     /* Code Body                                                      */
  1384.     /*----------------------------------------------------------------*/
  1385.     for (i = 0; i < numOfChar; i++)
  1386.     {
  1387.         if ((current_position->Object != NULL) &&
  1388.             (current_position->Object->OffsetToText == current_position->OffsetToText))
  1389.         {
  1390.             break;
  1391.         }
  1392.         if (current_position->OffsetToText == 0)
  1393.         {
  1394.             break;
  1395.         }
  1396.         if (BackwardCurrentPosition(b->data, 1) != 1)
  1397.         {
  1398.             break;
  1399.         }
  1400.     #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1401.         current_character =
  1402.             b->data->textBuffer[current_position->OffsetToText +
  1403.                                 1] | (b->data->textBuffer[current_position->OffsetToText] << 8);
  1404.     #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1405.         current_character =
  1406.             b->data->textBuffer[current_position->OffsetToText] | (b->data->
  1407.                                                                    textBuffer[current_position->OffsetToText + 1] << 8);
  1408.     #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1409.         count++;
  1410.         UI_EMS_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1411.         if (bflag)
  1412.         {
  1413.             break;
  1414.         }
  1415.     }
  1416.     b->highlight_start_position = *current_position;
  1417.     /* *current_position=saved_current_position; */
  1418.     MoveCursorToPosition(b->data, &saved_current_position);
  1419. #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1420.     current_character =
  1421.         b->data->textBuffer[current_position->OffsetToText +
  1422.                             1] | (b->data->textBuffer[current_position->OffsetToText] << 8);
  1423. #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1424.     current_character =
  1425.         b->data->textBuffer[current_position->OffsetToText] | (b->data->
  1426.                                                                textBuffer[current_position->OffsetToText + 1] << 8);
  1427. #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1428.     UI_EMS_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1429.     if(current_character == (UI_character_type)0x20) bflag =0;
  1430.     if (bflag)
  1431.     {
  1432.         b->flags &= ~UI_EMS_INPUT_BOX_WORD_HIGHLIGHT;
  1433.     }
  1434.     else
  1435.     {
  1436.         b->flags |= UI_EMS_INPUT_BOX_WORD_HIGHLIGHT;
  1437.     }
  1438.     b->highlight_end_position = *current_position;
  1439.     
  1440.     if (b->locate_cursor_flag)
  1441.     {
  1442.         gui_EMS_input_box_locate_cursor(b);
  1443.     }
  1444.     
  1445.     return (count);
  1446. }
  1447. /*****************************************************************************
  1448.  * FUNCTION
  1449.  *  gui_EMS_input_box_highlight_cursor_start
  1450.  * DESCRIPTION
  1451.  *  
  1452.  * PARAMETERS
  1453.  *  b       [?]     
  1454.  * RETURNS
  1455.  *  
  1456.  *****************************************************************************/
  1457. S32 gui_EMS_input_box_highlight_cursor_start(UI_EMS_input_box *b)
  1458. {
  1459.     /*----------------------------------------------------------------*/
  1460.     /* Local Variables                                                */
  1461.     /*----------------------------------------------------------------*/
  1462.     EMSPosition *current_position = &b->data->CurrentPosition;
  1463.     EMSPosition previous_position;
  1464.     EMSPosition saved_current_position = b->data->CurrentPosition;
  1465.     U8 done = 0, bflag;
  1466.     UI_character_type current_character;
  1467.     S32 count = 0;
  1468.     /*----------------------------------------------------------------*/
  1469.     /* Code Body                                                      */
  1470.     /*----------------------------------------------------------------*/
  1471.     if (BackwardCurrentPosition(b->data, 1) != 1)
  1472.     {
  1473.         b->flags &= ~UI_EMS_INPUT_BOX_WORD_HIGHLIGHT;
  1474.         return (0);
  1475.     }
  1476.     /* Move cursor forwards until a break character is encountered */
  1477.     while (!done)
  1478.     {
  1479.         if ((current_position->Object != NULL) &&
  1480.             (current_position->Object->OffsetToText == current_position->OffsetToText))
  1481.         {
  1482.             break;
  1483.         }
  1484.         if (current_position->OffsetToText >= b->data->textLength)
  1485.         {
  1486.             break;
  1487.         }
  1488.         if (ForwardCurrentPosition(b->data, 1) != 1)
  1489.         {
  1490.             break;
  1491.         }
  1492.     #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1493.         current_character =
  1494.             b->data->textBuffer[current_position->OffsetToText +
  1495.                                 1] | (b->data->textBuffer[current_position->OffsetToText] << 8);
  1496.     #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1497.         current_character =
  1498.             b->data->textBuffer[current_position->OffsetToText] | (b->data->
  1499.                                                                    textBuffer[current_position->OffsetToText + 1] << 8);
  1500.     #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1501.         count++;
  1502.         UI_EMS_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1503.         if (bflag)
  1504.         {
  1505.             break;
  1506.         }
  1507.     }
  1508.     b->highlight_end_position = *current_position;
  1509.     /* *current_position=saved_current_position; */
  1510.     MoveCursorToPosition(b->data, &saved_current_position);
  1511.     /* Move cursor backwards until a break character is encountered   */
  1512.     if (BackwardCurrentPosition(b->data, 1) != 1)
  1513.     {
  1514.         b->flags &= ~UI_EMS_INPUT_BOX_WORD_HIGHLIGHT;
  1515.         return (0);
  1516.     }
  1517. #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1518.     current_character =
  1519.         b->data->textBuffer[current_position->OffsetToText +
  1520.                             1] | (b->data->textBuffer[current_position->OffsetToText] << 8);
  1521. #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1522.     current_character =
  1523.         b->data->textBuffer[current_position->OffsetToText] | (b->data->
  1524.                                                                textBuffer[current_position->OffsetToText + 1] << 8);
  1525. #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1526.     UI_EMS_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1527.     if (bflag)
  1528.     {
  1529.         ForwardCurrentPosition(b->data, 1);
  1530.         done = 1;
  1531.         b->flags &= ~UI_EMS_INPUT_BOX_WORD_HIGHLIGHT;
  1532.         return (0);
  1533.     }
  1534.     else
  1535.     {
  1536.         done = 0;
  1537.         b->flags |= UI_EMS_INPUT_BOX_WORD_HIGHLIGHT;
  1538.     }
  1539.     while (!done)
  1540.     {
  1541.         previous_position = *current_position;
  1542.         if ((current_position->Object != NULL) &&
  1543.             (current_position->Object->OffsetToText == current_position->OffsetToText))
  1544.         {
  1545.             break;
  1546.         }
  1547.         if (current_position->OffsetToText == 0)
  1548.         {
  1549.             break;
  1550.         }
  1551.         if (BackwardCurrentPosition(b->data, 1) != 1)
  1552.         {
  1553.             break;
  1554.         }
  1555.     #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1556.         current_character =
  1557.             b->data->textBuffer[current_position->OffsetToText +
  1558.                                 1] | (b->data->textBuffer[current_position->OffsetToText] << 8);
  1559.     #else /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1560.         current_character =
  1561.             b->data->textBuffer[current_position->OffsetToText] | (b->data->
  1562.                                                                    textBuffer[current_position->OffsetToText + 1] << 8);
  1563.     #endif /* (EMS_BYTE_ORDER_BIG_ENDIAN) */ 
  1564.         count++;
  1565.         UI_EMS_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1566.         if (bflag)
  1567.         {
  1568.             break;
  1569.         }
  1570.     }
  1571.     b->highlight_start_position = previous_position;
  1572.     /* *current_position=previous_position; */
  1573.     MoveCursorToPosition(b->data, &previous_position);
  1574.     gui_EMS_input_box_locate_cursor(b);
  1575.     return (count);
  1576. }
  1577. /*****************************************************************************
  1578.  * FUNCTION
  1579.  *  gui_EMS_input_box_text_format_forward_seek
  1580.  * DESCRIPTION
  1581.  *  
  1582.  * PARAMETERS
  1583.  *  b                               [?]         
  1584.  *  t                               [?]         
  1585.  *  length                          [?]         
  1586.  *  isModifyExistedTextformat       [IN]        
  1587.  * RETURNS
  1588.  *  void
  1589.  *****************************************************************************/
  1590. void gui_EMS_input_box_text_format_forward_seek(
  1591.         UI_EMS_input_box *b,
  1592.         EMSTextFormat *t,
  1593.         S32 *length,
  1594.         BOOL isModifyExistedTextformat)
  1595. {
  1596.     /*----------------------------------------------------------------*/
  1597.     /* Local Variables                                                */
  1598.     /*----------------------------------------------------------------*/
  1599.     EMSPosition current_position = b->data->CurrentPosition;
  1600.     UI_character_type c;
  1601.     EMSObject *o;
  1602.     U8 r;
  1603.     U8 done = 0;
  1604.     S32 text_format_object_count = 0;
  1605.     S32 text_length = 0;
  1606.     BOOL isModify = isModifyExistedTextformat;
  1607.     /*----------------------------------------------------------------*/
  1608.     /* Code Body                                                      */
  1609.     /*----------------------------------------------------------------*/
  1610.     while (!done)
  1611.     {
  1612.         if (current_position.OffsetToText >= b->data->textLength)
  1613.         {
  1614.             break;
  1615.         }
  1616.         r = gui_EMS_input_box_get_next_object(b->data, &current_position, &c, &o);
  1617.         switch (r)
  1618.         {
  1619.             case 0:
  1620.                 done = 1;
  1621.                 break;
  1622.             case 1:
  1623.                 if (c == EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER)
  1624.                 {
  1625.                     done = 1;
  1626.                 }
  1627.                 if (text_format_object_count == 0)
  1628.                 {
  1629.                     text_length++;
  1630.                 }
  1631.                 break;
  1632.             case 2:
  1633.                 if (o->Type == EMS_TYPE_TEXT_FORMAT)
  1634.                 {
  1635.                     text_format_object_count++;
  1636.                     if (isModify)
  1637.                     {
  1638.                         o->data->text_format.Alignment = t->Alignment;
  1639.                     }
  1640.                 }
  1641.                 break;
  1642.         }
  1643.     }
  1644.     *length = text_length;
  1645. }
  1646. /*****************************************************************************
  1647.  * FUNCTION
  1648.  *  gui_EMS_input_box_text_format_backward_seek
  1649.  * DESCRIPTION
  1650.  *  
  1651.  * PARAMETERS
  1652.  *  b                               [?]         
  1653.  *  t                               [?]         
  1654.  *  length                          [?]         
  1655.  *  isModifyExistedTextformat       [IN]        
  1656.  * RETURNS
  1657.  *  void
  1658.  *****************************************************************************/
  1659. void gui_EMS_input_box_text_format_backward_seek(
  1660.         UI_EMS_input_box *b,
  1661.         EMSTextFormat *t,
  1662.         S32 *length,
  1663.         BOOL isModifyExistedTextformat)
  1664. {
  1665.     /*----------------------------------------------------------------*/
  1666.     /* Local Variables                                                */
  1667.     /*----------------------------------------------------------------*/
  1668.     S32 text_length = *length;
  1669.     EMSPosition current_position = b->data->CurrentPosition;
  1670.     UI_character_type c;
  1671.     EMSObject *o;
  1672.     U8 r;
  1673.     U8 done = 0;
  1674.     U8 counter_reset_flag = 0;
  1675.     S32 saved_text_length = 0;
  1676.     S32 old_OffsetToText;
  1677.     BOOL isModify = isModifyExistedTextformat;
  1678.     /*----------------------------------------------------------------*/
  1679.     /* Code Body                                                      */
  1680.     /*----------------------------------------------------------------*/
  1681.     while (!done)
  1682.     {
  1683.         if (BackwardCurrentPosition(b->data, 1) != 1)
  1684.         {
  1685.             if (counter_reset_flag)
  1686.             {
  1687.                 text_length = saved_text_length;
  1688.             }
  1689.             break;
  1690.         }
  1691.         gui_EMS_input_box_set_text_format_cursor_position(b);
  1692.         current_position = b->data->CurrentPosition;
  1693.         r = gui_EMS_input_box_get_next_object(b->data, &current_position, &c, &o);
  1694.         switch (r)
  1695.         {
  1696.             case 0:
  1697.                 if (counter_reset_flag)
  1698.                 {
  1699.                     text_length = saved_text_length;
  1700.                 }
  1701.                 counter_reset_flag = 0;
  1702.                 done = 1;
  1703.                 break;
  1704.             case 1:
  1705.                 if (c == EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER)
  1706.                 {
  1707.                     if (counter_reset_flag)
  1708.                     {
  1709.                         text_length = saved_text_length;
  1710.                     }
  1711.                     ForwardCurrentPosition(b->data, 1);
  1712.                     done = 1;
  1713.                 }
  1714.                 else
  1715.                 {
  1716.                     text_length++;
  1717.                 }
  1718.                 counter_reset_flag = 0;
  1719.                 break;
  1720.             case 2:
  1721.                 if (o->Type == EMS_TYPE_TEXT_FORMAT)
  1722.                 {
  1723.                     if (text_length > 0)
  1724.                     {
  1725.                         saved_text_length = text_length + 1;
  1726.                     }
  1727.                     else
  1728.                     {
  1729.                         saved_text_length = text_length;
  1730.                     }
  1731.                     text_length = 0;
  1732.                     if (isModify)
  1733.                     {
  1734.                         o->data->text_format.Alignment = t->Alignment;
  1735.                     }
  1736.                     counter_reset_flag = 1;
  1737.                 }
  1738.                 break;
  1739.         }
  1740.     }
  1741.     *length = text_length;
  1742. #if(EMS_ENABLE_TESTFIX_OBJECT_ORDERING)
  1743.     old_OffsetToText = b->data->CurrentPosition.OffsetToText;
  1744.     while (b->data->CurrentPosition.OffsetToText == old_OffsetToText)
  1745.     {
  1746.         if (BackwardCurrentPosition(b->data, 1) != 1)
  1747.         {
  1748.             break;
  1749.         }
  1750.     }
  1751.     if (b->data->CurrentPosition.OffsetToText != old_OffsetToText)
  1752.     {
  1753.         ForwardCurrentPosition(b->data, 1);
  1754.     }
  1755. #endif /* (EMS_ENABLE_TESTFIX_OBJECT_ORDERING) */ 
  1756. }
  1757. /*****************************************************************************
  1758.  * FUNCTION
  1759.  *  GetTextFormatObjectAtPosition
  1760.  * DESCRIPTION
  1761.  *  
  1762.  * PARAMETERS
  1763.  *  data        [?]     
  1764.  *  p           [?]     
  1765.  * RETURNS
  1766.  *  
  1767.  *****************************************************************************/
  1768. EMSObject *GetTextFormatObjectAtPosition(EMSData *data, EMSPosition *p)
  1769. {
  1770.     /*----------------------------------------------------------------*/
  1771.     /* Local Variables                                                */
  1772.     /*----------------------------------------------------------------*/
  1773.     EMSObject *current = data->listHead;
  1774.     U16 OffsetToText = (U16) p->OffsetToText;
  1775.     EMSObject *return_object = NULL;
  1776.     /*----------------------------------------------------------------*/
  1777.     /* Code Body                                                      */
  1778.     /*----------------------------------------------------------------*/
  1779.     while (current != NULL)
  1780.     {
  1781.         if ((current->Type == EMS_TYPE_TEXT_FORMAT) && (current->OffsetToText == OffsetToText))
  1782.         {
  1783.             return_object = current;
  1784.             break;
  1785.         }
  1786.         if (current->OffsetToText > OffsetToText)
  1787.         {
  1788.             break;
  1789.         }
  1790.         current = current->next;
  1791.     }
  1792.     return (return_object);
  1793. }
  1794. #ifdef __MMI_MESSAGES_EMS__
  1795. /*****************************************************************************
  1796.  * FUNCTION
  1797.  *  gui_EMS_input_box_find_paragraph_range
  1798.  * DESCRIPTION
  1799.  *  
  1800.  * PARAMETERS
  1801.  *  b                   [?]     
  1802.  *  offsetToText        [?]     
  1803.  *  textLength          [?]     
  1804.  * RETURNS
  1805.  *  void
  1806.  *****************************************************************************/
  1807. void gui_EMS_input_box_find_paragraph_range(UI_EMS_input_box *b, kal_uint16 *offsetToText, kal_uint16 *textLength)
  1808. {
  1809.     /*----------------------------------------------------------------*/
  1810.     /* Local Variables                                                */
  1811.     /*----------------------------------------------------------------*/
  1812.     kal_uint16 *offset = offsetToText;
  1813.     kal_uint16 *textLen = textLength;
  1814.     EMSPosition saved_position = b->data->CurrentPosition;
  1815.     EMSPosition current_position = b->data->CurrentPosition;
  1816.     UI_character_type c;
  1817.     EMSObject *o;
  1818.     U8 r;
  1819.     U8 done = 0;
  1820.     /*----------------------------------------------------------------*/
  1821.     /* Code Body                                                      */
  1822.     /*----------------------------------------------------------------*/
  1823.     /* Move to the beginning of paragraph */
  1824.     while (!done)
  1825.     {
  1826.         /* Reach the first position */
  1827.         if (BackwardCurrentPosition(b->data, 1) != 1)
  1828.         {
  1829.             break;
  1830.         }
  1831.         current_position = b->data->CurrentPosition;
  1832.         r = gui_EMS_input_box_get_next_object(b->data, &current_position, &c, &o);
  1833.         switch (r)
  1834.         {
  1835.                 /* check if reach the start of paragraph */
  1836.             case 1:
  1837.                 if (c == EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER)
  1838.                 {
  1839.                     ForwardCurrentPosition(b->data, 1);
  1840.                     done = 1;
  1841.                 }
  1842.                 break;
  1843.                 /* ignore object */
  1844.             case 2:
  1845.                 break;
  1846.                 /* impossible case */
  1847.             case 0:
  1848.             default:
  1849.                 MMI_ASSERT(0);
  1850.                 break;
  1851.         }
  1852.     }
  1853.     *offset = b->data->CurrentPosition.OffsetToText;
  1854.     done = 0;
  1855.     current_position = b->data->CurrentPosition;
  1856.     /* count to the end of the paragraph */
  1857.     while (!done)
  1858.     {
  1859.         if (current_position.OffsetToText >= b->data->textLength)
  1860.         {
  1861.             break;
  1862.         }
  1863.         r = gui_EMS_input_box_get_next_object(b->data, &current_position, &c, &o);
  1864.         switch (r)
  1865.         {
  1866.                 /* count the number of characters in the paragraph */
  1867.             case 1:
  1868.                 if (c == EMS_INPUTBOX_PARAGRAPH_BREAK_CHARACTER)
  1869.                 {
  1870.                     done = 1;
  1871.                     (*textLen)++;
  1872.                     /* Exclude 0x0d and 0x0a */
  1873.                     /* (*textLen)--; */
  1874.                 }
  1875.                 else
  1876.                 {
  1877.                     (*textLen)++;
  1878.                 }
  1879.                 break;
  1880.                 /* To the end of the message */
  1881.             case 0:
  1882.                 done = 1;
  1883.                 break;
  1884.                 /* ignore object */
  1885.             case 2:
  1886.                 break;
  1887.                 /* impossible case */
  1888.             default:
  1889.                 MMI_ASSERT(0);
  1890.                 break;
  1891.         }
  1892.     }
  1893.     MoveCursorToPosition(b->data, &saved_position);
  1894. }
  1895. /* Warning: Function requires the parameter t to be modified in some cases.
  1896.    So it is necessary to pass a copy instead of the actual data            */
  1897. /* MTK Joy added for text format insert, 0112 */
  1898. /*****************************************************************************
  1899.  * FUNCTION
  1900.  *  gui_EMS_input_box_insert_text_alignment
  1901.  * DESCRIPTION
  1902.  *  
  1903.  * PARAMETERS
  1904.  *  b       [?]     
  1905.  *  t       [?]     
  1906.  * RETURNS
  1907.  *  
  1908.  *****************************************************************************/
  1909. EMSTATUS gui_EMS_input_box_insert_text_alignment(UI_EMS_input_box *b, EMSTextFormat *t)
  1910. {
  1911.     /*----------------------------------------------------------------*/
  1912.     /* Local Variables                                                */
  1913.     /*----------------------------------------------------------------*/
  1914. #if (0)
  1915. /* under construction !*/
  1916. /* under construction !*/
  1917. /* under construction !*/
  1918. /* under construction !*/
  1919. /* under construction !*/
  1920. /* under construction !*/
  1921. #if(1)
  1922. /* under construction !*/
  1923. /* under construction !*/
  1924. #endif
  1925. /* under construction !*/
  1926. /* under construction !*/
  1927. /* under construction !*/
  1928. /* under construction !*/
  1929. /* under construction !*/
  1930. /* under construction !*/
  1931. /* under construction !*/
  1932. /* under construction !*/
  1933. /* under construction !*/
  1934. /* under construction !*/
  1935. /* under construction !*/
  1936. /* under construction !*/
  1937. /* under construction !*/
  1938. /* under construction !*/
  1939. /* under construction !*/
  1940. /* under construction !*/
  1941. /* under construction !*/
  1942. /* under construction !*/
  1943. /* under construction !*/
  1944. /* under construction !*/
  1945. /* under construction !*/
  1946. /* under construction !*/
  1947. /* under construction !*/
  1948. /* under construction !*/
  1949. /* under construction !*/
  1950. /* under construction !*/
  1951. /* under construction !*/
  1952. /* under construction !*/
  1953. /* under construction !*/
  1954. /* under construction !*/
  1955. /* under construction !*/
  1956. /* under construction !*/
  1957. /* under construction !*/
  1958. /* under construction !*/
  1959. /* under construction !*/
  1960. #if(0)
  1961. /* under construction !*/
  1962. /* under construction !*/
  1963. /* under construction !*/
  1964. /* under construction !*/
  1965. /* under construction !*/
  1966. /* under construction !*/
  1967. /* under construction !*/
  1968. #endif
  1969. /* under construction !*/
  1970. /* under construction !*/
  1971. /* under construction !*/
  1972. /* under construction !*/
  1973. /* under construction !*/
  1974. /* under construction !*/
  1975. /* under construction !*/
  1976. /* under construction !*/
  1977. /* under construction !*/
  1978. /* under construction !*/
  1979. #if(1)
  1980. /* under construction !*/
  1981. /* under construction !*/
  1982. /* under construction !*/
  1983. /* under construction !*/
  1984. /* under construction !*/
  1985. /* under construction !*/
  1986. /* under construction !*/
  1987. /* under construction !*/
  1988. #endif
  1989. /* under construction !*/
  1990. /* under construction !*/
  1991. /* under construction !*/
  1992. #if(EMS_BYTE_ORDER_BIG_ENDIAN)
  1993. /* under construction !*/
  1994. /* under construction !*/
  1995. #else
  1996. /* under construction !*/
  1997. /* under construction !*/
  1998. #endif
  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. /* under construction !*/
  2016. /* under construction !*/
  2017. /* under construction !*/
  2018. /* under construction !*/
  2019. /* under construction !*/
  2020. /* under construction !*/
  2021. /* under construction !*/
  2022. /* under construction !*/
  2023. /* under construction !*/
  2024. /* under construction !*/
  2025. /* under construction !*/
  2026. /* under construction !*/
  2027. /* under construction !*/
  2028. /* under construction !*/
  2029. /* under construction !*/
  2030. /* under construction !*/
  2031. /* under construction !*/
  2032. /* under construction !*/
  2033. /* under construction !*/
  2034. /* under construction !*/
  2035. /* under construction !*/
  2036. /* under construction !*/
  2037. /* under construction !*/
  2038. /* under construction !*/
  2039. /* under construction !*/
  2040. /* under construction !*/
  2041. /* under construction !*/
  2042. /* under construction !*/
  2043. /* under construction !*/
  2044. /* under construction !*/
  2045. /* under construction !*/
  2046. /* under construction !*/
  2047. /* under construction !*/
  2048. /* under construction !*/
  2049. /* under construction !*/
  2050. /* under construction !*/
  2051. /* under construction !*/
  2052. /* under construction !*/
  2053. /* under construction !*/
  2054. /* under construction !*/
  2055. /* under construction !*/
  2056. #endif /* (0) */ 
  2057.     kal_uint16 offsetToText = 0;
  2058.     kal_uint16 textLength = 0;
  2059.     EMSTATUS emsObjectStatus = EMS_OK;
  2060.     EMSTextFormat textFormat = *t;
  2061.     /*----------------------------------------------------------------*/
  2062.     /* Code Body                                                      */
  2063.     /*----------------------------------------------------------------*/
  2064.     if (b->data->textLength == 0)
  2065.     {
  2066.         return EMS_OK;
  2067.     }
  2068.     gui_EMS_input_box_find_paragraph_range(b, &offsetToText, &textLength);
  2069.     if (textLength == 0)
  2070.     {
  2071.         return EMS_OK;
  2072.     }
  2073.     textFormat.textLength = textLength * 2;
  2074.     textFormat.FontSize = EMS_FONTSIZE_NORMAL;
  2075.     textFormat.isBold = KAL_FALSE;
  2076.     textFormat.isItalic = KAL_FALSE;
  2077.     textFormat.isStrikethrough = KAL_FALSE;
  2078.     textFormat.isUnderline = KAL_FALSE;
  2079.     emsObjectStatus = AddTextAlignment(b->data, offsetToText, &textFormat);
  2080.     gui_EMS_input_box_set_text_format_cursor_position(b);
  2081.     return emsObjectStatus;
  2082. }
  2083. /*****************************************************************************
  2084.  * FUNCTION
  2085.  *  gui_EMS_input_box_insert_new_paragraph
  2086.  * DESCRIPTION
  2087.  *  
  2088.  * PARAMETERS
  2089.  *  b       [?]     
  2090.  *  t       [?]     
  2091.  * RETURNS
  2092.  *  
  2093.  *****************************************************************************/
  2094. EMSTATUS gui_EMS_input_box_insert_new_paragraph(UI_EMS_input_box *b, EMSTextFormat *t)
  2095. {
  2096.     /*----------------------------------------------------------------*/
  2097.     /* Local Variables                                                */
  2098.     /*----------------------------------------------------------------*/
  2099.     EMSTATUS emsObjectStatus;
  2100.     /*----------------------------------------------------------------*/
  2101.     /* Code Body                                                      */
  2102.     /*----------------------------------------------------------------*/
  2103.     emsObjectStatus = gui_EMS_input_box_insert_new_line(b);
  2104.     if (emsObjectStatus == EMS_OK)
  2105.     {
  2106.         emsObjectStatus = gui_EMS_input_box_insert_text_alignment(b, t);
  2107.     }
  2108.     return emsObjectStatus;
  2109. }
  2110. /* MTK end */
  2111. #endif /* __MMI_MESSAGES_EMS__ */ 
  2112. /*****************************************************************************
  2113.  * FUNCTION
  2114.  *  EMS_move_graphical_cursor
  2115.  * DESCRIPTION
  2116.  *  
  2117.  * PARAMETERS
  2118.  *  data            [?]         
  2119.  *  start_x         [IN]        
  2120.  *  cursor_x        [IN]        
  2121.  *  max_count       [IN]        
  2122.  * RETURNS
  2123.  *  void
  2124.  *****************************************************************************/
  2125. void EMS_move_graphical_cursor(EMSData *data, S32 start_x, S32 cursor_x, S32 max_count)
  2126. {
  2127.     /*----------------------------------------------------------------*/
  2128.     /* Local Variables                                                */
  2129.     /*----------------------------------------------------------------*/
  2130.     EMSPosition current_position = data->CurrentPosition;
  2131.     U8 done = 0;
  2132.     S32 x = start_x;
  2133.     S32 count = 0;
  2134.     U8 r;
  2135.     EMSObject *current_object;
  2136.     UI_character_type current_character;
  2137.     S32 width = 0, height;
  2138.     /* PMT START FIX HINDI ISSUES 20060604 */
  2139. #ifdef __MMI_HINDI_ALG__
  2140.     EMSData *data_chk_type = data;
  2141.     UI_character_type dummy_c = 0;
  2142.     S32 next_ems_moves = 0;
  2143.     PU8 src_p;
  2144.     PU8 dest_p;
  2145. #endif /* __MMI_HINDI_ALG__ */ 
  2146.     /* PMT END FIX HINDI ISSUES 20060604 */
  2147. #if defined(__MMI_LANG_VIETNAMESE__)
  2148.     /* W05.38 Fix Viet Tone Cursor Moving Issue */
  2149.     U8 viet_tone_move = 0;
  2150. #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  2151.     /*----------------------------------------------------------------*/
  2152.     /* Code Body                                                      */
  2153.     /*----------------------------------------------------------------*/
  2154.     while (!done)
  2155.     {
  2156.         if (count >= max_count)
  2157.         {
  2158.             break;
  2159.         }
  2160.         r = gui_EMS_input_box_get_next_object(data, &current_position, &current_character, &current_object);
  2161.         switch (r)
  2162.         {
  2163.             case 0:
  2164.                 done = 1;
  2165.                 break;
  2166.             case 1:
  2167.         #if(EMS_USE_CRLF_COMBINATION)
  2168.                 if (UI_TEST_CR_CHARACTER(current_character) && (current_position.OffsetToText < data->textLength) &&
  2169.                     UI_TEST_LF_CHARACTER(data->textBuffer[current_position.OffsetToText]))
  2170.                 {
  2171.                     width = 0;
  2172.                 }
  2173.                 else if (UI_TEST_LF_CHARACTER(current_character))
  2174.                 {
  2175.                     width = 0;
  2176.                 }
  2177.                 else
  2178.         #endif /* (EMS_USE_CRLF_COMBINATION) */ 
  2179.             #if(EMS_USE_ESC_COMBINATION)
  2180.                 if (UI_TEST_ESC_CHARACTER(current_character))
  2181.                 {
  2182.                     width = 0;
  2183.                 }
  2184.                 else
  2185.             #endif /* (EMS_USE_ESC_COMBINATION) */ 
  2186.                 {
  2187.                 #if defined(__MMI_LANG_VIETNAMESE__)
  2188.                     /* MTK Terry for Cursor Move Up and Down Issue */
  2189.                     UI_character_type dummy_c = 0;
  2190.                     viet_tone_mark tone_mark = VIET_TONE_NONE;
  2191.                     viet_vowel_letter viet_vowel = VIET_VOWEL_NONE;
  2192.                     if ((current_character > 0x0040) && (current_character < 0x01B1))
  2193.                     {
  2194.                         r = gui_EMS_input_box_get_next_object(data, &current_position, &dummy_c, &current_object);      /* get next character */
  2195.                         if (1 == r)
  2196.                         {
  2197.                             tone_mark = mmi_viet_tone_mark(dummy_c);
  2198.                             if (VIET_TONE_NONE != tone_mark)
  2199.                             {
  2200.                                 viet_vowel = mmi_viet_vowel_letter(current_character);
  2201.                                 if (VIET_VOWEL_NONE != viet_vowel)
  2202.                                 {
  2203.                                     current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  2204.                                     /* W05.38 Fix Viet Tone Cursor Moving Issue */
  2205.                                     viet_tone_move = 1;
  2206.                                 }
  2207.                                 else
  2208.                                 {
  2209.                                     r = gui_EMS_input_box_get_previous_object(
  2210.                                             data,
  2211.                                             &current_position,
  2212.                                             &dummy_c,
  2213.                                             &current_object);
  2214.                                 }
  2215.                             }
  2216.                             else
  2217.                             {
  2218.                                 r = gui_EMS_input_box_get_previous_object(
  2219.                                         data,
  2220.                                         &current_position,
  2221.                                         &dummy_c,
  2222.                                         &current_object);
  2223.                             }
  2224.                         }
  2225.                         else if (0 != r)
  2226.                         {
  2227.                             r = gui_EMS_input_box_get_previous_object(
  2228.                                     data,
  2229.                                     &current_position,
  2230.                                     &dummy_c,
  2231.                                     &current_object);
  2232.                         }
  2233.                     }
  2234.                 #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  2235.                     /* PMT START FIX HINDI ISSUES 20060604 */
  2236.                 #ifdef __MMI_HINDI_ALG__
  2237.                 #ifdef __MMI_HINDI_ALG__
  2238.                     src_p = (data->textBuffer + data->CurrentPosition.OffsetToText) - 2;
  2239.                 #endif 
  2240.                     if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  2241.                     {
  2242.                         dest_p = hf_get_next_cluster_p(src_p, src_p);
  2243.                         next_ems_moves = dest_p - src_p;
  2244.                         next_ems_moves = next_ems_moves >> 1;
  2245.                         if (next_ems_moves >= 2)    /* && r==2) //&& current_object->Type==EMS_TYPE_TEXT_FORMAT) */
  2246.                         {
  2247.                             ForwardCurrentPosition(data, next_ems_moves - 1);
  2248.                             count += next_ems_moves - 1;
  2249.                             next_ems_moves = 0;
  2250.                             width = hf_size_of_current_cluster(src_p, dest_p, 1);
  2251.                         }
  2252.                         else
  2253.                         {
  2254.                             gui_measure_character(current_character, &width, &height);
  2255.                         }
  2256.                         src_p = dest_p;
  2257.                     }
  2258.                     else
  2259.                 #endif /* __MMI_HINDI_ALG__ */ 
  2260.                         /* PMT END FIX HINDI ISSUES 20060604 */
  2261.                         gui_measure_character(current_character, &width, &height);
  2262.                     width += 1;
  2263.                 }
  2264.                 x += width;
  2265.                 break;
  2266.             #ifdef __MMI_MESSAGES_EMS__
  2267.             case 2:
  2268.                 if (current_object->Type == EMS_TYPE_TEXT_FORMAT)
  2269.                 {
  2270.                     width = 0;
  2271.                 }
  2272.                 else
  2273.                 {
  2274.                     gui_EMS_input_box_measure_object(current_object, &width, &height);
  2275.                     width += 2;
  2276.                 }
  2277.                 x += width;
  2278.                 break;
  2279.             #endif /* __MMI_MESSAGES_EMS__ */ 
  2280.         }
  2281.         if (x <= (cursor_x + (width >> 1)))
  2282.         {
  2283.             count++;
  2284.             if (ForwardCurrentPosition(data, 1) != 1)
  2285.             {
  2286.                 break;
  2287.             }
  2288.         #if defined(__MMI_LANG_VIETNAMESE__)
  2289.             /* W05.38 Fix Viet Tone Cursor Moving Issue */
  2290.             if (1 == viet_tone_move)
  2291.             {
  2292.                 if (ForwardCurrentPosition(data, 1) != 1)
  2293.                 {
  2294.                 }
  2295.                 viet_tone_move = 0;
  2296.             }
  2297.         #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  2298.         }
  2299.         else
  2300.         {
  2301.             break;
  2302.         }
  2303.     }
  2304. }
  2305. #endif /* (!UI_DISABLE_EMS_INPUT_BOX) */ 
  2306. /* msz00065_20051010 peng hua add for multitap thai begin */
  2307. #ifdef __MMI_MULTITAP_THAI__
  2308. /*****************************************************************************
  2309.  * FUNCTION
  2310.  *  gui_EMS_check_input_test_overflow
  2311.  * DESCRIPTION
  2312.  *  
  2313.  * PARAMETERS
  2314.  *  b       [?]         
  2315.  *  c       [IN]        
  2316.  * RETURNS
  2317.  *  
  2318.  *****************************************************************************/
  2319. U8 gui_EMS_check_input_test_overflow(UI_EMS_input_box *b, UI_character_type c)
  2320. {
  2321.     /*----------------------------------------------------------------*/
  2322.     /* Local Variables                                                */
  2323.     /*----------------------------------------------------------------*/
  2324.     U16 ch = (U16) c;
  2325.     U8 s[2] = {0, 0};
  2326.     S32 remaining_length;
  2327.     /*----------------------------------------------------------------*/
  2328.     /* Code Body                                                      */
  2329.     /*----------------------------------------------------------------*/
  2330. #ifdef __MMI_MESSAGES_EMS__
  2331.     EMS_cancel_object_focus();
  2332. #endif 
  2333.     if (b->UCS2_count > 0)
  2334.     {
  2335.         remaining_length = (EMS_get_remaining_length(b->data) >> 1);
  2336.     }
  2337.     else
  2338.     {
  2339.         remaining_length = EMS_get_remaining_length(b->data);
  2340.     }
  2341.     if (remaining_length <= 0)
  2342.     {
  2343.         return FALSE;
  2344.     }
  2345.     if (b->UCS2_count == 0)
  2346.     {
  2347.         if (UI_TEST_UCS2_CHARACTER(c))
  2348.         {
  2349.             if (EMSSetDCS(b->data, SMSAL_UCS2_DCS) != EMS_OK)
  2350.             {
  2351.                 EMSSetDCS(b->data, SMSAL_DEFAULT_DCS);
  2352.                 return FALSE;
  2353.             }
  2354.             else
  2355.             {
  2356.                 if (EMS_get_remaining_length(b->data) < 2)
  2357.                 {
  2358.                     EMSSetDCS(b->data, SMSAL_DEFAULT_DCS);
  2359.                     return FALSE;
  2360.                 }
  2361.                 else
  2362.                 {
  2363.                     EMSSetDCS(b->data, SMSAL_DEFAULT_DCS);
  2364.                     return TRUE;
  2365.                 }
  2366.             }
  2367.         }
  2368.         else if (UI_TEST_GSM_EXTENDED(c))
  2369.         {
  2370.             if (EMS_get_remaining_length(b->data) < 1)  /* JP : 408 info bar issue */
  2371.             {
  2372.                 return FALSE;
  2373.             }
  2374.         }
  2375.     }
  2376.     /* MTK end */
  2377.     /* If in Overwrite mode, delete the current character/object and insert the new one */
  2378.     if (b->flags & UI_EMS_INPUT_BOX_OVERWRITE_MODE)
  2379.     {
  2380.         return TRUE;
  2381.     }
  2382.     return TRUE;
  2383. }
  2384. #endif /* __MMI_MULTITAP_THAI__ */ 
  2385. /* msz00065_20051010 peng hua add for multitap thai end */
  2386. #ifdef __MMI_TOUCH_SCREEN__
  2387. static UI_EMS_input_box *gui_pen_scroll_EMS_input_box = NULL;
  2388. /*****************************************************************************
  2389.  * FUNCTION
  2390.  *  gui_EMS_input_box_scroll_by_pen
  2391.  * DESCRIPTION
  2392.  *  
  2393.  * PARAMETERS
  2394.  *  b                       [?]         
  2395.  *  offset_y                [IN]        
  2396.  *  EMS_input_box_event     [?]         
  2397.  * RETURNS
  2398.  *  void
  2399.  *****************************************************************************/
  2400. static void gui_EMS_input_box_scroll_by_pen(
  2401.                 UI_EMS_input_box *b,
  2402.                 S32 offset_y,
  2403.                 gui_EMS_input_box_pen_enum *EMS_input_box_event)
  2404. {
  2405.     /*----------------------------------------------------------------*/
  2406.     /* Local Variables                                                */
  2407.     /*----------------------------------------------------------------*/
  2408.     int move_gap = b->display_y + offset_y;
  2409.     /*----------------------------------------------------------------*/
  2410.     /* Code Body                                                      */
  2411.     /*----------------------------------------------------------------*/
  2412. #ifdef __MMI_MESSAGES_EMS__
  2413.     EMS_cancel_object_focus();
  2414. #endif 
  2415.     b->display_y = -offset_y;
  2416.     /* W06.06 Fix Cursor issue in EMS Input Box */
  2417.     if (!(b->flags & UI_EMS_INPUT_BOX_VIEW_MODE))
  2418.     {
  2419.         if (b->cursor_ay < -(b->display_y) || b->cursor_ay + b->cursor_line_height > b->height - b->display_y)
  2420.         {
  2421.             if (move_gap > 0)
  2422.             {
  2423.                 gui_show_EMS_input_box_ext(b, UI_cursor_x1, UI_cursor_y1 + b->cursor_line_height);
  2424.             }
  2425.             else
  2426.             {
  2427.                 if (0 == offset_y)
  2428.                 {
  2429.                     gui_show_EMS_input_box_ext(b, UI_cursor_x1, UI_cursor_y1 + move_gap);
  2430.                 }
  2431.                 else
  2432.                 {
  2433.                     gui_show_EMS_input_box_ext(b, UI_cursor_x1, UI_cursor_y1);
  2434.                 }
  2435.             }
  2436.         }
  2437.     }
  2438.     b->display_y = -offset_y;
  2439.     if (!(b->flags & UI_EMS_INPUT_BOX_VIEW_MODE) && (0 != offset_y))
  2440.     {
  2441.         gui_EMS_input_box_locate_cursor(b);
  2442.     }
  2443.     gui_show_EMS_input_box(b);
  2444.     gui_BLT_double_buffer(b->x, b->y, b->x + b->width, b->y + b->height);
  2445. }
  2446. /*****************************************************************************
  2447.  * FUNCTION
  2448.  *  gui_EMS_input_box_scroll_timer_hdlr
  2449.  * DESCRIPTION
  2450.  *  
  2451.  * PARAMETERS
  2452.  *  void
  2453.  * RETURNS
  2454.  *  void
  2455.  *****************************************************************************/
  2456. static void gui_EMS_input_box_scroll_timer_hdlr(void)
  2457. {
  2458.     /*----------------------------------------------------------------*/
  2459.     /* Local Variables                                                */
  2460.     /*----------------------------------------------------------------*/
  2461.     UI_EMS_input_box *b = gui_pen_scroll_EMS_input_box;
  2462.     gui_EMS_input_box_pen_enum EMS_input_box_event;
  2463.     /*----------------------------------------------------------------*/
  2464.     /* Code Body                                                      */
  2465.     /*----------------------------------------------------------------*/
  2466.     gui_pen_scroll_EMS_input_box = NULL;
  2467.     if (!b)
  2468.     {
  2469.         return;
  2470.     }
  2471.     gui_EMS_input_box_scroll_by_pen(b, b->pen_scroll_after_delay, &EMS_input_box_event);
  2472. }
  2473. /*****************************************************************************
  2474.  * FUNCTION
  2475.  *  gui_EMS_input_box_abort_scroll_timer
  2476.  * DESCRIPTION
  2477.  *  
  2478.  * PARAMETERS
  2479.  *  void
  2480.  * RETURNS
  2481.  *  void
  2482.  *****************************************************************************/
  2483. static void gui_EMS_input_box_abort_scroll_timer(void)
  2484. {
  2485.     /*----------------------------------------------------------------*/
  2486.     /* Local Variables                                                */
  2487.     /*----------------------------------------------------------------*/
  2488.     /*----------------------------------------------------------------*/
  2489.     /* Code Body                                                      */
  2490.     /*----------------------------------------------------------------*/
  2491.     gui_pen_scroll_EMS_input_box = NULL;
  2492. }
  2493. /*****************************************************************************
  2494.  * FUNCTION
  2495.  *  gui_EMS_input_box_start_scroll_timer
  2496.  * DESCRIPTION
  2497.  *  
  2498.  * PARAMETERS
  2499.  *  b           [?]         
  2500.  *  value       [IN]        
  2501.  * RETURNS
  2502.  *  void
  2503.  *****************************************************************************/
  2504. static void gui_EMS_input_box_start_scroll_timer(UI_EMS_input_box *b, S32 value)
  2505. {
  2506.     /*----------------------------------------------------------------*/
  2507.     /* Local Variables                                                */
  2508.     /*----------------------------------------------------------------*/
  2509.     /*----------------------------------------------------------------*/
  2510.     /* Code Body                                                      */
  2511.     /*----------------------------------------------------------------*/
  2512.     /* assert that no two input box at the same time */
  2513.     MMI_DBG_ASSERT(!gui_pen_scroll_EMS_input_box || gui_pen_scroll_EMS_input_box == b);
  2514.     b->pen_scroll_after_delay = value;
  2515.     gui_pen_scroll_EMS_input_box = b;
  2516.     gui_cancel_timer(gui_EMS_input_box_scroll_timer_hdlr);
  2517.     gui_start_timer(b->pen_scroll_delay_time, gui_EMS_input_box_scroll_timer_hdlr);
  2518.     gui_add_cleanup_hook(gui_EMS_input_box_abort_scroll_timer);
  2519. }
  2520. /*****************************************************************************
  2521.  * FUNCTION
  2522.  *  gui_EMS_input_box_set_pen_scroll_delay
  2523.  * DESCRIPTION
  2524.  *  
  2525.  * PARAMETERS
  2526.  *  b               [?]         
  2527.  *  delay_time      [IN]        
  2528.  * RETURNS
  2529.  *  void
  2530.  *****************************************************************************/
  2531. void gui_EMS_input_box_set_pen_scroll_delay(UI_EMS_input_box *b, S32 delay_time)
  2532. {
  2533.     /*----------------------------------------------------------------*/
  2534.     /* Local Variables                                                */
  2535.     /*----------------------------------------------------------------*/
  2536.     /*----------------------------------------------------------------*/
  2537.     /* Code Body                                                      */
  2538.     /*----------------------------------------------------------------*/
  2539.     MMI_DBG_ASSERT(delay_time < (S32) 0x0000FFFF);
  2540.     b->pen_scroll_delay_time = (S16) delay_time;
  2541. }
  2542. /*****************************************************************************
  2543.  * FUNCTION
  2544.  *  gui_EMS_input_box_translate_pen_event
  2545.  * DESCRIPTION
  2546.  *  
  2547.  * PARAMETERS
  2548.  *  b                       [?]         
  2549.  *  pen_event               [IN]        
  2550.  *  x                       [IN]        
  2551.  *  y                       [IN]        
  2552.  *  EMS_input_box_event     [?]         
  2553.  * RETURNS
  2554.  *  
  2555.  *****************************************************************************/
  2556. BOOL gui_EMS_input_box_translate_pen_event(
  2557.         UI_EMS_input_box *b,
  2558.         mmi_pen_event_type_enum pen_event,
  2559.         S16 x,
  2560.         S16 y,
  2561.         gui_EMS_input_box_pen_enum *EMS_input_box_event)
  2562. {
  2563.     /*----------------------------------------------------------------*/
  2564.     /* Local Variables                                                */
  2565.     /*----------------------------------------------------------------*/
  2566.     BOOL ret = MMI_TRUE;
  2567.     gui_EMS_input_box_pen_state_struct *pen_state;
  2568.     gui_scrollbar_pen_enum scrollbar_event;
  2569.     gui_pen_event_param_struct scrollbar_param;
  2570.     int scroll_bar_width;
  2571.     /*----------------------------------------------------------------*/
  2572.     /* Code Body                                                      */
  2573.     /*----------------------------------------------------------------*/
  2574.     if (UI_EMS_INPUT_BOX_DISABLE_SCROLLBAR & b->flags)
  2575.     {
  2576.         scroll_bar_width = 0;
  2577.     }
  2578.     else
  2579.     {
  2580.         scroll_bar_width = b->vbar.width;
  2581.     }
  2582.     pen_state = &b->pen_state;
  2583.     ret = MMI_TRUE;
  2584.     if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->pen_on_scroll_bar)
  2585.     {
  2586.         gui_vertical_scrollbar_translate_pen_event(&b->vbar, pen_event, x, y, &scrollbar_event, &scrollbar_param);
  2587.         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  2588.         {
  2589.             if (b->pen_scroll_delay_time > 0)   /* Delay time for scrollbar scrolling */
  2590.             {
  2591.                 gui_EMS_input_box_start_scroll_timer(b, scrollbar_param._u.i);
  2592.             }
  2593.             else
  2594.             {
  2595.                 gui_EMS_input_box_scroll_by_pen(b, scrollbar_param._u.i, EMS_input_box_event);
  2596.             }
  2597.         }
  2598.         *EMS_input_box_event = GUI_EMS_INPUT_BOX_PEN_SCROLL_BAR;
  2599.     }
  2600.     else
  2601.     {
  2602.         switch (pen_event)
  2603.         {
  2604.             case MMI_PEN_EVENT_DOWN:
  2605.                 if (PEN_CHECK_BOUND(x, y, b->x, b->y, b->width, b->height))
  2606.                 {
  2607.                     pen_state->pen_on_scroll_bar = 0;
  2608.                     if (!(b->flags & UI_EMS_INPUT_BOX_DISABLE_SCROLLBAR) &&
  2609.                         gui_vertical_scrollbar_translate_pen_event(
  2610.                             &b->vbar,
  2611.                             MMI_PEN_EVENT_DOWN,
  2612.                             x,
  2613.                             y,
  2614.                             &scrollbar_event,
  2615.                             &scrollbar_param))
  2616.                     {
  2617.                         pen_state->pen_on_scroll_bar = 1;
  2618.                         gui_vertical_scrollbar_set_minimum_pen_offset(&b->vbar, b->cursor_line_height);
  2619.                         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  2620.                         {
  2621.                             if (b->pen_scroll_delay_time > 0)   /* Delay time for scrollbar scrolling */
  2622.                             {
  2623.                                 gui_EMS_input_box_start_scroll_timer(b, scrollbar_param._u.i);
  2624.                             }
  2625.                             else
  2626.                             {
  2627.                                 gui_EMS_input_box_scroll_by_pen(b, scrollbar_param._u.i, EMS_input_box_event);
  2628.                             }
  2629.                         }
  2630.                         *EMS_input_box_event = GUI_EMS_INPUT_BOX_PEN_SCROLL_BAR;
  2631.                     }
  2632.                     else
  2633.                     {
  2634.                         *EMS_input_box_event = GUI_EMS_INPUT_BOX_PEN_TEXT_DOWN;
  2635.                     }
  2636.                 }
  2637.                 else
  2638.                 {
  2639.                     ret = MMI_FALSE;
  2640.                 }
  2641.                 break;
  2642.             case MMI_PEN_EVENT_UP:
  2643.                 if (PEN_CHECK_BOUND(x, y, b->x, b->y, b->width - scroll_bar_width, b->height))
  2644.                 {
  2645.                     *EMS_input_box_event = GUI_EMS_INPUT_BOX_PEN_TEXT_UP;
  2646.                 }
  2647.                 else
  2648.                 {
  2649.                     ret = MMI_FALSE;
  2650.                 }
  2651.                 break;
  2652.             case MMI_PEN_EVENT_MOVE:
  2653.             case MMI_PEN_EVENT_LONG_TAP:
  2654.             case MMI_PEN_EVENT_REPEAT:
  2655.             case MMI_PEN_EVENT_ABORT:
  2656.                 if (PEN_CHECK_BOUND(x, y, b->x, b->y, b->width - scroll_bar_width, b->height))
  2657.                 {
  2658.                 }
  2659.                 else
  2660.                 {
  2661.                     ret = MMI_FALSE;
  2662.                 }
  2663.                 break;
  2664.         }
  2665.     }
  2666.     return ret;
  2667. }
  2668. #endif /* __MMI_TOUCH_SCREEN__ */