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

MTK

开发平台:

C/C++

  1.         {
  2.             UI_editor_play_tone_cannot_insert();
  3.             return MMI_FALSE;
  4.         }
  5.         if (GSM_extended_flag)
  6.         {
  7.             b->GSM_ext_count++;
  8.         }
  9.         UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c); /* get next character */
  10.         if (b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  11.         {
  12.             if (b_flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
  13.             {
  14.                 UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
  15.                     c,
  16.                     b->UCS2_count,
  17.                     b->allocated_length,
  18.                     b->available_length);
  19.             }
  20.             else if (b_flags & UI_MULTI_LINE_INPUT_BOX_FORTY_FOUR_LESS_CHARACTER)
  21.             {
  22.                 UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE3(
  23.                     c,
  24.                     b->UCS2_count,
  25.                     b->allocated_length,
  26.                     b->available_length);
  27.             }
  28.             else
  29.             {
  30.                 UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(c, b->UCS2_count, b->allocated_length, b->available_length);
  31.             }
  32.         }
  33.         while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  34.         {
  35.             UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  36.             UI_STRING_INSERT_CHARACTER(p2, c);
  37.             c = old_c;
  38.         }
  39.         UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  40.         b->text_length += ((S32) p2 - (S32) p1);
  41.     }
  42.     
  43.     if (b->show_action_flag)
  44.     {
  45.         //hjf,force to update offset_y b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  46.         gui_show_multi_line_input_box(b);
  47.         //hjf,force to update offset_y b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  48.     }
  49.     
  50. #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  51.     if (GetMessagesCurrScrnID() == SCR_ID_MSG_WRITE)
  52.     {
  53.         g_nsm_msg_context.UCS2_count = b->UCS2_count;
  54.         MMI_multiline_inputbox.available_length = mmi_nsm2_get_remaining_len();
  55.         wgui_inputbox_buffer_size = (MMI_multiline_inputbox.available_length >> 1);
  56.         if (wgui_inputbox_information_flag)
  57.         {
  58.             wgui_redraw_input_information_bar();
  59.         }
  60.         g_nsm_msg_context.textlength = b->text_length;
  61.     }
  62. #endif /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  63. #if defined(__MMI_SMART_MESSAGE_MT__)
  64.     if (GetMessagesCurrScrnID() == SCR_ID_NSM_EDITOR)
  65.     {
  66.         picmsg_text_struct.ucs2_count = b->UCS2_count;
  67.         MMI_multiline_inputbox.available_length = mmi_nsm_get_infobar_maxlen();
  68.         wgui_inputbox_buffer_size = (MMI_multiline_inputbox.available_length >> 1);
  69.         wgui_redraw_input_information_bar();
  70.     }
  71. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  72.     b->validation_callback(b->text, b->cursor_p, (b->text_length >> 1) - 1);
  73.     b->change_callback();
  74.     UI_UNUSED_PARAMETER(dummy_c);
  75.     return MMI_TRUE;
  76. }
  77. void gui_multi_line_input_box_insert_character(multi_line_input_box *b, UI_character_type c)
  78. {
  79.     gui_multi_line_input_box_insert_character_internal(b,c);
  80. }
  81. /*****************************************************************************
  82.  * FUNCTION
  83.  *  gui_multi_line_input_box_insert_newline
  84.  * DESCRIPTION
  85.  *  
  86.  * PARAMETERS
  87.  *  b       [?]     
  88.  * RETURNS
  89.  *  void
  90.  *****************************************************************************/
  91. void gui_multi_line_input_box_insert_newline(multi_line_input_box *b)
  92. {
  93.     if(gui_multi_line_input_box_insert_character_internal(b,(UI_character_type)0x0D))
  94.         if(!gui_multi_line_input_box_insert_character_internal(b,(UI_character_type)0x0A))
  95.             gui_multi_line_input_box_delete_character(b);
  96. }
  97. /*****************************************************************************
  98.  * FUNCTION
  99.  *  gui_multi_line_current_character
  100.  * DESCRIPTION
  101.  *  
  102.  * PARAMETERS
  103.  *  b       [?]     
  104.  * RETURNS
  105.  *  
  106.  *****************************************************************************/
  107. UI_character_type gui_multi_line_current_character(multi_line_input_box *b)
  108. {
  109.     /*----------------------------------------------------------------*/
  110.     /* Local Variables                                                */
  111.     /*----------------------------------------------------------------*/
  112.     UI_buffer_type cursor_p = b->cursor_p;
  113.     UI_character_type current_character;
  114.     /*----------------------------------------------------------------*/
  115.     /* Code Body                                                      */
  116.     /*----------------------------------------------------------------*/
  117.     if (b->cursor_p == b->text)
  118.     {
  119.         return 0;
  120.     }
  121.     else
  122.     {
  123.         UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  124.         return current_character;
  125.     }
  126. }
  127. /*****************************************************************************
  128.  * FUNCTION
  129.  *  gui_EMS_current_character
  130.  * DESCRIPTION
  131.  *  
  132.  * PARAMETERS
  133.  *  b       [?]     
  134.  * RETURNS
  135.  *  
  136.  *****************************************************************************/
  137. UI_character_type gui_EMS_current_character(UI_EMS_input_box *b)
  138. {
  139.     /*----------------------------------------------------------------*/
  140.     /* Local Variables                                                */
  141.     /*----------------------------------------------------------------*/
  142.     UI_character_type current_character = 0;
  143. #ifdef __MMI_HINDI_ALG__
  144.     U8 object_type_check;
  145.     EMSObject *o;
  146.     EMSPosition p = b->data->CurrentPosition;
  147.     EMSData *data = b->data;
  148.     /*----------------------------------------------------------------*/
  149.     /* Code Body                                                      */
  150.     /*----------------------------------------------------------------*/
  151.     object_type_check = gui_EMS_input_box_get_previous_object(data, &p, &current_character, &o);
  152.     if (object_type_check == 2)
  153.     {
  154.         return 0;
  155.     }
  156. #endif /* __MMI_HINDI_ALG__ */ 
  157.     if (b->data->CurrentPosition.OffsetToText == 0)
  158.     {
  159.         return 0;
  160.     }
  161.     else
  162.     {
  163.         current_character = *((UI_character_type*) (b->data->textBuffer + b->data->CurrentPosition.OffsetToText - 2));
  164.         return current_character;
  165.     }
  166. }
  167. /*****************************************************************************
  168.  * FUNCTION
  169.  *  gui_single_line_current_character
  170.  * DESCRIPTION
  171.  *  
  172.  * PARAMETERS
  173.  *  b       [?]     
  174.  * RETURNS
  175.  *  
  176.  *****************************************************************************/
  177. UI_character_type gui_single_line_current_character(single_line_input_box *b)
  178. {
  179.     /*----------------------------------------------------------------*/
  180.     /* Local Variables                                                */
  181.     /*----------------------------------------------------------------*/
  182.     UI_buffer_type current_text_p = b->current_text_p;
  183.     UI_character_type current_character = 0;
  184.     /*----------------------------------------------------------------*/
  185.     /* Code Body                                                      */
  186.     /*----------------------------------------------------------------*/
  187.     if (b->current_text_p == 0)
  188.     {
  189.         return 0;
  190.     }
  191.     else
  192.     {
  193.         UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, current_character);
  194.         return current_character;
  195.     }
  196. }
  197. /*****************************************************************************
  198.  * FUNCTION
  199.  *  gui_multi_line_input_box_insert_multitap_character
  200.  * DESCRIPTION
  201.  *  Inserts a multitap character at the current cursor position
  202.  *  
  203.  *  This function is normally used as the input_callback
  204.  *  function with multitap input objects
  205.  * PARAMETERS
  206.  *  b       [IN]        Is the multi-line inputbox object
  207.  *  c       [IN]        Is the character to be inserted
  208.  * RETURNS
  209.  *  void
  210.  *****************************************************************************/
  211. void gui_multi_line_input_box_insert_multitap_character(multi_line_input_box *b, UI_character_type c)
  212. {
  213.     /*----------------------------------------------------------------*/
  214.     /* Local Variables                                                */
  215.     /*----------------------------------------------------------------*/
  216.     UI_buffer_type p1, p2;
  217. #ifdef __MMI_HINDI_ALG__
  218.     UI_buffer_type middle_pointer, first_cons_ptr, second_cons_ptr;
  219.     static U8 cursor_pos_flag = 0;
  220. #endif /* __MMI_HINDI_ALG__ */ 
  221.     UI_character_type old_c, dummy_c = 0;
  222.     U32 b_flags = b->flags;
  223.     S32 text_length = b->text_length;
  224.     /* MTK Terry for 0x81 support for Phone Book */
  225.     U8 temp_0x81 = 0;
  226.     /*----------------------------------------------------------------*/
  227.     /* Code Body                                                      */
  228.     /*----------------------------------------------------------------*/
  229.     // check can be changed or not 
  230.     if(b->change_event_handler)
  231.     {
  232.         UI_buffer_type tmp_p = b->cursor_p;
  233.         if (b_flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP)
  234.         {
  235.             UI_STRING_GET_PREVIOUS_CHARACTER(tmp_p, dummy_c);
  236.             if(!b->change_event_handler(GUI_MULTI_LINE_INPUT_BOX_DELETE_CHAR,dummy_c))
  237.                 return;
  238.         }
  239.         if(!b->change_event_handler(GUI_MULTI_LINE_INPUT_BOX_INSERT_CHAR,c))
  240.             return;
  241.     }
  242.     
  243.     p1 = p2 = b->cursor_p;
  244.     if ((MMI_current_input_ext_type & INPUT_TYPE_EXT_USE_0x81_ENCODING)
  245.         /* &&(b_flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP) */ )
  246.     {
  247.         if (b_flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP)
  248.         {
  249.             UI_STRING_GET_NEXT_CHARACTER(p1, old_c);    /* get next character */
  250.             UI_STRING_GET_PREVIOUS_CHARACTER(p2, dummy_c);
  251.             UI_STRING_INSERT_CHARACTER(p2, c);
  252.             temp_0x81 = mmi_phb_convert_to_0x81((S8*) b->text, FALSE);
  253.             UI_STRING_GET_PREVIOUS_CHARACTER(p2, old_c);
  254.             UI_STRING_INSERT_CHARACTER(p2, dummy_c);
  255.         }
  256.         else
  257.         {
  258.             temp_0x81 = mmi_phb_convert_to_0x81((S8*) b->text, FALSE);
  259.         }
  260.     }
  261.     if ((MMI_current_input_ext_type & INPUT_TYPE_EXT_USE_0x81_ENCODING) && (0 != temp_0x81))
  262.     {
  263.         if ((text_length >> 1) >= (b->allocated_length >> 1) - 3)
  264.         {
  265.             if ((b_flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP) &&
  266.                 ((text_length >> 1) == (b->allocated_length >> 1) - 3))
  267.             {
  268.             }
  269.             else
  270.             {
  271.                 UI_editor_play_tone_cannot_insert();    /* play error tone */
  272.                 return;
  273.             }
  274.         }
  275.     }
  276.     else
  277.     {
  278.         if (b_flags & UI_MULTI_LINE_INPUT_BOX_CHECK_GSM_EXTENDED)
  279.         {
  280.             /* No support for inserting GSM extended characters through multitap */
  281.             if (UI_TEST_GSM_EXTENDED(c))
  282.             {
  283.                 UI_editor_play_tone_cannot_insert();    /* play error tone */
  284.                 return;
  285.             }
  286.             if (b->UCS2_count == 0)
  287.             {
  288.                 text_length += (b->GSM_ext_count * ENCODING_LENGTH);
  289.             }
  290.         }
  291.         if ((b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH) && (b->UCS2_count == 0) &&
  292.             UI_TEST_UCS2_CHARACTER(c))
  293.         {
  294.             if ((((b->flags & UI_MULTI_LINE_INPUT_BOX_SMS_MAX_LENGTH_HANDLING) &&
  295.                   ((((b->text_length - 2) - ENCODING_LENGTH) >> 1) >= MAX_MSG_SIZE_UCS2)) ||
  296.                  ((b->flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER) &&
  297.                   ((b->text_length - 2) >= ((b->available_length >> 1) - 1))) ||
  298.                  ((b->text_length - 2) >= (b->available_length >> 1))))
  299.             {
  300.                 if ((b_flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER) &&
  301.                     (text_length >= UI_UCS2_STRING_HALF_LENGTH_MINUS_ONE(b->available_length)))
  302.                 {
  303.                     UI_editor_play_tone_cannot_insert();    /* play error tone */
  304.                     return;
  305.                 }
  306.                 else if ((b_flags & UI_MULTI_LINE_INPUT_BOX_FORTY_FOUR_LESS_CHARACTER) &&
  307.                          (text_length >= UI_UCS2_STRING_HALF_LENGTH_MINUS_FORTYFOUR(b->available_length)))
  308.                 {
  309.                     UI_editor_play_tone_cannot_insert();    /* play error tone */
  310.                     return;
  311.                 }
  312.                 else if (text_length >= UI_UCS2_STRING_HALF_LENGTH(b->available_length))
  313.                 {
  314.                     UI_editor_play_tone_cannot_insert();
  315.                     return;
  316.                 }
  317.             }
  318.         }
  319.         /* MTK Terry for 0x81 encoding */
  320.         if (text_length > b->available_length)
  321.         {
  322.             UI_editor_play_tone_cannot_insert();
  323.             return;
  324.         }
  325.     }
  326.     if (b_flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP)
  327.     {
  328.         UI_STRING_GET_PREVIOUS_CHARACTER(b->cursor_p, dummy_c); /* get previous character */
  329.     #ifdef __MMI_HINDI_ALG__
  330.         if (cursor_pos_flag && ((c == 49) || (c == 0x901) || (c == 0x902)))     /* Only when multitap input is 1 */
  331.         {
  332.             UI_STRING_GET_PREVIOUS_CHARACTER(save_cursor_p, dummy_c);
  333.             b->cursor_p = save_cursor_p;
  334.             cursor_pos_flag = 0;
  335.         }
  336.         cursor_pos_flag = 0;
  337.     #endif /* __MMI_HINDI_ALG__ */ 
  338.         p1 = p2 = b->cursor_p;
  339.     #ifdef __MMI_HINDI_ALG__
  340.         middle_pointer = p1;
  341.         first_cons_ptr = p1 - 2;
  342.     #endif /* __MMI_HINDI_ALG__ */ 
  343.         UI_STRING_GET_NEXT_CHARACTER(p1, old_c);    /* get next character */
  344.         if (!UI_STRING_END_OF_STRING_CHARACTER(old_c))
  345.         {
  346.             UI_STRING_INSERT_CHARACTER(p2, c);
  347.             if (b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  348.             {
  349.                 if (b_flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
  350.                 {
  351.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  352.                         old_c,
  353.                         c,
  354.                         b->UCS2_count,
  355.                         b->allocated_length,
  356.                         b->available_length);
  357.                 }
  358.                 else if (b_flags & UI_MULTI_LINE_INPUT_BOX_FORTY_FOUR_LESS_CHARACTER)
  359.                 {
  360.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE3(
  361.                         old_c,
  362.                         c,
  363.                         b->UCS2_count,
  364.                         b->allocated_length,
  365.                         b->available_length);
  366.                 }
  367.                 else
  368.                 {
  369.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  370.                         old_c,
  371.                         c,
  372.                         b->UCS2_count,
  373.                         b->allocated_length,
  374.                         b->available_length);
  375.                 }
  376.             }
  377.             b->cursor_p = p2;
  378.         #ifdef __MMI_HINDI_ALG__
  379.             second_cons_ptr = b->cursor_p;
  380.             if ((UI_CHK_CONSONANT(*first_cons_ptr)) && (UI_CHK_CONSONANT(*second_cons_ptr)) && (*middle_pointer == 0x4d))       /* tarun4 */
  381.             {
  382.                 U8 skip_moves = 0;
  383.                 PU8 first_ptr = second_cons_ptr;
  384.                 PU8 second_ptr;
  385.                 save_cursor_p = b->cursor_p;
  386.                 second_ptr = hf_get_next_cluster_p(first_ptr, first_ptr);
  387.                 skip_moves = second_ptr - first_ptr;    /* Number of moves */
  388.                 skip_moves = skip_moves >> 1;
  389.                 while (skip_moves--)
  390.                 {
  391.                     UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  392.                 }
  393.                 cursor_pos_flag = 1;
  394.             }
  395.         #endif /* __MMI_HINDI_ALG__ */ 
  396.         }
  397.         else    /* UI_STRING_END_OF_STRING_CHARACTER(old_c) */
  398.         {
  399.             p1 = b->cursor_p;
  400.             UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c); /* get next character */
  401.             while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  402.             {
  403.                 UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  404.                 UI_STRING_INSERT_CHARACTER(p2, c);
  405.                 c = old_c;
  406.             }
  407.             UI_STRING_INSERT_CHARACTER(p2, c);
  408.             if (b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  409.             {
  410.                 UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(old_c, c, b->UCS2_count, b->allocated_length, b->available_length);
  411.             }
  412.             b->text_length += ((S32) p2 - (S32) p1);
  413.         }
  414.     }
  415.     else    /* b_flags & UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP */
  416.     {
  417.     #ifdef __MMI_HINDI_ALG__
  418.         cursor_pos_flag = 0;
  419.     #endif 
  420.         p1 = p2 = b->cursor_p;
  421.         if (b_flags & UI_MULTI_LINE_INPUT_BOX_OVERWRITE_MODE)
  422.         {
  423.             UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  424.             if ((p1 == b->last_position_p) && (text_length >= b->available_length))
  425.             {
  426.                 UI_editor_play_tone_cannot_insert();
  427.                 return;
  428.             }
  429.             if (!UI_STRING_END_OF_STRING_CHARACTER(old_c))
  430.             {
  431.                 UI_STRING_INSERT_CHARACTER(p2, c);
  432.                 if (b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  433.                 {
  434.                     if (b_flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
  435.                     {
  436.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  437.                             old_c,
  438.                             c,
  439.                             b->UCS2_count,
  440.                             b->allocated_length,
  441.                             b->available_length);
  442.                     }
  443.                     else if (b_flags & UI_MULTI_LINE_INPUT_BOX_FORTY_FOUR_LESS_CHARACTER)
  444.                     {
  445.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE3(
  446.                             old_c,
  447.                             c,
  448.                             b->UCS2_count,
  449.                             b->allocated_length,
  450.                             b->available_length);
  451.                     }
  452.                     else
  453.                     {
  454.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  455.                             old_c,
  456.                             c,
  457.                             b->UCS2_count,
  458.                             b->allocated_length,
  459.                             b->available_length);
  460.                     }
  461.                 }
  462.                 b->cursor_p = p2;
  463.             }
  464.             else    /* !UI_STRING_END_OF_STRING_CHARACTER(old_c) */
  465.             {
  466.                 p1 = b->cursor_p;
  467.                 UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  468.                 while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  469.                 {
  470.                     UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  471.                     UI_STRING_INSERT_CHARACTER(p2, c);
  472.                     c = old_c;
  473.                 }
  474.                 UI_STRING_INSERT_CHARACTER(p2, c);
  475.                 if (b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  476.                 {
  477.                     if (b_flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
  478.                     {
  479.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  480.                             old_c,
  481.                             c,
  482.                             b->UCS2_count,
  483.                             b->allocated_length,
  484.                             b->available_length);
  485.                     }
  486.                     else if (b_flags & UI_MULTI_LINE_INPUT_BOX_FORTY_FOUR_LESS_CHARACTER)
  487.                     {
  488.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE3(
  489.                             old_c,
  490.                             c,
  491.                             b->UCS2_count,
  492.                             b->allocated_length,
  493.                             b->available_length);
  494.                     }
  495.                     else
  496.                     {
  497.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  498.                             old_c,
  499.                             c,
  500.                             b->UCS2_count,
  501.                             b->allocated_length,
  502.                             b->available_length);
  503.                     }
  504.                 }
  505.                 b->text_length += ((S32) p2 - (S32) p1);
  506.             }
  507.         }
  508.         else    /* b_flags & UI_MULTI_LINE_INPUT_BOX_OVERWRITE_MODE */
  509.         {
  510.             if (text_length >= b->available_length && (0 == temp_0x81))
  511.             {
  512.                 UI_editor_play_tone_cannot_insert();
  513.                 return;
  514.             }
  515.             UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  516.             if (b_flags & UI_MULTI_LINE_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  517.             {
  518.                 if (b_flags & UI_MULTI_LINE_INPUT_BOX_ONE_LESS_CHARACTER)
  519.                 {
  520.                     UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
  521.                         c,
  522.                         b->UCS2_count,
  523.                         b->allocated_length,
  524.                         b->available_length);
  525.                 }
  526.                 else if (b_flags & UI_MULTI_LINE_INPUT_BOX_FORTY_FOUR_LESS_CHARACTER)
  527.                 {
  528.                     UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE3(
  529.                         c,
  530.                         b->UCS2_count,
  531.                         b->allocated_length,
  532.                         b->available_length);
  533.                 }
  534.                 else
  535.                 {
  536.                     UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(c, b->UCS2_count, b->allocated_length, b->available_length);
  537.                 }
  538.             }
  539.             while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  540.             {
  541.                 UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  542.                 UI_STRING_INSERT_CHARACTER(p2, c);
  543.                 c = old_c;
  544.             }
  545.             UI_STRING_INSERT_CHARACTER(p2, c);
  546.             b->text_length += ((S32) p2 - (S32) p1);
  547.         }
  548.         b->flags |= UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP;
  549.     }
  550.     //hjf,force to update offset_y  b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  551.     gui_show_multi_line_input_box(b);   /* show multiline input box */
  552.     //hjf,force to update offset_y b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  553. #if defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__)
  554.     if (GetMessagesCurrScrnID() == SCR_ID_MSG_WRITE)
  555.     {
  556.         g_nsm_msg_context.UCS2_count = b->UCS2_count;
  557.         MMI_multiline_inputbox.available_length = mmi_nsm2_get_remaining_len();
  558.         wgui_inputbox_buffer_size = (MMI_multiline_inputbox.available_length >> 1);
  559.         if (wgui_inputbox_information_flag)
  560.         {
  561.             wgui_redraw_input_information_bar();
  562.         }
  563.         g_nsm_msg_context.textlength = b->text_length;
  564.     }
  565. #endif /* defined(__MMI_SMART_MESSAGE_MO__) && !defined(__MMI_MESSAGES_EMS__) */ 
  566. #if defined(__MMI_SMART_MESSAGE_MT__)
  567.     if (GetMessagesCurrScrnID() == SCR_ID_NSM_EDITOR)
  568.     {
  569.         picmsg_text_struct.ucs2_count = b->UCS2_count;
  570.         MMI_multiline_inputbox.available_length = mmi_nsm_get_infobar_maxlen();
  571.         wgui_inputbox_buffer_size = (MMI_multiline_inputbox.available_length >> 1);
  572.         wgui_redraw_input_information_bar();
  573.     }
  574. #endif /* defined(__MMI_SMART_MESSAGE_MT__) */ 
  575.     b->validation_callback(b->text, b->cursor_p, (b->text_length >> 1) - 1);    /* call validation callback func */
  576.     b->change_callback();
  577.     UI_UNUSED_PARAMETER(dummy_c);
  578. }
  579. /*****************************************************************************
  580.  * FUNCTION
  581.  *  gui_multi_line_input_box_confirm_multitap_character
  582.  * DESCRIPTION
  583.  *  Completes the multitap input sequence
  584.  *  
  585.  *  This function is normally used as the input_complete_callback
  586.  *  function with multitap input objects
  587.  * PARAMETERS
  588.  *  b       [IN]        Is the multi-line inputbox object
  589.  * RETURNS
  590.  *  void
  591.  *****************************************************************************/
  592. void gui_multi_line_input_box_confirm_multitap_character(multi_line_input_box *b)
  593. {
  594.     /*----------------------------------------------------------------*/
  595.     /* Local Variables                                                */
  596.     /*----------------------------------------------------------------*/
  597.     /*----------------------------------------------------------------*/
  598.     /* Code Body                                                      */
  599.     /*----------------------------------------------------------------*/
  600.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_STATE_MULTITAP;
  601. }
  602. /* PMT dara added for Multitap thai */
  603. #ifdef __MMI_MULTITAP_THAI__
  604. /*****************************************************************************
  605.  * FUNCTION
  606.  *  gui_multi_line_input_box_get_previous_character
  607.  * DESCRIPTION
  608.  *  get the previous character
  609.  * PARAMETERS
  610.  *  b       [IN]        Is the multi-line inputbox object
  611.  *  c       [?]         
  612.  * RETURNS
  613.  *  void
  614.  *****************************************************************************/
  615. U8 gui_multi_line_input_box_get_previous_character(multi_line_input_box *b, UI_character_type *c)
  616. {
  617.     /*----------------------------------------------------------------*/
  618.     /* Local Variables                                                */
  619.     /*----------------------------------------------------------------*/
  620.     /*----------------------------------------------------------------*/
  621.     /* Code Body                                                      */
  622.     /*----------------------------------------------------------------*/
  623.     if (b->text == NULL)
  624.     {
  625.         return 0;
  626.     }
  627.     if (b->cursor_p == b->text)
  628.     {
  629.         return 0;
  630.     }
  631.     /* c = (data->textBuffer[current_position->OffsetToText-1]|(data->textBuffer[current_position->OffsetToText-2]<<8)); */
  632.     *c = (*(b->cursor_p - 2)) | (*(b->cursor_p - 1)) << 8;
  633.     return 1;
  634. }
  635. #endif /* __MMI_MULTITAP_THAI__ */ 
  636. /* msz065_20050420 Peng Hua add for multitap thai input method end */
  637. /*****************************************************************************
  638.  * FUNCTION
  639.  *  gui_multi_line_input_box_previous
  640.  * DESCRIPTION
  641.  *  Moves the cursor to the previous character
  642.  * PARAMETERS
  643.  *  b       [IN]        Is the multi-line inputbox object
  644.  * RETURNS
  645.  *  void
  646.  *****************************************************************************/
  647. void gui_multi_line_input_box_previous(multi_line_input_box *b)
  648. {
  649.     /*----------------------------------------------------------------*/
  650.     /* Local Variables                                                */
  651.     /*----------------------------------------------------------------*/
  652.     UI_character_type dummy_c = 0;
  653.     UI_buffer_type save_text_p = b->cursor_p;
  654. #if defined(__MMI_LANG_VIETNAMESE__)
  655.     UI_character_type previous_unicode = 0;
  656.     viet_tone_mark tone_mark = VIET_TONE_NONE;
  657.     viet_vowel_letter viet_vowel = VIET_VOWEL_NONE;
  658. #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  659.     /* MTK Steven 20050505 */
  660. #if defined(__MMI_LANG_THAI__)
  661.     UI_character_type pre_one_char = 0;
  662.     UI_character_type pre_two_char = 0;
  663.     UI_character_type pre_three_char = 0;
  664. #endif /* defined(__MMI_LANG_THAI__) */ 
  665.     /* MTK End */
  666. #ifdef __MMI_HINDI_ALG__
  667.     /* Added for knowing the current character is hindi or not */
  668.     UI_buffer_type check_text_p = b->cursor_p;
  669. #endif /* __MMI_HINDI_ALG__ */ 
  670.     /*----------------------------------------------------------------*/
  671.     /* Code Body                                                      */
  672.     /*----------------------------------------------------------------*/
  673.     if (b->text == NULL)
  674.     {
  675.         UI_editor_play_tone_cannot_navigate();
  676.         return;
  677.     }
  678.     if (b->cursor_p == b->text)
  679.     {
  680.         UI_editor_play_tone_cannot_navigate();
  681.         return;
  682.     }
  683. #ifdef __MMI_HINDI_ALG__
  684.     UI_STRING_GET_PREVIOUS_CHARACTER(check_text_p, dummy_c);    /* get previous character */
  685.     /* If Hindi Character */
  686.     if (UI_HINDI_CHARACTER_UCS2_RANGE(dummy_c))
  687.     {
  688.         /* Move by a syllable rather than by a character as in English */
  689.         b->cursor_p = hf_get_prev_cluster_p(b->text, b->cursor_p);
  690.     }
  691.     else
  692. #endif /* __MMI_HINDI_ALG__ */ 
  693.     {
  694.         UI_STRING_GET_PREVIOUS_CHARACTER(b->cursor_p, dummy_c); /* get previous character */
  695.     }
  696. #if defined(__MMI_LANG_VIETNAMESE__)
  697.     if ((dummy_c >= 0x0300) && (dummy_c <= 0x0323))
  698.     {
  699.         UI_STRING_GET_PREVIOUS_CHARACTER(b->cursor_p, previous_unicode);        /* get next character */
  700.         viet_vowel = mmi_viet_vowel_letter(previous_unicode);
  701.         if (VIET_VOWEL_NONE != viet_vowel)
  702.         {
  703.             tone_mark = mmi_viet_tone_mark(dummy_c);
  704.             if (VIET_TONE_NONE != tone_mark)
  705.             {
  706.                 dummy_c = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  707.             }
  708.             else
  709.             {
  710.                 UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, previous_unicode);
  711.             }
  712.         }
  713.         else
  714.         {
  715.             UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, previous_unicode);
  716.         }
  717.     }
  718. #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  719.     /* MTK Steven 20050505  */
  720. #if defined(__MMI_LANG_THAI__)
  721.     if (isThaiChar(dummy_c))
  722.     {
  723.         UI_STRING_GET_PREVIOUS_CHARACTER(b->cursor_p, pre_one_char);
  724.         if (isThaiChar(pre_one_char))
  725.         {
  726.             if (!RequireToMoveCursor(pre_one_char, dummy_c))
  727.             {
  728.                 if (b->cursor_p != b->text)
  729.                 {
  730.                     UI_STRING_GET_PREVIOUS_CHARACTER(b->cursor_p, pre_two_char);
  731.                     if (isThaiChar(pre_two_char))
  732.                     {
  733.                         if (!RequireToMoveCursor(pre_two_char, pre_one_char))
  734.                         {
  735.                             if (b->cursor_p != b->text)
  736.                             {
  737.                                 UI_STRING_GET_PREVIOUS_CHARACTER(b->cursor_p, pre_three_char);
  738.                                 if (isThaiChar(pre_three_char))
  739.                                 {
  740.                                     if (RequireToMoveCursor(pre_three_char, pre_two_char))
  741.                                     {
  742.                                         UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  743.                                     }
  744.                                 }
  745.                                 else
  746.                                 {
  747.                                     UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  748.                                 }
  749.                             }
  750.                         }
  751.                         else
  752.                         {
  753.                             UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  754.                         }
  755.                     }
  756.                     else
  757.                     {
  758.                         UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  759.                     }
  760.                 }
  761.             }
  762.             else
  763.             {
  764.                 UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  765.             }
  766.         }
  767.         else
  768.         {
  769.             UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  770.         }
  771.     }
  772. #endif /* defined(__MMI_LANG_THAI__) */ 
  773.     /* MTK End */
  774. #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
  775.     if (IS_ARABIC_CHARACTER(dummy_c))
  776.     {
  777.         U16 idx;
  778.         idx = (b->cursor_p - b->text + 2) / 2 - 1;
  779.         while (idx > 0)
  780.         {
  781.             if (OrgToSha[idx] == OrgToSha[idx - 1])
  782.             {
  783.                 UI_STRING_GET_PREVIOUS_CHARACTER(b->cursor_p, dummy_c);
  784.             }
  785.             else
  786.             {
  787.                 break;
  788.             }
  789.             idx--;
  790.         }
  791.     }
  792. #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */ 
  793.     if (b->icon_callback)
  794.     {
  795.         /* previous_text_p is the first character to be deleted */
  796.         S32 cnt;
  797.         UI_character_type tmp_c;
  798.         UI_STRING_GET_PREVIOUS_CHARACTER(save_text_p, tmp_c);
  799.         for (cnt = 1; cnt <= MMI_MULTILINE_ICON_MAX_STRING_LEN; cnt++)
  800.         {
  801.             if (save_text_p < b->text)
  802.             {
  803.                 break;
  804.             }
  805.             if (cnt == b->icon_callback(save_text_p, MMI_FALSE, NULL, NULL, 0, 0))
  806.             {
  807.                 /* Delete an icon as character sequence */
  808.                 b->cursor_p = save_text_p;
  809.                 dummy_c = tmp_c;
  810.                 break;
  811.             }
  812.             UI_STRING_GET_PREVIOUS_CHARACTER(save_text_p, tmp_c);
  813.         }
  814.     }
  815. #if(MULTILINE_INPUTBOX_USE_CRLF_COMBINATION)
  816.     else if (UI_TEST_LF_CHARACTER(dummy_c) && (b->cursor_p != b->text))
  817.     {
  818.         UI_STRING_GET_PREVIOUS_CHARACTER(b->cursor_p, dummy_c);
  819.         if (!UI_TEST_CR_CHARACTER(dummy_c))
  820.         {
  821.             UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  822.         }
  823.     }
  824. #endif /* (MULTILINE_INPUTBOX_USE_CRLF_COMBINATION) */ 
  825.     
  826.     if (b->show_action_flag)
  827.     {
  828.         b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  829.         gui_show_multi_line_input_box(b);   /* show multiline input box */
  830.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  831.     }
  832.     
  833. }
  834. /*****************************************************************************
  835.  * FUNCTION
  836.  *  gui_multi_line_input_box_next
  837.  * DESCRIPTION
  838.  *  Moves the cursor to the next character
  839.  * PARAMETERS
  840.  *  b       [IN]        Is the multi-line inputbox object
  841.  * RETURNS
  842.  *  void
  843.  *****************************************************************************/
  844. void gui_multi_line_input_box_next(multi_line_input_box *b)
  845. {
  846.     /*----------------------------------------------------------------*/
  847.     /* Local Variables                                                */
  848.     /*----------------------------------------------------------------*/
  849.     UI_buffer_type cursor_p = b->cursor_p;
  850.     UI_character_type current_character;
  851. #if defined(__MMI_LANG_VIETNAMESE__)
  852.     UI_character_type next_unicode = 0;
  853.     viet_tone_mark tone_mark = VIET_TONE_NONE;
  854.     viet_vowel_letter viet_vowel = VIET_VOWEL_NONE;
  855. #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  856.     /* MTK Steven 20050505 */
  857. #if defined(__MMI_LANG_THAI__)
  858.     UI_character_type next_one_char = 0;
  859.     UI_character_type next_two_char = 0;
  860.     UI_character_type next_three_char = 0;
  861. #endif /* defined(__MMI_LANG_THAI__) */ 
  862.     /* MTK End */
  863. #ifdef __MMI_HINDI_ALG__
  864.     /* Added for knowing the current character is hindi or not */
  865.     UI_buffer_type check_text_p = b->cursor_p;
  866. #endif /* __MMI_HINDI_ALG__ */ 
  867.     /*----------------------------------------------------------------*/
  868.     /* Code Body                                                      */
  869.     /*----------------------------------------------------------------*/
  870.     if (b->text == NULL)
  871.     {
  872.         UI_editor_play_tone_cannot_navigate();
  873.         return;
  874.     }
  875. #ifdef __MMI_HINDI_ALG__
  876.     UI_STRING_GET_NEXT_CHARACTER(check_text_p, current_character);      /* get previous character */
  877.     /* If Hindi Character */
  878.     if (UI_HINDI_CHARACTER_UCS2_RANGE(current_character))
  879.     {
  880.         /* Move by a syllable rather than by a character as in English */
  881.         cursor_p = (U8*) hf_get_next_cluster_p(b->cursor_p, b->cursor_p);
  882.     }
  883.     else
  884. #endif /* __MMI_HINDI_ALG__ */ 
  885.     {
  886.         UI_STRING_GET_NEXT_CHARACTER(cursor_p, current_character);      /* get next character */
  887.     }
  888. #if defined(__MMI_LANG_VIETNAMESE__)
  889.     if ((current_character > 0x0040) && (current_character < 0x01B1))
  890.     {
  891.         UI_STRING_GET_NEXT_CHARACTER(cursor_p, next_unicode);   /* get next character */
  892.         tone_mark = mmi_viet_tone_mark(next_unicode);
  893.         if (VIET_TONE_NONE != tone_mark)
  894.         {
  895.             viet_vowel = mmi_viet_vowel_letter(current_character);
  896.             if (VIET_VOWEL_NONE != viet_vowel)
  897.             {
  898.                 current_character = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  899.             }
  900.             else
  901.             {
  902.                 UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, next_unicode);
  903.             }
  904.         }
  905.         else
  906.         {
  907.             UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, next_unicode);
  908.         }
  909.     }
  910. #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  911.     /* MTK Steven 20050505 */
  912. #if defined(__MMI_LANG_THAI__)
  913.     if (isThaiChar(current_character) && *cursor_p != '')
  914.     {
  915.         UI_STRING_GET_NEXT_CHARACTER(cursor_p, next_one_char);
  916.         if (isThaiChar(next_one_char))
  917.         {
  918.             if (!RequireToMoveCursor(current_character, next_one_char))
  919.             {
  920.                 if (*cursor_p == '')
  921.                 {
  922.                     current_character = next_one_char;
  923.                 }
  924.                 else
  925.                 {
  926.                     UI_STRING_GET_NEXT_CHARACTER(cursor_p, next_two_char);
  927.                     if (isThaiChar(next_two_char))
  928.                     {
  929.                         if (!RequireToMoveCursor(next_one_char, next_two_char))
  930.                         {
  931.                             if (*cursor_p == '')
  932.                             {
  933.                                 current_character = next_two_char;
  934.                             }
  935.                             else
  936.                             {
  937.                                 UI_STRING_GET_NEXT_CHARACTER(cursor_p, next_three_char);
  938.                                 if (isThaiChar(next_three_char))
  939.                                 {
  940.                                     if (!RequireToMoveCursor(next_two_char, next_three_char))
  941.                                     {
  942.                                         current_character = next_three_char;
  943.                                     }
  944.                                     else
  945.                                     {
  946.                                         UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  947.                                     }
  948.                                 }
  949.                                 else
  950.                                 {
  951.                                     UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  952.                                 }
  953.                             }
  954.                         }
  955.                         else
  956.                         {
  957.                             UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  958.                         }
  959.                     }
  960.                     else
  961.                     {
  962.                         UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  963.                     }
  964.                 }
  965.             }
  966.             else
  967.             {
  968.                 UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  969.             }
  970.         }
  971.         else
  972.         {
  973.             UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  974.         }
  975.     }
  976. #endif /* defined(__MMI_LANG_THAI__) */ 
  977.     /* MTK End */
  978. #if defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__)
  979.     if (IS_ARABIC_CHARACTER(current_character))
  980.     {
  981.         U16 idx;
  982.         idx = (cursor_p - b->text) / 2 - 1;
  983.         while (idx < unshaped_text_len)
  984.         {
  985.             if (OrgToSha[idx] == OrgToSha[idx + 1])
  986.             {
  987.                 UI_STRING_GET_NEXT_CHARACTER(cursor_p, current_character);
  988.             }
  989.             else
  990.             {
  991.                 break;
  992.             }
  993.             idx++;
  994.         }
  995.     }
  996. #endif /* defined(__MMI_LANG_ARABIC__) || defined(__MMI_LANG_PERSIAN__) */ 
  997.     if (UI_STRING_END_OF_STRING_CHARACTER(current_character))
  998.     {
  999.         UI_editor_play_tone_cannot_navigate();
  1000.         return;
  1001.     }
  1002.     if (b->icon_callback)
  1003.     {
  1004.         S32 cnt;
  1005.         if ((cnt = b->icon_callback(b->cursor_p, MMI_FALSE, NULL, NULL, 0, 0)) > 0)
  1006.         {
  1007.             cursor_p = b->cursor_p + ((cnt - 1) << 1);
  1008.             UI_STRING_GET_NEXT_CHARACTER(cursor_p, current_character);
  1009.         }
  1010.     }
  1011. #if(MULTILINE_INPUTBOX_USE_CRLF_COMBINATION)
  1012.     else if (UI_TEST_CR_CHARACTER(current_character))
  1013.     {
  1014.         UI_STRING_GET_NEXT_CHARACTER(cursor_p, current_character);
  1015.         if (!UI_TEST_LF_CHARACTER(current_character))
  1016.         {
  1017.             UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  1018.         }
  1019.     }
  1020. #endif /* (MULTILINE_INPUTBOX_USE_CRLF_COMBINATION) */ 
  1021.     b->cursor_p = cursor_p;
  1022.     
  1023.     if (b->show_action_flag)
  1024.     {
  1025.         b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1026.         gui_show_multi_line_input_box(b);   /* show multiline input box */
  1027.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1028.     }
  1029.    
  1030. }
  1031. #if(MULTILINE_INPUTBOX_USE_CRLF_COMBINATION)
  1032. /*****************************************************************************
  1033.  * FUNCTION
  1034.  *  gui_multi_line_input_box_handle_CRLF_navigation
  1035.  * DESCRIPTION
  1036.  *  
  1037.  * PARAMETERS
  1038.  *  b       [?]     
  1039.  * RETURNS
  1040.  *  void
  1041.  *****************************************************************************/
  1042. void gui_multi_line_input_box_handle_CRLF_navigation(multi_line_input_box *b)
  1043. {
  1044.     /*----------------------------------------------------------------*/
  1045.     /* Local Variables                                                */
  1046.     /*----------------------------------------------------------------*/
  1047.     UI_buffer_type cursor_p = b->cursor_p;
  1048.     UI_character_type current_character;
  1049.     /*----------------------------------------------------------------*/
  1050.     /* Code Body                                                      */
  1051.     /*----------------------------------------------------------------*/
  1052.     UI_STRING_GET_NEXT_CHARACTER(cursor_p, current_character);
  1053.     if (UI_TEST_LF_CHARACTER(current_character))
  1054.     {
  1055.         UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  1056.         UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, current_character);
  1057.         if (UI_TEST_CR_CHARACTER(current_character))
  1058.         {
  1059.             UI_STRING_GET_PREVIOUS_CHARACTER(b->cursor_p, current_character);
  1060.         }
  1061.     }
  1062. }
  1063. #endif /* (MULTILINE_INPUTBOX_USE_CRLF_COMBINATION) */ 
  1064. /* Used for move to next and previous line */
  1065. /*****************************************************************************
  1066.  * FUNCTION
  1067.  *  gui_multi_line_input_box_handle_icon_navigation
  1068.  * DESCRIPTION
  1069.  *  
  1070.  * PARAMETERS
  1071.  *  b       [?]     
  1072.  * RETURNS
  1073.  *  void
  1074.  *****************************************************************************/
  1075. void gui_multi_line_input_box_handle_icon_navigation(multi_line_input_box *b)
  1076. {
  1077.     /*----------------------------------------------------------------*/
  1078.     /* Local Variables                                                */
  1079.     /*----------------------------------------------------------------*/
  1080.     UI_buffer_type cursor_p = b->cursor_p;
  1081.     UI_character_type dummy_c;
  1082.     S32 cnt;
  1083.     /*----------------------------------------------------------------*/
  1084.     /* Code Body                                                      */
  1085.     /*----------------------------------------------------------------*/
  1086.     if (!b->icon_callback)
  1087.     {
  1088.         return;
  1089.     }
  1090.     UI_STRING_GET_PREVIOUS_CHARACTER(cursor_p, dummy_c);
  1091.     for (cnt = 2; cnt <= MMI_MULTILINE_ICON_MAX_STRING_LEN; cnt++)
  1092.     {
  1093.         /* Inside character sequence */
  1094.         if (b->icon_callback(cursor_p, MMI_FALSE, NULL, NULL, 0, 0) >= cnt)
  1095.         {
  1096.             b->cursor_p = cursor_p;
  1097.             break;
  1098.         }
  1099.     }
  1100. }
  1101. /*****************************************************************************
  1102.  * FUNCTION
  1103.  *  gui_multi_line_input_box_previous_line
  1104.  * DESCRIPTION
  1105.  *  Moves the cursor to the previous line
  1106.  * PARAMETERS
  1107.  *  b       [IN]        Is the multi-line inputbox object
  1108.  * RETURNS
  1109.  *  void
  1110.  *****************************************************************************/
  1111. void gui_multi_line_input_box_previous_line(multi_line_input_box *b)
  1112. {
  1113.     /*----------------------------------------------------------------*/
  1114.     /* Local Variables                                                */
  1115.     /*----------------------------------------------------------------*/
  1116.     S32 i, fh;
  1117.     UI_buffer_type p;
  1118.     UI_character_type dummy_c = 0;
  1119.     S32 line_width = 0, width = 0, height = 0;
  1120.     /*----------------------------------------------------------------*/
  1121.     /* Code Body                                                      */
  1122.     /*----------------------------------------------------------------*/
  1123.     /* MTK Terry For Font Type when Key Down or UP */
  1124.     gui_set_font(b->text_font);
  1125.     if (b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE)
  1126.     {
  1127.         if (b->text_offset_y < 0)
  1128.         {
  1129.             /* Note that scrolling offset might be exactly one line if UI_MULTI_LINE_INPUT_BOX_RICHTEXT is set. */
  1130.             fh = gui_get_character_height() + 1;    /* +1 added for 1 pixel gap between lines */
  1131.             b->text_offset_y += fh;
  1132.             if (b->text_offset_y > 0)
  1133.             {
  1134.                 b->text_offset_y = 0;
  1135.             }
  1136.         }
  1137.         else if (b->flags & UI_MULTI_LINE_INPUT_BOX_INSIDE_INLINE_MENU) /* Pixtel - 2/16/04 - Gurinder - Move to the previos item on up key in case on inline box. */
  1138.         {
  1139.             //Gurinder - 20/4/2004 - Use Inline Navigation Function Instead Of Noraml Text Menu
  1140.             //gui_fixed_list_menu_goto_previous_item(&MMI_fixed_list_menu);
  1141.             //show_fixed_list();
  1142.             //inline_fixed_list_goto_previous_item();
  1143.             hilited_item_changed = 1;
  1144.         }
  1145.     }
  1146.     else
  1147.     {
  1148.         if (b->line_before_cursor_line_p == b->cursor_line_p)
  1149.         {
  1150.         #if defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__)
  1151.             if (MMI_multi_line_inputbox_present)
  1152.             {
  1153.                 //handle_inline_full_screen_edit_close();
  1154.                 //Gurinder - 20/4/2004 - Use Inline Navigation Function Instead Of Noraml Text Menu
  1155.                 //gui_fixed_list_menu_goto_previous_item(&MMI_fixed_list_menu);
  1156.                 //show_fixed_list();
  1157.                 //inline_fixed_list_goto_previous_item();
  1158.                 hilited_item_changed = 1;
  1159.             }
  1160.             else
  1161.         #endif /* defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__) */ 
  1162.             if (b->header_height > 0 && b->text_offset_y < 0)
  1163.             {
  1164.                 b->text_offset_y += 20;
  1165.                 if (b->text_offset_y > 0)
  1166.                 {
  1167.                     b->text_offset_y = 0;
  1168.                 }
  1169.                 b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1170. b->ext_flags |= GUI_MULTI_LINE_INPUT_BOX_DISABLE_FORCE_CURSOR_APPEAR;
  1171.                 gui_show_multi_line_input_box(b);   /* show multiline input box */
  1172.                 b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1173. b->ext_flags &= ~GUI_MULTI_LINE_INPUT_BOX_DISABLE_FORCE_CURSOR_APPEAR;
  1174. StopMyTimer(BLINKING_CURSOR);
  1175.             }
  1176.             else
  1177.             {
  1178.                 UI_editor_play_tone_cannot_navigate();  /* play error tone */
  1179.             }
  1180.             return;
  1181.         }
  1182.         /* MTK Terry for Move Up by Width */
  1183.         UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  1184.         gui_measure_character(dummy_c, &width, &height);
  1185.         if (UI_TEST_CR_CHARACTER(dummy_c))
  1186.         {
  1187.             width = 0;
  1188.         }
  1189.         else if (UI_TEST_LF_CHARACTER(dummy_c))
  1190.         {
  1191.             width = 0;
  1192.         }
  1193.         else if (UI_STRING_END_OF_STRING_CHARACTER(dummy_c))
  1194.         {
  1195.             width = 0;
  1196.         }
  1197.         b->cursor_x -= (width);
  1198.         p = b->cursor_p = b->line_before_cursor_line_p;
  1199.         for (i = 0; line_width <= b->cursor_x + (width >> 1); i++)
  1200.         {
  1201.             if (p == b->cursor_line_p)
  1202.             {
  1203.                 break;
  1204.             }
  1205.             else
  1206.             {
  1207.                 b->cursor_p = p;
  1208.             }
  1209.             UI_STRING_GET_NEXT_CHARACTER(p, dummy_c);
  1210.         #if defined(__MMI_LANG_VIETNAMESE__)
  1211.             /* MTK Terry for Cursor Move Up and Down Issue */
  1212.             if ((dummy_c > 0x0040) && (dummy_c < 0x01B1))
  1213.             {
  1214.                 UI_character_type next_unicode = 0;
  1215.                 viet_tone_mark tone_mark = VIET_TONE_NONE;
  1216.                 viet_vowel_letter viet_vowel = VIET_VOWEL_NONE;
  1217.                 UI_STRING_GET_NEXT_CHARACTER(p, next_unicode);  /* get next character */
  1218.                 tone_mark = mmi_viet_tone_mark(next_unicode);
  1219.                 if (VIET_TONE_NONE != tone_mark)
  1220.                 {
  1221.                     viet_vowel = mmi_viet_vowel_letter(dummy_c);
  1222.                     if (VIET_VOWEL_NONE != viet_vowel)
  1223.                     {
  1224.                         dummy_c = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  1225.                     }
  1226.                     else
  1227.                     {
  1228.                         UI_STRING_GET_PREVIOUS_CHARACTER(p, next_unicode);
  1229.                     }
  1230.                 }
  1231.                 else
  1232.                 {
  1233.                     UI_STRING_GET_PREVIOUS_CHARACTER(p, next_unicode);
  1234.                 }
  1235.             }
  1236.         #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  1237.             gui_measure_character(dummy_c, &width, &height);
  1238.             line_width += (width + b->text_gap);
  1239.         }
  1240.         gui_multi_line_input_box_handle_icon_navigation(b);
  1241.     #if(MULTILINE_INPUTBOX_USE_CRLF_COMBINATION)
  1242.         gui_multi_line_input_box_handle_CRLF_navigation(b);
  1243.     #endif 
  1244.         //hjf,force to update offset_y b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1245.         gui_show_multi_line_input_box(b);   /* show multiline input box */
  1246.         //hjf,force to update offset_y b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1247.     }
  1248.     UI_UNUSED_PARAMETER(dummy_c);
  1249. }
  1250. /*****************************************************************************
  1251.  * FUNCTION
  1252.  *  gui_multi_line_input_box_next_line
  1253.  * DESCRIPTION
  1254.  *  Moves the cursor to the next line
  1255.  * PARAMETERS
  1256.  *  b       [IN]        Is the multi-line inputbox object
  1257.  * RETURNS
  1258.  *  void
  1259.  *****************************************************************************/
  1260. void gui_multi_line_input_box_next_line(multi_line_input_box *b)
  1261. {
  1262.     /*----------------------------------------------------------------*/
  1263.     /* Local Variables                                                */
  1264.     /*----------------------------------------------------------------*/
  1265.     /* MTK Terry Redesign the next line operation */
  1266.     /* Some issues happened because the dh is not the same as the b->text_height and we can't get the next line height */
  1267.     /* We use b->text_height instead of dh and adjust the move distance when reaching the last line of the text */
  1268.     S32 i, fh /* ,dh */ ;
  1269.     UI_buffer_type p;
  1270.     UI_character_type dummy_c = 0;
  1271.     S32 line_width = 0, width = 0, height = 0;
  1272.     /*----------------------------------------------------------------*/
  1273.     /* Code Body                                                      */
  1274.     /*----------------------------------------------------------------*/
  1275.     /* MTK Terry For Font Type when Key Down or UP */
  1276.     gui_set_font(b->text_font);
  1277.     if (b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE)
  1278.     {
  1279.         /* Note that scrolling offset might be exactly one line if UI_MULTI_LINE_INPUT_BOX_RICHTEXT is set. */
  1280.         fh = gui_get_character_height() + 1;    /* +1 added for 1 pixel gap between lines */
  1281.         if (fh <= 0)
  1282.         {
  1283.             fh = 1;
  1284.         }
  1285.         /* Leo add: enlarge the hidden area to show all strings when strings with different languages */
  1286.         //dh=(b->edit_height/fh);   /*MTK Terry roll back for stop watch title display need to discuss with Leo*/
  1287.         //dh=(b->edit_height/fh)-1;
  1288.         //dh*=fh;
  1289.         //START TARUN PMT 20041023 Added for sms chat issue
  1290.         //if ( (b->text_offset_y-fh)!=(-(b->text_height-(dh+fh)))) /*Comment this line here and have no idea why to need this line*/
  1291.         //END TARUN PMT 20041023
  1292.         {
  1293.             /* MTK Terry for In-Line Multiline Next Line Behavior */
  1294.             if ((b->text_offset_y /*-fh */ ) > (-(b->text_height - b->edit_height /* dh */ )))
  1295.             {
  1296.                 b->text_offset_y -= fh;
  1297.                 if (b->text_offset_y < b->edit_height - b->text_height)
  1298.                 {
  1299.                     b->text_offset_y = b->edit_height - b->text_height;
  1300.                 }
  1301.             }
  1302.             else if (b->flags & UI_MULTI_LINE_INPUT_BOX_INSIDE_INLINE_MENU)
  1303.             {
  1304.                 //Gurinder - 20/4/2004 - Use Inline Navigation Function Instead Of Noraml Text Menu
  1305.                 //gui_fixed_list_menu_goto_first_item(&MMI_fixed_list_menu);
  1306.                 /* MTK Terry for in line multiline read only to clear g_mmi_wgui_halfline_marquee_scroll_enable */
  1307.                 if (complete_inline_item_edit)
  1308.                 {
  1309.                     complete_inline_item_edit();
  1310.                 }
  1311.                 inline_fixed_list_goto_next_item();
  1312.                 hilited_item_changed = 1;
  1313.                 //show_fixed_list();
  1314.                 //Fix List Navigation Problem With Read Only Control - Gurinder - 3/27/2004.
  1315.                 //register_fixed_list_keys();
  1316.                 //End
  1317.             }
  1318.         }
  1319.     }
  1320.     else    /* b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE */
  1321.     {
  1322.         if (b->line_after_cursor_line_p == b->cursor_line_p)
  1323.         {
  1324.         #if defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__)
  1325.             if (MMI_multi_line_inputbox_present)
  1326.             {
  1327.                 //handle_inline_full_screen_edit_close();
  1328.                 //Gurinder - 20/4/2004 - Use Inline Navigation Function Instead Of Noraml Text Menu
  1329.                 //inline_fixed_list_goto_next_item();
  1330.                 //gui_fixed_list_menu_goto_next_item(&MMI_fixed_list_menu);
  1331.                 //show_fixed_list();
  1332.                 hilited_item_changed = 1;
  1333.             }
  1334.             else
  1335.         #endif /* defined(__MMI_INSCREEN_MULTILINE_TEXTBOX__) */ 
  1336.             if (b->footer_height > 0 && (b->text_offset_y + b->text_height > b->edit_height))
  1337.             {
  1338.                 b->text_offset_y -= 20;
  1339.                 if (b->text_offset_y < b->edit_height - b->text_height)
  1340.                 {
  1341.                     b->text_offset_y = b->edit_height - b->text_height;
  1342.                 }
  1343.                 b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1344. b->ext_flags |= GUI_MULTI_LINE_INPUT_BOX_DISABLE_FORCE_CURSOR_APPEAR;
  1345.                 gui_show_multi_line_input_box(b);   /* show multiline input box */
  1346.                 b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1347. b->ext_flags &=~GUI_MULTI_LINE_INPUT_BOX_DISABLE_FORCE_CURSOR_APPEAR;
  1348. StopMyTimer(BLINKING_CURSOR);
  1349.             }
  1350.             else
  1351.             {
  1352.                 UI_editor_play_tone_cannot_navigate();
  1353.             }
  1354.             return;
  1355.         }
  1356.         /* MTK Terry for Move Down by Width */
  1357.         UI_STRING_GET_NEXT_CHARACTER(b->cursor_p, dummy_c);
  1358.         gui_measure_character(dummy_c, &width, &height);
  1359.         if (UI_TEST_CR_CHARACTER(dummy_c))
  1360.         {
  1361.             width = 0;
  1362.         }
  1363.         else if (UI_TEST_LF_CHARACTER(dummy_c))
  1364.         {
  1365.             width = 0;
  1366.         }
  1367.         else if (UI_STRING_END_OF_STRING_CHARACTER(dummy_c))
  1368.         {
  1369.             width = 0;
  1370.         }
  1371.         b->cursor_x -= (width);
  1372.         p = b->cursor_p = b->line_after_cursor_line_p;
  1373.         for (i = 0; line_width <= b->cursor_x + (width >> 1); i++)
  1374.         {
  1375.             /* MTK Terry for Cursor Moving */
  1376.             b->cursor_p = p;
  1377.             if (p == b->line_after_cursor_line_last_p)
  1378.             {
  1379.                 break;
  1380.             }
  1381.             UI_STRING_GET_NEXT_CHARACTER(p, dummy_c);
  1382.         #if defined(__MMI_LANG_VIETNAMESE__)
  1383.             /* MTK Terry for Cursor Move Up and Down Issue */
  1384.             if ((dummy_c > 0x0040) && (dummy_c < 0x01B1))
  1385.             {
  1386.                 UI_character_type next_unicode = 0;
  1387.                 viet_tone_mark tone_mark = VIET_TONE_NONE;
  1388.                 viet_vowel_letter viet_vowel = VIET_VOWEL_NONE;
  1389.                 UI_STRING_GET_NEXT_CHARACTER(p, next_unicode);  /* get next character */
  1390.                 tone_mark = mmi_viet_tone_mark(next_unicode);
  1391.                 if (VIET_TONE_NONE != tone_mark)
  1392.                 {
  1393.                     viet_vowel = mmi_viet_vowel_letter(dummy_c);
  1394.                     if (VIET_VOWEL_NONE != viet_vowel)
  1395.                     {
  1396.                         dummy_c = mmi_viet_combine_vowel_tone(viet_vowel, tone_mark);
  1397.                     }
  1398.                     else
  1399.                     {
  1400.                         UI_STRING_GET_PREVIOUS_CHARACTER(p, next_unicode);
  1401.                     }
  1402.                 }
  1403.                 else
  1404.                 {
  1405.                     UI_STRING_GET_PREVIOUS_CHARACTER(p, next_unicode);
  1406.                 }
  1407.             }
  1408.         #endif /* defined(__MMI_LANG_VIETNAMESE__) */ 
  1409.             gui_measure_character(dummy_c, &width, &height);
  1410.             line_width += (width + b->text_gap);
  1411.         }
  1412.         gui_multi_line_input_box_handle_icon_navigation(b);
  1413.     #if(MULTILINE_INPUTBOX_USE_CRLF_COMBINATION)
  1414.         gui_multi_line_input_box_handle_CRLF_navigation(b);
  1415.     #endif 
  1416.         //hjf,force to update offset_y b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1417.         gui_show_multi_line_input_box(b);   /* show multiline input box */
  1418.         //hjf,force to update offset_y b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1419.     }
  1420.     UI_UNUSED_PARAMETER(dummy_c);
  1421. }
  1422. /*****************************************************************************
  1423.  * FUNCTION
  1424.  *  gui_multi_line_input_box_previous_page
  1425.  * DESCRIPTION
  1426.  *  Moves the cursor to the previous page
  1427.  * PARAMETERS
  1428.  *  b       [IN]        Is the multi-line inputbox object
  1429.  * RETURNS
  1430.  *  void
  1431.  *****************************************************************************/
  1432. void gui_multi_line_input_box_previous_page(multi_line_input_box *b)
  1433. {
  1434.     /*----------------------------------------------------------------*/
  1435.     /* Local Variables                                                */
  1436.     /*----------------------------------------------------------------*/
  1437.     /*----------------------------------------------------------------*/
  1438.     /* Code Body                                                      */
  1439.     /*----------------------------------------------------------------*/
  1440. #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  1441.     if (b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_VIEW_PAGING_MODE)
  1442.     {
  1443.         gui_paging_multi_line_input_box_previous_page(b);
  1444.     }
  1445.     else
  1446.     {
  1447. #endif /* __UI_PAGING_IN_MULTILINE_EDITOR__ */
  1448.         UI_UNUSED_PARAMETER(b);
  1449.         /* Feature not available */
  1450. #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  1451.     }
  1452. #endif /* __UI_PAGING_IN_MULTILINE_EDITOR__ */
  1453. }
  1454. /*****************************************************************************
  1455.  * FUNCTION
  1456.  *  gui_multi_line_input_box_next_page
  1457.  * DESCRIPTION
  1458.  *  Moves the cursor to the next page
  1459.  * PARAMETERS
  1460.  *  b       [IN]        Is the multi-line inputbox object
  1461.  * RETURNS
  1462.  *  void
  1463.  *****************************************************************************/
  1464. void gui_multi_line_input_box_next_page(multi_line_input_box *b)
  1465. {
  1466.     /*----------------------------------------------------------------*/
  1467.     /* Local Variables                                                */
  1468.     /*----------------------------------------------------------------*/
  1469.     /*----------------------------------------------------------------*/
  1470.     /* Code Body                                                      */
  1471.     /*----------------------------------------------------------------*/
  1472. #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  1473.     if (b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_VIEW_PAGING_MODE)
  1474.     {
  1475.         gui_paging_multi_line_input_box_next_page(b);
  1476.     }
  1477.     else
  1478.     {
  1479. #endif /* __UI_PAGING_IN_MULTILINE_EDITOR__ */       
  1480.         UI_UNUSED_PARAMETER(b);
  1481.         /* Feature not available */
  1482. #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  1483.     }
  1484. #endif /* __UI_PAGING_IN_MULTILINE_EDITOR__ */
  1485. }
  1486. #ifdef __UI_PAGING_IN_MULTILINE_EDITOR__
  1487. /*****************************************************************************
  1488.  * FUNCTION
  1489.  *  gui_paging_multi_line_input_box_previous_page
  1490.  * DESCRIPTION
  1491.  *  show the previous page of the book
  1492.  * PARAMETERS
  1493.  *  b       [IN]        Is the multi-line inputbox object
  1494.  * RETURNS
  1495.  *  void
  1496.  *****************************************************************************/
  1497. void gui_paging_multi_line_input_box_previous_page(multi_line_input_box *b)
  1498. {
  1499.     /*----------------------------------------------------------------*/
  1500.     /* Local Variables                                                */
  1501.     /*----------------------------------------------------------------*/
  1502.     S32 fh;
  1503.     UI_character_type dummy_c = 0;
  1504.     /*----------------------------------------------------------------*/
  1505.     /* Code Body                                                      */
  1506.     /*----------------------------------------------------------------*/
  1507.     gui_set_font(b->text_font);
  1508.     if (b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE)
  1509.     {
  1510.         if (b->text_offset_y < 0)
  1511.         {
  1512.             fh = gui_get_character_height() + 1;    /* +1 added for 1 pixel gap between lines */
  1513.             if (b->end_id == b->last_page_id && b->last_page_flag == 1)
  1514.             {
  1515.                 /* prev_height=height of the text in the last page which can be a maximum of the window height.This variable is used to 
  1516.                    maintain the text relocation */
  1517.                 b->text_offset_y += b->last_window_text_height;
  1518.                 b->last_page_flag = 0;
  1519.             }
  1520.             else
  1521.             {
  1522.                 b->text_offset_y += b->edit_height_displayed_lines;
  1523.             }
  1524.             if (b->text_offset_y >= -(b->page_details[PAGE_ZERO].page_height - b->edit_height_displayed_lines) &&
  1525.                 b->size_of_total_data > GUI_PAGE_SIZE)
  1526.             {
  1527.                 gui_paging_multi_line_input_box_get_previous_page_callback(b);
  1528.                 if (b->page_details[PAGE_ZERO].page_id != 0)
  1529.                 {
  1530.                     b->text_offset_y -= b->page_details[PAGE_ZERO].page_height;
  1531.                     /*
  1532.                      * to maintain the text relocation issue we save the height of page at 0th index before a new page entry.According to 
  1533.                      * paging algorithm,after a new page entry ,page at 0th index will come to index 1 of the buffer.If the height of the saved value differs 
  1534.                      * with the height of page at index 1 then this condition will be tested
  1535.                      */
  1536.                     b->page_details[PAGE_ZERO].page_id = b->start_id;
  1537.                     if (b->page_zero_prev_height != b->page_details[PAGE_ONE].page_height)
  1538.                     {
  1539.                         b->text_offset_y -= fh;
  1540.                     }
  1541.                 }
  1542.             }
  1543.             if (b->text_offset_y > 0)
  1544.             {
  1545.                 b->text_offset_y = 0;
  1546.             }
  1547.         }
  1548.     }
  1549.     UI_UNUSED_PARAMETER(dummy_c);
  1550. }
  1551. /*****************************************************************************
  1552.  * FUNCTION
  1553.  *  gui_paging_multi_line_input_box_next_page
  1554.  * DESCRIPTION
  1555.  *  show the next page of the book
  1556.  * PARAMETERS
  1557.  *  b       [IN]        Is the multi-line inputbox object
  1558.  * RETURNS
  1559.  *  void
  1560.  *****************************************************************************/
  1561. void gui_paging_multi_line_input_box_next_page(multi_line_input_box *b)
  1562. {
  1563.     /*----------------------------------------------------------------*/
  1564.     /* Local Variables                                                */
  1565.     /*----------------------------------------------------------------*/
  1566.     S32 fh;
  1567.     UI_character_type dummy_c = 0;
  1568.     /* static S32 percentage_offset = 0; */
  1569.     /*----------------------------------------------------------------*/
  1570.     /* Code Body                                                      */
  1571.     /*----------------------------------------------------------------*/
  1572.     gui_set_font(b->text_font);
  1573.     if (b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE)
  1574.     {
  1575.         fh = gui_get_character_height() + 1;    /* +1 added for 1 pixel gap between lines */
  1576.         if (fh <= 0)
  1577.         {
  1578.             fh = 1;
  1579.         }
  1580.         if ((b->text_offset_y) > (-(b->text_height - b->edit_height)))
  1581.         {
  1582.             b->text_offset_y -= b->edit_height_displayed_lines; /* ritesh */
  1583.             if (b->text_offset_y <=
  1584.                 -(b->page_details[PAGE_ZERO].page_height + b->page_details[PAGE_ONE].page_height +
  1585.                   b->page_details[PAGE_TWO].page_height - b->edit_height_displayed_lines))
  1586.             {
  1587.                 if (b->end_id < b->last_page_id)
  1588.                 {
  1589.                     b->text_offset_y += b->page_details[PAGE_ZERO].page_height;
  1590.                     gui_paging_multi_line_input_box_get_next_page_callback(b);
  1591.                 }
  1592.                 else
  1593.                 {
  1594.                     if (b->text_offset_y - b->edit_height_displayed_lines < -b->text_height && b->last_page_flag == 0)
  1595.                     {
  1596.                         b->last_window_text_height = b->text_height + b->text_offset_y;
  1597.                         b->last_page_flag = 1;
  1598.                     }
  1599.                 }
  1600.             }
  1601.             if (b->text_offset_y < b->edit_height - b->text_height)
  1602.             {
  1603.                 b->text_offset_y = b->edit_height_displayed_lines - b->text_height;
  1604.             }
  1605.         }
  1606.     }
  1607.     UI_UNUSED_PARAMETER(dummy_c);
  1608. }
  1609. /*****************************************************************************
  1610.  * FUNCTION
  1611.  *  gui_paging_multi_line_input_box_next_line_in_paging
  1612.  * DESCRIPTION
  1613.  *  show the next line of current page
  1614.  * PARAMETERS
  1615.  *  b       [IN]        Is the multi-line inputbox object
  1616.  * RETURNS
  1617.  *  void
  1618.  *****************************************************************************/
  1619. void gui_paging_multi_line_input_box_next_line_in_paging(multi_line_input_box *b)
  1620. {
  1621.     /*----------------------------------------------------------------*/
  1622.     /* Local Variables                                                */
  1623.     /*----------------------------------------------------------------*/
  1624.     S32 fh;
  1625.     UI_character_type dummy_c = 0;
  1626.     /*----------------------------------------------------------------*/
  1627.     /* Code Body                                                      */
  1628.     /*----------------------------------------------------------------*/
  1629.     gui_set_font(b->text_font);
  1630.     if (b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE)
  1631.     {
  1632.         fh = gui_get_character_height() + 1;    /* +1 added for 1 pixel gap between lines */
  1633.         if (fh <= 0)
  1634.         {
  1635.             fh = 1;
  1636.         }
  1637.         if ((b->text_offset_y) > (-(b->text_height - b->edit_height)))
  1638.         {
  1639.             if (b->ext_flags & GUI_MULTI_LINE_INPUT_BOX_AUTO_SCROLL_MODE && b->scroll_speed != 0 &&
  1640.                 b->next_line_scroll_flag == 0)
  1641.             {
  1642.                 b->text_offset_y -= (fh * b->scroll_speed) / GUI_SCROLL_STEPS_LINE_BY_LINE;     /* ritesh */
  1643.             }
  1644.             else
  1645.             {
  1646.                 b->text_offset_y -= fh;
  1647.                 b->next_line_scroll_flag = 0;
  1648.             }
  1649.             /* if text_offset_y reaches to the height of last page -  currently dispalyed height then we need next page */
  1650.             if (b->text_offset_y <=
  1651.                 -(b->page_details[PAGE_ZERO].page_height + b->page_details[PAGE_ONE].page_height +
  1652.                   b->page_details[PAGE_TWO].page_height - b->edit_height_displayed_lines))
  1653.             {
  1654.                 if (b->end_id <= b->last_page_id - 1)
  1655.                 {
  1656.                     b->text_offset_y += b->page_details[PAGE_ZERO].page_height;
  1657.                     gui_paging_multi_line_input_box_get_next_page_callback(b);
  1658.                 }
  1659.             }
  1660.             if (b->text_offset_y < b->edit_height - b->text_height)
  1661.             {
  1662.                 b->text_offset_y = b->edit_height - b->text_height;
  1663.             }
  1664.         }
  1665.     }
  1666.     UI_UNUSED_PARAMETER(dummy_c);
  1667. }
  1668. /*****************************************************************************
  1669.  * FUNCTION
  1670.  *  gui_paging_multi_line_input_box_previous_line_in_paging
  1671.  * DESCRIPTION
  1672.  *  show the previous line of current page
  1673.  * PARAMETERS
  1674.  *  b       [IN]        Is the multi-line inputbox object
  1675.  * RETURNS
  1676.  *  void
  1677.  *****************************************************************************/
  1678. void gui_paging_multi_line_input_box_previous_line_in_paging(multi_line_input_box *b)
  1679. {
  1680.     /*----------------------------------------------------------------*/
  1681.     /* Local Variables                                                */
  1682.     /*----------------------------------------------------------------*/
  1683.     S32 fh;
  1684.     UI_character_type dummy_c = 0;
  1685.     /*----------------------------------------------------------------*/
  1686.     /* Code Body                                                      */
  1687.     /*----------------------------------------------------------------*/
  1688.     gui_set_font(b->text_font);
  1689.     if (b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE)
  1690.     {
  1691.         if (b->text_offset_y < 0)
  1692.         {
  1693.             fh = gui_get_character_height() + 1;    /* +1 added for 1 pixel gap between lines */
  1694.             b->text_offset_y += fh;
  1695.             if (b->text_offset_y >= -(b->page_details[PAGE_ZERO].page_height - b->edit_height_displayed_lines)) /* if text_offset_y reaches to height of page at 0th index */
  1696.             {
  1697.                 gui_paging_multi_line_input_box_get_previous_page_callback(b);
  1698.                 if (b->page_details[0].page_id != PAGE_ZERO)
  1699.                 {
  1700.                     b->text_offset_y -= b->page_details[PAGE_ZERO].page_height;
  1701.                     b->page_details[PAGE_ZERO].page_id = b->start_id;
  1702.                     /*
  1703.                      * to maintain the text relocation issue we save the height of page at 0th index before a new page entry.According to 
  1704.                      * paging algorithm,after a new page entry ,page at 0th index will come to index 1 of the buffer.If the height of the saved value differs 
  1705.                      * with the height of page at index 1 then this condition will be tested
  1706.                      */
  1707.                     if (b->page_zero_prev_height != b->page_details[PAGE_ONE].page_height)
  1708.                     {
  1709.                         b->text_offset_y -= fh;
  1710.                     }
  1711.                 }
  1712.             }
  1713.             if (b->text_offset_y > 0)
  1714.             {
  1715.                 b->text_offset_y = 0;
  1716.             }
  1717.         }
  1718.     }
  1719.     UI_UNUSED_PARAMETER(dummy_c);
  1720. }
  1721. #endif /* __UI_PAGING_IN_MULTILINE_EDITOR__ */ 
  1722. /*****************************************************************************
  1723.  * FUNCTION
  1724.  *  gui_multi_line_input_box_toggle_insert_mode
  1725.  * DESCRIPTION
  1726.  *  Toggles between Insert and Overwrite modes
  1727.  * PARAMETERS
  1728.  *  b       [IN]        Is the multi-line inputbox object
  1729.  * RETURNS
  1730.  *  void
  1731.  *****************************************************************************/
  1732. void gui_multi_line_input_box_toggle_insert_mode(multi_line_input_box *b)
  1733. {
  1734.     /*----------------------------------------------------------------*/
  1735.     /* Local Variables                                                */
  1736.     /*----------------------------------------------------------------*/
  1737.     /*----------------------------------------------------------------*/
  1738.     /* Code Body                                                      */
  1739.     /*----------------------------------------------------------------*/
  1740.     if (b->flags & UI_MULTI_LINE_INPUT_BOX_OVERWRITE_MODE)
  1741.     {
  1742.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_OVERWRITE_MODE;
  1743.     }
  1744.     else
  1745.     {
  1746.         b->flags |= UI_MULTI_LINE_INPUT_BOX_OVERWRITE_MODE;
  1747.     }
  1748. }
  1749. /*****************************************************************************
  1750.  * FUNCTION
  1751.  *  gui_multi_line_input_box_highlight_cursor_end
  1752.  * DESCRIPTION
  1753.  *  
  1754.  * PARAMETERS
  1755.  *  b       [IN]        Is the multi-line inputbox object
  1756.  * RETURNS
  1757.  *  void
  1758.  *****************************************************************************/
  1759. S32 gui_multi_line_input_box_highlight_cursor_end(multi_line_input_box *b)
  1760. {
  1761.     /*----------------------------------------------------------------*/
  1762.     /* Local Variables                                                */
  1763.     /*----------------------------------------------------------------*/
  1764.     UI_buffer_type saved_current_position = b->cursor_p;
  1765.     UI_buffer_type current_position = b->cursor_p;
  1766.     UI_buffer_type previous_position;
  1767.     UI_buffer_type last_position_p = b->last_position_p;
  1768.     U8 done = 0, bflag;
  1769.     UI_character_type current_character;
  1770.     S32 count = 0;
  1771.     /*----------------------------------------------------------------*/
  1772.     /* Code Body                                                      */
  1773.     /*----------------------------------------------------------------*/
  1774.     UI_STRING_GET_PREVIOUS_CHARACTER(last_position_p, current_character);
  1775.     /* Move cursor backwards until a break character is encountered   */
  1776.     while (!done)
  1777.     {
  1778.         previous_position = current_position;
  1779.         if (current_position == b->text)
  1780.         {
  1781.             break;
  1782.         }
  1783.         UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
  1784.         count++;
  1785.         UI_MULTI_LINE_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1786.         if (bflag)
  1787.         {
  1788.             break;
  1789.         }
  1790.     }
  1791.     b->highlight_start_position = previous_position;
  1792.     current_position = saved_current_position;
  1793.     /* Move cursor forwards until a break character is encountered */
  1794.     if (current_position >= last_position_p)
  1795.     {
  1796.         done = 1;
  1797.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1798.     }
  1799.     else
  1800.     {
  1801.         UI_STRING_GET_NEXT_CHARACTER(current_position, current_character);
  1802.         UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
  1803.         UI_MULTI_LINE_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1804.         if (bflag)
  1805.         {
  1806.             done = 1;
  1807.             b->flags &= ~UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1808.         }
  1809.         else
  1810.         {
  1811.             done = 0;
  1812.             b->flags |= UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1813.         }
  1814.     }
  1815.     while (!done)
  1816.     {
  1817.         if (current_position >= last_position_p)
  1818.         {
  1819.             break;
  1820.         }
  1821.         UI_STRING_GET_NEXT_CHARACTER(current_position, current_character);
  1822.         count++;
  1823.         UI_MULTI_LINE_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1824.         if (bflag)
  1825.         {
  1826.             UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
  1827.             break;
  1828.         }
  1829.     }
  1830.     b->highlight_end_position = current_position;
  1831.     b->cursor_p = current_position;
  1832.     b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1833.     gui_show_multi_line_input_box(b);
  1834.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1835.     return (count);
  1836. }
  1837. /*****************************************************************************
  1838.  * FUNCTION
  1839.  *  gui_multi_line_input_box_highlight_cursor_start
  1840.  * DESCRIPTION
  1841.  *  
  1842.  * PARAMETERS
  1843.  *  b       [IN]        Is the multi-line inputbox object
  1844.  * RETURNS
  1845.  *  S32
  1846.  *****************************************************************************/
  1847. S32 gui_multi_line_input_box_highlight_cursor_start(multi_line_input_box *b)
  1848. {
  1849.     /*----------------------------------------------------------------*/
  1850.     /* Local Variables                                                */
  1851.     /*----------------------------------------------------------------*/
  1852.     UI_buffer_type saved_current_position = b->cursor_p;
  1853.     UI_buffer_type current_position = b->cursor_p;
  1854.     UI_buffer_type previous_position;
  1855.     UI_buffer_type last_position_p = b->last_position_p;
  1856.     U8 done = 0, bflag;
  1857.     UI_character_type current_character;
  1858.     S32 count = 0;
  1859.     /*----------------------------------------------------------------*/
  1860.     /* Code Body                                                      */
  1861.     /*----------------------------------------------------------------*/
  1862.     if (current_position == b->text)
  1863.     {
  1864.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1865.         return (0);
  1866.     }
  1867.     UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
  1868.     /* Move cursor forwards until a break character is encountered */
  1869.     while (!done)
  1870.     {
  1871.         if (current_position >= last_position_p)
  1872.         {
  1873.             break;
  1874.         }
  1875.         UI_STRING_GET_NEXT_CHARACTER(current_position, current_character);
  1876.         count++;
  1877.         UI_MULTI_LINE_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1878.         if (bflag)
  1879.         {
  1880.             UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
  1881.             break;
  1882.         }
  1883.     }
  1884.     b->highlight_end_position = current_position;
  1885.     current_position = saved_current_position;
  1886.     /* Move cursor backwards until a break character is encountered   */
  1887.     if (current_position == b->text)
  1888.     {
  1889.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1890.         return (0);
  1891.     }
  1892.     UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
  1893.     UI_MULTI_LINE_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1894.     if (bflag)
  1895.     {
  1896.         UI_STRING_GET_NEXT_CHARACTER(current_position, current_character);
  1897.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1898.         return (0);
  1899.     }
  1900.     else
  1901.     {
  1902.         done = 0;
  1903.         b->flags |= UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1904.     }
  1905.     while (!done)
  1906.     {
  1907.         previous_position = current_position;
  1908.         if (current_position == b->text)
  1909.         {
  1910.             break;
  1911.         }
  1912.         UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
  1913.         count++;
  1914.         UI_MULTI_LINE_INPUT_BOX_BREAK_CHARACTER(current_character, bflag);
  1915.         if (bflag)
  1916.         {
  1917.             break;
  1918.         }
  1919.     }
  1920.     b->highlight_start_position = previous_position;
  1921.     b->cursor_p = previous_position;
  1922.     b->flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1923.     gui_show_multi_line_input_box(b);
  1924.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1925.     return (count);
  1926. }
  1927. /*****************************************************************************
  1928.  * FUNCTION
  1929.  *  gui_multi_line_input_box_highlight_cursor_number
  1930.  * DESCRIPTION
  1931.  *  
  1932.  * PARAMETERS
  1933.  *  b       [IN]        Is the multi-line inputbox object
  1934.  *  n       [IN]        
  1935.  * RETURNS
  1936.  *  S32
  1937.  *****************************************************************************/
  1938. S32 gui_multi_line_input_box_highlight_cursor_number(multi_line_input_box *b, S32 n)
  1939. {
  1940.     /*----------------------------------------------------------------*/
  1941.     /* Local Variables                                                */
  1942.     /*----------------------------------------------------------------*/
  1943.     UI_buffer_type saved_current_position = b->cursor_p;
  1944.     UI_buffer_type current_position = b->cursor_p;
  1945.     UI_buffer_type previous_position;
  1946.     U8 done = 0, bflag = 0;
  1947.     UI_character_type current_character;
  1948.     S32 count = 0;
  1949.     /*----------------------------------------------------------------*/
  1950.     /* Code Body                                                      */
  1951.     /*----------------------------------------------------------------*/
  1952.     if (current_position == b->text)
  1953.     {
  1954.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1955.         return (0);
  1956.     }
  1957.     b->highlight_end_position = current_position;
  1958.     /* Move cursor backwards until n characters count out or a break character is encountered    */
  1959.     while (!done)
  1960.     {
  1961.         previous_position = current_position;
  1962.         if (n <= 0)
  1963.         {
  1964.             break;
  1965.         }
  1966.         if (current_position <= b->text)
  1967.         {
  1968.             break;
  1969.         }
  1970.         UI_STRING_GET_PREVIOUS_CHARACTER(current_position, current_character);
  1971.         UI_MULTI_LINE_INPUT_BOX_BREAK_CHARACTER(current_character, bflag) if (bflag)
  1972.         {
  1973.             break;
  1974.         }
  1975.         count++;
  1976.         n--;
  1977.     }
  1978.     b->highlight_start_position = previous_position;
  1979.     b->cursor_p = saved_current_position;
  1980.     if (current_position == b->cursor_p)
  1981.     {
  1982.         b->flags &= ~UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1983.     }
  1984.     else if (!(bflag && (count == 0)))
  1985.     {
  1986.         b->flags |= UI_MULTI_LINE_INPUT_BOX_WORD_HIGHLIGHT;
  1987.     }
  1988.     b->highlight_start_position = previous_position;
  1989.     
  1990.     if (b->show_action_flag)
  1991.     {
  1992.         gui_show_multi_line_input_box(b);
  1993.     }
  1994.     
  1995.     b->flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1996.     return (count);
  1997. }
  1998. /* GUI: dialer input box functions              */
  1999. UI_dialer_input_box_theme *current_dialer_input_box_theme = NULL;
  2000. /*****************************************************************************
  2001.  * FUNCTION
  2002.  *  gui_set_dialer_input_box_current_theme
  2003.  * DESCRIPTION
  2004.  *  Applies the current theme for the single-line inputbox.
  2005.  * PARAMETERS
  2006.  *  b       [IN]        Is the single-line inputbox object
  2007.  * RETURNS
  2008.  *  void
  2009.  *****************************************************************************/
  2010. void gui_set_dialer_input_box_current_theme(dialer_input_box *b)
  2011. {
  2012.     /*----------------------------------------------------------------*/
  2013.     /* Local Variables                                                */
  2014.     /*----------------------------------------------------------------*/
  2015.     /*----------------------------------------------------------------*/
  2016.     /* Code Body                                                      */
  2017.     /*----------------------------------------------------------------*/
  2018.     b->text_color = current_dialer_input_box_theme->normal_text_color;
  2019.     b->background_filler = current_dialer_input_box_theme->normal_filler;
  2020.     b->selection_color = current_dialer_input_box_theme->selection_color;
  2021.     b->selection_text_color = current_dialer_input_box_theme->selection_text_color;
  2022.     b->cursor_color = current_dialer_input_box_theme->cursor_color;
  2023.     b->text_font = current_dialer_input_box_theme->text_font;
  2024.     b->text_gap = current_dialer_input_box_theme->text_gap;
  2025.     b->flags |= current_dialer_input_box_theme->flags;
  2026. }
  2027. /*****************************************************************************
  2028.  * FUNCTION
  2029.  *  gui_set_dialer_input_box_theme
  2030.  * DESCRIPTION
  2031.  *  Applies the given theme to the single-line inputbox.
  2032.  * PARAMETERS
  2033.  *  b       [IN]        Is the single-line inputbox object
  2034.  *  t       [?]         
  2035.  * RETURNS
  2036.  *  void
  2037.  *****************************************************************************/
  2038. void gui_set_dialer_input_box_theme(dialer_input_box *b, UI_dialer_input_box_theme *t)
  2039. {
  2040.     /*----------------------------------------------------------------*/
  2041.     /* Local Variables                                                */
  2042.     /*----------------------------------------------------------------*/
  2043.     /*----------------------------------------------------------------*/
  2044.     /* Code Body                                                      */
  2045.     /*----------------------------------------------------------------*/
  2046.     b->text_color = t->normal_text_color;
  2047.     b->background_filler = t->normal_filler;
  2048.     b->selection_color = t->selection_color;
  2049.     b->selection_text_color = t->selection_text_color;
  2050.     b->cursor_color = t->cursor_color;
  2051.     b->text_font = t->text_font;
  2052.     b->text_gap = t->text_gap;
  2053.     b->flags |= t->flags;
  2054. }
  2055. /*****************************************************************************
  2056.  * FUNCTION
  2057.  *  gui_dialer_input_box_clear
  2058.  * DESCRIPTION
  2059.  *  Initilaize dialer input box to defualtr
  2060.  * PARAMETERS
  2061.  *  b       [IN]        Is the dialer inputbox object
  2062.  * RETURNS
  2063.  *  void
  2064.  *****************************************************************************/
  2065. void gui_dialer_input_box_clear(dialer_input_box *b)
  2066. {
  2067.     /*----------------------------------------------------------------*/
  2068.     /* Local Variables                                                */
  2069.     /*----------------------------------------------------------------*/
  2070.     /*----------------------------------------------------------------*/
  2071.     /* Code Body                                                      */
  2072.     /*----------------------------------------------------------------*/
  2073.     if (b->text == NULL)
  2074.     {
  2075.         b->text_length = 0;
  2076.         b->allocated_length = 0;
  2077.         b->available_length = 0;
  2078.     }
  2079.     else
  2080.     {
  2081.         b->text[0] = '';
  2082.         b->text[1] = 0;
  2083.         b->text_length = 2;
  2084.     }
  2085.     b->current_text_p = b->text;
  2086.     b->last_position_p = b->text;
  2087.     b->UCS2_count = 0;
  2088.     if (b->flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  2089.     {
  2090.         b->available_length = b->allocated_length;
  2091.     }
  2092. }
  2093. /*****************************************************************************
  2094.  * FUNCTION
  2095.  *  gui_create_dialer_input_box
  2096.  * DESCRIPTION
  2097.  *  Creates a single line input box
  2098.  *  
  2099.  *  The object should be allocated before calling this function.
  2100.  *  The buffer is automatically allocated by the inputbox.
  2101.  *  The buffer is set to blank on creation of this object.
  2102.  *  See also gui_destroy_dialer_input_box()
  2103.  * PARAMETERS
  2104.  *  b           [IN]        Is the single-line inputbox object (pre-allocated)
  2105.  *  x           [IN]        Is the left-top corner
  2106.  *  y           [IN]        Is the left-top corner
  2107.  *  width       [IN]        Is the width of the inputbox
  2108.  *  height      [IN]        Is the height of the inputbox
  2109.  *  length      [IN]        Is the length of the buffer to use
  2110.  * RETURNS
  2111.  *  void
  2112.  *****************************************************************************/
  2113. void gui_create_dialer_input_box(dialer_input_box *b, S32 x, S32 y, S32 width, S32 height, S32 length)
  2114. {
  2115.     /*----------------------------------------------------------------*/
  2116.     /* Local Variables                                                */
  2117.     /*----------------------------------------------------------------*/
  2118.     /*----------------------------------------------------------------*/
  2119.     /* Code Body                                                      */
  2120.     /*----------------------------------------------------------------*/
  2121.     b->x = x;
  2122.     b->y = y;
  2123.     b->width = width;
  2124.     b->height = height;
  2125.     b->text = (UI_buffer_type) gui_malloc(length * sizeof(UI_character_type));
  2126.     b->allocated_length = length;
  2127.     b->available_length = length;
  2128.     gui_dialer_input_box_clear(b);
  2129.     b->current_text_p = b->text;
  2130.     b->flags = 0;
  2131.     gui_set_dialer_input_box_current_theme(b);
  2132.     b->validation_callback = UI_dummy_validation_function;
  2133.     b->overflow_callback = UI_dummy_function;
  2134.     b->change_callback = UI_dummy_function;
  2135.     b->UCS2_count = 0;
  2136. }
  2137. /*****************************************************************************
  2138.  * FUNCTION
  2139.  *  gui_create_dialer_input_box_use_buffer
  2140.  * DESCRIPTION
  2141.  *  Creates a single line input box
  2142.  *  
  2143.  *  The object should be allocated before calling this function.
  2144.  *  Also, the buffer should be allocated and passed to this function.
  2145.  *  The buffer is set to blank on creation of this object.
  2146.  * PARAMETERS
  2147.  *  b           [IN]        Is the single-line inputbox object (pre-allocated)
  2148.  *  x           [IN]        Is the left-top corner
  2149.  *  y           [IN]        Is the left-top corner
  2150.  *  width       [IN]        Is the width of the inputbox
  2151.  *  height      [IN]        Is the height of the inputbox
  2152.  *  buffer      [IN]        Is the buffer the inputbox should use (pre-allocated)
  2153.  *  length      [IN]        Is the length of the buffer
  2154.  * RETURNS
  2155.  *  void
  2156.  *****************************************************************************/
  2157. void gui_create_dialer_input_box_use_buffer(
  2158.         dialer_input_box *b,
  2159.         S32 x,
  2160.         S32 y,
  2161.         S32 width,
  2162.         S32 height,
  2163.         UI_string_type buffer,
  2164.         S32 length)
  2165. {
  2166.     /*----------------------------------------------------------------*/
  2167.     /* Local Variables                                                */
  2168.     /*----------------------------------------------------------------*/
  2169.     /*----------------------------------------------------------------*/
  2170.     /* Code Body                                                      */
  2171.     /*----------------------------------------------------------------*/
  2172.     b->x = x;
  2173.     b->y = y;
  2174.     b->width = width;
  2175.     b->height = height;
  2176.     b->text = (UI_buffer_type) buffer;
  2177.     b->allocated_length = length;
  2178.     b->available_length = length;
  2179.     b->flags = 0;
  2180.     gui_dialer_input_box_clear(b);
  2181.     b->current_text_p = b->text;
  2182.     gui_set_dialer_input_box_current_theme(b);
  2183.     b->overflow_callback = UI_dummy_function;
  2184.     b->change_callback = UI_dummy_function;
  2185.     b->validation_callback = UI_dummy_validation_function;
  2186.     b->UCS2_count = 0;
  2187. }
  2188. /*****************************************************************************
  2189.  * FUNCTION
  2190.  *  gui_create_dialer_input_box_set_buffer
  2191.  * DESCRIPTION
  2192.  *  Creates a single line input box
  2193.  *  
  2194.  *  The object should be allocated before calling this function.
  2195.  *  Also, the buffer should be allocated and passed to this function.
  2196.  *  The buffer retains the string passed.
  2197.  * PARAMETERS
  2198.  *  b                   [IN]        Is the single-line inputbox object (pre-allocated)
  2199.  *  x                   [IN]        Is the left-top corner
  2200.  *  y                   [IN]        Is the left-top corner
  2201.  *  width               [IN]        Is the width of the inputbox
  2202.  *  height              [IN]        Is the height of the inputbox
  2203.  *  buffer              [IN]        Is the buffer the inputbox should use (pre-allocated)
  2204.  *  length              [IN]        Is the length of the buffer
  2205.  *  text_length         [IN]        
  2206.  *  edit_position       [IN]        Is the cursor_position
  2207.  * RETURNS
  2208.  *  void
  2209.  *****************************************************************************/
  2210. void gui_create_dialer_input_box_set_buffer(
  2211.         dialer_input_box *b,
  2212.         S32 x,
  2213.         S32 y,
  2214.         S32 width,
  2215.         S32 height,
  2216.         UI_string_type buffer,
  2217.         S32 length,
  2218.         S32 text_length,
  2219.         S32 edit_position)
  2220. {
  2221.     /*----------------------------------------------------------------*/
  2222.     /* Local Variables                                                */
  2223.     /*----------------------------------------------------------------*/
  2224.     UI_character_type dummy_c = 0;
  2225.     UI_buffer_type text;
  2226.     S32 i;
  2227.     /*----------------------------------------------------------------*/
  2228.     /* Code Body                                                      */
  2229.     /*----------------------------------------------------------------*/
  2230.     b->x = x;
  2231.     b->y = y;
  2232.     b->width = width;
  2233.     b->height = height;
  2234.     b->text = (UI_buffer_type) buffer;
  2235.     b->current_text_p = b->text;
  2236.     b->allocated_length = length;
  2237.     b->available_length = length;
  2238.     b->UCS2_count = 0;
  2239.     if (b->text != NULL)
  2240.     {
  2241.         text = b->text;
  2242.         for (i = 0; i < edit_position; i++)
  2243.         {
  2244.             UI_STRING_GET_NEXT_CHARACTER(text, dummy_c);
  2245.             UI_TEST_UCS2_INCREMENT_COUNT(dummy_c, b->UCS2_count);
  2246.             if (UI_STRING_END_OF_STRING_CHARACTER(dummy_c))
  2247.             {
  2248.                 break;
  2249.             }
  2250.         }
  2251.         b->current_text_p = text;
  2252.         for (i = edit_position; !UI_STRING_END_OF_STRING_CHARACTER(dummy_c); i++)
  2253.         {
  2254.             UI_STRING_GET_NEXT_CHARACTER(text, dummy_c);
  2255.             UI_TEST_UCS2_INCREMENT_COUNT(dummy_c, b->UCS2_count);
  2256.         }
  2257.         b->text_length = text_length;
  2258.         b->last_position_p = b->current_text_p;
  2259.     }
  2260.     else    /* b->text!=NULL */
  2261.     {
  2262.         b->text_length = 0;
  2263.     }
  2264.     b->flags = 0;
  2265.     gui_set_dialer_input_box_current_theme(b);
  2266.     b->overflow_callback = UI_dummy_function;
  2267.     b->change_callback = UI_dummy_function;
  2268.     b->validation_callback = UI_dummy_validation_function;
  2269. }
  2270. /*****************************************************************************
  2271.  * FUNCTION
  2272.  *  gui_move_dialer_input_box
  2273.  * DESCRIPTION
  2274.  *  Moves a single line input box
  2275.  * PARAMETERS
  2276.  *  b       [IN]        Is the single-line inputbox object (pre-allocated)
  2277.  *  x       [IN]        Is the left-top corner
  2278.  *  y       [IN]        Is the left-top corner
  2279.  * RETURNS
  2280.  *  void
  2281.  *****************************************************************************/
  2282. void gui_move_dialer_input_box(dialer_input_box *b, S32 x, S32 y)
  2283. {
  2284.     /*----------------------------------------------------------------*/
  2285.     /* Local Variables                                                */
  2286.     /*----------------------------------------------------------------*/
  2287.     /*----------------------------------------------------------------*/
  2288.     /* Code Body                                                      */
  2289.     /*----------------------------------------------------------------*/
  2290.     b->x = x;
  2291.     b->y = y;
  2292. }
  2293. /*****************************************************************************
  2294.  * FUNCTION
  2295.  *  gui_dialer_input_box_show_cursor
  2296.  * DESCRIPTION
  2297.  *  Displays the cursor in a single-line inputbox (internal function)
  2298.  *  
  2299.  *  This function is used internally.
  2300.  * PARAMETERS
  2301.  *  b           [IN]        Is the single-line inputbox object
  2302.  *  x           [IN]        Is the left-top corner of the cursor
  2303.  *  y           [IN]        Is the left-top corner of the cursor
  2304.  *  height      [IN]        Is the height of cursor
  2305.  * RETURNS
  2306.  *  void
  2307.  *****************************************************************************/
  2308. void gui_dialer_input_box_show_cursor(dialer_input_box *b, S32 x, S32 y, S32 height)
  2309. {
  2310.     /*----------------------------------------------------------------*/
  2311.     /* Local Variables                                                */
  2312.     /*----------------------------------------------------------------*/
  2313.     color c = b->cursor_color;
  2314.     /*----------------------------------------------------------------*/
  2315.     /* Code Body                                                      */
  2316.     /*----------------------------------------------------------------*/
  2317. #if(UI_BLINKING_CURSOR_SUPPORT)
  2318.     UI_inputbox_show_cursor(x, y, x + 1, y + height - 1, c);
  2319. #else 
  2320.     gui_fill_rectangle(x, y, x + 1, y + height - 1, c);
  2321. #endif 
  2322. }
  2323. /* MTK Elvis for color dialing font */
  2324. /*****************************************************************************
  2325.  * FUNCTION
  2326.  *  gui_get_dialing_font_color
  2327.  * DESCRIPTION
  2328.  *  get dialing font color
  2329.  * PARAMETERS
  2330.  *  c       [IN]        Is the single-line inputbox object
  2331.  * RETURNS
  2332.  *  color
  2333.  *****************************************************************************/
  2334. color gui_get_dialing_font_color(UI_character_type c)
  2335. {
  2336.     /*----------------------------------------------------------------*/
  2337.     /* Local Variables                                                */
  2338.     /*----------------------------------------------------------------*/
  2339.     U32 nIdx;
  2340.     /*----------------------------------------------------------------*/
  2341.     /* Code Body                                                      */
  2342.     /*----------------------------------------------------------------*/
  2343.     for (nIdx = 0; color_dialing_font_map[nIdx].ch; nIdx++)
  2344.     {
  2345.         if (color_dialing_font_map[nIdx].ch == c)
  2346.         {
  2347.             return color_dialing_font_map[nIdx].c;
  2348.         }
  2349.     }
  2350.     return color_dialing_font_map[nIdx].c;
  2351. }
  2352. /* MTK end */
  2353. /*****************************************************************************
  2354.  * FUNCTION
  2355.  *  gui_show_dialer_input_box
  2356.  * DESCRIPTION
  2357.  *  Displays a single-line inputbox
  2358.  * PARAMETERS
  2359.  *  b       [IN]        Is the single-line inputbox object
  2360.  * RETURNS
  2361.  *  void
  2362.  *****************************************************************************/
  2363. void gui_show_dialer_input_box(dialer_input_box *b)
  2364. {
  2365.     /*----------------------------------------------------------------*/
  2366.     /* Local Variables                                                */
  2367.     /*----------------------------------------------------------------*/
  2368.     /*----------------------------------------------------------------*/
  2369.     /* Code Body                                                      */
  2370.     /*----------------------------------------------------------------*/
  2371.     gui_show_dialer_input_box_ext(b, (-1), (-1));
  2372. }
  2373. /*****************************************************************************
  2374.  * FUNCTION
  2375.  *  gui_show_dialer_input_box_ext
  2376.  * DESCRIPTION
  2377.  *  
  2378.  * PARAMETERS
  2379.  *  b               [?]         
  2380.  *  move_to_x       [IN]        
  2381.  *  move_to_y       [IN]        
  2382.  * RETURNS
  2383.  *  void
  2384.  *****************************************************************************/
  2385. void gui_show_dialer_input_box_ext(dialer_input_box *b, S32 move_to_x, S32 move_to_y)
  2386. {
  2387.     /*----------------------------------------------------------------*/
  2388.     /* Local Variables                                                */
  2389.     /*----------------------------------------------------------------*/
  2390.     S32 x1, y1, x2, y2;
  2391.     UI_filled_area *f = b->background_filler;
  2392.     U8 selection_flag = 0;
  2393. #if(0)
  2394.    byte overwrite_mode_flag=0;
  2395. #endif /* (0) */ 
  2396.     UI_character_type current_character;
  2397.     S32 character_width = 0;
  2398.     UI_buffer_type previous_text_p;
  2399.     UI_buffer_type current_text_p = b->text;
  2400.     U32 flags = b->flags;
  2401.     S32 text_x, text_y, character_height;
  2402.     U8 cursor_displayed_flag = 0;
  2403.     U8 cusrsor_set_flag = 0;
  2404.     S32 text_gap = b->text_gap;
  2405.     color b_normal_text_color = b->text_color;
  2406.     color b_selection_text_color = b->selection_text_color;
  2407.     color b_selection_color = b->selection_color;
  2408.     /* UI_character_type  mask_character=b->mask_character; */
  2409.     UI_buffer_type b_current_text_p = b->current_text_p;
  2410.     UI_buffer_type b_text = b->text;
  2411.     /*----------------------------------------------------------------*/
  2412.     /* Code Body                                                      */
  2413.     /*----------------------------------------------------------------*/
  2414.     x1 = b->x;
  2415.     y1 = b->y;
  2416.     x2 = x1 + b->width - 1;
  2417.     y2 = y1 + b->height - 1;
  2418.     gui_set_clip(x1, y1, x2, y2);
  2419.     gui_draw_filled_area(x1, y1, x2, y2, f);
  2420.     gui_set_text_clip(x1, y1, x2, y2);
  2421.     gui_set_font(b->text_font);
  2422.     if (current_text_p != NULL)
  2423.     {
  2424.         if (flags & UI_DIALER_INPUT_BOX_STATE_MULTITAP)
  2425.         {
  2426.             selection_flag = 1;
  2427.         }
  2428.     #if(0)
  2429.       if((flags & UI_DIALER_INPUT_BOX_OVERWRITE_MODE) && (!selection_flag))
  2430.       {
  2431.          overwrite_mode_flag=1;
  2432.       }
  2433.     #endif /* (0) */ 
  2434.         character_height = gui_get_character_height();
  2435.         current_character = (UI_character_type) - 1;
  2436.     #if(0)
  2437.       while(!UI_STRING_END_OF_STRING_CHARACTER(current_character))
  2438.       {
  2439.          UI_STRING_GET_NEXT_CHARACTER(current_text_p,current_character);
  2440.       }
  2441.       UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p,current_character);
  2442.       b->last_position_p=current_text_p;
  2443.     #else /* (0) */ 
  2444.         current_text_p = b->last_position_p;
  2445.     #endif /* (0) */ 
  2446.         text_x = x2 - 4;
  2447.         /* start vijay 20050228, for touch dial screen */
  2448.     #if( defined(__MMI_TOUCH_DIAL_SCREEN__))
  2449.         text_y = y2 - character_height + 2;
  2450.     #else 
  2451.         text_y = y2 - character_height - 2; /* previous implementation */
  2452.     #endif 
  2453.         /* end vijay */
  2454.         if (b_text != current_text_p)
  2455.         {
  2456.             gui_set_text_color(b_normal_text_color);
  2457.             while (current_text_p != b_text)
  2458.             {
  2459.                 previous_text_p = current_text_p;
  2460.                 UI_STRING_GET_PREVIOUS_CHARACTER(current_text_p, current_character);
  2461.                 character_width = gui_get_character_width(current_character);
  2462.                 if ((text_x - (character_width + text_gap)) < x1)
  2463.                 {
  2464.                     b->n_lines++;   /* vandana */
  2465.                     text_x = x2 - 4;
  2466.                     text_y -= character_height;
  2467.                     if (text_y < y1)
  2468.                     {
  2469.                         break;
  2470.                     }
  2471.                 }
  2472.                 if ((-1) == move_to_x && (-1) == move_to_y)
  2473.                 {
  2474.                     if (previous_text_p == b_current_text_p)
  2475.                     {
  2476.                         if (selection_flag)
  2477.                         {
  2478.                             text_x -= (character_width + text_gap);
  2479.                             gui_fill_rectangle(
  2480.                                 text_x,
  2481.                                 text_y - 1,
  2482.                                 text_x + character_width,
  2483.                                 text_y + character_height,
  2484.                                 b_selection_color);
  2485.                             gui_set_text_color(b_selection_text_color);
  2486.                             /* MTK Elvis for R2L characters */
  2487.                             if (r2lMMIFlag)
  2488.                             {
  2489.                                 gui_move_text_cursor(text_x + character_width, text_y);
  2490.                             }
  2491.                             else
  2492.                             {
  2493.                                 gui_move_text_cursor(text_x, text_y);
  2494.                             }
  2495.                             /* MTK end */
  2496.                             gui_print_character(current_character);
  2497.                             gui_set_text_color(b_normal_text_color);
  2498.                             cursor_displayed_flag = 1;
  2499.                         }
  2500.                         else
  2501.                         {
  2502.                             if (!cursor_displayed_flag)
  2503.                             {
  2504.                                 if (!(flags & UI_DIALER_INPUT_BOX_DISABLE_DRAW) &&
  2505.                                     !(flags & UI_DIALER_INPUT_BOX_DISABLE_CURSOR_DRAW))
  2506.                                 {
  2507.                                     if (flags & UI_DIALER_INPUT_BOX_SHOW_BLOCK_CURSOR)
  2508.                                     {
  2509.                                         gui_fill_rectangle(
  2510.                                             text_x,
  2511.                                             text_y - 1,
  2512.                                             text_x + character_width,
  2513.                                             text_y + character_height,
  2514.                                             b_selection_color);
  2515.                                     }
  2516.                                     else
  2517.                                     {
  2518.                                         gui_dialer_input_box_show_cursor(b, text_x - 1, text_y - 1, character_height);
  2519.                                         b->cursor_x = (text_x - 1);
  2520.                                         b->cursor_y = (text_y - 1);
  2521.                                     }
  2522.                                 }
  2523.                                 cursor_displayed_flag = 1;
  2524.                             }
  2525.                             text_x -= (character_width + text_gap);
  2526.                             /* MTK Elvis for R2L characters */
  2527.                             if (r2lMMIFlag)
  2528.                             {
  2529.                                 gui_move_text_cursor(text_x + character_width, text_y);
  2530.                             }
  2531.                             else
  2532.                             {
  2533.                                 gui_move_text_cursor(text_x, text_y);
  2534.                             }
  2535.                             //MTK end
  2536.                             //MTK Elvis for color dialling font
  2537.                         #ifdef __MMI_COLOR_DIALLING_FONT__
  2538.                             gui_set_text_color(gui_get_dialing_font_color(current_character));
  2539.                         #endif 
  2540.                             /* MTK end */
  2541.                             gui_print_character(current_character);
  2542.                         }
  2543.                     }
  2544.                 #if(0)
  2545.             else if(overwrite_mode_flag && (current_text_p==b_current_text_p))
  2546.             {
  2547.                text_x-=(character_width+text_gap);
  2548.                pixtel_UI_fill_rectangle(text_x,text_y-1,text_x+character_width,text_y+character_height,b_selection_color);
  2549.                pixtel_UI_set_text_color(b_selection_text_color);
  2550.                pixtel_UI_move_text_cursor(text_x,text_y);
  2551.                pixtel_UI_print_character(current_character);
  2552.                pixtel_UI_set_text_color(b_normal_text_color);
  2553.                cursor_displayed_flag=1;
  2554.             }
  2555.                 #endif /* (0) */ 
  2556.                     else    /* previous_text_p==b_current_text_p */
  2557.                     {
  2558.                         text_x -= (character_width + text_gap);
  2559.                         /* MTK Elvis for R2L characters */
  2560.                         if (r2lMMIFlag)
  2561.                         {
  2562.                             gui_move_text_cursor(text_x + character_width, text_y);
  2563.                         }
  2564.                         else
  2565.                         {
  2566.                             gui_move_text_cursor(text_x, text_y);
  2567.                         }
  2568.                         /* MTK end */
  2569.                         /* MTK Elvis for color dialling font */
  2570.                     #ifdef __MMI_COLOR_DIALLING_FONT__
  2571.                         gui_set_text_color(gui_get_dialing_font_color(current_character));
  2572.                     #endif 
  2573.                         /* MTK end */
  2574.                         gui_print_character(current_character);
  2575.                     }
  2576.                 }
  2577.                 else    /* (-1) == move_to_x && (-1) == move_to_y */
  2578.                 {
  2579.                     text_x -= (character_width + text_gap);
  2580.                     if (((text_x) < move_to_x) && ((text_y + character_height) >= move_to_y) && (text_y < move_to_y) &&
  2581.                         (!cusrsor_set_flag))
  2582.                     {
  2583.                         b->cursor_x = text_x - 1;
  2584.                         b->cursor_y = text_y - 1;
  2585.                         b->current_text_p = previous_text_p;
  2586.                         cusrsor_set_flag = 1;
  2587.                     }
  2588.                 }
  2589.             }
  2590.         }
  2591.         if (!cursor_displayed_flag && ((-1) == move_to_x) && ((-1) == move_to_y))
  2592.         {
  2593.             if (!(flags & UI_DIALER_INPUT_BOX_DISABLE_DRAW) && !(flags & UI_DIALER_INPUT_BOX_DISABLE_CURSOR_DRAW))
  2594.             {
  2595.                 if (flags & UI_DIALER_INPUT_BOX_SHOW_BLOCK_CURSOR)
  2596.                 {
  2597.                     gui_fill_rectangle(
  2598.                         text_x,
  2599.                         text_y - 1,
  2600.                         text_x + character_width,
  2601.                         text_y + character_height,
  2602.                         b_selection_color);
  2603.                 }
  2604.                 else
  2605.                 {
  2606.                     gui_dialer_input_box_show_cursor(b, text_x - 1, text_y - 1, character_height);
  2607.                     b->cursor_x = (text_x - 1);
  2608.                     b->cursor_y = (text_y - 1);
  2609.                 }
  2610.             }
  2611.         }
  2612.         if ((((-1) != move_to_x) || ((-1) != move_to_y)) && (!cusrsor_set_flag))
  2613.         {
  2614.             b->cursor_x = text_x - 1;
  2615.             b->cursor_y = text_y - 1;
  2616.             b->current_text_p = current_text_p;
  2617.             cusrsor_set_flag = 1;
  2618.         }
  2619.     }
  2620. }
  2621. /*****************************************************************************
  2622.  * FUNCTION
  2623.  *  gui_destroy_dialer_input_box
  2624.  * DESCRIPTION
  2625.  *  frees the buffer allocated for the box and resets the input box
  2626.  *  
  2627.  *  This doesn't free the single-line inputbox object. It only
  2628.  *  frees the buffer that is used to store the text.
  2629.  * PARAMETERS
  2630.  *  b       [IN]        Is the single-line inputbox object
  2631.  * RETURNS
  2632.  *  void
  2633.  *****************************************************************************/
  2634. void gui_destroy_dialer_input_box(dialer_input_box *b)
  2635. {
  2636.     /*----------------------------------------------------------------*/
  2637.     /* Local Variables                                                */
  2638.     /*----------------------------------------------------------------*/
  2639.     /*----------------------------------------------------------------*/
  2640.     /* Code Body                                                      */
  2641.     /*----------------------------------------------------------------*/
  2642.     b->text_length = 0;
  2643.     b->allocated_length = 0;
  2644.     b->available_length = 0;
  2645.     b->UCS2_count = 0;
  2646.     gui_free(b->text);
  2647.     b->current_text_p = b->text;
  2648. }
  2649. /*****************************************************************************
  2650.  * FUNCTION
  2651.  *  gui_dialer_inputbox_locate_cursor
  2652.  * DESCRIPTION
  2653.  *  locate cursor positin of dialer input box
  2654.  *  
  2655.  *  This doesn't free the single-line inputbox object. It only
  2656.  *  frees the buffer that is used to store the text.
  2657.  * PARAMETERS
  2658.  *  b       [IN]        Is the dialer inputbox object
  2659.  * RETURNS
  2660.  *  void
  2661.  *****************************************************************************/
  2662. void gui_dialer_inputbox_locate_cursor(dialer_input_box *b)
  2663. {
  2664.     /*----------------------------------------------------------------*/
  2665.     /* Local Variables                                                */
  2666.     /*----------------------------------------------------------------*/
  2667.     UI_character_type c = (UI_character_type) - 1;
  2668.     UI_buffer_type current_text_p = b->text;
  2669.     /*----------------------------------------------------------------*/
  2670.     /* Code Body                                                      */
  2671.     /*----------------------------------------------------------------*/
  2672.     while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  2673.     {
  2674.         UI_STRING_GET_NEXT_CHARACTER(current_text_p, c);
  2675.     }
  2676.     b->last_position_p = current_text_p;
  2677. }
  2678. /*****************************************************************************
  2679.  * FUNCTION
  2680.  *  gui_dialer_input_box_delete_character
  2681.  * DESCRIPTION
  2682.  *  Deletes a character before the current cursor position (Backspace)
  2683.  * PARAMETERS
  2684.  *  b       [IN]        Is the single-line inputbox object
  2685.  * RETURNS