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

MTK

开发平台:

C/C++

  1.  *  void
  2.  *****************************************************************************/
  3. void gui_dialer_input_box_delete_character(dialer_input_box *b)
  4. {
  5.     /*----------------------------------------------------------------*/
  6.     /* Local Variables                                                */
  7.     /*----------------------------------------------------------------*/
  8.     UI_buffer_type current_text_p;
  9.     UI_buffer_type previous_text_p;
  10.     UI_character_type current_character = (UI_character_type) - 1;
  11.     UI_character_type dummy_c = 0;
  12.     /*----------------------------------------------------------------*/
  13.     /* Code Body                                                      */
  14.     /*----------------------------------------------------------------*/
  15.     current_text_p = b->current_text_p;
  16.     previous_text_p = b->current_text_p;
  17.     if (previous_text_p == b->text)
  18.     {
  19.         UI_editor_play_tone_cannot_change();
  20.         return;
  21.     }
  22.     UI_STRING_GET_PREVIOUS_CHARACTER(previous_text_p, dummy_c);
  23.     b->text_length -= ((S32) current_text_p - (S32) previous_text_p);
  24.     b->current_text_p = previous_text_p;
  25.     if (b->flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  26.     {
  27.         UI_TEST_UCS2_DECREMENT_COUNT_SET_LENGTH(dummy_c, b->UCS2_count, b->allocated_length, b->available_length);
  28.     }
  29.     while (!UI_STRING_END_OF_STRING_CHARACTER(current_character))
  30.     {
  31.         UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  32.         UI_STRING_INSERT_CHARACTER(previous_text_p, current_character);
  33.     }
  34.     if (b->flags & UI_DIALER_INPUT_BOX_STATE_MULTITAP)
  35.     {
  36.         b->flags &= ~UI_DIALER_INPUT_BOX_STATE_MULTITAP;
  37.     }
  38.     UI_STRING_GET_PREVIOUS_CHARACTER(b->last_position_p, current_character);
  39.     /* gui_dialer_inputbox_locate_cursor(b); */
  40.     b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
  41.     b->change_callback();
  42. }
  43. /*****************************************************************************
  44.  * FUNCTION
  45.  *  gui_dialer_input_box_delete_current_character
  46.  * DESCRIPTION
  47.  *  Deletes a character at the current cursor position (Delete)
  48.  * PARAMETERS
  49.  *  b       [IN]        Is the single-line inputbox object
  50.  * RETURNS
  51.  *  void
  52.  *****************************************************************************/
  53. void gui_dialer_input_box_delete_current_character(dialer_input_box *b)
  54. {
  55.     /*----------------------------------------------------------------*/
  56.     /* Local Variables                                                */
  57.     /*----------------------------------------------------------------*/
  58.     UI_buffer_type current_text_p;
  59.     UI_buffer_type previous_text_p;
  60.     UI_character_type current_character = (UI_character_type) - 1;
  61.     /*----------------------------------------------------------------*/
  62.     /* Code Body                                                      */
  63.     /*----------------------------------------------------------------*/
  64.     current_text_p = b->current_text_p;
  65.     previous_text_p = b->current_text_p;
  66.     UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  67.     if (!UI_STRING_END_OF_STRING_CHARACTER(current_character))
  68.     {
  69.         if (b->flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  70.         {
  71.             UI_TEST_UCS2_DECREMENT_COUNT_SET_LENGTH(
  72.                 current_character,
  73.                 b->allocated_length,
  74.                 b->UCS2_count,
  75.                 b->available_length);
  76.         }
  77.         while (!UI_STRING_END_OF_STRING_CHARACTER(current_character))
  78.         {
  79.             UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  80.             UI_STRING_INSERT_CHARACTER(previous_text_p, current_character);
  81.         }
  82.         b->text_length -= ((S32) current_text_p - (S32) previous_text_p);
  83.         if (b->flags & UI_DIALER_INPUT_BOX_STATE_MULTITAP)
  84.         {
  85.             b->flags &= ~UI_DIALER_INPUT_BOX_STATE_MULTITAP;
  86.         }
  87.         UI_STRING_GET_PREVIOUS_CHARACTER(b->last_position_p, current_character);
  88.         /* gui_dialer_inputbox_locate_cursor(b); */
  89.         b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
  90.         b->change_callback();
  91.     }
  92.     else
  93.     {
  94.         UI_editor_play_tone_cannot_change();
  95.     }
  96. }
  97. /*****************************************************************************
  98.  * FUNCTION
  99.  *  gui_dialer_input_box_delete_all
  100.  * DESCRIPTION
  101.  *  Deletes all characters
  102.  * PARAMETERS
  103.  *  b       [IN]        Is the single-line inputbox object
  104.  * RETURNS
  105.  *  void
  106.  *****************************************************************************/
  107. void gui_dialer_input_box_delete_all(dialer_input_box *b)
  108. {
  109.     /*----------------------------------------------------------------*/
  110.     /* Local Variables                                                */
  111.     /*----------------------------------------------------------------*/
  112.     UI_character_type c;
  113.     UI_buffer_type p = b->text;
  114.     /*----------------------------------------------------------------*/
  115.     /* Code Body                                                      */
  116.     /*----------------------------------------------------------------*/
  117.     UI_STRING_GET_NEXT_CHARACTER(p, c);
  118.     UI_UNUSED_PARAMETER(c);
  119.     /* MTK Elvis 20040611 donot play tone while the text buffer is zero */
  120. #if 0
  121. /* under construction !*/
  122. /* under construction !*/
  123. /* under construction !*/
  124. /* under construction !*/
  125. #endif /* 0 */ 
  126.     /* MTK end */
  127.     gui_dialer_input_box_clear(b);
  128.     b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
  129.     b->change_callback();
  130. }
  131. /*****************************************************************************
  132.  * FUNCTION
  133.  *  gui_dialer_input_box_toggle_insert_mode
  134.  * DESCRIPTION
  135.  *  Toggles between Insert and Overwrite modes
  136.  * PARAMETERS
  137.  *  b       [IN]        Is the single-line inputbox object
  138.  * RETURNS
  139.  *  void
  140.  *****************************************************************************/
  141. void gui_dialer_input_box_toggle_insert_mode(dialer_input_box *b)
  142. {
  143.     /*----------------------------------------------------------------*/
  144.     /* Local Variables                                                */
  145.     /*----------------------------------------------------------------*/
  146.     /*----------------------------------------------------------------*/
  147.     /* Code Body                                                      */
  148.     /*----------------------------------------------------------------*/
  149.     if (b->flags & UI_DIALER_INPUT_BOX_OVERWRITE_MODE)
  150.     {
  151.         b->flags &= ~UI_DIALER_INPUT_BOX_OVERWRITE_MODE;
  152.     }
  153.     else
  154.     {
  155.         b->flags |= UI_DIALER_INPUT_BOX_OVERWRITE_MODE;
  156.     }
  157. }
  158. /*****************************************************************************
  159.  * FUNCTION
  160.  *  gui_dialer_input_box_insert_character
  161.  * DESCRIPTION
  162.  *  Inserts a character at the current cursor position
  163.  * PARAMETERS
  164.  *  b       [IN]        Is the single-line inputbox object
  165.  *  c       [IN]        Is the character to be inserted
  166.  * RETURNS
  167.  *  void
  168.  *****************************************************************************/
  169. void gui_dialer_input_box_insert_character(dialer_input_box *b, UI_character_type c)
  170. {
  171.     /*----------------------------------------------------------------*/
  172.     /* Local Variables                                                */
  173.     /*----------------------------------------------------------------*/
  174.     UI_buffer_type p1, p2;
  175.     UI_character_type old_c, dummy_c = 0;
  176.     U32 b_flags = b->flags;
  177.     /*----------------------------------------------------------------*/
  178.     /* Code Body                                                      */
  179.     /*----------------------------------------------------------------*/
  180.     if ((b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH) && (b->UCS2_count == 0) && UI_TEST_UCS2_CHARACTER(c))
  181.     {
  182.         if ((b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER) &&
  183.             (b->text_length >= UI_UCS2_STRING_HALF_LENGTH_MINUS_ONE(b->available_length)))
  184.         {
  185.             UI_editor_play_tone_cannot_insert();
  186.             return;
  187.         }
  188.         else if (b->text_length >= UI_UCS2_STRING_HALF_LENGTH(b->available_length))
  189.         {
  190.             UI_editor_play_tone_cannot_insert();    /* play error tone */
  191.             return;
  192.         }
  193.     }
  194.     p1 = p2 = b->current_text_p;
  195.     if (b_flags & UI_DIALER_INPUT_BOX_OVERWRITE_MODE)
  196.     {
  197.         UI_STRING_GET_NEXT_CHARACTER(p1, old_c);    /* get next character */
  198.         if ((p1 == b->last_position_p) && ((b->text_length) >= b->available_length))
  199.         {
  200.             return;
  201.         }
  202.         if (!UI_STRING_END_OF_STRING_CHARACTER(old_c))  /* check for end of string */
  203.         {
  204.             UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  205.             if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  206.             {
  207.                 if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  208.                 {
  209.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  210.                         old_c,
  211.                         c,
  212.                         b->UCS2_count,
  213.                         b->allocated_length,
  214.                         b->available_length);
  215.                 }
  216.                 else
  217.                 {
  218.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  219.                         old_c,
  220.                         c,
  221.                         b->UCS2_count,
  222.                         b->allocated_length,
  223.                         b->available_length);
  224.                 }
  225.             }
  226.             b->current_text_p = p2;
  227.         }
  228.         else    /* !UI_STRING_END_OF_STRING_CHARACTER(old_c) */
  229.         {
  230.             if (b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE)
  231.             {
  232.                 if ((b->text_length) >= (b->available_length))
  233.                 {
  234.                     UI_buffer_type p3, p4;
  235.                     UI_character_type cc;
  236.                     if (b->current_text_p != b->text)
  237.                     {
  238.                         p3 = p4 = b->text;
  239.                         UI_STRING_GET_NEXT_CHARACTER(p3, cc);
  240.                         while (p3 != b->current_text_p)
  241.                         {
  242.                             UI_STRING_GET_NEXT_CHARACTER(p3, cc);
  243.                             UI_STRING_INSERT_CHARACTER(p4, cc);
  244.                         }
  245.                         UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);   /* get previous character */
  246.                         UI_STRING_INSERT_CHARACTER(b->current_text_p, c);       /* insert character */
  247.                     }
  248.                 }
  249.                 else    /* (b->text_length)>=(b->available_length) */
  250.                 {
  251.                     UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  252.                     if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  253.                     {
  254.                         if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  255.                         {
  256.                             UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
  257.                                 c,
  258.                                 b->UCS2_count,
  259.                                 b->allocated_length,
  260.                                 b->available_length);
  261.                         }
  262.                         else
  263.                         {
  264.                             UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(
  265.                                 c,
  266.                                 b->UCS2_count,
  267.                                 b->allocated_length,
  268.                                 b->available_length);
  269.                         }
  270.                     }
  271.                     while (!UI_STRING_END_OF_STRING_CHARACTER(c))       /* check for end of string */
  272.                     {
  273.                         UI_STRING_GET_NEXT_CHARACTER(p1, old_c);        /* get next character */
  274.                         UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  275.                         c = old_c;
  276.                     }
  277.                     UI_STRING_INSERT_CHARACTER(p2, c);
  278.                     b->text_length += ((S32) p2 - (S32) p1);
  279.                     UI_STRING_GET_NEXT_CHARACTER(b->last_position_p, dummy_c);
  280.                 }
  281.             }
  282.             else    /* b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE */
  283.             {
  284.                 if ((b->text_length) >= (b->available_length))
  285.                 {
  286.                     UI_editor_play_tone_cannot_insert();
  287.                     return;
  288.                 }
  289.                 p1 = b->current_text_p;
  290.                 UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  291.                 while (!UI_STRING_END_OF_STRING_CHARACTER(c))   /* check for end of string */
  292.                 {
  293.                     UI_STRING_GET_NEXT_CHARACTER(p1, old_c);    /* get next character */
  294.                     UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  295.                     c = old_c;
  296.                 }
  297.                 UI_STRING_INSERT_CHARACTER(p2, c);
  298.                 if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  299.                 {
  300.                     if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  301.                     {
  302.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  303.                             old_c,
  304.                             c,
  305.                             b->UCS2_count,
  306.                             b->allocated_length,
  307.                             b->available_length);
  308.                     }
  309.                     else
  310.                     {
  311.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  312.                             old_c,
  313.                             c,
  314.                             b->UCS2_count,
  315.                             b->allocated_length,
  316.                             b->available_length);
  317.                     }
  318.                 }
  319.                 b->text_length += ((S32) p2 - (S32) p1);
  320.             }
  321.         }
  322.     }
  323.     else    /* b_flags & UI_DIALER_INPUT_BOX_OVERWRITE_MODE */
  324.     {
  325.         if (b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE)
  326.         {
  327.             if ((b->text_length) >= (b->available_length))
  328.             {
  329.                 UI_buffer_type p3, p4;
  330.                 UI_character_type cc;
  331.                 if (b->current_text_p != b->text)
  332.                 {
  333.                     p3 = p4 = b->text;
  334.                     UI_STRING_GET_NEXT_CHARACTER(p3, cc);
  335.                     while (p3 != b->current_text_p)
  336.                     {
  337.                         UI_STRING_GET_NEXT_CHARACTER(p3, cc);
  338.                         UI_STRING_INSERT_CHARACTER(p4, cc);
  339.                     }
  340.                     UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
  341.                     UI_STRING_INSERT_CHARACTER(b->current_text_p, c);
  342.                 }
  343.             }
  344.             else    /* (b->text_length)>=(b->available_length) */
  345.             {
  346.                 UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  347.                 if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  348.                 {
  349.                     if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  350.                     {
  351.                         UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
  352.                             c,
  353.                             b->UCS2_count,
  354.                             b->allocated_length,
  355.                             b->available_length);
  356.                     }
  357.                     else
  358.                     {
  359.                         UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(
  360.                             c,
  361.                             b->UCS2_count,
  362.                             b->allocated_length,
  363.                             b->available_length);
  364.                     }
  365.                 }
  366.                 while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  367.                 {
  368.                     UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  369.                     UI_STRING_INSERT_CHARACTER(p2, c);
  370.                     c = old_c;
  371.                 }
  372.                 UI_STRING_INSERT_CHARACTER(p2, c);
  373.                 b->text_length += ((S32) p2 - (S32) p1);
  374.                 UI_STRING_GET_NEXT_CHARACTER(b->last_position_p, dummy_c);
  375.             }
  376.         }
  377.         else    /* b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE */
  378.         {
  379.             if ((b->text_length) >= (b->available_length))
  380.             {
  381.                 UI_editor_play_tone_cannot_insert();
  382.                 return;
  383.             }
  384.             UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  385.             if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  386.             {
  387.                 if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  388.                 {
  389.                     UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
  390.                         c,
  391.                         b->UCS2_count,
  392.                         b->allocated_length,
  393.                         b->available_length);
  394.                 }
  395.                 else
  396.                 {
  397.                     UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(c, b->UCS2_count, b->allocated_length, b->available_length);
  398.                 }
  399.             }
  400.             while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  401.             {
  402.                 UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  403.                 UI_STRING_INSERT_CHARACTER(p2, c);
  404.                 c = old_c;
  405.             }
  406.             UI_STRING_INSERT_CHARACTER(p2, c);
  407.             b->text_length += ((S32) p2 - (S32) p1);
  408.             UI_STRING_GET_NEXT_CHARACTER(b->last_position_p, dummy_c);
  409.         }
  410.     }
  411.     /* gui_dialer_inputbox_locate_cursor(b); */
  412.     b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
  413.     b->change_callback();
  414.     UI_UNUSED_PARAMETER(dummy_c);
  415. }
  416. /*****************************************************************************
  417.  * FUNCTION
  418.  *  gui_dialer_input_box_test_overflow
  419.  * DESCRIPTION
  420.  *  check ifor overfloaw of dialer input box
  421.  * PARAMETERS
  422.  *  b       [IN]        Is the dialer input box object
  423.  * RETURNS
  424.  *  byte
  425.  *****************************************************************************/
  426. U8 gui_dialer_input_box_test_overflow(dialer_input_box *b)
  427. {
  428.     /*----------------------------------------------------------------*/
  429.     /* Local Variables                                                */
  430.     /*----------------------------------------------------------------*/
  431.     /*----------------------------------------------------------------*/
  432.     /* Code Body                                                      */
  433.     /*----------------------------------------------------------------*/
  434.     if ((b->text_length) >= (b->available_length))
  435.     {
  436.         return (1);
  437.     }
  438.     return (0);
  439. }
  440. /*****************************************************************************
  441.  * FUNCTION
  442.  *  gui_dialer_input_box_test_first_position
  443.  * DESCRIPTION
  444.  *  check if current cursorposition is at first character
  445.  * PARAMETERS
  446.  *  b       [IN]        Is the dialer input box object
  447.  * RETURNS
  448.  *  byte
  449.  *****************************************************************************/
  450. U8 gui_dialer_input_box_test_first_position(dialer_input_box *b)
  451. {
  452.     /*----------------------------------------------------------------*/
  453.     /* Local Variables                                                */
  454.     /*----------------------------------------------------------------*/
  455.     /*----------------------------------------------------------------*/
  456.     /* Code Body                                                      */
  457.     /*----------------------------------------------------------------*/
  458.     if (b->current_text_p == b->text)
  459.     {
  460.         return (1);
  461.     }
  462.     return (0);
  463. }
  464. /*****************************************************************************
  465.  * FUNCTION
  466.  *  gui_dialer_input_box_test_last_position
  467.  * DESCRIPTION
  468.  *  return text length of dialer nut box
  469.  * PARAMETERS
  470.  *  b       [IN]        Is the dialer input box object
  471.  * RETURNS
  472.  *  byte
  473.  *****************************************************************************/
  474. U8 gui_dialer_input_box_test_last_position(dialer_input_box *b)
  475. {
  476.     /*----------------------------------------------------------------*/
  477.     /* Local Variables                                                */
  478.     /*----------------------------------------------------------------*/
  479.     UI_character_type dummy_c = 0;
  480.     UI_buffer_type current_text_p = b->current_text_p;
  481.     /*----------------------------------------------------------------*/
  482.     /* Code Body                                                      */
  483.     /*----------------------------------------------------------------*/
  484.     UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
  485.     UI_UNUSED_PARAMETER(dummy_c);
  486.     if (current_text_p == b->last_position_p)
  487.     {
  488.         return (1);
  489.     }
  490.     return (0);
  491. }
  492. /*****************************************************************************
  493.  * FUNCTION
  494.  *  gui_dialer_input_box_test_last_character_position
  495.  * DESCRIPTION
  496.  *  return text length of dialer nut box
  497.  * PARAMETERS
  498.  *  b       [IN]        Is the dialer input box object
  499.  * RETURNS
  500.  *  byte
  501.  *****************************************************************************/
  502. U8 gui_dialer_input_box_test_last_character_position(dialer_input_box *b)
  503. {
  504.     /*----------------------------------------------------------------*/
  505.     /* Local Variables                                                */
  506.     /*----------------------------------------------------------------*/
  507.     UI_character_type dummy_c = 0;
  508.     UI_buffer_type current_text_p = b->current_text_p;
  509.     /*----------------------------------------------------------------*/
  510.     /* Code Body                                                      */
  511.     /*----------------------------------------------------------------*/
  512.     UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
  513.     if (current_text_p == b->last_position_p)
  514.     {
  515.         return (1);
  516.     }
  517.     UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
  518.     UI_UNUSED_PARAMETER(dummy_c);
  519.     if (current_text_p == b->last_position_p)
  520.     {
  521.         return (1);
  522.     }
  523.     return (0);
  524. }
  525. /*****************************************************************************
  526.  * FUNCTION
  527.  *  gui_dialer_input_box_test_last_position_overflow
  528.  * DESCRIPTION
  529.  *  return text length of dialer nut box
  530.  * PARAMETERS
  531.  *  b       [IN]        Is the dialer input box object
  532.  * RETURNS
  533.  *  byte
  534.  *****************************************************************************/
  535. U8 gui_dialer_input_box_test_last_position_overflow(dialer_input_box *b)
  536. {
  537.     /*----------------------------------------------------------------*/
  538.     /* Local Variables                                                */
  539.     /*----------------------------------------------------------------*/
  540.     U8 flag1 = 0;
  541.     U8 flag2 = 0;
  542.     UI_character_type dummy_c = 0;
  543.     UI_buffer_type current_text_p = b->current_text_p;
  544.     /*----------------------------------------------------------------*/
  545.     /* Code Body                                                      */
  546.     /*----------------------------------------------------------------*/
  547.     UI_STRING_GET_NEXT_CHARACTER(current_text_p, dummy_c);
  548.     UI_UNUSED_PARAMETER(dummy_c);
  549.     if (current_text_p == b->last_position_p)
  550.     {
  551.         flag1 = 1;
  552.     }
  553.     if ((b->text_length) >= (b->available_length))
  554.     {
  555.         flag2 = 1;
  556.     }
  557.     if (flag1 && flag2)
  558.     {
  559.         return (1);
  560.     }
  561.     return (0);
  562. }
  563. /*****************************************************************************
  564.  * FUNCTION
  565.  *  gui_dialer_input_box_get_text_length
  566.  * DESCRIPTION
  567.  *  return text length of dialer nut box
  568.  * PARAMETERS
  569.  *  b       [IN]        Is the dialer input box object
  570.  * RETURNS
  571.  *  S32 return txt length of dialer iput box
  572.  *****************************************************************************/
  573. S32 gui_dialer_input_box_get_text_length(dialer_input_box *b)
  574. {
  575.     /*----------------------------------------------------------------*/
  576.     /* Local Variables                                                */
  577.     /*----------------------------------------------------------------*/
  578.     /*----------------------------------------------------------------*/
  579.     /* Code Body                                                      */
  580.     /*----------------------------------------------------------------*/
  581.     return (((b->text_length) >> 1) - 1);
  582. }
  583. /*****************************************************************************
  584.  * FUNCTION
  585.  *  gui_dialer_input_box_insert_multitap_character
  586.  * DESCRIPTION
  587.  *  Inserts a multitap character at the current cursor position
  588.  *  
  589.  *  This function is normally used as the input_callback
  590.  *  function with multitap input objects
  591.  * PARAMETERS
  592.  *  b       [IN]        Is the single-line inputbox object
  593.  *  c       [IN]        Is the character to be inserted
  594.  * RETURNS
  595.  *  void
  596.  *****************************************************************************/
  597. void gui_dialer_input_box_insert_multitap_character(dialer_input_box *b, UI_character_type c)
  598. {
  599.     /*----------------------------------------------------------------*/
  600.     /* Local Variables                                                */
  601.     /*----------------------------------------------------------------*/
  602.     UI_buffer_type p1, p2;
  603.     UI_character_type old_c, dummy_c = 0;
  604.     U32 b_flags = b->flags;
  605.     /*----------------------------------------------------------------*/
  606.     /* Code Body                                                      */
  607.     /*----------------------------------------------------------------*/
  608.     if ((b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH) && (b->UCS2_count == 0) && UI_TEST_UCS2_CHARACTER(c))
  609.     {
  610.         if ((b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER) &&
  611.             (b->text_length >= UI_UCS2_STRING_HALF_LENGTH_MINUS_ONE(b->available_length)))
  612.         {
  613.             UI_editor_play_tone_cannot_insert();    /* play error tone of cannot insert */
  614.             return;
  615.         }
  616.         else if (b->text_length >= UI_UCS2_STRING_HALF_LENGTH(b->available_length))
  617.         {
  618.             UI_editor_play_tone_cannot_insert();
  619.             return;
  620.         }
  621.     }
  622.     if ((b_flags & UI_DIALER_INPUT_BOX_STATE_MULTITAP) && (b->current_text_p != b->text))
  623.     {
  624.         UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
  625.         p1 = p2 = b->current_text_p;
  626.         UI_STRING_GET_NEXT_CHARACTER(p1, old_c);        /* get next character */
  627.         if (!UI_STRING_END_OF_STRING_CHARACTER(old_c))  /* check for end of string */
  628.         {
  629.             UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  630.             if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  631.             {
  632.                 if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  633.                 {
  634.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  635.                         old_c,
  636.                         c,
  637.                         b->UCS2_count,
  638.                         b->allocated_length,
  639.                         b->available_length);
  640.                 }
  641.                 else
  642.                 {
  643.                     UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  644.                         old_c,
  645.                         c,
  646.                         b->UCS2_count,
  647.                         b->allocated_length,
  648.                         b->available_length);
  649.                 }
  650.             }
  651.             b->current_text_p = p2;
  652.         }
  653.         else    /* !UI_STRING_END_OF_STRING_CHARACTER(old_c) */
  654.         {
  655.             if (b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE)
  656.             {
  657.                 if ((b->text_length) >= (b->available_length))
  658.                 {
  659.                     UI_buffer_type p3, p4;
  660.                     UI_character_type cc;
  661.                     if (b->current_text_p != b->text)
  662.                     {
  663.                         p3 = p4 = b->text;
  664.                         UI_STRING_GET_NEXT_CHARACTER(p3, cc);   /* get next character */
  665.                         while (p3 != b->current_text_p)
  666.                         {
  667.                             UI_STRING_GET_NEXT_CHARACTER(p3, cc);
  668.                             UI_STRING_INSERT_CHARACTER(p4, cc);
  669.                         }
  670.                         UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
  671.                         UI_STRING_INSERT_CHARACTER(b->current_text_p, c);
  672.                     }
  673.                 }
  674.                 else    /* (b->text_length)>=(b->available_length) */
  675.                 {
  676.                     p1 = b->current_text_p;
  677.                     UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  678.                     while (!UI_STRING_END_OF_STRING_CHARACTER(c))       /* check for end of string */
  679.                     {
  680.                         UI_STRING_GET_NEXT_CHARACTER(p1, old_c);        /* get next character */
  681.                         UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  682.                         c = old_c;
  683.                     }
  684.                     UI_STRING_INSERT_CHARACTER(p2, c);
  685.                     if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  686.                     {
  687.                         if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  688.                         {
  689.                             UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  690.                                 old_c,
  691.                                 c,
  692.                                 b->UCS2_count,
  693.                                 b->allocated_length,
  694.                                 b->available_length);
  695.                         }
  696.                         else
  697.                         {
  698.                             UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  699.                                 old_c,
  700.                                 c,
  701.                                 b->UCS2_count,
  702.                                 b->allocated_length,
  703.                                 b->available_length);
  704.                         }
  705.                     }
  706.                     b->text_length += ((S32) p2 - (S32) p1);
  707.                 }
  708.             }
  709.             else    /* b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE */
  710.             {
  711.                 p1 = b->current_text_p;
  712.                 UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  713.                 while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  714.                 {
  715.                     UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  716.                     UI_STRING_INSERT_CHARACTER(p2, c);
  717.                     c = old_c;
  718.                 }
  719.                 UI_STRING_INSERT_CHARACTER(p2, c);
  720.                 if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  721.                 {
  722.                     if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  723.                     {
  724.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  725.                             old_c,
  726.                             c,
  727.                             b->UCS2_count,
  728.                             b->allocated_length,
  729.                             b->available_length);
  730.                     }
  731.                     else
  732.                     {
  733.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  734.                             old_c,
  735.                             c,
  736.                             b->UCS2_count,
  737.                             b->allocated_length,
  738.                             b->available_length);
  739.                     }
  740.                 }
  741.                 b->text_length += ((S32) p2 - (S32) p1);
  742.             }
  743.         }
  744.     }
  745.     else    /* (b_flags & UI_DIALER_INPUT_BOX_STATE_MULTITAP) && (b->current_text_p!=b->text) */
  746.     {
  747.         p1 = p2 = b->current_text_p;
  748.         if (b_flags & UI_DIALER_INPUT_BOX_OVERWRITE_MODE)
  749.         {
  750.             UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  751.             if ((p1 == b->last_position_p) && ((b->text_length) >= b->available_length))
  752.             {
  753.                 if (b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE)
  754.                 {
  755.                     UI_buffer_type p3, p4;
  756.                     UI_character_type cc;
  757.                     if (b->current_text_p != b->text)
  758.                     {
  759.                         p3 = p4 = b->text;
  760.                         UI_STRING_GET_NEXT_CHARACTER(p3, cc);   /* get next character */
  761.                         while (p3 != b->current_text_p)
  762.                         {
  763.                             UI_STRING_GET_NEXT_CHARACTER(p3, cc);
  764.                             UI_STRING_INSERT_CHARACTER(p4, cc);
  765.                         }
  766.                         UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
  767.                         UI_STRING_INSERT_CHARACTER(b->current_text_p, c);
  768.                     }
  769.                     return;
  770.                 }
  771.                 else    /* b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE */
  772.                 {
  773.                     UI_editor_play_tone_cannot_insert();    /* play error tone of cannot insert */
  774.                     return;
  775.                 }
  776.             }
  777.             if (!UI_STRING_END_OF_STRING_CHARACTER(old_c))  /* check for end of string */
  778.             {
  779.                 UI_STRING_INSERT_CHARACTER(p2, c);
  780.                 if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  781.                 {
  782.                     if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  783.                     {
  784.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  785.                             old_c,
  786.                             c,
  787.                             b->UCS2_count,
  788.                             b->allocated_length,
  789.                             b->available_length);
  790.                     }
  791.                     else
  792.                     {
  793.                         UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  794.                             old_c,
  795.                             c,
  796.                             b->UCS2_count,
  797.                             b->allocated_length,
  798.                             b->available_length);
  799.                     }
  800.                 }
  801.                 b->current_text_p = p2;
  802.             }
  803.             else    /* !UI_STRING_END_OF_STRING_CHARACTER(old_c) */
  804.             {
  805.                 if (b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE)
  806.                 {
  807.                     if ((b->text_length) >= (b->available_length))
  808.                     {
  809.                         UI_buffer_type p3, p4;
  810.                         UI_character_type cc;
  811.                         if (b->current_text_p != b->text)
  812.                         {
  813.                             p3 = p4 = b->text;
  814.                             UI_STRING_GET_NEXT_CHARACTER(p3, cc);       /* get */
  815.                             while (p3 != b->current_text_p)
  816.                             {
  817.                                 UI_STRING_GET_NEXT_CHARACTER(p3, cc);
  818.                                 UI_STRING_INSERT_CHARACTER(p4, cc);
  819.                             }
  820.                             UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
  821.                             UI_STRING_INSERT_CHARACTER(b->current_text_p, c);
  822.                         }
  823.                     }
  824.                     else    /* (b->text_length)>=(b->available_length) */
  825.                     {
  826.                         p1 = b->current_text_p;
  827.                         UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  828.                         while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  829.                         {
  830.                             UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  831.                             UI_STRING_INSERT_CHARACTER(p2, c);
  832.                             c = old_c;
  833.                         }
  834.                         UI_STRING_INSERT_CHARACTER(p2, c);  /* insert character */
  835.                         if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  836.                         {
  837.                             if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  838.                             {
  839.                                 UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  840.                                     old_c,
  841.                                     c,
  842.                                     b->UCS2_count,
  843.                                     b->allocated_length,
  844.                                     b->available_length);
  845.                             }
  846.                             else
  847.                             {
  848.                                 UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  849.                                     old_c,
  850.                                     c,
  851.                                     b->UCS2_count,
  852.                                     b->allocated_length,
  853.                                     b->available_length);
  854.                             }
  855.                         }
  856.                         b->text_length += ((S32) p2 - (S32) p1);
  857.                     }
  858.                 }
  859.                 else    /* b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE */
  860.                 {
  861.                     if ((b->text_length) >= (b->available_length))
  862.                     {
  863.                         UI_editor_play_tone_cannot_insert();
  864.                         return;
  865.                     }
  866.                     p1 = b->current_text_p;
  867.                     UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  868.                     while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  869.                     {
  870.                         UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  871.                         UI_STRING_INSERT_CHARACTER(p2, c);
  872.                         c = old_c;
  873.                     }
  874.                     UI_STRING_INSERT_CHARACTER(p2, c);  /* insert chatracte */
  875.                     if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  876.                     {
  877.                         if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  878.                         {
  879.                             UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH_TYPE2(
  880.                                 old_c,
  881.                                 c,
  882.                                 b->UCS2_count,
  883.                                 b->allocated_length,
  884.                                 b->available_length);
  885.                         }
  886.                         else
  887.                         {
  888.                             UI_TEST_UCS2_CHANGE_COUNT_SET_LENGTH(
  889.                                 old_c,
  890.                                 c,
  891.                                 b->UCS2_count,
  892.                                 b->allocated_length,
  893.                                 b->available_length);
  894.                         }
  895.                     }
  896.                     b->text_length += ((S32) p2 - (S32) p1);
  897.                 }
  898.             }
  899.         }
  900.         else    /* b_flags & UI_DIALER_INPUT_BOX_OVERWRITE_MODE */
  901.         {
  902.             if (b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE)
  903.             {
  904.                 if ((b->text_length) >= (b->available_length))
  905.                 {
  906.                     UI_buffer_type p3, p4;
  907.                     UI_character_type cc;
  908.                     if (b->current_text_p != b->text)
  909.                     {
  910.                         p3 = p4 = b->text;
  911.                         UI_STRING_GET_NEXT_CHARACTER(p3, cc);
  912.                         while (p3 != b->current_text_p)
  913.                         {
  914.                             UI_STRING_GET_NEXT_CHARACTER(p3, cc);
  915.                             UI_STRING_INSERT_CHARACTER(p4, cc);
  916.                         }
  917.                         UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
  918.                         UI_STRING_INSERT_CHARACTER(b->current_text_p, c);
  919.                     }
  920.                 }
  921.                 else    /* (b->text_length)>=(b->available_length) */
  922.                 {
  923.                     UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  924.                     if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  925.                     {
  926.                         if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  927.                         {
  928.                             UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
  929.                                 c,
  930.                                 b->UCS2_count,
  931.                                 b->allocated_length,
  932.                                 b->available_length);
  933.                         }
  934.                         else
  935.                         {
  936.                             UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(
  937.                                 c,
  938.                                 b->UCS2_count,
  939.                                 b->allocated_length,
  940.                                 b->available_length);
  941.                         }
  942.                     }
  943.                     while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  944.                     {
  945.                         UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  946.                         UI_STRING_INSERT_CHARACTER(p2, c);
  947.                         c = old_c;
  948.                     }
  949.                     UI_STRING_INSERT_CHARACTER(p2, c);
  950.                     b->text_length += ((S32) p2 - (S32) p1);
  951.                     UI_STRING_GET_NEXT_CHARACTER(b->last_position_p, dummy_c);
  952.                 }
  953.             }
  954.             else    /* b_flags & UI_DIALER_INPUT_BOX_CHARACTER_QUEUE */
  955.             {
  956.                 if ((b->text_length) >= (b->available_length))
  957.                 {
  958.                     UI_editor_play_tone_cannot_insert();
  959.                     return;
  960.                 }
  961.                 UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  962.                 if (b_flags & UI_DIALER_INPUT_BOX_USE_ENCODING_BASED_LENGTH)
  963.                 {
  964.                     if (b_flags & UI_DIALER_INPUT_BOX_ONE_LESS_CHARACTER)
  965.                     {
  966.                         UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH_TYPE2(
  967.                             c,
  968.                             b->UCS2_count,
  969.                             b->allocated_length,
  970.                             b->available_length);
  971.                     }
  972.                     else
  973.                     {
  974.                         UI_TEST_UCS2_INCREMENT_COUNT_SET_LENGTH(
  975.                             c,
  976.                             b->UCS2_count,
  977.                             b->allocated_length,
  978.                             b->available_length);
  979.                     }
  980.                 }
  981.                 while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  982.                 {
  983.                     UI_STRING_GET_NEXT_CHARACTER(p1, old_c);
  984.                     UI_STRING_INSERT_CHARACTER(p2, c);
  985.                     c = old_c;
  986.                 }
  987.                 UI_STRING_INSERT_CHARACTER(p2, c);
  988.                 b->text_length += ((S32) p2 - (S32) p1);
  989.                 UI_STRING_GET_NEXT_CHARACTER(b->last_position_p, dummy_c);
  990.             }
  991.         }
  992.         b->flags |= UI_DIALER_INPUT_BOX_STATE_MULTITAP;
  993.     }
  994.     /* gui_dialer_inputbox_locate_cursor(b); */
  995.     b->validation_callback(b->text, b->current_text_p, (b->text_length >> 1) - 1);
  996.     b->change_callback();
  997.     UI_UNUSED_PARAMETER(dummy_c);
  998. }
  999. /*****************************************************************************
  1000.  * FUNCTION
  1001.  *  gui_dialer_input_box_confirm_multitap_character
  1002.  * DESCRIPTION
  1003.  *  Completes the multitap input sequence.
  1004.  *  
  1005.  *  This function is normally used as the input_complete_callback
  1006.  *  function with multitap input objects
  1007.  * PARAMETERS
  1008.  *  b       [IN]        Is the single-line inputbox object
  1009.  * RETURNS
  1010.  *  void
  1011.  *****************************************************************************/
  1012. void gui_dialer_input_box_confirm_multitap_character(dialer_input_box *b)
  1013. {
  1014.     /*----------------------------------------------------------------*/
  1015.     /* Local Variables                                                */
  1016.     /*----------------------------------------------------------------*/
  1017.     /*----------------------------------------------------------------*/
  1018.     /* Code Body                                                      */
  1019.     /*----------------------------------------------------------------*/
  1020.     b->flags &= ~UI_DIALER_INPUT_BOX_STATE_MULTITAP;
  1021. }
  1022. /*****************************************************************************
  1023.  * FUNCTION
  1024.  *  gui_dialer_input_box_previous
  1025.  * DESCRIPTION
  1026.  *  Moves the cursor to the previous character
  1027.  * PARAMETERS
  1028.  *  b       [IN]        Is the single-line inputbox object
  1029.  * RETURNS
  1030.  *  void
  1031.  *****************************************************************************/
  1032. void gui_dialer_input_box_previous(dialer_input_box *b)
  1033. {
  1034.     /*----------------------------------------------------------------*/
  1035.     /* Local Variables                                                */
  1036.     /*----------------------------------------------------------------*/
  1037.     UI_character_type dummy_c = 0;
  1038.     /*----------------------------------------------------------------*/
  1039.     /* Code Body                                                      */
  1040.     /*----------------------------------------------------------------*/
  1041.     if (b->text == NULL)
  1042.     {
  1043.         UI_editor_play_tone_cannot_navigate();
  1044.         return;
  1045.     }
  1046.     if (b->current_text_p == b->text)
  1047.     {
  1048.         UI_editor_play_tone_cannot_navigate();
  1049.         return;
  1050.     }
  1051.     UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
  1052.     UI_UNUSED_PARAMETER(dummy_c);
  1053. }
  1054. /*****************************************************************************
  1055.  * FUNCTION
  1056.  *  gui_dialer_input_box_next
  1057.  * DESCRIPTION
  1058.  *  Moves the cursor to the next character
  1059.  * PARAMETERS
  1060.  *  b       [IN]        Is the single-line inputbox object
  1061.  * RETURNS
  1062.  *  void
  1063.  *****************************************************************************/
  1064. void gui_dialer_input_box_next(dialer_input_box *b)
  1065. {
  1066.     /*----------------------------------------------------------------*/
  1067.     /* Local Variables                                                */
  1068.     /*----------------------------------------------------------------*/
  1069.     UI_buffer_type current_text_p = b->current_text_p;
  1070.     UI_character_type current_character;
  1071.     /*----------------------------------------------------------------*/
  1072.     /* Code Body                                                      */
  1073.     /*----------------------------------------------------------------*/
  1074.     if (b->text == NULL)
  1075.     {
  1076.         UI_editor_play_tone_cannot_navigate();
  1077.         return;
  1078.     }
  1079.     UI_STRING_GET_NEXT_CHARACTER(current_text_p, current_character);
  1080.     if (UI_STRING_END_OF_STRING_CHARACTER(current_character))
  1081.     {
  1082.         UI_editor_play_tone_cannot_navigate();
  1083.         return;
  1084.     }
  1085.     b->current_text_p = current_text_p;
  1086. }
  1087. /*****************************************************************************
  1088.  * FUNCTION
  1089.  *  gui_resize_dialer_input_box
  1090.  * DESCRIPTION
  1091.  *  Changes the size of the single-line inputbox.
  1092.  * PARAMETERS
  1093.  *  b           [IN]        Is the single-line inputbox object
  1094.  *  width       [IN]        Is the new width
  1095.  *  height      [IN]        Is the new height
  1096.  * RETURNS
  1097.  *  void
  1098.  *****************************************************************************/
  1099. void gui_resize_dialer_input_box(dialer_input_box *b, S32 width, S32 height)
  1100. {
  1101.     /*----------------------------------------------------------------*/
  1102.     /* Local Variables                                                */
  1103.     /*----------------------------------------------------------------*/
  1104.     /*----------------------------------------------------------------*/
  1105.     /* Code Body                                                      */
  1106.     /*----------------------------------------------------------------*/
  1107.     b->width = width;
  1108.     b->height = height;
  1109. }
  1110. /*****************************************************************************
  1111.  * FUNCTION
  1112.  *  gui_dialer_input_box_goto_first_character
  1113.  * DESCRIPTION
  1114.  *  go to first charcter of dialer input box
  1115.  * PARAMETERS
  1116.  *  b       [IN]        Dialer input bx
  1117.  * RETURNS
  1118.  *  void
  1119.  *****************************************************************************/
  1120. void gui_dialer_input_box_goto_first_character(dialer_input_box *b)
  1121. {
  1122.     /*----------------------------------------------------------------*/
  1123.     /* Local Variables                                                */
  1124.     /*----------------------------------------------------------------*/
  1125.     /*----------------------------------------------------------------*/
  1126.     /* Code Body                                                      */
  1127.     /*----------------------------------------------------------------*/
  1128.     b->current_text_p = b->text;
  1129. }
  1130. /*****************************************************************************
  1131.  * FUNCTION
  1132.  *  gui_dialer_input_box_goto_last_character
  1133.  * DESCRIPTION
  1134.  *  go to last charcter of dialer input box
  1135.  * PARAMETERS
  1136.  *  b       [IN]        Dialer input bx
  1137.  * RETURNS
  1138.  *  void
  1139.  *****************************************************************************/
  1140. void gui_dialer_input_box_goto_last_character(dialer_input_box *b)
  1141. {
  1142.     /*----------------------------------------------------------------*/
  1143.     /* Local Variables                                                */
  1144.     /*----------------------------------------------------------------*/
  1145.     UI_character_type dummy_c = 0;
  1146.     U8 done = 0;
  1147.     /*----------------------------------------------------------------*/
  1148.     /* Code Body                                                      */
  1149.     /*----------------------------------------------------------------*/
  1150.     b->current_text_p = b->text;
  1151.     if (b->text != NULL)
  1152.     {
  1153.         while (!done)
  1154.         {
  1155.             UI_STRING_GET_NEXT_CHARACTER(b->current_text_p, dummy_c);
  1156.             if (UI_STRING_END_OF_STRING_CHARACTER(dummy_c))
  1157.             {
  1158.                 break;
  1159.             }
  1160.         }
  1161.         if (b->current_text_p != b->text)
  1162.         {
  1163.             UI_STRING_GET_PREVIOUS_CHARACTER(b->current_text_p, dummy_c);
  1164.         }
  1165.     }
  1166. }
  1167. /* Interfaces to play error tones in the editors   */
  1168. #include "SettingProfile.h"
  1169. #include "ProfileGprots.h"
  1170. #include "KeyBrd.h"
  1171. U8 UI_editor_tones_flag = 1;
  1172. /*****************************************************************************
  1173.  * FUNCTION
  1174.  *  UI_editor_play_tone_cannot_change
  1175.  * DESCRIPTION
  1176.  *  play tone of cannot change
  1177.  * PARAMETERS
  1178.  *  void
  1179.  * RETURNS
  1180.  *  void
  1181.  *****************************************************************************/
  1182. void UI_editor_play_tone_cannot_change(void)
  1183. {
  1184.     /*----------------------------------------------------------------*/
  1185.     /* Local Variables                                                */
  1186.     /*----------------------------------------------------------------*/
  1187.     /*----------------------------------------------------------------*/
  1188.     /* Code Body                                                      */
  1189.     /*----------------------------------------------------------------*/
  1190.     if (!UI_editor_tones_flag)
  1191.     {
  1192.         return;
  1193.     }
  1194.     StopCurrentKeyPadTone();
  1195.     playRequestedTone(ERROR_TONE);
  1196. }
  1197. /*****************************************************************************
  1198.  * FUNCTION
  1199.  *  UI_editor_play_tone_cannot_navigate
  1200.  * DESCRIPTION
  1201.  *  play tone of cannot navigate
  1202.  * PARAMETERS
  1203.  *  void
  1204.  * RETURNS
  1205.  *  void
  1206.  *****************************************************************************/
  1207. void UI_editor_play_tone_cannot_navigate(void)
  1208. {
  1209.     /*----------------------------------------------------------------*/
  1210.     /* Local Variables                                                */
  1211.     /*----------------------------------------------------------------*/
  1212.     /*----------------------------------------------------------------*/
  1213.     /* Code Body                                                      */
  1214.     /*----------------------------------------------------------------*/
  1215.     if (!UI_editor_tones_flag)
  1216.     {
  1217.         return;
  1218.     }
  1219.     StopCurrentKeyPadTone();
  1220.     playRequestedTone(ERROR_TONE);
  1221. }
  1222. /*****************************************************************************
  1223.  * FUNCTION
  1224.  *  UI_editor_play_tone_cannot_insert
  1225.  * DESCRIPTION
  1226.  *  play tone of cannot insert error
  1227.  * PARAMETERS
  1228.  *  void
  1229.  * RETURNS
  1230.  *  void
  1231.  *****************************************************************************/
  1232. #ifdef __MMI_POPUP_REACH_MAX_LENGTH_MSG__
  1233. #include "globaldefs.h"
  1234. #include "t9def.h"
  1235. #endif /* __MMI_POPUP_REACH_MAX_LENGTH_MSG__ */ 
  1236. void UI_editor_play_tone_cannot_insert(void)
  1237. {
  1238. #ifdef __MMI_POPUP_REACH_MAX_LENGTH_MSG__
  1239.     /*----------------------------------------------------------------*/
  1240.     /* Local Variables                                                */
  1241.     /*----------------------------------------------------------------*/
  1242.     /*----------------------------------------------------------------*/
  1243.     /* Code Body                                                      */
  1244.     /*----------------------------------------------------------------*/
  1245.     DisplayPopup((PU8) GetString(STR_INPUT_METHOD_REACH_MAX_LEN), IMG_GLOBAL_WARNING, 0, 1000, (U8) WARNING_TONE);
  1246. #else /* __MMI_POPUP_REACH_MAX_LENGTH_MSG__ */ 
  1247.     if (!UI_editor_tones_flag)
  1248.     {
  1249.         return;
  1250.     }
  1251.     StopCurrentKeyPadTone();
  1252.     playRequestedTone(ERROR_TONE);
  1253. #endif /* __MMI_POPUP_REACH_MAX_LENGTH_MSG__ */ 
  1254. }
  1255. /*****************************************************************************
  1256.  * FUNCTION
  1257.  *  UI_editor_play_tone_invalid_data
  1258.  * DESCRIPTION
  1259.  *  play tone of invalid data
  1260.  * PARAMETERS
  1261.  *  void
  1262.  * RETURNS
  1263.  *  void
  1264.  *****************************************************************************/
  1265. void UI_editor_play_tone_invalid_data(void)
  1266. {
  1267.     /*----------------------------------------------------------------*/
  1268.     /* Local Variables                                                */
  1269.     /*----------------------------------------------------------------*/
  1270.     /*----------------------------------------------------------------*/
  1271.     /* Code Body                                                      */
  1272.     /*----------------------------------------------------------------*/
  1273.     if (!UI_editor_tones_flag)
  1274.     {
  1275.         return;
  1276.     }
  1277.     StopCurrentKeyPadTone();    /* stop cuurent tone */
  1278.     playRequestedTone(ERROR_TONE);
  1279. }
  1280. /*****************************************************************************
  1281.  * FUNCTION
  1282.  *  UI_editor_disable_tones
  1283.  * DESCRIPTION
  1284.  *  disable editor tone
  1285.  * PARAMETERS
  1286.  *  void
  1287.  * RETURNS
  1288.  *  void
  1289.  *****************************************************************************/
  1290. void UI_editor_disable_tones(void)
  1291. {
  1292.     /*----------------------------------------------------------------*/
  1293.     /* Local Variables                                                */
  1294.     /*----------------------------------------------------------------*/
  1295.     /*----------------------------------------------------------------*/
  1296.     /* Code Body                                                      */
  1297.     /*----------------------------------------------------------------*/
  1298.     UI_editor_tones_flag = 0;
  1299. }
  1300. /*****************************************************************************
  1301.  * FUNCTION
  1302.  *  UI_editor_enable_tones
  1303.  * DESCRIPTION
  1304.  *  enabel editor tone
  1305.  * PARAMETERS
  1306.  *  void
  1307.  * RETURNS
  1308.  *  void
  1309.  *****************************************************************************/
  1310. void UI_editor_enable_tones(void)
  1311. {
  1312.     /*----------------------------------------------------------------*/
  1313.     /* Local Variables                                                */
  1314.     /*----------------------------------------------------------------*/
  1315.     /*----------------------------------------------------------------*/
  1316.     /* Code Body                                                      */
  1317.     /*----------------------------------------------------------------*/
  1318.     UI_editor_tones_flag = 1;
  1319. }
  1320. #if defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__)
  1321. /* Check the chracter for WCSS permitted input character */
  1322. /*****************************************************************************
  1323.  * FUNCTION
  1324.  *  UI_check_WCSS_normal_character
  1325.  * DESCRIPTION
  1326.  *  
  1327.  * PARAMETERS
  1328.  *  c               [IN]        
  1329.  *  input_type      [?]         
  1330.  * RETURNS
  1331.  *  
  1332.  *****************************************************************************/
  1333. static S8 UI_check_WCSS_normal_character(UI_character_type c, U8 *input_type)
  1334. {
  1335.     /*----------------------------------------------------------------*/
  1336.     /* Local Variables                                                */
  1337.     /*----------------------------------------------------------------*/
  1338.     /*----------------------------------------------------------------*/
  1339.     /* Code Body                                                      */
  1340.     /*----------------------------------------------------------------*/
  1341.     if (((UI_character_type) c == (UI_character_type) 0x41))    /* 'A' */
  1342.     {
  1343.         *input_type = INPUT_MODE_MULTITAP_UPPERCASE_ABC_NO_NUMERIC | PIXTEL_UI_WCSS_SPACE_DEFAULT_CHARACTER;
  1344.         return 1;
  1345.     }
  1346.     else if (((UI_character_type) c == (UI_character_type) 0x61))       /* 'a' */
  1347.     {
  1348.         *input_type = INPUT_MODE_MULTITAP_LOWERCASE_ABC_NO_NUMERIC | PIXTEL_UI_WCSS_SPACE_DEFAULT_CHARACTER;
  1349.         return 1;
  1350.     }
  1351.     else if (((UI_character_type) c == (UI_character_type) 0x4E))       /* 'N' */
  1352.     {
  1353.         *input_type = INPUT_MODE_123;
  1354.         return 1;
  1355.     }
  1356.     else if (((UI_character_type) c == (UI_character_type) 0x6E))       /* 'n' */
  1357.     {
  1358.         *input_type = INPUT_MODE_123_SYMBOLS;
  1359.         return 1;
  1360.     }
  1361.     else if (((UI_character_type) c == (UI_character_type) 0x58))       /* 'X' */
  1362.     {
  1363.         *input_type = INPUT_MODE_MULTITAP_UPPERCASE_ABC | PIXTEL_UI_WCSS_SPACE_DEFAULT_CHARACTER;
  1364.         return 1;
  1365.     }
  1366.     else if (((UI_character_type) c == (UI_character_type) 0x78))       /* 'x' */
  1367.     {
  1368.         *input_type = INPUT_MODE_MULTITAP_LOWERCASE_ABC | PIXTEL_UI_WCSS_SPACE_DEFAULT_CHARACTER;
  1369.         return 1;
  1370.     }
  1371.     else if (((UI_character_type) c == (UI_character_type) 0x4D))       /* 'M' */
  1372.     {
  1373.         *input_type =
  1374.             INPUT_MODE_MULTITAP_UPPERCASE_ABC | PIXTEL_UI_WCSS_SPACE_DEFAULT_CHARACTER |
  1375.             PIXTEL_UI_ALL_INPUT_METHODS_ALLOWED;
  1376.         return 1;
  1377.     }
  1378.     else if (((UI_character_type) c == (UI_character_type) 0x6D))       /* 'm' */
  1379.     {
  1380.         *input_type =
  1381.             INPUT_MODE_MULTITAP_LOWERCASE_ABC | PIXTEL_UI_WCSS_SPACE_DEFAULT_CHARACTER |
  1382.             PIXTEL_UI_ALL_INPUT_METHODS_ALLOWED;
  1383.         return 1;
  1384.     }
  1385.     else
  1386.     {
  1387.         return 0;
  1388.     }
  1389. }
  1390. /* Insert default chracter 0 or ' ' according to input format character. */
  1391. /*****************************************************************************
  1392.  * FUNCTION
  1393.  *  UI_insert_WCSS_default_character
  1394.  * DESCRIPTION
  1395.  *  
  1396.  * PARAMETERS
  1397.  *  str     [?]         
  1398.  *  c       [IN]        
  1399.  * RETURNS
  1400.  *  
  1401.  *****************************************************************************/
  1402. static U8 *UI_insert_WCSS_default_character(U8 *str, UI_character_type c)
  1403. {
  1404.     /*----------------------------------------------------------------*/
  1405.     /* Local Variables                                                */
  1406.     /*----------------------------------------------------------------*/
  1407.     /*----------------------------------------------------------------*/
  1408.     /* Code Body                                                      */
  1409.     /*----------------------------------------------------------------*/
  1410.     switch (c)
  1411.     {
  1412.         case 0x41:
  1413.         case 0x61:
  1414.         case 0x58:
  1415.         case 0x78:
  1416.         case 0x4D:
  1417.         case 0x6D:
  1418.             c = 0x20;   /* ' ' */
  1419.             break;
  1420.         case 0x4E:
  1421.         case 0x6E:
  1422.             c = 0x30;   /* '0' */
  1423.             break;
  1424.         default:
  1425.             /* Keep default value of c */
  1426.             break;
  1427.     }
  1428.     (*((str))++) = (U8) (((c) & 0xff));
  1429.     (*((str))++) = (U8) (((c) >> 8));
  1430.     return str;
  1431. }
  1432. /*****************************************************************************
  1433.  * FUNCTION
  1434.  *  gui_parse_WCSS_string
  1435.  * DESCRIPTION
  1436.  *  Parse the WCSS format string, check for invalid format and create default string.
  1437.  * PARAMETERS
  1438.  *  s1                  [IN]        IN input format
  1439.  *  s2                  [IN]        OUT   text buffer
  1440.  *  s3                  [IN]        OUT   parsed format (typically cat115buffer)
  1441.  *  str_len             [IN]        IN length of dchar including ''
  1442.  *  reserve_data        [IN]        IN whether history is present
  1443.  *  for(?)              [OUT]       Invalid format
  1444.  * RETURNS
  1445.  *  void
  1446.  *****************************************************************************/
  1447. S8 gui_parse_WCSS_string(U8 *s1, U8 *s2, U8 *s3, S16 str_len, U8 reserve_data)
  1448. {
  1449.     /*----------------------------------------------------------------*/
  1450.     /* Local Variables                                                */
  1451.     /*----------------------------------------------------------------*/
  1452.     UI_character_type c, dst_ch;
  1453.     U8 input_type;
  1454.     U8 *original_s2 = s2;
  1455.     U8 *prev_s2;
  1456.     U8 *original_s3 = s3;
  1457.     /*----------------------------------------------------------------*/
  1458.     /* Code Body                                                      */
  1459.     /*----------------------------------------------------------------*/
  1460.     UI_STRING_GET_NEXT_CHARACTER(s1, c) while (!UI_STRING_END_OF_STRING_CHARACTER(c) && str_len > 1)
  1461.     {
  1462.         if (UI_check_WCSS_normal_character(c, &input_type))
  1463.         {
  1464.             *s3++ = input_type;
  1465.             if (reserve_data == 0)
  1466.             {
  1467.                 s2 = UI_insert_WCSS_default_character(s2, c);
  1468.             }
  1469.             else
  1470.             {
  1471.                 /* Default string might be shorter than required by s1 (input format) */
  1472.                 prev_s2 = s2;
  1473.                 UI_STRING_GET_NEXT_CHARACTER(s2, dst_ch);
  1474.                 if (dst_ch == 0)
  1475.                 {
  1476.                     reserve_data = 0;
  1477.                     s2 = UI_insert_WCSS_default_character(prev_s2, c);
  1478.                 }
  1479.             }
  1480.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1481.             str_len--;
  1482.         }
  1483.         else if (c == 0x5C) /* '\' */
  1484.         {
  1485.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1486.             if (UI_STRING_END_OF_STRING_CHARACTER(c))
  1487.             {
  1488.                 goto parse_error;
  1489.             }
  1490.             *s3++ = 0xff;   /* Not editable character */
  1491.             if (reserve_data == 0)
  1492.             {
  1493.                 UI_STRING_INSERT_CHARACTER(s2, c);
  1494.             }
  1495.             else
  1496.             {
  1497.                 /* Default string might be shorter than required by s1 (input format) */
  1498.                 prev_s2 = s2;
  1499.                 UI_STRING_GET_NEXT_CHARACTER(s2, dst_ch);
  1500.                 if (dst_ch == 0)
  1501.                 {
  1502.                     reserve_data = 0;
  1503.                     s2 = prev_s2;
  1504.                     UI_STRING_INSERT_CHARACTER(s2, c);
  1505.                 }
  1506.             }
  1507.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1508.             str_len--;
  1509.         }
  1510.         else if (c == 0x2A) /* '*' */
  1511.         {
  1512.             S16 i = 0;
  1513.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1514.             if (UI_STRING_END_OF_STRING_CHARACTER(c) || (!UI_check_WCSS_normal_character(c, &input_type)))
  1515.             {
  1516.                 goto parse_error;
  1517.             }
  1518.             for (i = 0; i < str_len - 1; i++)
  1519.             {
  1520.                 /* Setup format only. No default value for * format */
  1521.                 /* s2 = UI_insert_WCSS_default_character(s2, c); */
  1522.                 *s3++ = input_type | PIXTEL_UI_WCSS_STAR_INPUT;
  1523.             }
  1524.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1525.             if (!UI_STRING_END_OF_STRING_CHARACTER(c))
  1526.             {
  1527.                 goto parse_error;
  1528.             }
  1529.             c = 0;
  1530.             break;
  1531.         }
  1532.         else if ((c >= 0x31) && (c <= 0x39))    /* '1' - '9' */
  1533.         {
  1534.             S16 n = c - 0x30;
  1535.             S16 i = 0;
  1536.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1537.             while ((c >= 0x30) && (c <= 0x39))  /* '0' - '9' */
  1538.             {
  1539.                 n *= 10;
  1540.                 n += (c - 0x30);
  1541.                 UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1542.             }
  1543.             if (UI_STRING_END_OF_STRING_CHARACTER(c) || (!UI_check_WCSS_normal_character(c, &input_type)))
  1544.             {
  1545.                 goto parse_error;
  1546.             }
  1547.             if (n > str_len - 1)
  1548.             {
  1549.                 goto parse_error;
  1550.             }
  1551.             for (i = 0; i < n; i++)
  1552.             {
  1553.                 *s3++ = input_type;
  1554.                 if (reserve_data == 0)
  1555.                 {
  1556.                     s2 = UI_insert_WCSS_default_character(s2, c);
  1557.                 }
  1558.                 else
  1559.                 {
  1560.                     /* Default string might be shorter than required by s1 (input format) */
  1561.                     prev_s2 = s2;
  1562.                     UI_STRING_GET_NEXT_CHARACTER(s2, dst_ch);
  1563.                     if (dst_ch == 0)
  1564.                     {
  1565.                         reserve_data = 0;
  1566.                         s2 = UI_insert_WCSS_default_character(prev_s2, c);
  1567.                     }
  1568.                 }
  1569.             }
  1570.             str_len -= n;
  1571.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1572.         }
  1573.         else
  1574.         {
  1575.             goto parse_error;
  1576.         }
  1577.     }
  1578.     /* Buffer size smaller than required by input-format */
  1579.     if (!UI_STRING_END_OF_STRING_CHARACTER(c))
  1580.     {
  1581.         goto parse_error;
  1582.     }
  1583.     *s3 = '';
  1584.     if (reserve_data == 0)
  1585.     {
  1586.         *s2++ = 0;
  1587.         *s2 = 0;
  1588.     }
  1589.     return 0;
  1590.   parse_error:
  1591.     *original_s3 = '';
  1592.     if (reserve_data == 0)
  1593.     {
  1594.         *original_s2++ = 0;
  1595.         *original_s2 = 0;
  1596.     }
  1597.     return (S8) (-1);
  1598. }
  1599. /*****************************************************************************
  1600.  * FUNCTION
  1601.  *  get_category_115_format_buffer_length
  1602.  * DESCRIPTION
  1603.  *  Get the exact length of WCSS input format buffer
  1604.  * PARAMETERS
  1605.  *  s1              [IN]        IN input format
  1606.  *  buffer_size     [IN]        IN maximum length of dchar including ''
  1607.  * RETURNS
  1608.  *  0        Variable length
  1609.  *  -1       Invalid format
  1610.  *  otherwise
  1611.  *****************************************************************************/
  1612. S32 get_category_115_format_buffer_length(U8 *s1, S32 buffer_size)
  1613. {
  1614.     /*----------------------------------------------------------------*/
  1615.     /* Local Variables                                                */
  1616.     /*----------------------------------------------------------------*/
  1617.     UI_character_type c;
  1618.     U8 input_type;
  1619.     S32 special_char = 0;
  1620.     S32 format_length = 0;
  1621.     /*----------------------------------------------------------------*/
  1622.     /* Code Body                                                      */
  1623.     /*----------------------------------------------------------------*/
  1624.     UI_STRING_GET_NEXT_CHARACTER(s1, c) while (!UI_STRING_END_OF_STRING_CHARACTER(c))
  1625.     {
  1626.         if (UI_check_WCSS_normal_character(c, &input_type))
  1627.         {
  1628.             format_length++;
  1629.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1630.         }
  1631.         else if (c == 0x5C) /* '\' */
  1632.         {
  1633.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1634.             if (UI_STRING_END_OF_STRING_CHARACTER(c))
  1635.             {
  1636.                 return -1;
  1637.             }
  1638.             special_char++;
  1639.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1640.         }
  1641.         else if (c == 0x2A) /* '*' */
  1642.         {
  1643.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1644.             if (UI_STRING_END_OF_STRING_CHARACTER(c) || (!UI_check_WCSS_normal_character(c, &input_type)))
  1645.             {
  1646.                 return -1;
  1647.             }
  1648.             else
  1649.             {
  1650.                 if (format_length + special_char <= buffer_size - 1)
  1651.                 {
  1652.                     return 0;
  1653.                 }
  1654.                 else
  1655.                 {
  1656.                     return -1;
  1657.                 }
  1658.             }
  1659.         }
  1660.         else if ((c >= 0x31) && (c <= 0x39))    /* '1' - '9' */
  1661.         {
  1662.             S16 n = c - 0x30;
  1663.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1664.             while ((c >= 0x30) && (c <= 0x39))  /* '0' - '9' */
  1665.             {
  1666.                 n *= 10;
  1667.                 n += (c - 0x30);
  1668.                 UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1669.             }
  1670.             if (UI_STRING_END_OF_STRING_CHARACTER(c) || (!UI_check_WCSS_normal_character(c, &input_type)))
  1671.             {
  1672.                 return -1;
  1673.             }
  1674.             format_length += n;
  1675.             UI_STRING_GET_NEXT_CHARACTER(s1, c);
  1676.         }
  1677.         else
  1678.         {
  1679.             return -1;
  1680.         }
  1681.     }
  1682.     /* Note: we allow the case that format_length == 0. However, user cannot
  1683.        edit at all */
  1684.     if (format_length + special_char <= buffer_size - 1)
  1685.     {
  1686.         return (format_length + special_char);
  1687.     }
  1688.     else
  1689.     {
  1690.         return -1;
  1691.     }
  1692. }
  1693. #endif /* defined(__MMI_WCSS_INPUT_FORMAT_SUPPORT__) */ 
  1694. #ifdef __MMI_TOUCH_DIAL_SCREEN__
  1695. /*****************************************************************************
  1696.  * FUNCTION
  1697.  *  gui_dialing_screen_translate_pen_position
  1698.  * DESCRIPTION
  1699.  *  
  1700.  * PARAMETERS
  1701.  *  dialing_keypad      [?]         
  1702.  *  x                   [IN]        
  1703.  *  y                   [IN]        
  1704.  *  item_index          [?]         
  1705.  * RETURNS
  1706.  *  void
  1707.  *****************************************************************************/
  1708. void gui_dialing_screen_translate_pen_position(dialing_keypad_struct *dialing_keypad, S32 x, S32 y, S32 *item_index)
  1709. {
  1710.     /*----------------------------------------------------------------*/
  1711.     /* Local Variables                                                */
  1712.     /*----------------------------------------------------------------*/
  1713.     S32 total_height = 0, total_width = 0;
  1714.     S32 i, j;
  1715.     /*----------------------------------------------------------------*/
  1716.     /* Code Body                                                      */
  1717.     /*----------------------------------------------------------------*/
  1718.     total_height += dialing_keypad->keypad_y;
  1719.     total_width += dialing_keypad->keypad_x;
  1720.     *item_index = -1;   /* 053005 Calvin added for function key */
  1721.     for (i = 0; i < dialing_keypad->n_rows; i++)
  1722.     {
  1723.         total_height += dialing_keypad->key_height;
  1724.         if (total_height > y)
  1725.         {
  1726.             for (j = 0; j < dialing_keypad->n_column; j++)
  1727.             {
  1728.                 total_width += dialing_keypad->key_width;
  1729.                 if (total_width > x)
  1730.                 {
  1731.                     *item_index = i * dialing_keypad->n_column + j + 1;
  1732.                     dialing_keypad->selected_key_x =
  1733.                         dialing_keypad->keypad_x + (dialing_keypad->key_width) * j +
  1734.                         (dialing_keypad->horizontal_gap) * j;
  1735.                     dialing_keypad->selected_key_y =
  1736.                         dialing_keypad->keypad_y + (dialing_keypad->key_height) * i +
  1737.                         (dialing_keypad->vertical_gap) * i;
  1738.                     dialing_keypad->key_type = *item_index;
  1739.                     break;
  1740.                 }
  1741.                 else
  1742.                 {
  1743.                     total_width += dialing_keypad->horizontal_gap;
  1744.                     if (total_width > x)
  1745.                     {
  1746.                         *item_index = -1;
  1747.                         return;
  1748.                     }
  1749.                 }
  1750.             }
  1751.             break;
  1752.         }
  1753.         else
  1754.         {
  1755.             total_height += dialing_keypad->vertical_gap;
  1756.             if (total_height > y)
  1757.             {
  1758.                 *item_index = -1;
  1759.                 return;
  1760.             }
  1761.         }
  1762.     }
  1763.     /* 053005 Calvin added for function key */
  1764. #if defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__)
  1765.     if (*item_index != -1)
  1766.     {
  1767.         return;
  1768.     }
  1769.     total_height = dialing_keypad->keypad_func_y;
  1770.     total_width = dialing_keypad->keypad_func_x;
  1771.     if (x < dialing_keypad->keypad_func_x || y < dialing_keypad->keypad_func_y) /* 110105 dialing handle Calvin added */
  1772.     {
  1773.         return;
  1774.     }
  1775.     for (i = 0; i < dialing_keypad->func_n_rows; i++)
  1776.     {
  1777.         total_height += dialing_keypad->func_key_height;
  1778.         if (total_height > y)
  1779.         {
  1780.             for (j = 0; j < dialing_keypad->func_n_column; j++)
  1781.             {
  1782.                 total_width += dialing_keypad->func_key_width;
  1783.                 if (total_width > x)
  1784.                 {
  1785.                     *item_index =
  1786.                         dialing_keypad->n_rows * dialing_keypad->n_column + i * dialing_keypad->func_n_column + j + 1;
  1787.                     dialing_keypad->selected_key_x =
  1788.                         dialing_keypad->keypad_func_x + (dialing_keypad->func_key_width) * j +
  1789.                         (dialing_keypad->func_horizontal_gap) * j;
  1790.                     dialing_keypad->selected_key_y =
  1791.                         dialing_keypad->keypad_func_y + (dialing_keypad->func_key_height) * i +
  1792.                         (dialing_keypad->func_vertical_gap) * i;
  1793.                     dialing_keypad->key_type = *item_index;
  1794.                     break;
  1795.                 }
  1796.                 else
  1797.                 {
  1798.                     total_width += dialing_keypad->func_horizontal_gap;
  1799.                     if (total_width > x)
  1800.                     {
  1801.                         *item_index = -1;
  1802.                         return;
  1803.                     }
  1804.                 }
  1805.             }
  1806.             break;
  1807.         }
  1808.         else
  1809.         {
  1810.             total_height += dialing_keypad->func_vertical_gap;
  1811.             if (total_height > y)
  1812.             {
  1813.                 *item_index = -1;
  1814.                 return;
  1815.             }
  1816.         }
  1817.     }
  1818. #endif /* defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__) */ 
  1819.     /* Calvin end */
  1820. }
  1821. /***********************************************************************
  1822.    __GDI_MEMORY_PROFILE_2__ is used to decide whether multilayer is on or off.
  1823.    if multilayer is enable, no buffer is used.
  1824.    we can use one layer for keypad bg image, and another for selected keys.
  1825. ***********************************************************************/
  1826. #ifndef __GDI_MEMORY_PROFILE_2__
  1827. U8 key_buffer[(MMI_DIALING_KEY_WIDTH + 1) * (MMI_DIALING_KEY_HEIGHT + 1) * 2];
  1828. #endif 
  1829. /*****************************************************************************
  1830.  * FUNCTION
  1831.  *  gui_dialing_key_select
  1832.  * DESCRIPTION
  1833.  *  
  1834.  * PARAMETERS
  1835.  *  dialing_keypad      [?]         
  1836.  *  item_index          [IN]        
  1837.  * RETURNS
  1838.  *  void
  1839.  *****************************************************************************/
  1840. void gui_dialing_key_select(dialing_keypad_struct *dialing_keypad, S32 item_index)
  1841. {
  1842.     /*----------------------------------------------------------------*/
  1843.     /* Local Variables                                                */
  1844.     /*----------------------------------------------------------------*/
  1845.     S32 x1, y1, x2, y2;
  1846.     S32 width, height;
  1847.     S32 key_width, key_height;
  1848.     MMI_ID_TYPE image_id;
  1849.     /*----------------------------------------------------------------*/
  1850.     /* Code Body                                                      */
  1851.     /*----------------------------------------------------------------*/
  1852.     /* 053005 Calvin added for function key */
  1853. #if defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__)
  1854.     if (item_index >= MMI_DIALING_KEY_FUNC)
  1855.     {
  1856.         key_width = dialing_keypad->func_key_width;
  1857.         key_height = dialing_keypad->func_key_height;
  1858.     }
  1859.     else
  1860. #endif /* defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__) */ 
  1861.     {
  1862.         key_width = dialing_keypad->key_width;
  1863.         key_height = dialing_keypad->key_height;
  1864.     }
  1865.     /* Calvin end */
  1866.     x1 = dialing_keypad->selected_key_x;
  1867.     y1 = dialing_keypad->selected_key_y;
  1868.     /* 053005 Calvin added for function key */
  1869.     x2 = x1 + key_width - 1;
  1870.     y2 = y1 + key_height - 1;
  1871.     /* Calvin end */
  1872. #ifndef __GDI_MEMORY_PROFILE_2__
  1873.     dialing_keypad->selected_key_bitmap.buf_ptr = key_buffer;   /* (U8*)gui_malloc((MMI_DIALING_KEY_WIDTH+1)*(MMI_DIALING_KEY_HEIGHT+1)*2); */
  1874.     gdi_layer_push_clip();
  1875.     gdi_layer_set_clip(x1, y1, x2, y2);
  1876.     gdi_image_cache_bmp_get(x1, y1, x2, y2, &dialing_keypad->selected_key_bitmap);
  1877.     gdi_layer_pop_clip();
  1878. #endif /* __GDI_MEMORY_PROFILE_2__ */ 
  1879.     gdi_layer_push_clip();
  1880.     gdi_layer_set_clip(x1, y1, x2, y2);
  1881.     image_id = dialing_key_image[item_index - 1];
  1882.     gui_measure_image(get_image(image_id), &width, &height);
  1883.     /* 053005 Calvin added for function key */
  1884.     x1 = x1 + ((key_width - width) >> 1);
  1885.     y1 = y1 + ((key_height - height) >> 1);
  1886.     /* Calvin end */
  1887.     gui_show_image(x1, y1, get_image(image_id));
  1888.     gdi_layer_pop_clip();
  1889. }
  1890. /*****************************************************************************
  1891.  * FUNCTION
  1892.  *  gui_dialing_key_unselect
  1893.  * DESCRIPTION
  1894.  *  
  1895.  * PARAMETERS
  1896.  *  dialing_keypad      [?]     
  1897.  * RETURNS
  1898.  *  void
  1899.  *****************************************************************************/
  1900. void gui_dialing_key_unselect(dialing_keypad_struct *dialing_keypad)
  1901. {
  1902.     /*----------------------------------------------------------------*/
  1903.     /* Local Variables                                                */
  1904.     /*----------------------------------------------------------------*/
  1905.     S16 x1, x2, y1, y2;
  1906. #if defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__)
  1907.     S32 item_index = dialing_keypad->key_type;
  1908. #endif 
  1909.     /*----------------------------------------------------------------*/
  1910.     /* Code Body                                                      */
  1911.     /*----------------------------------------------------------------*/
  1912.     x1 = dialing_keypad->selected_key_x;
  1913.     y1 = dialing_keypad->selected_key_y;
  1914. #if defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__)
  1915.     if (item_index >= MMI_DIALING_KEY_FUNC)
  1916.     {
  1917.         x2 = x1 + dialing_keypad->func_key_width - 1;
  1918.         y2 = y1 + dialing_keypad->func_key_height - 1;
  1919.     }
  1920.     else
  1921. #endif /* defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__) */ 
  1922.     {
  1923.         x2 = x1 + dialing_keypad->key_width - 1;
  1924.         y2 = y1 + dialing_keypad->key_height - 1;
  1925.     }
  1926.     gdi_layer_push_clip();
  1927.     gdi_layer_set_clip(x1, y1, x2, y2);
  1928. #ifdef __GDI_MEMORY_PROFILE_2__
  1929.     gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
  1930. #else 
  1931.     gdi_image_cache_bmp_draw(x1, y1, &dialing_keypad->selected_key_bitmap);
  1932. #endif 
  1933.     gdi_layer_pop_clip();
  1934. }
  1935. /* 110105 dialing deflect Calvin Start */
  1936. #ifdef __MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__
  1937. /*****************************************************************************
  1938.  * FUNCTION
  1939.  *  gui_show_dialing_key
  1940.  * DESCRIPTION
  1941.  *  Shows the phonebook icon on the dialing screen.
  1942.  * PARAMETERS
  1943.  *  key             [IN]        
  1944.  *  enableFlag      [IN]        
  1945.  * RETURNS
  1946.  *  void
  1947.  *****************************************************************************/
  1948. void gui_show_dialing_key(gui_dialing_key key, BOOL enableFlag)
  1949. {
  1950.     /*----------------------------------------------------------------*/
  1951.     /* Local Variables                                                */
  1952.     /*----------------------------------------------------------------*/
  1953.     S32 x1, y1, x2, y2;
  1954.     S32 item_index = 0;
  1955.     MMI_ID_TYPE item_icon;
  1956.     /*----------------------------------------------------------------*/
  1957.     /* Code Body                                                      */
  1958.     /*----------------------------------------------------------------*/
  1959.     switch (key)
  1960.     {
  1961.         case MMI_DIALING_KEY_PHB:
  1962.             if (enableFlag)
  1963.             {
  1964.                 item_icon = IMG_DIALING_KEY_PHB;
  1965.             }
  1966.             else
  1967.             {
  1968.                 item_icon = IMG_DIALING_KEY_PHB_DISABLED;
  1969.             }
  1970.             break;
  1971.         case MMI_DIALING_KEY_CALL:
  1972.             if (enableFlag)
  1973.             {
  1974.                 item_icon = IMG_DIALING_KEY_CALL;
  1975.             }
  1976.             else
  1977.             {
  1978.                 item_icon = IMG_DIALING_KEY_CALL_DISABLED;
  1979.             }
  1980.             break;
  1981.   //KP Jerry add on 2006-11-12 start
  1982.   case MMI_DIALING_KEY_IPCALL:
  1983.                 if(enableFlag)
  1984.                 {
  1985.                     item_icon = IMG_DIALING_KEY_IPCALL;
  1986.                 }
  1987.                 else
  1988.                 {
  1989.                     item_icon = IMG_DIALING_KEY_IPCALL_DISABLED;
  1990.                 }
  1991.             break;
  1992.   //KP Jerry add on 2006-11-12 end
  1993.         default:
  1994.             return;
  1995.     }
  1996.     item_index = key - (MMI_DIALING_KEY_FUNC);
  1997.     x1 = MMI_DIALING_KEYPAD_FUNC_X + (item_index / MMI_DIALING_KEYPAD_FUNC_ROWS) * (MMI_DIALING_FUNC_KEY_WIDTH +
  1998.                                                                                     MMI_DIALING_FUNC_KEY_HORIZONTAL_GAP);
  1999.     y1 = MMI_DIALING_KEYPAD_FUNC_Y + (item_index / MMI_DIALING_KEYPAD_FUNC_COLOMNS) * (MMI_DIALING_FUNC_KEY_HEIGHT +
  2000.                                                                                        MMI_DIALING_FUNC_KEY_VERTICAL_GAP);
  2001.     x2 = x1 + MMI_DIALING_FUNC_KEY_WIDTH - 1;
  2002.     y2 = y1 + MMI_DIALING_FUNC_KEY_HEIGHT - 1;
  2003.     gdi_layer_push_clip();
  2004.     gdi_layer_set_clip(x1, y1, x2, y2);
  2005.     gdi_image_draw(x1, y1, (U8*) get_image(item_icon));
  2006.     gdi_layer_pop_clip();
  2007. }
  2008. #endif /* __MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__ */ 
  2009. /* 110105 dialing deflect Calvin Start */
  2010. /*****************************************************************************
  2011.  * FUNCTION
  2012.  *  gui_dialing_screen_translate_pen_event
  2013.  * DESCRIPTION
  2014.  *  
  2015.  * PARAMETERS
  2016.  *  dialing_keypad          [?]         
  2017.  *  x                       [IN]        
  2018.  *  y                       [IN]        
  2019.  *  pen_event               [IN]        
  2020.  *  menu_event              [?]         
  2021.  *  dialing_key_param       [?]         
  2022.  * RETURNS
  2023.  *  
  2024.  *****************************************************************************/
  2025. BOOL gui_dialing_screen_translate_pen_event(
  2026.         dialing_keypad_struct *dialing_keypad,
  2027.         S32 x,
  2028.         S32 y,
  2029.         mmi_pen_event_type_enum pen_event,
  2030.         gui_dialing_key_pen_enum *menu_event,
  2031.         gui_pen_event_param_struct *dialing_key_param)
  2032. {
  2033.     /*----------------------------------------------------------------*/
  2034.     /* Local Variables                                                */
  2035.     /*----------------------------------------------------------------*/
  2036.     BOOL ret;
  2037.     S32 item_index;
  2038.     S32 x1, y1, x2, y2;
  2039.     /*----------------------------------------------------------------*/
  2040.     /* Code Body                                                      */
  2041.     /*----------------------------------------------------------------*/
  2042.     ret = TRUE;
  2043.     *menu_event = GUI_DIALING_PEN_NONE;
  2044.     /* 053005 Calvin */
  2045. #if defined (__MMI_MAINLCD_240X320__) && defined (__MMI_TOUCH_DIAL_SCREEN__)
  2046.     x1 = dialing_keypad->keypad_x;
  2047.     y1 = dialing_keypad->keypad_y;
  2048. #else /* defined (__MMI_MAINLCD_240X320__) && defined (__MMI_TOUCH_DIAL_SCREEN__) */ 
  2049.     x1 = dialing_keypad->keypad_x;
  2050.     y1 = dialing_keypad->keypad_y;
  2051. #endif /* defined (__MMI_MAINLCD_240X320__) && defined (__MMI_TOUCH_DIAL_SCREEN__) */ 
  2052.     /* Calvin end */
  2053.     x2 = x1 + dialing_keypad->keypad_width - 1;
  2054.     y2 = y1 + dialing_keypad->keypad_height - 1;
  2055.     switch (pen_event)
  2056.     {
  2057.         case MMI_PEN_EVENT_DOWN:
  2058.             if (PEN_CHECK_BOUND(x, y, x1, y1, dialing_keypad->keypad_width, dialing_keypad->keypad_height))
  2059.             {
  2060.                 gui_dialing_screen_translate_pen_position(dialing_keypad, x, y, &item_index);
  2061.                 if (item_index == -1)   /* No key is selected */
  2062.                 {
  2063.                     ret = FALSE;
  2064.                 }
  2065.                 /* PMT HIMANSHU START 20050825 */
  2066.             #ifdef __MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__
  2067.                 else if (item_index == MMI_DIALING_KEY_CALL && mmi_bootup_get_active_flight_mode())
  2068.                 {
  2069.                     ret = FALSE;
  2070.                 }
  2071. //KP Jerry add on 2006-11-13 start
  2072. else if ( (item_index == MMI_DIALING_KEY_IPCALL && mmi_bootup_get_active_flight_mode()) || (item_index == MMI_DIALING_KEY_IPCALL && g_idle_context.IsOnSimErrorDialerScreen == 1) )
  2073. {
  2074. ret = FALSE;
  2075. }
  2076. //KP Jerry add on 2006-11-13 end
  2077.             #endif /* __MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__ */ 
  2078.                 /* PMT HIMANSHU END 20050825 */
  2079.                 else
  2080.                 {
  2081.                     gui_dialing_key_select(dialing_keypad, item_index);
  2082.                 }
  2083.             }
  2084.             else
  2085.             {
  2086.                 ret = FALSE;
  2087.             }
  2088.             break;
  2089.         case MMI_PEN_EVENT_UP:
  2090.             if (PEN_CHECK_BOUND
  2091.                 (x, y, dialing_keypad->selected_key_x, dialing_keypad->selected_key_y, dialing_keypad->key_width,
  2092.                  dialing_keypad->key_height))
  2093.             {
  2094.                 gui_dialing_screen_translate_pen_position(dialing_keypad, x, y, &item_index);
  2095.                 gui_dialing_key_unselect(dialing_keypad);
  2096.                 if (item_index > MMI_DIALING_KEY_START && item_index < MMI_DIALING_KEY_STAR)
  2097.                 {
  2098.                     *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_DIG_I;
  2099.                     GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param, item_index);
  2100.                 }
  2101.                 else
  2102.                 {
  2103.                     switch (item_index)
  2104.                     {
  2105.                         case MMI_DIALING_KEY_STAR:
  2106.                             GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param, KEY_STAR);
  2107.                             *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_STAR;
  2108.                             break;
  2109.                         case MMI_DIALING_KEY_ZERO:
  2110.                             GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param, 0);
  2111.                             *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_DIG_I;
  2112.                             break;
  2113.                         case MMI_DIALING_KEY_HASH:
  2114.                             GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param, KEY_POUND);
  2115.                             *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_HASH;
  2116.                             break;
  2117.                             /* 071005 Calvin added for function key */
  2118.                     #if defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__)
  2119.                         case MMI_DIALING_KEY_PHB:
  2120.                             *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_PHB;
  2121.                             break;
  2122.                         case MMI_DIALING_KEY_CALL:
  2123.                             *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_CALL;
  2124.                             break;
  2125. //KP Jerry add on 2006-11-12 start
  2126. case MMI_DIALING_KEY_IPCALL:
  2127. *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_IPCALL;
  2128. break;
  2129. //KP Jerry add on 2006-11-12 end
  2130.                     #endif /* defined (__MMI_TOUCH_DIAL_SCREEN_WITH_FUNCTION__) */ 
  2131.                             /* Calvin end */
  2132.                     }
  2133.                 }
  2134.             }
  2135.             else
  2136.             {
  2137.                 ret = FALSE;
  2138.             }
  2139.             break;
  2140.         case MMI_PEN_EVENT_MOVE:
  2141.             if (!PEN_CHECK_BOUND
  2142.                 (x, y, dialing_keypad->selected_key_x, dialing_keypad->selected_key_y, dialing_keypad->key_width,
  2143.                  dialing_keypad->key_height))
  2144.             {
  2145.                 if (dialing_keypad->key_type == MMI_DIALING_KEY_STAR)
  2146.                 {
  2147.                     GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param, KEY_STAR);
  2148.                     *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_STAR;
  2149.                 }
  2150.                 else
  2151.                 {
  2152.                     *menu_event = GUI_DIALING_KEYPAD_HIGHLIGHT_CHANGED;
  2153.                 }
  2154.             }
  2155.             else if (PEN_CHECK_BOUND
  2156.                      (x, y, dialing_keypad->selected_key_x, dialing_keypad->selected_key_y, dialing_keypad->key_width,
  2157.                       dialing_keypad->key_height))
  2158.             {
  2159.                 gui_dialing_screen_translate_pen_position(dialing_keypad, x, y, &item_index);
  2160.                 gui_dialing_key_select(dialing_keypad, item_index);
  2161.                 //*menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_DIG_I;
  2162.                 //GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param,item_index );
  2163.             }
  2164.             break;
  2165.         case MMI_PEN_EVENT_LONG_TAP:
  2166.             if (PEN_CHECK_BOUND
  2167.                 (x, y, dialing_keypad->selected_key_x, dialing_keypad->selected_key_y, dialing_keypad->key_width,
  2168.                  dialing_keypad->key_height))
  2169.             {
  2170.                 gui_dialing_screen_translate_pen_position(dialing_keypad, x, y, &item_index);
  2171.                 /* start vijay 20050624vijay...chngaes done for activating silent mode */
  2172.                 if (item_index >= MMI_DIALING_KEY_START && item_index <= MMI_DIALING_KEY_STAR)
  2173.                 {
  2174.                     *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_DIG_I;
  2175.                     GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param, item_index);
  2176.                 }
  2177.                 else if (item_index == MMI_DIALING_KEY_HASH)
  2178.                 {
  2179.                     *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_HASH;
  2180.                     GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param, KEY_POUND);
  2181.                 }
  2182.                 /* end vijay */
  2183.             }
  2184.             break;
  2185.         case MMI_PEN_EVENT_REPEAT:
  2186.             if (PEN_CHECK_BOUND
  2187.                 (x, y, dialing_keypad->selected_key_x, dialing_keypad->selected_key_y, dialing_keypad->key_width,
  2188.                  dialing_keypad->key_height))
  2189.             {
  2190.                 gui_dialing_screen_translate_pen_position(dialing_keypad, x, y, &item_index);
  2191.                 if (item_index > MMI_DIALING_KEY_START && item_index < MMI_DIALING_KEY_STAR)
  2192.                 {
  2193.                     *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_DIG_I;
  2194.                     GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param, item_index);
  2195.                 }
  2196.                 else if (item_index == MMI_DIALING_KEY_STAR)
  2197.                 {
  2198.                     *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_STAR;
  2199.                 }
  2200.                 else if (item_index == MMI_DIALING_KEY_ZERO)
  2201.                 {
  2202.                     *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_DIG_I;
  2203.                     GUI_PEN_EVENT_PARAM_SET_INTEGER(dialing_key_param, 0);
  2204.                 }
  2205.                 else if (item_index == MMI_DIALING_KEY_HASH)
  2206.                 {
  2207.                     *menu_event = GUI_DIALING_KEYPAD_PEN_INSERT_HASH;
  2208.                 }
  2209.             }
  2210.             else
  2211.             {
  2212.                 ret = FALSE;
  2213.             }
  2214.             break;
  2215.     }
  2216.     return ret;
  2217. }
  2218. #endif /* __MMI_TOUCH_DIAL_SCREEN__ */ /* __MMI_TOUCH_SCREEN__ */
  2219. /* end vijay */
  2220. #ifdef __MMI_TOUCH_SCREEN__
  2221. /*****************************************************************************
  2222.  * FUNCTION
  2223.  *  gui_single_line_input_box_translate_pen_event
  2224.  * DESCRIPTION
  2225.  *  
  2226.  * PARAMETERS
  2227.  *  b                               [?]         
  2228.  *  pen_event                       [IN]        
  2229.  *  x                               [IN]        
  2230.  *  y                               [IN]        
  2231.  *  single_line_input_box_event     [?]         
  2232.  * RETURNS
  2233.  *  
  2234.  *****************************************************************************/
  2235. BOOL gui_single_line_input_box_translate_pen_event(
  2236.         single_line_input_box *b,
  2237.         mmi_pen_event_type_enum pen_event,
  2238.         S16 x,
  2239.         S16 y,
  2240.         gui_single_line_input_box_pen_enum *single_line_input_box_event)
  2241. {
  2242.     /*----------------------------------------------------------------*/
  2243.     /* Local Variables                                                */
  2244.     /*----------------------------------------------------------------*/
  2245.     BOOL ret = MMI_TRUE;
  2246.     /*----------------------------------------------------------------*/
  2247.     /* Code Body                                                      */
  2248.     /*----------------------------------------------------------------*/
  2249.     switch (pen_event)
  2250.     {
  2251.         case MMI_PEN_EVENT_DOWN:
  2252.             if (PEN_CHECK_BOUND(x, y, b->x, b->y, b->width, b->height))
  2253.             {
  2254.                 *single_line_input_box_event = GUI_SINGLE_LINE_INPUT_BOX_PEN_TEXT_DOWN;
  2255.             }
  2256.             else
  2257.             {
  2258.                 ret = MMI_FALSE;
  2259.             }
  2260.             break;
  2261.         case MMI_PEN_EVENT_UP:
  2262.             if (PEN_CHECK_BOUND(x, y, b->x, b->y, b->width, b->height))
  2263.             {
  2264.                 *single_line_input_box_event = GUI_SINGLE_LINE_INPUT_BOX_PEN_TEXT_UP;
  2265.             }
  2266.             else
  2267.             {
  2268.                 ret = MMI_FALSE;
  2269.             }
  2270.             break;
  2271.         case MMI_PEN_EVENT_MOVE:
  2272.         case MMI_PEN_EVENT_LONG_TAP:
  2273.         case MMI_PEN_EVENT_REPEAT:
  2274.         case MMI_PEN_EVENT_ABORT:
  2275.             if (PEN_CHECK_BOUND(x, y, b->x, b->y, b->width, b->height))
  2276.             {
  2277.             }
  2278.             else
  2279.             {
  2280.                 ret = MMI_FALSE;
  2281.             }
  2282.             break;
  2283.     }
  2284.     return ret;
  2285. }
  2286. static multi_line_input_box *gui_pen_scroll_multi_line_input_box = NULL;
  2287. /*****************************************************************************
  2288.  * FUNCTION
  2289.  *  gui_multi_line_input_box_scroll_by_pen
  2290.  * DESCRIPTION
  2291.  *  
  2292.  * PARAMETERS
  2293.  *  b                               [?]         
  2294.  *  offset_y                        [IN]        
  2295.  *  multi_line_input_box_event      [?]         
  2296.  * RETURNS
  2297.  *  void
  2298.  *****************************************************************************/
  2299. static void gui_multi_line_input_box_scroll_by_pen(
  2300.                 multi_line_input_box *b,
  2301.                 S32 offset_y,
  2302.                 gui_multi_line_input_box_pen_enum *multi_line_input_box_event)
  2303. {
  2304.     /*----------------------------------------------------------------*/
  2305.     /* Local Variables                                                */
  2306.     /*----------------------------------------------------------------*/
  2307.     int move_gap = b->text_offset_y + offset_y;
  2308.     int line_height;
  2309.     /*----------------------------------------------------------------*/
  2310.     /* Code Body                                                      */
  2311.     /*----------------------------------------------------------------*/
  2312.     b->text_offset_y = -offset_y;
  2313.     /* W05.35 For Scroll Issue with Header Height */
  2314.     /* W06.02 Fix Cursor Display Issue */
  2315.     /* W06.26 Remove compile warnings and review cursor position issue */
  2316.     StopMyTimer(BLINKING_CURSOR);
  2317.     if (b->max_line_height)
  2318.     {
  2319.         line_height = b->max_line_height;
  2320.     }
  2321.     else
  2322.     {
  2323.         line_height = b->min_line_height;
  2324.     }
  2325.     if ((b->cursor_y) < -(b->text_offset_y) ||
  2326.         (b->cursor_y + line_height) > b->edit_height - b->text_offset_y)
  2327.     {
  2328.         S32 new_UI_cursor_y1 = UI_cursor_y1;
  2329.         if (move_gap > 0)
  2330.         {
  2331.             new_UI_cursor_y1 = UI_cursor_y1 + line_height;
  2332.         }
  2333.         if ((new_UI_cursor_y1 + line_height) > (b->y + b->height))
  2334.         {
  2335.             new_UI_cursor_y1 = b->y + b->height - line_height;
  2336.         }
  2337.         else if (new_UI_cursor_y1 < b->y)
  2338.         {
  2339.             new_UI_cursor_y1 = b->y  + line_height;
  2340.         }
  2341.         gui_show_multi_line_input_box_ext(b, UI_cursor_x1, new_UI_cursor_y1);
  2342.     }
  2343.     b->text_offset_y = -offset_y;
  2344.     gui_show_multi_line_input_box(b);
  2345.     gui_BLT_double_buffer(b->x, b->y, b->x + b->width, b->y + b->height);
  2346. }
  2347. /*****************************************************************************
  2348.  * FUNCTION
  2349.  *  gui_multi_line_input_box_scroll_timer_hdlr
  2350.  * DESCRIPTION
  2351.  *  
  2352.  * PARAMETERS
  2353.  *  void
  2354.  * RETURNS
  2355.  *  void
  2356.  *****************************************************************************/
  2357. static void gui_multi_line_input_box_scroll_timer_hdlr(void)
  2358. {
  2359.     /*----------------------------------------------------------------*/
  2360.     /* Local Variables                                                */
  2361.     /*----------------------------------------------------------------*/
  2362.     multi_line_input_box *b = gui_pen_scroll_multi_line_input_box;
  2363.     gui_multi_line_input_box_pen_enum multi_line_input_box_event;
  2364.     /*----------------------------------------------------------------*/
  2365.     /* Code Body                                                      */
  2366.     /*----------------------------------------------------------------*/
  2367.     gui_pen_scroll_multi_line_input_box = NULL;
  2368.     if (!b)
  2369.     {
  2370.         return;
  2371.     }
  2372.     gui_multi_line_input_box_scroll_by_pen(b, b->pen_scroll_after_delay, &multi_line_input_box_event);
  2373. }
  2374. /*****************************************************************************
  2375.  * FUNCTION
  2376.  *  gui_multi_line_input_box_abort_scroll_timer
  2377.  * DESCRIPTION
  2378.  *  
  2379.  * PARAMETERS
  2380.  *  void
  2381.  * RETURNS
  2382.  *  void
  2383.  *****************************************************************************/
  2384. static void gui_multi_line_input_box_abort_scroll_timer(void)
  2385. {
  2386.     /*----------------------------------------------------------------*/
  2387.     /* Local Variables                                                */
  2388.     /*----------------------------------------------------------------*/
  2389.     /*----------------------------------------------------------------*/
  2390.     /* Code Body                                                      */
  2391.     /*----------------------------------------------------------------*/
  2392.     gui_pen_scroll_multi_line_input_box = NULL;
  2393. }
  2394. /*****************************************************************************
  2395.  * FUNCTION
  2396.  *  gui_multi_line_input_box_start_scroll_timer
  2397.  * DESCRIPTION
  2398.  *  
  2399.  * PARAMETERS
  2400.  *  b           [?]         
  2401.  *  value       [IN]        
  2402.  * RETURNS
  2403.  *  void
  2404.  *****************************************************************************/
  2405. static void gui_multi_line_input_box_start_scroll_timer(multi_line_input_box *b, S32 value)
  2406. {
  2407.     /*----------------------------------------------------------------*/
  2408.     /* Local Variables                                                */
  2409.     /*----------------------------------------------------------------*/
  2410.     /*----------------------------------------------------------------*/
  2411.     /* Code Body                                                      */
  2412.     /*----------------------------------------------------------------*/
  2413.     /* assert that no two input box at the same time */
  2414.     MMI_DBG_ASSERT(!gui_pen_scroll_multi_line_input_box || gui_pen_scroll_multi_line_input_box == b);
  2415.     b->pen_scroll_after_delay = value;
  2416.     gui_pen_scroll_multi_line_input_box = b;
  2417.     gui_cancel_timer(gui_multi_line_input_box_scroll_timer_hdlr);
  2418.     gui_start_timer(b->pen_scroll_delay_time, gui_multi_line_input_box_scroll_timer_hdlr);
  2419.     gui_add_cleanup_hook(gui_multi_line_input_box_abort_scroll_timer);
  2420. }
  2421. /*****************************************************************************
  2422.  * FUNCTION
  2423.  *  gui_multi_line_input_box_set_pen_scroll_delay
  2424.  * DESCRIPTION
  2425.  *  
  2426.  * PARAMETERS
  2427.  *  b               [?]         
  2428.  *  delay_time      [IN]        
  2429.  * RETURNS
  2430.  *  void
  2431.  *****************************************************************************/
  2432. void gui_multi_line_input_box_set_pen_scroll_delay(multi_line_input_box *b, S32 delay_time)
  2433. {
  2434.     /*----------------------------------------------------------------*/
  2435.     /* Local Variables                                                */
  2436.     /*----------------------------------------------------------------*/
  2437.     /*----------------------------------------------------------------*/
  2438.     /* Code Body                                                      */
  2439.     /*----------------------------------------------------------------*/
  2440.     MMI_DBG_ASSERT(delay_time < (S32) 0x0000FFFF);
  2441.     b->pen_scroll_delay_time = (S16) delay_time;
  2442. }
  2443. /*****************************************************************************
  2444.  * FUNCTION
  2445.  *  gui_multi_line_input_box_translate_pen_event
  2446.  * DESCRIPTION
  2447.  *  
  2448.  * PARAMETERS
  2449.  *  b                               [?]         
  2450.  *  pen_event                       [IN]        
  2451.  *  x                               [IN]        
  2452.  *  y                               [IN]        
  2453.  *  multi_line_input_box_event      [?]         
  2454.  * RETURNS
  2455.  *  
  2456.  *****************************************************************************/
  2457. BOOL gui_multi_line_input_box_translate_pen_event(
  2458.         multi_line_input_box *b,
  2459.         mmi_pen_event_type_enum pen_event,
  2460.         S16 x,
  2461.         S16 y,
  2462.         gui_multi_line_input_box_pen_enum *multi_line_input_box_event)
  2463. {
  2464.     /*----------------------------------------------------------------*/
  2465.     /* Local Variables                                                */
  2466.     /*----------------------------------------------------------------*/
  2467.     BOOL ret = MMI_TRUE;
  2468.     gui_multi_line_input_box_pen_state_struct *pen_state;
  2469.     gui_scrollbar_pen_enum scrollbar_event;
  2470.     gui_pen_event_param_struct scrollbar_param;
  2471.     int scroll_bar_width;
  2472.     BOOL scroll_bar_active = MMI_TRUE;
  2473.     /*----------------------------------------------------------------*/
  2474.     /* Code Body                                                      */
  2475.     /*----------------------------------------------------------------*/
  2476.     /* W06.04 Fix UI_MULTI_LINE_INPUT_BOX_AUTO_DISABLE_SCROLLBAR issue in Touch Screen */
  2477.     if ((b->flags & UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR)
  2478.         || ((b->flags & UI_MULTI_LINE_INPUT_BOX_AUTO_DISABLE_SCROLLBAR) && (b->vbar.scale > b->vbar.range)))
  2479.     {
  2480.         scroll_bar_width = 0;
  2481.         scroll_bar_active = FALSE;
  2482.     }
  2483.     else
  2484.     {
  2485.         scroll_bar_width = b->vbar.width;
  2486.         scroll_bar_active = TRUE;
  2487.     }
  2488.     pen_state = &b->pen_state;
  2489.     ret = MMI_TRUE;
  2490.     if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->pen_on_scroll_bar)
  2491.     {
  2492.         gui_vertical_scrollbar_translate_pen_event(&b->vbar, pen_event, x, y, &scrollbar_event, &scrollbar_param);
  2493.         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  2494.         {
  2495.             if (b->pen_scroll_delay_time > 0)   /* Delay time for scrollbar scrolling */
  2496.             {
  2497.                 gui_multi_line_input_box_start_scroll_timer(b, scrollbar_param._u.i);
  2498.             }
  2499.             else
  2500.             {
  2501.                 gui_multi_line_input_box_scroll_by_pen(b, scrollbar_param._u.i, multi_line_input_box_event);
  2502.             }
  2503.         }
  2504.         *multi_line_input_box_event = GUI_MULTI_LINE_INPUT_BOX_PEN_SCROLL_BAR;
  2505.     }
  2506.     else
  2507.     {
  2508.         switch (pen_event)
  2509.         {
  2510.             case MMI_PEN_EVENT_DOWN:
  2511.                 if (PEN_CHECK_BOUND(x, y, b->x, b->y, b->width, b->height))
  2512.                 {
  2513.                     pen_state->pen_on_scroll_bar = 0;
  2514.                     if (scroll_bar_active /* !(b->flags&UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR) */  &&
  2515.                         gui_vertical_scrollbar_translate_pen_event(
  2516.                             &b->vbar,
  2517.                             MMI_PEN_EVENT_DOWN,
  2518.                             x,
  2519.                             y,
  2520.                             &scrollbar_event,
  2521.                             &scrollbar_param))
  2522.                     {
  2523.                         pen_state->pen_on_scroll_bar = 1;
  2524.                         /* W06.06 When the text is empty, max_line_height equals zero */
  2525.                         if (b->max_line_height)
  2526.                         {
  2527.                             gui_vertical_scrollbar_set_minimum_pen_offset(&b->vbar, b->max_line_height);
  2528.                         }
  2529.                         else
  2530.                         {
  2531.                             gui_vertical_scrollbar_set_minimum_pen_offset(&b->vbar, b->min_line_height);
  2532.                         }
  2533.                         if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
  2534.                         {
  2535.                             if (b->pen_scroll_delay_time > 0)   /* Delay time for scrollbar scrolling */
  2536.                             {
  2537.                                 gui_multi_line_input_box_start_scroll_timer(b, scrollbar_param._u.i);
  2538.                             }
  2539.                             else
  2540.                             {
  2541.                                 gui_multi_line_input_box_scroll_by_pen(
  2542.                                     b,
  2543.                                     scrollbar_param._u.i,
  2544.                                     multi_line_input_box_event);
  2545.                             }
  2546.                         }
  2547.                         *multi_line_input_box_event = GUI_MULTI_LINE_INPUT_BOX_PEN_SCROLL_BAR;
  2548.                     }
  2549.                     else
  2550.                     {
  2551.                         *multi_line_input_box_event = GUI_MULTI_LINE_INPUT_BOX_PEN_TEXT_DOWN;
  2552.                     }
  2553.                 }
  2554.                 else
  2555.                 {
  2556.                     ret = MMI_FALSE;
  2557.                 }
  2558.                 break;
  2559.             case MMI_PEN_EVENT_UP:
  2560.                 if (PEN_CHECK_BOUND(x, y, b->x, b->y, b->width - scroll_bar_width, b->height) &&
  2561.                     !(b->flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE))
  2562.                 {
  2563.                     *multi_line_input_box_event = GUI_MULTI_LINE_INPUT_BOX_PEN_TEXT_UP;
  2564.                 }
  2565.                 else
  2566.                 {
  2567.                     ret = MMI_FALSE;
  2568.                 }
  2569.                 break;
  2570.             case MMI_PEN_EVENT_MOVE:
  2571.             case MMI_PEN_EVENT_LONG_TAP:
  2572.             case MMI_PEN_EVENT_REPEAT:
  2573.             case MMI_PEN_EVENT_ABORT:
  2574.                 if (PEN_CHECK_BOUND(x, y, b->x, b->y, b->width - scroll_bar_width, b->height))
  2575.                 {
  2576.                 }
  2577.                 else
  2578.                 {
  2579.                     ret = MMI_FALSE;
  2580.                 }
  2581.                 break;
  2582.         }
  2583.     }
  2584.     return ret;
  2585. }
  2586. #endif /* __MMI_TOUCH_SCREEN__ */ 
  2587. /*****************************************************************************
  2588.  * FUNCTION
  2589.  *  gui_multi_line_input_box_get_remaining_length
  2590.  * DESCRIPTION
  2591.  *  
  2592.  * PARAMETERS
  2593.  *  b       [?]     
  2594.  * RETURNS
  2595.  *  
  2596.  *****************************************************************************/
  2597. int gui_multi_line_input_box_get_remaining_length(multi_line_input_box *b)
  2598. {
  2599.     /*----------------------------------------------------------------*/
  2600.     /* Local Variables                                                */
  2601.     /*----------------------------------------------------------------*/
  2602.     S32 n, max_n;
  2603.     U8 temp_0x81 = 0;
  2604.     /*----------------------------------------------------------------*/
  2605.     /* Code Body                                                      */
  2606.     /*----------------------------------------------------------------*/
  2607.     n = (b->text_length >> 1) - 1;
  2608.     max_n = (b->available_length >> 1) - 1;
  2609.     if ((b->flags & UI_MULTI_LINE_INPUT_BOX_CHECK_GSM_EXTENDED) && (b->UCS2_count == 0))
  2610.     {
  2611.         n += b->GSM_ext_count;
  2612.     }
  2613.     if ((b->flags & UI_MULTI_LINE_INPUT_BOX_PLUS_CHARACTER_HANDLING) && (b->text[0] == '+'))
  2614.     {
  2615.         n--;
  2616.         max_n--;
  2617.     }
  2618.     if (MMI_current_input_ext_type & INPUT_TYPE_EXT_USE_0x81_ENCODING)
  2619.     {
  2620.         temp_0x81 = mmi_phb_convert_to_0x81((S8*) b->text, FALSE);
  2621.         if (0 != temp_0x81)
  2622.         {
  2623.             max_n = (b->allocated_length >> 1) - 4;
  2624.             n = temp_0x81 - 3;
  2625.         }
  2626.     }
  2627.     return max_n - n;
  2628. }
  2629. /*****************************************************************************
  2630.  * FUNCTION
  2631.  *  gui_single_line_input_box_get_remaining_length
  2632.  * DESCRIPTION
  2633.  *  
  2634.  * PARAMETERS
  2635.  *  b       [?]     
  2636.  * RETURNS
  2637.  *  
  2638.  *****************************************************************************/
  2639. int gui_single_line_input_box_get_remaining_length(single_line_input_box *b)
  2640. {
  2641.     /*----------------------------------------------------------------*/
  2642.     /* Local Variables                                                */
  2643.     /*----------------------------------------------------------------*/
  2644.     S32 n, max_n;
  2645.     /*----------------------------------------------------------------*/
  2646.     /* Code Body                                                      */
  2647.     /*----------------------------------------------------------------*/
  2648.     n = (b->text_length >> 1) - 1;
  2649.     max_n = (b->available_length >> 1) - 1;
  2650.     if ((b->flags & UI_MULTI_LINE_INPUT_BOX_CHECK_GSM_EXTENDED) && (b->UCS2_count == 0))
  2651.     {
  2652.         n += b->GSM_ext_count;
  2653.     }
  2654.     if ((b->flags & UI_MULTI_LINE_INPUT_BOX_PLUS_CHARACTER_HANDLING) && (b->text[0] == '+'))
  2655.     {
  2656.         n--;
  2657.         max_n--;
  2658.     }
  2659.     return max_n - n;
  2660. }
  2661. void gui_multi_line_input_box_register_infobar_callback(
  2662.                         multi_line_input_box *b,
  2663.                         void(*redraw_callback)(S32 x1,S32 y1,S32 x2,S32 y2),
  2664.                         void(*reminder_char_callback)(S32 x1,S32 y1,S32 x2,S32 y2),
  2665.                         U32 height)
  2666. {
  2667.     if(height==0)   height = INFORMATION_BAR_HEIGHT;
  2668.     
  2669.     b->infobar_redraw_callback = redraw_callback;
  2670.     b->infobar_reminder_char_callback = reminder_char_callback;
  2671. wgui_inputbox_information_bar_height = height;
  2672. }
  2673. void gui_multi_line_input_box_register_change_event_handler(
  2674.                         multi_line_input_box *b,
  2675.                         MMI_BOOL (*handler)(gui_multi_line_input_box_change_event_enum event,U16 C))
  2676. {
  2677.     b->change_event_handler = handler;
  2678. }