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

MTK

开发平台:

C/C++

  1.         gui_set_text_color(text_color);
  2.         gui_print_character((UI_character_type) DOW_list[i]);
  3.         x += d->cell_width + d->cell_gap;
  4.     }
  5.     gdi_layer_pop_clip();
  6. }
  7. #ifdef __MMI_TOUCH_SCREEN__
  8. /*****************************************************************************
  9.  * FUNCTION
  10.  *  DOW_translate_pen_position
  11.  * DESCRIPTION
  12.  *  Translate pen events for DOW
  13.  * PARAMETERS
  14.  *  d               [IN]        DOW input box
  15.  *  x               [IN]        X coordniate
  16.  *  cell_index      [OUT]       Corresponding cell index ( -1 for invalid position)
  17.  * RETURNS
  18.  *  void
  19.  *****************************************************************************/
  20. static void DOW_translate_pen_position(DOW_select *d, S32 x, S32 *cell_index)
  21. {
  22.     /*----------------------------------------------------------------*/
  23.     /* Local Variables                                                */
  24.     /*----------------------------------------------------------------*/
  25.     S32 i, offset;
  26.     /*----------------------------------------------------------------*/
  27.     /* Code Body                                                      */
  28.     /*----------------------------------------------------------------*/
  29.     offset = d->x + d->offset_x;
  30.     if (x < offset)
  31.     {
  32.         *cell_index = -1;
  33.         return;
  34.     }
  35.     for (i = 0; i < 7; i++)
  36.     {
  37.         offset += d->cell_width + d->cell_gap;
  38.         if (x < offset)
  39.         {
  40.             *cell_index = i;
  41.             return;
  42.         }
  43.     }
  44.     *cell_index = -1;
  45. }
  46. /*****************************************************************************
  47.  * FUNCTION
  48.  *  DOW_translate_pen_event
  49.  * DESCRIPTION
  50.  *  Translate pen events for DOW
  51.  * PARAMETERS
  52.  *  d               [IN]        DOW input box
  53.  *  pen_event       [IN]        
  54.  *  x               [IN]        
  55.  *  y               [IN]        
  56.  *  DOW_event       [?]         
  57.  *  DOW_param       [?]         
  58.  * RETURNS
  59.  *  void
  60.  *****************************************************************************/
  61. BOOL DOW_translate_pen_event(
  62.         DOW_select *d,
  63.         mmi_pen_event_type_enum pen_event,
  64.         S16 x,
  65.         S16 y,
  66.         DOW_pen_event_enum *DOW_event,
  67.         gui_pen_event_param_struct *DOW_param)
  68. {
  69.     /*----------------------------------------------------------------*/
  70.     /* Local Variables                                                */
  71.     /*----------------------------------------------------------------*/
  72.     BOOL ret = MMI_TRUE;
  73.     /*----------------------------------------------------------------*/
  74.     /* Code Body                                                      */
  75.     /*----------------------------------------------------------------*/
  76.     *DOW_event = DOW_PEN_NONE;
  77.     GUI_PEN_EVENT_PARAM_SET_VOID(DOW_param);
  78.     /* Only react to pen down event */
  79.     if (pen_event == MMI_PEN_EVENT_DOWN)
  80.     {
  81.         if (PEN_CHECK_BOUND(x, y, d->x, d->y, d->width, d->height))
  82.         {
  83.             S32 cell_index;
  84.             DOW_translate_pen_position(d, x, &cell_index);
  85.             if (cell_index >= 0)
  86.             {
  87.                 if (d->highlighted_cell != cell_index)
  88.                 {
  89.                     *DOW_event = DOW_PEN_CHANGE_HIGHLIGHT_AND_TOGGLE_I;
  90.                     GUI_PEN_EVENT_PARAM_SET_INTEGER(DOW_param, cell_index);
  91.                 }
  92.                 else
  93.                 {
  94.                     *DOW_event = DOW_PEN_TOGGLE_CURRENT_ITEM;
  95.                 }
  96.             }
  97.         }
  98.         else
  99.         {
  100.             ret = MMI_FALSE;
  101.         }
  102.     }
  103.     return ret;
  104. }
  105. #endif /* __MMI_TOUCH_SCREEN__ */ 
  106. /*****************************************************************************
  107.  * FUNCTION
  108.  *  DOW_select_previous
  109.  * DESCRIPTION
  110.  *  set focus on previous select day of DOW input box
  111.  * PARAMETERS
  112.  *  d       [IN]        DOW input box
  113.  * RETURNS
  114.  *  void
  115.  *****************************************************************************/
  116. void DOW_select_previous(DOW_select *d)
  117. {
  118.     /*----------------------------------------------------------------*/
  119.     /* Local Variables                                                */
  120.     /*----------------------------------------------------------------*/
  121.     /*----------------------------------------------------------------*/
  122.     /* Code Body                                                      */
  123.     /*----------------------------------------------------------------*/
  124.     if ((S32) d->highlighted_cell <= 0)
  125.     {
  126.         return;
  127.     }
  128.     d->highlighted_cell--;
  129. }
  130. /*****************************************************************************
  131.  * FUNCTION
  132.  *  DOW_select_next
  133.  * DESCRIPTION
  134.  *  set focus on next  select day of DOW input box
  135.  * PARAMETERS
  136.  *  d       [IN]        DOW input box
  137.  * RETURNS
  138.  *  void
  139.  *****************************************************************************/
  140. void DOW_select_next(DOW_select *d)
  141. {
  142.     /*----------------------------------------------------------------*/
  143.     /* Local Variables                                                */
  144.     /*----------------------------------------------------------------*/
  145.     /*----------------------------------------------------------------*/
  146.     /* Code Body                                                      */
  147.     /*----------------------------------------------------------------*/
  148.     if (d->highlighted_cell >= 6)
  149.     {
  150.         return;
  151.     }
  152.     d->highlighted_cell++;
  153. }
  154. /*****************************************************************************
  155.  * FUNCTION
  156.  *  DOW_select_toggle_item
  157.  * DESCRIPTION
  158.  *  toggle the select or unslect day of DOW input box
  159.  * PARAMETERS
  160.  *  d       [IN]        DOW input box
  161.  * RETURNS
  162.  *  void
  163.  *****************************************************************************/
  164. void DOW_select_toggle_item(DOW_select *d)
  165. {
  166.     /*----------------------------------------------------------------*/
  167.     /* Local Variables                                                */
  168.     /*----------------------------------------------------------------*/
  169.     /*----------------------------------------------------------------*/
  170.     /* Code Body                                                      */
  171.     /*----------------------------------------------------------------*/
  172.     if (((S32) d->highlighted_cell < 0) || (d->highlighted_cell > 6))
  173.     {
  174.         return;
  175.     }
  176.     if (d->states[d->highlighted_cell] == 1)
  177.     {
  178.         d->states[d->highlighted_cell] = 0;
  179.     }
  180.     else if (d->states[d->highlighted_cell] == 0)
  181.     {
  182.         d->states[d->highlighted_cell] = 1;
  183.     }
  184. }
  185. /*****************************************************************************
  186.  * FUNCTION
  187.  *  DOW_select_highlight_item
  188.  * DESCRIPTION
  189.  *  highlight particular day of DOW input box
  190.  * PARAMETERS
  191.  *  d       [IN]        DOW input box
  192.  *  i       [IN]        Highlighted index
  193.  * RETURNS
  194.  *  void
  195.  *****************************************************************************/
  196. void DOW_select_highlight_item(DOW_select *d, S32 i)
  197. {
  198.     /*----------------------------------------------------------------*/
  199.     /* Local Variables                                                */
  200.     /*----------------------------------------------------------------*/
  201.     /*----------------------------------------------------------------*/
  202.     /* Code Body                                                      */
  203.     /*----------------------------------------------------------------*/
  204.     if ((i < 0) || (i > 6))
  205.     {
  206.         return;
  207.     }
  208.     d->highlighted_cell = (U8) i;
  209. }
  210. /* Time period input object   */
  211. /* color theme of time period input box */
  212. UI_filled_area time_period_input_background_filler = {UI_FILLED_AREA_TYPE_COLOR,
  213.     UI_NULL_IMAGE,
  214.     NULL,
  215.     {255, 255, 255, 100},
  216.     {0, 0, 0, 0},
  217.     {0, 0, 0, 100},
  218.     {0, 0, 0, 0},
  219.     0
  220. };
  221. /*****************************************************************************
  222.  * FUNCTION
  223.  *  time_period_input_show_background
  224.  * DESCRIPTION
  225.  *  show background of time period
  226.  * PARAMETERS
  227.  *  d       [IN]        
  228.  * RETURNS
  229.  *  void
  230.  *****************************************************************************/
  231. void time_period_input_show_background(time_period_input *d)
  232. {
  233.     /*----------------------------------------------------------------*/
  234.     /* Local Variables                                                */
  235.     /*----------------------------------------------------------------*/
  236.     S32 x1, y1, x2, y2;
  237.     /*----------------------------------------------------------------*/
  238.     /* Code Body                                                      */
  239.     /*----------------------------------------------------------------*/
  240.     gdi_layer_reset_clip();
  241.     x1 = d->x;
  242.     y1 = d->y;
  243.     x2 = x1 + d->width - 1;
  244.     y2 = y1 + d->height - 1;
  245.     //20051012 HIMANSHU START INLINE TIME PERIOD
  246.     // for drawing the transparent background for highlighted Time-Period menu item.
  247.     //PMT HIMANSHU INLINE TIME PERIOD START 20051022
  248.     /* There is no need to draw white background now as the text now will not be
  249.        shown because of the flag UI_MENUITEM_EXT_DISABLE_FOCUSSED_TEXT_DISPLAY */
  250.     //      if(wgui_is_wallpaper_on_bottom()==MMI_TRUE)
  251.     //              gdi_draw_solid_rect(x1,y1,x2,y2,GDI_COLOR_TRANSPARENT);
  252.     //      else
  253.     //              gui_draw_filled_area(x1,y1,x2,y2,&time_period_input_background_filler);
  254.     //PMT HIMANSHU INLINE TIME PERIOD END 20051022
  255.     //20051012 HIMANSHU END INLINE TIME PERIOD
  256.     x1 = d->hours_input_box1.x;
  257.     y1 = d->y;
  258.     x2 = d->minutes_input_box1.x + d->minutes_input_box1.width - 1;
  259.     y2 = y1 + d->height - 1;
  260.     gui_draw_filled_area(x1, y1, x2, y2, &date_time_input_background_filler);
  261.     x1 = d->hours_input_box2.x;
  262.     y1 = d->y;
  263.     x2 = d->minutes_input_box2.x + d->minutes_input_box2.width - 1;
  264.     y2 = y1 + d->height - 1;
  265.     gui_draw_filled_area(x1, y1, x2, y2, &date_time_input_background_filler);
  266. }
  267. /*****************************************************************************
  268.  * FUNCTION
  269.  *  time_period_input_reset_focus
  270.  * DESCRIPTION
  271.  *  reset foucus of time period input box
  272.  * PARAMETERS
  273.  *  d       [IN]        
  274.  * RETURNS
  275.  *  void
  276.  *****************************************************************************/
  277. void time_period_input_reset_focus(time_period_input *d)
  278. {
  279.     /*----------------------------------------------------------------*/
  280.     /* Local Variables                                                */
  281.     /*----------------------------------------------------------------*/
  282.     /*----------------------------------------------------------------*/
  283.     /* Code Body                                                      */
  284.     /*----------------------------------------------------------------*/
  285.     d->hours_input_box1.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  286.     d->hours_input_box1.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  287.     d->hours_input_box1.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  288.     d->minutes_input_box1.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  289.     d->minutes_input_box1.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  290.     d->minutes_input_box1.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  291.     d->hours_input_box2.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  292.     d->hours_input_box2.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  293.     d->hours_input_box2.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  294.     d->minutes_input_box2.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  295.     d->minutes_input_box2.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  296.     d->minutes_input_box2.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  297.     d->focus_input_box = NULL;
  298. }
  299. /*****************************************************************************
  300.  * FUNCTION
  301.  *  time_period_input_set_focus
  302.  * DESCRIPTION
  303.  *  set foucus of time period input box depend on current focus
  304.  * PARAMETERS
  305.  *  d       [IN]        
  306.  * RETURNS
  307.  *  void
  308.  *****************************************************************************/
  309. void time_period_input_set_focus(time_period_input *d)
  310. {
  311.     /*----------------------------------------------------------------*/
  312.     /* Local Variables                                                */
  313.     /*----------------------------------------------------------------*/
  314.     /*----------------------------------------------------------------*/
  315.     /* Code Body                                                      */
  316.     /*----------------------------------------------------------------*/
  317.     if ((d->current_focus < 1) || (d->current_focus > 4))
  318.     {
  319.         return;
  320.     }
  321.     switch (d->focus_list[d->current_focus])
  322.     {
  323.         case TIME_PERIOD_INPUT_FOCUS_HOURS1:
  324.             d->hours_input_box1.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  325.             d->hours_input_box1.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  326.             d->hours_input_box1.flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  327.             d->focus_input_box = &d->hours_input_box1;
  328.             break;
  329.         case TIME_PERIOD_INPUT_FOCUS_MINUTES1:
  330.             d->minutes_input_box1.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  331.             d->minutes_input_box1.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  332.             d->minutes_input_box1.flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  333.             d->focus_input_box = &d->minutes_input_box1;
  334.             break;
  335.         case TIME_PERIOD_INPUT_FOCUS_HOURS2:
  336.             d->hours_input_box2.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  337.             d->hours_input_box2.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  338.             d->hours_input_box2.flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  339.             d->focus_input_box = &d->hours_input_box2;
  340.             break;
  341.         case TIME_PERIOD_INPUT_FOCUS_MINUTES2:
  342.             d->minutes_input_box2.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  343.             d->minutes_input_box2.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  344.             d->minutes_input_box2.flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  345.             d->focus_input_box = &d->minutes_input_box2;
  346.             break;
  347.     }
  348. }
  349. /*****************************************************************************
  350.  * FUNCTION
  351.  *  time_period_input_set_default_focus
  352.  * DESCRIPTION
  353.  *  set defualt foucs of time period input box
  354.  * PARAMETERS
  355.  *  d       [IN]        
  356.  * RETURNS
  357.  *  void
  358.  *****************************************************************************/
  359. void time_period_input_set_default_focus(time_period_input *d)
  360. {
  361.     /*----------------------------------------------------------------*/
  362.     /* Local Variables                                                */
  363.     /*----------------------------------------------------------------*/
  364.     S32 i;
  365.     /*----------------------------------------------------------------*/
  366.     /* Code Body                                                      */
  367.     /*----------------------------------------------------------------*/
  368.     switch (d->flags & TIME_PERIOD_INPUT_TYPE_DEFAULT_FOCUS_MASK)
  369.     {
  370.         case TIME_PERIOD_INPUT_TYPE_DEFAULT_FOCUS_HOURS1:
  371.             for (i = 0; i < 6; i++)
  372.             {
  373.                 if (d->focus_list[i] == TIME_PERIOD_INPUT_FOCUS_HOURS1)
  374.                 {
  375.                     d->current_focus = i;
  376.                 }
  377.             }
  378.             break;
  379.         case TIME_PERIOD_INPUT_TYPE_DEFAULT_FOCUS_MINUTES1:
  380.             for (i = 0; i < 6; i++)
  381.             {
  382.                 if (d->focus_list[i] == TIME_PERIOD_INPUT_FOCUS_MINUTES1)
  383.                 {
  384.                     d->current_focus = i;
  385.                 }
  386.             }
  387.             break;
  388.         case TIME_PERIOD_INPUT_TYPE_DEFAULT_FOCUS_HOURS2:
  389.             for (i = 0; i < 6; i++)
  390.             {
  391.                 if (d->focus_list[i] == TIME_PERIOD_INPUT_FOCUS_HOURS2)
  392.                 {
  393.                     d->current_focus = i;
  394.                 }
  395.             }
  396.             break;
  397.         case TIME_PERIOD_INPUT_TYPE_DEFAULT_FOCUS_MINUTES2:
  398.             for (i = 0; i < 6; i++)
  399.             {
  400.                 if (d->focus_list[i] == TIME_PERIOD_INPUT_FOCUS_MINUTES2)
  401.                 {
  402.                     d->current_focus = i;
  403.                 }
  404.             }
  405.             break;
  406.     }
  407. }
  408. /*****************************************************************************
  409.  * FUNCTION
  410.  *  create_time_period_input
  411.  * DESCRIPTION
  412.  *  set defualt foucs of time period input box
  413.  * PARAMETERS
  414.  *  d                   [IN]        
  415.  *  x                   [IN]        Start x position of time period input
  416.  *  y                   [IN]        Start y position of time period input
  417.  *  width               [IN]        Width of time  period input
  418.  *  height              [IN]        Height of time period input
  419.  *  flags               [IN]        
  420.  *  hours_buffer1       [IN]        Hours buffer first range
  421.  *  minutes_buffer1     [IN]        Minutes buffer first range
  422.  *  hours_buffer2       [IN]        Hours buffer max range
  423.  *  minutes_buffer2     [IN]        Minutes buffer max range
  424.  * RETURNS
  425.  *  void
  426.  *****************************************************************************/
  427. void create_time_period_input(
  428.         time_period_input *d,
  429.         S32 x,
  430.         S32 y,
  431.         S32 width,
  432.         S32 height,
  433.         U32 flags,
  434.         UI_buffer_type hours_buffer1,
  435.         UI_buffer_type minutes_buffer1,
  436.         UI_buffer_type hours_buffer2,
  437.         UI_buffer_type minutes_buffer2)
  438. {
  439.     /*----------------------------------------------------------------*/
  440.     /* Local Variables                                                */
  441.     /*----------------------------------------------------------------*/
  442.     S32 w1, w2, h, ox, oy, sw1, sw2, tw, l;
  443.     UI_single_line_input_box_theme *t = current_single_line_input_box_theme;
  444.     /*----------------------------------------------------------------*/
  445.     /* Code Body                                                      */
  446.     /*----------------------------------------------------------------*/
  447.     d->x = x;
  448.     d->y = y;
  449.     d->width = width;
  450.     d->height = height;
  451.     d->flags = flags;
  452.     w1 = TIME_PERIOD_INPUT_HOURS_WIDTH;
  453.     w2 = TIME_PERIOD_INPUT_MINUTES_WIDTH;
  454.     sw1 = TIME_PERIOD_INPUT_SEPERATOR_WIDTH1;
  455.     sw2 = TIME_PERIOD_INPUT_SEPERATOR_WIDTH2;
  456.     tw = w1 + sw1 + w2 + sw2 + w1 + sw1 + w2;
  457.     h = TIME_PERIOD_INPUT_HEIGHT;
  458.     oy = (height >> 1) - (h >> 1);
  459.     switch (flags & TIME_PERIOD_INPUT_JUSTIFY_MASK)
  460.     {
  461.         case TIME_PERIOD_INPUT_RIGHT_JUSTIFY:
  462.             ox = (width - tw);
  463.             break;
  464.         case TIME_PERIOD_INPUT_CENTER_JUSTIFY:
  465.             ox = (width >> 1) - (tw >> 1);
  466.             break;
  467.         default:
  468.             ox = 0;
  469.             break;
  470.     }
  471.     d->focus_list[0] = TIME_PERIOD_INPUT_FOCUS_NONE;
  472.     d->focus_list[5] = TIME_PERIOD_INPUT_FOCUS_NONE;
  473.     d->focus_list[1] = TIME_PERIOD_INPUT_FOCUS_HOURS1;
  474.     d->focus_list[2] = TIME_PERIOD_INPUT_FOCUS_MINUTES1;
  475.     d->focus_list[3] = TIME_PERIOD_INPUT_FOCUS_HOURS2;
  476.     d->focus_list[4] = TIME_PERIOD_INPUT_FOCUS_MINUTES2;
  477.     d->hours1_x = ox;
  478.     ox += w1 + sw1;
  479.     d->minutes1_x = ox;
  480.     ox += w2 + sw2;
  481.     d->hours2_x = ox;
  482.     ox += w1 + sw1;
  483.     d->minutes2_x = ox;
  484.     d->flags |= TIME_PERIOD_INPUT_TYPE_DEFAULT_FOCUS_HOURS1;
  485.     current_single_line_input_box_theme = &date_time_input_theme;
  486.     d->hours1_y = oy;
  487.     d->minutes1_y = oy;
  488.     d->hours2_y = oy;
  489.     d->minutes2_y = oy;
  490.     d->s1_y = oy;
  491.     d->s2_y = oy;
  492.     d->s3_y = oy;
  493.     if ((h + 2) > height)
  494.     {
  495.         h = height - 2;
  496.     }
  497.     /* MTK Elvis for R2L characters */
  498.     l = gui_strlen((UI_string_type) hours_buffer1) /* +1 */ ;
  499.     /* create single input box of hours 1 */
  500.     gui_create_single_line_input_box_set_buffer(
  501.         &d->hours_input_box1,
  502.         x + d->hours1_x,
  503.         y + d->hours1_y,
  504.         w1,
  505.         h,
  506.         (UI_string_type) hours_buffer1,
  507.         TIME_PERIOD_INPUT_HOURS_BUFFER_LENGTH,
  508.         (l + 1) * ENCODING_LENGTH,
  509.         0);
  510.     d->hours_input_box1.flags |=
  511.         (UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE | UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR |
  512.          UI_SINGLE_LINE_INPUT_BOX_NO_BORDER);
  513.     gui_single_line_input_box_goto_first_character(&d->hours_input_box1);
  514.     l = gui_strlen((UI_string_type) minutes_buffer1) /* +1 */ ;
  515.     /* create single input box of minutes 1 */
  516.     gui_create_single_line_input_box_set_buffer(
  517.         &d->minutes_input_box1,
  518.         x + d->minutes1_x,
  519.         y + d->minutes1_y,
  520.         w2,
  521.         h,
  522.         (UI_string_type) minutes_buffer1,
  523.         TIME_PERIOD_INPUT_MINUTES_BUFFER_LENGTH,
  524.         (l + 1) * ENCODING_LENGTH,
  525.         0);
  526.     d->minutes_input_box1.flags |=
  527.         (UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE | UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR |
  528.          UI_SINGLE_LINE_INPUT_BOX_NO_BORDER);
  529.     gui_single_line_input_box_goto_first_character(&d->minutes_input_box1);
  530.     l = gui_strlen((UI_string_type) hours_buffer1) /* +1 */ ;
  531.     /* create single input box of hours 2 */
  532.     gui_create_single_line_input_box_set_buffer(
  533.         &d->hours_input_box2,
  534.         x + d->hours2_x,
  535.         y + d->hours2_y,
  536.         w1,
  537.         h,
  538.         (UI_string_type) hours_buffer2,
  539.         TIME_PERIOD_INPUT_HOURS_BUFFER_LENGTH,
  540.         (l + 1) * ENCODING_LENGTH,
  541.         0);
  542.     d->hours_input_box2.flags |=
  543.         (UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE | UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR |
  544.          UI_SINGLE_LINE_INPUT_BOX_NO_BORDER);
  545.     gui_single_line_input_box_goto_first_character(&d->hours_input_box2);
  546.     l = gui_strlen((UI_string_type) minutes_buffer2) /* +1 */ ;
  547.     /* create single input box of minutes 2 */
  548.     gui_create_single_line_input_box_set_buffer(
  549.         &d->minutes_input_box2,
  550.         x + d->minutes2_x,
  551.         y + d->minutes2_y,
  552.         w2,
  553.         h,
  554.         (UI_string_type) minutes_buffer2,
  555.         TIME_PERIOD_INPUT_MINUTES_BUFFER_LENGTH,
  556.         (l + 1) * ENCODING_LENGTH,
  557.         0);
  558.     d->minutes_input_box2.flags |=
  559.         (UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE | UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR |
  560.          UI_SINGLE_LINE_INPUT_BOX_NO_BORDER);
  561.     gui_single_line_input_box_goto_first_character(&d->minutes_input_box2);
  562.     time_period_input_reset_focus(d);
  563.     time_period_input_set_default_focus(d);
  564.     time_period_input_set_focus(d);
  565.     current_single_line_input_box_theme = t;
  566.     /* MTK end */
  567.     /* Setup default validation functions  */
  568.     d->hours_input_box1.validation_callback = default_inline_time_hours_validation;
  569.     d->minutes_input_box1.validation_callback = default_inline_time_minutes_validation;
  570.     d->hours_input_box2.validation_callback = default_inline_time_hours_validation;
  571.     d->minutes_input_box2.validation_callback = default_inline_time_minutes_validation;
  572. }
  573. /*****************************************************************************
  574.  * FUNCTION
  575.  *  show_time_period_input
  576.  * DESCRIPTION
  577.  *  show time period input box
  578.  * PARAMETERS
  579.  *  d       [IN]        
  580.  * RETURNS
  581.  *  void
  582.  *****************************************************************************/
  583. void show_time_period_input(time_period_input *d)
  584. {
  585.     /*----------------------------------------------------------------*/
  586.     /* Local Variables                                                */
  587.     /*----------------------------------------------------------------*/
  588.     UI_single_line_input_box_theme *t = current_single_line_input_box_theme;
  589.     S32 sw;
  590.     /*----------------------------------------------------------------*/
  591.     /* Code Body                                                      */
  592.     /*----------------------------------------------------------------*/
  593.     current_single_line_input_box_theme = &date_time_input_theme;
  594.     gui_set_single_line_input_box_current_theme(&d->hours_input_box1);
  595.     gui_set_single_line_input_box_current_theme(&d->minutes_input_box1);
  596.     gui_set_single_line_input_box_current_theme(&d->hours_input_box2);
  597.     gui_set_single_line_input_box_current_theme(&d->minutes_input_box2);
  598.     /* show single input box of hours 1 */
  599.     gui_show_single_line_input_box(&d->hours_input_box1);
  600.     /* show single input box of minutes 1 */
  601.     gui_show_single_line_input_box(&d->minutes_input_box1);
  602.     /* show single input box of hours2 */
  603.     gui_show_single_line_input_box(&d->hours_input_box2);
  604.     /* show single input box of minutes2 */
  605.     gui_show_single_line_input_box(&d->minutes_input_box2);
  606.     gdi_layer_reset_clip();
  607.     gui_set_font(d->hours_input_box1.text_font);
  608.     gui_set_text_color(d->hours_input_box1.normal_text_color);
  609.     if (r2lMMIFlag)
  610.     {
  611.         gui_set_font(d->hours_input_box1.text_font);
  612.         sw = gui_get_character_width(d->seperator1);
  613.         gui_move_text_cursor(d->s1_x + sw, d->s1_y + d->y);
  614.     }
  615.     else
  616.     {
  617.         gui_move_text_cursor(d->s1_x, d->s1_y + d->y);
  618.     }
  619.     gui_print_character(d->seperator1);
  620.     if (r2lMMIFlag)
  621.     {
  622.         gui_set_font(d->hours_input_box1.text_font);
  623.         sw = gui_get_character_width(d->seperator2);
  624.         gui_move_text_cursor(d->s2_x + sw, d->s2_y + d->y);
  625.     }
  626.     else
  627.     {
  628.         gui_move_text_cursor(d->s2_x, d->s2_y + d->y);
  629.     }
  630.     gui_print_character(d->seperator2);
  631.     if (r2lMMIFlag)
  632.     {
  633.         gui_set_font(d->hours_input_box2.text_font);
  634.         sw = gui_get_character_width(d->seperator1);
  635.         gui_move_text_cursor(d->s3_x + sw, d->s3_y + d->y);
  636.     }
  637.     else
  638.     {
  639.         gui_move_text_cursor(d->s3_x, d->s3_y + d->y);
  640.     }
  641.     gui_print_character(d->seperator1);
  642.     gdi_layer_blt_previous(d->x, d->y, d->x + d->width - 1, d->y + d->height - 1);
  643.     current_single_line_input_box_theme = t;
  644. }
  645. /*****************************************************************************
  646.  * FUNCTION
  647.  *  time_period_input_set_next_focus
  648.  * DESCRIPTION
  649.  *  set fopcus to next box of time period input box
  650.  * PARAMETERS
  651.  *  d       [IN]        
  652.  * RETURNS
  653.  *  byte
  654.  *****************************************************************************/
  655. U8 time_period_input_set_next_focus(time_period_input *d)
  656. {
  657.     /*----------------------------------------------------------------*/
  658.     /* Local Variables                                                */
  659.     /*----------------------------------------------------------------*/
  660.     /*----------------------------------------------------------------*/
  661.     /* Code Body                                                      */
  662.     /*----------------------------------------------------------------*/
  663.     if (d->focus_list[d->current_focus + 1] == TIME_PERIOD_INPUT_FOCUS_NONE)
  664.     {
  665.         return (0);
  666.     }
  667.     else
  668.     {
  669.         time_period_input_reset_focus(d);
  670.         d->current_focus++;
  671.         time_period_input_set_focus(d);
  672.     #if defined(__MMI_TOUCH_SCREEN__)
  673.         gui_single_line_input_box_goto_first_character(d->focus_input_box);
  674.     #endif 
  675.         return (1);
  676.     }
  677. }
  678. /*****************************************************************************
  679.  * FUNCTION
  680.  *  time_period_input_set_previous_focus
  681.  * DESCRIPTION
  682.  *  set fopcus to previous  box of time period input box
  683.  * PARAMETERS
  684.  *  d       [IN]        
  685.  * RETURNS
  686.  *  byte
  687.  *****************************************************************************/
  688. U8 time_period_input_set_previous_focus(time_period_input *d)
  689. {
  690.     /*----------------------------------------------------------------*/
  691.     /* Local Variables                                                */
  692.     /*----------------------------------------------------------------*/
  693.     /*----------------------------------------------------------------*/
  694.     /* Code Body                                                      */
  695.     /*----------------------------------------------------------------*/
  696.     if (d->focus_list[d->current_focus - 1] == TIME_PERIOD_INPUT_FOCUS_NONE)
  697.     {
  698.         return (0);
  699.     }
  700.     else
  701.     {
  702.         time_period_input_reset_focus(d);
  703.         d->current_focus--;
  704.         time_period_input_set_focus(d);
  705.     #if defined(__MMI_TOUCH_SCREEN__)
  706.         gui_single_line_input_box_goto_last_character(d->focus_input_box);
  707.         gui_single_line_input_box_previous(d->focus_input_box);
  708.     #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
  709.         return (1);
  710.     }
  711. }
  712. #if defined (__MMI_TOUCH_SCREEN__)
  713. /*****************************************************************************
  714.  * FUNCTION
  715.  *  time_period_input_move_to_x_y
  716.  * DESCRIPTION
  717.  *  set the cursor position to (x,y) position
  718.  * PARAMETERS
  719.  *  tp      [IN]        Time period input box S32 x S32 y
  720.  *  x       [IN]        
  721.  *  y       [IN]        
  722.  * RETURNS
  723.  *  void
  724.  *****************************************************************************/
  725. void time_period_input_move_to_x_y(time_period_input *tp, S32 x, S32 y)
  726. {
  727.     /*----------------------------------------------------------------*/
  728.     /* Local Variables                                                */
  729.     /*----------------------------------------------------------------*/
  730.     int i = 1;
  731.     /*----------------------------------------------------------------*/
  732.     /* Code Body                                                      */
  733.     /*----------------------------------------------------------------*/
  734.     if (PEN_CHECK_BOUND(x, y, tp->x, tp->y, tp->width, tp->height) &&
  735.         !(PEN_CHECK_BOUND
  736.           (x, y, tp->minutes_input_box1.x + tp->minutes_input_box1.width, tp->y,
  737.            tp->hours_input_box1.x - (tp->minutes_input_box1.x + tp->minutes_input_box1.width), tp->height)))
  738.     {
  739.         if (PEN_CHECK_BOUND
  740.             (x, y, tp->hours_input_box1.x, tp->hours_input_box1.y, tp->hours_input_box1.width,
  741.              tp->hours_input_box1.height))
  742.         {
  743.             gui_single_line_input_box_goto_first_character(tp->focus_input_box);
  744.             time_period_input_reset_focus(tp);
  745.             for (;; i++)
  746.             {
  747.                 if (tp->focus_list[i] == TIME_PERIOD_INPUT_FOCUS_HOURS1)
  748.                 {
  749.                     tp->current_focus = i;
  750.                     break;
  751.                 }
  752.             }
  753.             time_period_input_set_focus(tp);
  754.         }
  755.         else if (PEN_CHECK_BOUND
  756.                  (x, y, tp->minutes_input_box1.x, tp->minutes_input_box1.y, tp->minutes_input_box1.width,
  757.                   tp->minutes_input_box1.height))
  758.         {
  759.             gui_single_line_input_box_goto_first_character(tp->focus_input_box);
  760.             time_period_input_reset_focus(tp);
  761.             for (;; i++)
  762.             {
  763.                 if (tp->focus_list[i] == TIME_PERIOD_INPUT_FOCUS_MINUTES1)
  764.                 {
  765.                     tp->current_focus = i;
  766.                     break;
  767.                 }
  768.             }
  769.             time_period_input_set_focus(tp);
  770.         }
  771.         else if (PEN_CHECK_BOUND
  772.                  (x, y, tp->hours_input_box2.x, tp->hours_input_box2.y, tp->hours_input_box2.width,
  773.                   tp->hours_input_box2.height))
  774.         {
  775.             gui_single_line_input_box_goto_first_character(tp->focus_input_box);
  776.             time_period_input_reset_focus(tp);
  777.             for (;; i++)
  778.             {
  779.                 if (tp->focus_list[i] == TIME_PERIOD_INPUT_FOCUS_HOURS2)
  780.                 {
  781.                     tp->current_focus = i;
  782.                     break;
  783.                 }
  784.             }
  785.             time_period_input_set_focus(tp);
  786.         }
  787.         else if (PEN_CHECK_BOUND
  788.                  (x, y, tp->minutes_input_box2.x, tp->minutes_input_box2.y, tp->minutes_input_box2.width,
  789.                   tp->minutes_input_box2.height))
  790.         {
  791.             gui_single_line_input_box_goto_first_character(tp->focus_input_box);
  792.             time_period_input_reset_focus(tp);
  793.             for (;; i++)
  794.             {
  795.                 if (tp->focus_list[i] == TIME_PERIOD_INPUT_FOCUS_MINUTES2)
  796.                 {
  797.                     tp->current_focus = i;
  798.                     break;
  799.                 }
  800.             }
  801.             time_period_input_set_focus(tp);
  802.         }
  803.         else
  804.         {
  805.             return;
  806.         }
  807.         gui_show_single_line_input_box_ext(tp->focus_input_box, x, y);
  808.         if (gui_single_line_input_box_test_last_character_position(tp->focus_input_box))
  809.         {
  810.             gui_single_line_input_box_goto_last_character(tp->focus_input_box);
  811.             gui_single_line_input_box_previous(tp->focus_input_box);
  812.         }
  813.         show_time_period_input(tp);
  814.     }
  815. }
  816. #endif /* defined (__MMI_TOUCH_SCREEN__) */ 
  817. /*****************************************************************************
  818.  * FUNCTION
  819.  *  time_period_input_set_seperators
  820.  * DESCRIPTION
  821.  *  set the mask of time period input box
  822.  * PARAMETERS
  823.  *  d               [IN]        
  824.  *  seperator1      [IN]        Separator of first time period
  825.  *  seperator2      [IN]        Seperartor of second time period
  826.  * RETURNS
  827.  *  void
  828.  *****************************************************************************/
  829. void time_period_input_set_seperators(time_period_input *d, UI_character_type seperator1, UI_character_type seperator2)
  830. {
  831.     /*----------------------------------------------------------------*/
  832.     /* Local Variables                                                */
  833.     /*----------------------------------------------------------------*/
  834.     S32 sw1, sw2, x1, x2;
  835.     /*----------------------------------------------------------------*/
  836.     /* Code Body                                                      */
  837.     /*----------------------------------------------------------------*/
  838.     d->seperator1 = seperator1;
  839.     d->seperator2 = seperator2;
  840.     gui_set_font(d->hours_input_box1.text_font);
  841.     sw1 = gui_get_character_width(d->seperator1);
  842.     sw2 = gui_get_character_width(d->seperator2);
  843.     x1 = d->hours_input_box1.x + d->hours_input_box1.width - 1;
  844.     x2 = d->minutes_input_box1.x;
  845.     d->s1_x = x1 + ((x2 - x1) >> 1) - (sw1 >> 1);
  846.     x1 = d->minutes_input_box1.x + d->minutes_input_box1.width - 1;
  847.     x2 = d->hours_input_box2.x;
  848.     d->s2_x = x1 + ((x2 - x1) >> 1) - (sw2 >> 1);
  849.     x1 = d->hours_input_box2.x + d->hours_input_box2.width - 1;
  850.     x2 = d->minutes_input_box2.x;
  851.     d->s3_x = x1 + ((x2 - x1) >> 1) - (sw1 >> 1);
  852. }
  853. /* glbal variable store value of current time period input box */
  854. time_period_input *current_time_period_input = NULL;
  855. /*----------------------------------------------------------------------------
  856. Function:         current_time_period_input_callback
  857. Description:   a function pointer of time period input callback 
  858. Input Parameters: none
  859.                
  860. Output Parameters:   none
  861. Returns:       none
  862. ----------------------------------------------------------------------------*/
  863. void (*current_time_period_input_callback) (void) = UI_dummy_function;
  864. /*****************************************************************************
  865.  * FUNCTION
  866.  *  set_current_time_period_input
  867.  * DESCRIPTION
  868.  *  set the valeu of global variable of current time period input
  869.  *  equal to value pass as parameter
  870.  * PARAMETERS
  871.  *  d       [IN]        
  872.  * RETURNS
  873.  *  void
  874.  *****************************************************************************/
  875. void set_current_time_period_input(time_period_input *d)
  876. {
  877.     /*----------------------------------------------------------------*/
  878.     /* Local Variables                                                */
  879.     /*----------------------------------------------------------------*/
  880.     /*----------------------------------------------------------------*/
  881.     /* Code Body                                                      */
  882.     /*----------------------------------------------------------------*/
  883.     current_time_period_input = d;
  884. }
  885. /*****************************************************************************
  886.  * FUNCTION
  887.  *  time_period_input_direct_input
  888.  * DESCRIPTION
  889.  *  insert the character in time period input
  890.  *  and show the time period input box
  891.  * PARAMETERS
  892.  *  c       [IN]        
  893.  * RETURNS
  894.  *  void
  895.  *****************************************************************************/
  896. void time_period_input_direct_input(UI_character_type c)
  897. {
  898.     /*----------------------------------------------------------------*/
  899.     /* Local Variables                                                */
  900.     /*----------------------------------------------------------------*/
  901.     /*----------------------------------------------------------------*/
  902.     /* Code Body                                                      */
  903.     /*----------------------------------------------------------------*/
  904.     if (current_time_period_input == NULL)
  905.     {
  906.         return;
  907.     }
  908.     if (current_time_period_input->focus_input_box == NULL)
  909.     {
  910.         return;
  911.     }
  912.     if (gui_single_line_input_box_test_last_position_overflow(current_time_period_input->focus_input_box))
  913.     {
  914.         if (time_period_input_set_next_focus(current_time_period_input))
  915.         {
  916.             gui_single_line_input_box_insert_character(current_time_period_input->focus_input_box, c);
  917.         }
  918.     }
  919.     else
  920.     {
  921.         gui_single_line_input_box_insert_character(current_time_period_input->focus_input_box, c);
  922.         if (gui_single_line_input_box_test_last_position_overflow(current_time_period_input->focus_input_box))
  923.         {
  924.             if (!time_period_input_set_next_focus(current_time_period_input))
  925.             {
  926.                 gui_single_line_input_box_previous(current_time_period_input->focus_input_box);
  927.             }
  928.         }
  929.     }
  930.     show_time_period_input(current_time_period_input);
  931.     current_time_period_input_callback();
  932. }
  933. /*****************************************************************************
  934.  * FUNCTION
  935.  *  time_period_input_direct_input_nodraw
  936.  * DESCRIPTION
  937.  *  insert the character in date input box and redraw date input box
  938.  * PARAMETERS
  939.  *  c       [IN]        
  940.  * RETURNS
  941.  *  void
  942.  *****************************************************************************/
  943. void time_period_input_direct_input_nodraw(UI_character_type c)
  944. {
  945.     /*----------------------------------------------------------------*/
  946.     /* Local Variables                                                */
  947.     /*----------------------------------------------------------------*/
  948.     /*----------------------------------------------------------------*/
  949.     /* Code Body                                                      */
  950.     /*----------------------------------------------------------------*/
  951.     if (current_time_period_input == NULL)
  952.     {
  953.         return;
  954.     }
  955.     if (current_time_period_input->focus_input_box == NULL)
  956.     {
  957.         return;
  958.     }
  959.     if (gui_single_line_input_box_test_last_position_overflow(current_time_period_input->focus_input_box))
  960.     {
  961.         if (time_period_input_set_next_focus(current_time_period_input))
  962.         {
  963.             gui_single_line_input_box_insert_character(current_time_period_input->focus_input_box, c);
  964.         }
  965.     }
  966.     else
  967.     {
  968.         gui_single_line_input_box_insert_character(current_time_period_input->focus_input_box, c);
  969.         if (gui_single_line_input_box_test_last_position_overflow(current_time_period_input->focus_input_box))
  970.         {
  971.             if (!time_period_input_set_next_focus(current_time_period_input))
  972.             {
  973.                 gui_single_line_input_box_previous(current_time_period_input->focus_input_box);
  974.             }
  975.         }
  976.     }
  977.     current_time_period_input_callback();
  978. }
  979. /*****************************************************************************
  980.  * FUNCTION
  981.  *  time_period_input_test_last_position
  982.  * DESCRIPTION
  983.  *  test current position is the last position or not
  984.  * PARAMETERS
  985.  *  tp                  [?]         
  986.  *  time_input(?)       [IN]        *t
  987.  * RETURNS
  988.  *  S32
  989.  *****************************************************************************/
  990. S32 time_period_input_test_last_position(time_period_input *tp)
  991. {
  992.     /*----------------------------------------------------------------*/
  993.     /* Local Variables                                                */
  994.     /*----------------------------------------------------------------*/
  995.     /*----------------------------------------------------------------*/
  996.     /* Code Body                                                      */
  997.     /*----------------------------------------------------------------*/
  998.     if (tp->focus_list[tp->current_focus + 1] != TIME_PERIOD_INPUT_FOCUS_NONE)
  999.     {
  1000.         return 0;
  1001.     }
  1002.     else
  1003.     {
  1004.         if (gui_single_line_input_box_test_last_character_position(tp->focus_input_box))
  1005.         {
  1006.             return 1;
  1007.         }
  1008.         else
  1009.         {
  1010.             return 0;
  1011.         }
  1012.     }
  1013. }
  1014. /*****************************************************************************
  1015.  * FUNCTION
  1016.  *  time_period_input_delete_character
  1017.  * DESCRIPTION
  1018.  *  delete caharcter of time period input box
  1019.  * PARAMETERS
  1020.  *  void
  1021.  * RETURNS
  1022.  *  void
  1023.  *****************************************************************************/
  1024. void time_period_input_delete_character(void)
  1025. {
  1026.     /*----------------------------------------------------------------*/
  1027.     /* Local Variables                                                */
  1028.     /*----------------------------------------------------------------*/
  1029.     /*----------------------------------------------------------------*/
  1030.     /* Code Body                                                      */
  1031.     /*----------------------------------------------------------------*/
  1032.     if (current_time_period_input == NULL)
  1033.     {
  1034.         return;
  1035.     }
  1036.     if (current_time_period_input->focus_input_box == NULL)
  1037.     {
  1038.         return;
  1039.     }
  1040.     if (gui_single_line_input_box_test_first_position(current_time_period_input->focus_input_box))
  1041.     {
  1042.         time_period_input_set_previous_focus(current_time_period_input);
  1043.     }
  1044.     else
  1045.     {
  1046.         gui_single_line_input_box_delete_character(current_time_period_input->focus_input_box);
  1047.         if (gui_single_line_input_box_test_first_position(current_time_period_input->focus_input_box))
  1048.         {
  1049.             time_period_input_set_previous_focus(current_time_period_input);
  1050.         }
  1051.     }
  1052.     /* show time period input box */
  1053.     show_time_period_input(current_time_period_input);
  1054.     current_time_period_input_callback();
  1055. }
  1056. /*****************************************************************************
  1057.  * FUNCTION
  1058.  *  time_period_input_previous_character
  1059.  * DESCRIPTION
  1060.  *  
  1061.  * PARAMETERS
  1062.  *  void
  1063.  * RETURNS
  1064.  *  void
  1065.  *****************************************************************************/
  1066. void time_period_input_previous_character(void)
  1067. {
  1068.     /*----------------------------------------------------------------*/
  1069.     /* Local Variables                                                */
  1070.     /*----------------------------------------------------------------*/
  1071.     /*----------------------------------------------------------------*/
  1072.     /* Code Body                                                      */
  1073.     /*----------------------------------------------------------------*/
  1074.     if (current_time_period_input == NULL)
  1075.     {
  1076.         return;
  1077.     }
  1078.     if (current_time_period_input->focus_input_box == NULL)
  1079.     {
  1080.         return;
  1081.     }
  1082.     if (gui_single_line_input_box_test_first_position(current_time_period_input->focus_input_box))
  1083.     {
  1084.         if (time_period_input_set_previous_focus(current_time_period_input))
  1085.         {
  1086.             gui_single_line_input_box_goto_last_character(current_time_period_input->focus_input_box);
  1087.             gui_single_line_input_box_previous(current_time_period_input->focus_input_box);
  1088.         }
  1089.     }
  1090.     else
  1091.     {
  1092.         gui_single_line_input_box_previous(current_time_period_input->focus_input_box);
  1093.     }
  1094.     /* show time period input box */
  1095.     show_time_period_input(current_time_period_input);
  1096. }
  1097. /*****************************************************************************
  1098.  * FUNCTION
  1099.  *  time_period_input_next_character
  1100.  * DESCRIPTION
  1101.  *  
  1102.  * PARAMETERS
  1103.  *  void
  1104.  * RETURNS
  1105.  *  void
  1106.  *****************************************************************************/
  1107. void time_period_input_next_character(void)
  1108. {
  1109.     /*----------------------------------------------------------------*/
  1110.     /* Local Variables                                                */
  1111.     /*----------------------------------------------------------------*/
  1112.     /*----------------------------------------------------------------*/
  1113.     /* Code Body                                                      */
  1114.     /*----------------------------------------------------------------*/
  1115.     if (current_time_period_input == NULL)
  1116.     {
  1117.         return;
  1118.     }
  1119.     if (current_time_period_input->focus_input_box == NULL)
  1120.     {
  1121.         return;
  1122.     }
  1123.     if (gui_single_line_input_box_test_last_character_position(current_time_period_input->focus_input_box))
  1124.     {
  1125.         time_period_input_set_next_focus(current_time_period_input);
  1126.     }
  1127.     else
  1128.     {
  1129.         gui_single_line_input_box_next(current_time_period_input->focus_input_box);
  1130.     }
  1131.     /* show time period input box */
  1132.     show_time_period_input(current_time_period_input);
  1133. }
  1134. /*****************************************************************************
  1135.  * FUNCTION
  1136.  *  time_period_input_toggle_insert_mode
  1137.  * DESCRIPTION
  1138.  *  cahneg the insert mode of time period input box
  1139.  * PARAMETERS
  1140.  *  void
  1141.  * RETURNS
  1142.  *  void
  1143.  *****************************************************************************/
  1144. void time_period_input_toggle_insert_mode(void)
  1145. {
  1146.     /*----------------------------------------------------------------*/
  1147.     /* Local Variables                                                */
  1148.     /*----------------------------------------------------------------*/
  1149.     /*----------------------------------------------------------------*/
  1150.     /* Code Body                                                      */
  1151.     /*----------------------------------------------------------------*/
  1152.     if (current_time_period_input == NULL)
  1153.     {
  1154.         return;
  1155.     }
  1156.     if (current_time_period_input->focus_input_box == NULL)
  1157.     {
  1158.         return;
  1159.     }
  1160.     gui_single_line_input_box_toggle_insert_mode(current_time_period_input->focus_input_box);
  1161.     /* show time period input box */
  1162.     show_time_period_input(current_time_period_input);
  1163. }
  1164. /*****************************************************************************
  1165.  * FUNCTION
  1166.  *  time_period_input_delete_current_character
  1167.  * DESCRIPTION
  1168.  *  delete current  character of time period input box
  1169.  * PARAMETERS
  1170.  *  void
  1171.  * RETURNS
  1172.  *  void
  1173.  *****************************************************************************/
  1174. void time_period_input_delete_current_character(void)
  1175. {
  1176.     /*----------------------------------------------------------------*/
  1177.     /* Local Variables                                                */
  1178.     /*----------------------------------------------------------------*/
  1179.     /*----------------------------------------------------------------*/
  1180.     /* Code Body                                                      */
  1181.     /*----------------------------------------------------------------*/
  1182.     if (current_time_period_input == NULL)
  1183.     {
  1184.         return;
  1185.     }
  1186.     if (current_time_period_input->focus_input_box == NULL)
  1187.     {
  1188.         return;
  1189.     }
  1190.     gui_single_line_input_box_delete_current_character(current_time_period_input->focus_input_box);
  1191.     /* show time period input box */
  1192.     show_time_period_input(current_time_period_input);
  1193.     current_time_period_input_callback();
  1194. }
  1195. /*****************************************************************************
  1196.  * FUNCTION
  1197.  *  time_period_input_delete_all_characters
  1198.  * DESCRIPTION
  1199.  *  delete all character of time period input box
  1200.  * PARAMETERS
  1201.  *  void
  1202.  * RETURNS
  1203.  *  void
  1204.  *****************************************************************************/
  1205. void time_period_input_delete_all_characters(void)
  1206. {
  1207.     /*----------------------------------------------------------------*/
  1208.     /* Local Variables                                                */
  1209.     /*----------------------------------------------------------------*/
  1210.     /*----------------------------------------------------------------*/
  1211.     /* Code Body                                                      */
  1212.     /*----------------------------------------------------------------*/
  1213.     if (current_time_period_input == NULL)
  1214.     {
  1215.         return;
  1216.     }
  1217.     if (current_time_period_input->focus_input_box == NULL)
  1218.     {
  1219.         return;
  1220.     }
  1221.     gui_single_line_input_box_delete_all(current_time_period_input->focus_input_box);
  1222.     /* show time period input box */
  1223.     show_time_period_input(current_time_period_input);
  1224.     current_time_period_input_callback();
  1225. }
  1226. /*****************************************************************************
  1227.  * FUNCTION
  1228.  *  time_period_input_numeric_keyboard_input_handler
  1229.  * DESCRIPTION
  1230.  *  handle time period numeric input
  1231.  * PARAMETERS
  1232.  *  keyc        [IN]        
  1233.  * RETURNS
  1234.  *  void
  1235.  *****************************************************************************/
  1236. void time_period_input_numeric_keyboard_input_handler(S32 keyc)
  1237. {
  1238.     /*----------------------------------------------------------------*/
  1239.     /* Local Variables                                                */
  1240.     /*----------------------------------------------------------------*/
  1241.     /*----------------------------------------------------------------*/
  1242.     /* Code Body                                                      */
  1243.     /*----------------------------------------------------------------*/
  1244.     if (keyc >= '0' && keyc <= '9')
  1245.     {
  1246.         time_period_input_direct_input((U8) keyc);
  1247.     }
  1248.     else if (keyc == 0x08)
  1249.     {
  1250.         time_period_input_delete_character();
  1251.     }
  1252.     else if (keyc == 0x1b)
  1253.     {
  1254.         time_period_input_delete_all_characters();
  1255.     }
  1256.     else if (keyc == 0x0d);
  1257. }
  1258. /*****************************************************************************
  1259.  * FUNCTION
  1260.  *  time_period_input_handle_key_down
  1261.  * DESCRIPTION
  1262.  *  handle time periosd key down event
  1263.  * PARAMETERS
  1264.  *  k       [IN]        
  1265.  * RETURNS
  1266.  *  void
  1267.  *****************************************************************************/
  1268. void time_period_input_handle_key_down(MMI_key_code_type k)
  1269. {
  1270.     /*----------------------------------------------------------------*/
  1271.     /* Local Variables                                                */
  1272.     /*----------------------------------------------------------------*/
  1273.     /*----------------------------------------------------------------*/
  1274.     /* Code Body                                                      */
  1275.     /*----------------------------------------------------------------*/
  1276.     time_period_input_direct_input((UI_character_type) ('0' + k));
  1277. }
  1278. /*****************************************************************************
  1279.  * FUNCTION
  1280.  *  time_period_input_key_handler
  1281.  * DESCRIPTION
  1282.  *  register  key handlers of time period input box
  1283.  * PARAMETERS
  1284.  *  vkey_code       [IN]        
  1285.  *  key_state       [IN]        
  1286.  * RETURNS
  1287.  *  void
  1288.  *****************************************************************************/
  1289. void time_period_input_key_handler(S32 vkey_code, S32 key_state)
  1290. {
  1291. #if(MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32)
  1292.     /*----------------------------------------------------------------*/
  1293.     /* Local Variables                                                */
  1294.     /*----------------------------------------------------------------*/
  1295.     /*----------------------------------------------------------------*/
  1296.     /* Code Body                                                      */
  1297.     /*----------------------------------------------------------------*/
  1298.     if (key_state)
  1299.     {
  1300.         switch (vkey_code)
  1301.         {
  1302.             case 37:
  1303.                 time_period_input_previous_character();
  1304.                 break;
  1305.             case 38:    /* up */
  1306.                 break;
  1307.             case 39:
  1308.                 time_period_input_next_character();
  1309.                 break;
  1310.             case 40:    /* down */
  1311.                 break;
  1312.             case 36:    /* home */
  1313.                 break;
  1314.             case 35:    /* end */
  1315.                 break;
  1316.             case 33:    /* page up */
  1317.                 break;
  1318.             case 34:    /* page down */
  1319.                 break;
  1320.             case 45:
  1321.                 time_period_input_toggle_insert_mode();
  1322.                 break;
  1323.             case 46:
  1324.                 time_period_input_delete_current_character();
  1325.                 break;
  1326.         }
  1327.     }
  1328. #else /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  1329.     UI_UNUSED_PARAMETER(vkey_code);
  1330.     UI_UNUSED_PARAMETER(key_state);
  1331. #endif /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  1332. }
  1333. /*****************************************************************************
  1334.  * FUNCTION
  1335.  *  time_period_input_register_keys
  1336.  * DESCRIPTION
  1337.  *  register all key handlers of time period input box
  1338.  * PARAMETERS
  1339.  *  void
  1340.  * RETURNS
  1341.  *  void
  1342.  *****************************************************************************/
  1343. void time_period_input_register_keys(void)
  1344. {
  1345.     /*----------------------------------------------------------------*/
  1346.     /* Local Variables                                                */
  1347.     /*----------------------------------------------------------------*/
  1348.     /*----------------------------------------------------------------*/
  1349.     /* Code Body                                                      */
  1350.     /*----------------------------------------------------------------*/
  1351.     register_MMI_key_input_handler();
  1352.     register_key_down_handler(time_period_input_handle_key_down);
  1353.     register_keyboard_input_handler(time_period_input_numeric_keyboard_input_handler);
  1354.     SetKeyHandler(time_period_input_previous_character, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1355.     SetKeyHandler(time_period_input_next_character, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1356.     register_keyboard_key_handler(time_period_input_key_handler);
  1357. }
  1358. /*****************************************************************************
  1359.  * FUNCTION
  1360.  *  time_period_input_clear_keys
  1361.  * DESCRIPTION
  1362.  *  clear all key handlers of time period input box
  1363.  * PARAMETERS
  1364.  *  void
  1365.  * RETURNS
  1366.  *  void
  1367.  *****************************************************************************/
  1368. void time_period_input_clear_keys(void)
  1369. {
  1370.     /*----------------------------------------------------------------*/
  1371.     /* Local Variables                                                */
  1372.     /*----------------------------------------------------------------*/
  1373.     /*----------------------------------------------------------------*/
  1374.     /* Code Body                                                      */
  1375.     /*----------------------------------------------------------------*/
  1376.     clear_MMI_key_input_handler();
  1377.     clear_key_down_handler();
  1378.     clear_keyboard_input_handler();
  1379.     ClearKeyHandler(KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1380.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1381.     clear_keyboard_key_handler();
  1382. }
  1383. /*****************************************************************************
  1384.  * FUNCTION
  1385.  *  register_time_period_input_callback
  1386.  * DESCRIPTION
  1387.  *  register current time period input callback function
  1388.  * PARAMETERS
  1389.  *  f       [IN]        
  1390.  * RETURNS
  1391.  *  void
  1392.  *****************************************************************************/
  1393. void register_time_period_input_callback(void (*f) (void))
  1394. {
  1395.     /*----------------------------------------------------------------*/
  1396.     /* Local Variables                                                */
  1397.     /*----------------------------------------------------------------*/
  1398.     /*----------------------------------------------------------------*/
  1399.     /* Code Body                                                      */
  1400.     /*----------------------------------------------------------------*/
  1401.     current_time_period_input_callback = f;
  1402. }
  1403. /*****************************************************************************
  1404.  * FUNCTION
  1405.  *  clear_time_period_input_callback
  1406.  * DESCRIPTION
  1407.  *  set current time period input callback to dummy function
  1408.  * PARAMETERS
  1409.  *  void
  1410.  * RETURNS
  1411.  *  void
  1412.  *****************************************************************************/
  1413. void clear_time_period_input_callback(void)
  1414. {
  1415.     /*----------------------------------------------------------------*/
  1416.     /* Local Variables                                                */
  1417.     /*----------------------------------------------------------------*/
  1418.     /*----------------------------------------------------------------*/
  1419.     /* Code Body                                                      */
  1420.     /*----------------------------------------------------------------*/
  1421.     current_time_period_input_callback = UI_dummy_function;
  1422. }
  1423. /* Default IP field validation functions  */
  1424. /*****************************************************************************
  1425.  * FUNCTION
  1426.  *  default_inline_IP_field_validation
  1427.  * DESCRIPTION
  1428.  *  validaion function of IP4 input box
  1429.  * PARAMETERS
  1430.  *  text            [IN]        
  1431.  *  cursor          [IN]        
  1432.  *  text_length     [IN]        
  1433.  * RETURNS
  1434.  *  void
  1435.  *****************************************************************************/
  1436. void default_inline_IP_field_validation(UI_buffer_type text, UI_buffer_type cursor, S32 text_length)
  1437. {
  1438.     /*----------------------------------------------------------------*/
  1439.     /* Local Variables                                                */
  1440.     /*----------------------------------------------------------------*/
  1441.     S32 i = gui_atoi((UI_string_type) text);
  1442.     /*----------------------------------------------------------------*/
  1443.     /* Code Body                                                      */
  1444.     /*----------------------------------------------------------------*/
  1445.     if (i < 0)
  1446.     {
  1447.         i = 0;
  1448.         gui_sprintf((UI_string_type) text, "%03d", i);
  1449.         UI_editor_play_tone_invalid_data();
  1450.     }
  1451.     else if (i > 255)
  1452.     {
  1453.         i = 255;
  1454.         gui_sprintf((UI_string_type) text, "%03d", i);
  1455.         UI_editor_play_tone_invalid_data();
  1456.     }
  1457. }
  1458. /* IP4 input object  */
  1459. /*****************************************************************************
  1460.  * FUNCTION
  1461.  *  IP4_input_show_background
  1462.  * DESCRIPTION
  1463.  *  show background of Ip4 input box
  1464.  * PARAMETERS
  1465.  *  d       [IN]        
  1466.  * RETURNS
  1467.  *  void
  1468.  *****************************************************************************/
  1469. void IP4_input_show_background(IP4_input *d)
  1470. {
  1471.     /*----------------------------------------------------------------*/
  1472.     /* Local Variables                                                */
  1473.     /*----------------------------------------------------------------*/
  1474.     S32 x1, y1, x2, y2;
  1475.     /*----------------------------------------------------------------*/
  1476.     /* Code Body                                                      */
  1477.     /*----------------------------------------------------------------*/
  1478.     gdi_layer_reset_clip();
  1479.     x1 = d->x;
  1480.     y1 = d->y;
  1481.     x2 = x1 + d->width - 1;
  1482.     y2 = y1 + d->height - 1;
  1483.     gui_draw_filled_area(x1, y1, x2, y2, &date_time_input_background_filler);
  1484. }
  1485. /*****************************************************************************
  1486.  * FUNCTION
  1487.  *  IP4_input_reset_focus
  1488.  * DESCRIPTION
  1489.  *  reset focus of IP4 input box to default
  1490.  * PARAMETERS
  1491.  *  d       [IN]        
  1492.  * RETURNS
  1493.  *  void
  1494.  *****************************************************************************/
  1495. void IP4_input_reset_focus(IP4_input *d)
  1496. {
  1497.     /*----------------------------------------------------------------*/
  1498.     /* Local Variables                                                */
  1499.     /*----------------------------------------------------------------*/
  1500.     /*----------------------------------------------------------------*/
  1501.     /* Code Body                                                      */
  1502.     /*----------------------------------------------------------------*/
  1503.     d->field_input_box1.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  1504.     d->field_input_box1.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  1505.     d->field_input_box1.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1506.     d->field_input_box2.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  1507.     d->field_input_box2.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  1508.     d->field_input_box2.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1509.     d->field_input_box3.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  1510.     d->field_input_box3.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  1511.     d->field_input_box3.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1512.     d->field_input_box4.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  1513.     d->field_input_box4.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  1514.     d->field_input_box4.flags |= UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1515.     d->focus_input_box = NULL;
  1516. }
  1517. /*****************************************************************************
  1518.  * FUNCTION
  1519.  *  IP4_input_set_focus
  1520.  * DESCRIPTION
  1521.  *  set focus to particaulr field depend on teh value
  1522.  *  of current focus
  1523.  * PARAMETERS
  1524.  *  d       [IN]        
  1525.  * RETURNS
  1526.  *  void
  1527.  *****************************************************************************/
  1528. void IP4_input_set_focus(IP4_input *d)
  1529. {
  1530.     /*----------------------------------------------------------------*/
  1531.     /* Local Variables                                                */
  1532.     /*----------------------------------------------------------------*/
  1533.     /*----------------------------------------------------------------*/
  1534.     /* Code Body                                                      */
  1535.     /*----------------------------------------------------------------*/
  1536.     if ((d->current_focus < 1) || (d->current_focus > 4))
  1537.     {
  1538.         return;
  1539.     }
  1540.     switch (d->focus_list[d->current_focus])
  1541.     {
  1542.         case IP4_INPUT_FOCUS_FIELD1:
  1543.             d->field_input_box1.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  1544.             d->field_input_box1.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  1545.             d->field_input_box1.flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1546.             d->focus_input_box = &d->field_input_box1;
  1547.             break;
  1548.         case IP4_INPUT_FOCUS_FIELD2:
  1549.             d->field_input_box2.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  1550.             d->field_input_box2.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  1551.             d->field_input_box2.flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1552.             d->focus_input_box = &d->field_input_box2;
  1553.             break;
  1554.         case IP4_INPUT_FOCUS_FIELD3:
  1555.             d->field_input_box3.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  1556.             d->field_input_box3.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  1557.             d->field_input_box3.flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1558.             d->focus_input_box = &d->field_input_box3;
  1559.             break;
  1560.         case IP4_INPUT_FOCUS_FIELD4:
  1561.             d->field_input_box4.flags &= ~UI_SINGLE_LINE_INPUT_BOX_STATE_NORMAL;
  1562.             d->field_input_box4.flags |= UI_SINGLE_LINE_INPUT_BOX_STATE_SELECTED;
  1563.             d->field_input_box4.flags &= ~UI_SINGLE_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW;
  1564.             d->focus_input_box = &d->field_input_box4;
  1565.             break;
  1566.     }
  1567. }
  1568. /*****************************************************************************
  1569.  * FUNCTION
  1570.  *  IP4_input_set_default_focus
  1571.  * DESCRIPTION
  1572.  *  set focus to default box of IP4
  1573.  * PARAMETERS
  1574.  *  d       [IN]        
  1575.  * RETURNS
  1576.  *  void
  1577.  *****************************************************************************/
  1578. void IP4_input_set_default_focus(IP4_input *d)
  1579. {
  1580.     /*----------------------------------------------------------------*/
  1581.     /* Local Variables                                                */
  1582.     /*----------------------------------------------------------------*/
  1583.     S32 i = 0;
  1584.     /*----------------------------------------------------------------*/
  1585.     /* Code Body                                                      */
  1586.     /*----------------------------------------------------------------*/
  1587.     switch (d->flags & IP4_INPUT_TYPE_DEFAULT_FOCUS_MASK)
  1588.     {
  1589.         case IP4_INPUT_TYPE_DEFAULT_FOCUS_FIELD1:
  1590.             for (i = 0; i < 6; i++)
  1591.             {
  1592.                 if (d->focus_list[i] == IP4_INPUT_FOCUS_FIELD1)
  1593.                 {
  1594.                     d->current_focus = i;
  1595.                 }
  1596.             }
  1597.             break;
  1598.         case IP4_INPUT_TYPE_DEFAULT_FOCUS_FIELD2:
  1599.             for (i = 0; i < 6; i++)
  1600.             {
  1601.                 if (d->focus_list[i] == IP4_INPUT_FOCUS_FIELD2)
  1602.                 {
  1603.                     d->current_focus = i;
  1604.                 }
  1605.             }
  1606.             break;
  1607.         case IP4_INPUT_TYPE_DEFAULT_FOCUS_FIELD3:
  1608.             for (i = 0; i < 6; i++)
  1609.             {
  1610.                 if (d->focus_list[i] == IP4_INPUT_FOCUS_FIELD3)
  1611.                 {
  1612.                     d->current_focus = i;
  1613.                 }
  1614.             }
  1615.             break;
  1616.         case IP4_INPUT_TYPE_DEFAULT_FOCUS_FIELD4:
  1617.             for (i = 0; i < 6; i++)
  1618.             {
  1619.                 if (d->focus_list[i] == IP4_INPUT_FOCUS_FIELD4)
  1620.                 {
  1621.                     d->current_focus = i;
  1622.                 }
  1623.             }
  1624.             break;
  1625.     }
  1626. }
  1627. /*****************************************************************************
  1628.  * FUNCTION
  1629.  *  create_IP4_input
  1630.  * DESCRIPTION
  1631.  *  create Ip4 input box
  1632.  * PARAMETERS
  1633.  *  d                   [IN]        
  1634.  *  x                   [IN]        Start x postion of ip4 input box
  1635.  *  y                   [IN]        Start y position of ip4 input box
  1636.  *  width               [IN]        Width of ip4 input box
  1637.  *  height              [IN]        
  1638.  *  flags               [IN]        
  1639.  *  b1                  [IN]        Buffer1 of ip4 input box
  1640.  *  b2                  [IN]        Buffer 2 of ip4 input box
  1641.  *  b3                  [IN]        Buffer 3o f ip4 input box
  1642.  *  b4                  [IN]        Buffer 4 of ip4 input box
  1643.  *  heighthight(?)      [IN]        Of ip4 input box
  1644.  * RETURNS
  1645.  *  void
  1646.  *****************************************************************************/
  1647. void create_IP4_input(
  1648.         IP4_input *d,
  1649.         S32 x,
  1650.         S32 y,
  1651.         S32 width,
  1652.         S32 height,
  1653.         U32 flags,
  1654.         UI_buffer_type b1,
  1655.         UI_buffer_type b2,
  1656.         UI_buffer_type b3,
  1657.         UI_buffer_type b4)
  1658. {
  1659.     /*----------------------------------------------------------------*/
  1660.     /* Local Variables                                                */
  1661.     /*----------------------------------------------------------------*/
  1662.     S32 w, h, ox, oy, sw, tw, l;
  1663.     UI_single_line_input_box_theme *t = current_single_line_input_box_theme;
  1664.     /*----------------------------------------------------------------*/
  1665.     /* Code Body                                                      */
  1666.     /*----------------------------------------------------------------*/
  1667.     d->x = x;
  1668.     d->y = y;
  1669.     d->width = width;
  1670.     d->height = height;
  1671.     d->flags = flags;
  1672.     if (((width >> 2) - 1) < IP4_INPUT_FIELD_WIDTH)
  1673.     {
  1674.         w = (width >> 2) - 1;
  1675.     }
  1676.     else
  1677.     {
  1678.         w = IP4_INPUT_FIELD_WIDTH;
  1679.     }
  1680.     sw = IP4_INPUT_SEPERATOR_WIDTH;
  1681.     tw = w + sw + w + sw + w + sw + w;
  1682.     h = IP4_INPUT_HEIGHT;
  1683.     oy = (height >> 1) - (h >> 1);
  1684.     switch (flags & IP4_INPUT_JUSTIFY_MASK)
  1685.     {
  1686.         case IP4_INPUT_RIGHT_JUSTIFY:
  1687.             ox = (width - tw - 2);
  1688.             break;
  1689.         case IP4_INPUT_CENTER_JUSTIFY:
  1690.             ox = (width >> 1) - (tw >> 1);
  1691.             break;
  1692.         default:
  1693.             ox = 2;
  1694.             break;
  1695.     }
  1696.     d->focus_list[0] = IP4_INPUT_FOCUS_NONE;
  1697.     d->focus_list[5] = IP4_INPUT_FOCUS_NONE;
  1698.     d->focus_list[1] = IP4_INPUT_FOCUS_FIELD1;
  1699.     d->focus_list[2] = IP4_INPUT_FOCUS_FIELD2;
  1700.     d->focus_list[3] = IP4_INPUT_FOCUS_FIELD3;
  1701.     d->focus_list[4] = IP4_INPUT_FOCUS_FIELD4;
  1702.     d->field1_x = ox;
  1703.     ox += w + sw;
  1704.     d->field2_x = ox;
  1705.     ox += w + sw;
  1706.     d->field3_x = ox;
  1707.     ox += w + sw;
  1708.     d->field4_x = ox;
  1709.     ox += w + sw;
  1710.     d->flags |= IP4_INPUT_TYPE_DEFAULT_FOCUS_FIELD1;
  1711.     current_single_line_input_box_theme = &date_time_input_theme;
  1712.     d->field1_y = oy;
  1713.     d->field2_y = oy;
  1714.     d->field3_y = oy;
  1715.     d->field4_y = oy;
  1716.     d->s1_y = oy;
  1717.     d->s2_y = oy;
  1718.     d->s3_y = oy;
  1719.     if ((h + 2) > height)
  1720.     {
  1721.         h = height - 2;
  1722.     }
  1723.     l = gui_strlen((UI_string_type) b1) /* +1 */ ;
  1724.     /* craete single inpyut box of field1 */
  1725.     gui_create_single_line_input_box_set_buffer(
  1726.         &d->field_input_box1,
  1727.         x + d->field1_x,
  1728.         y + d->field1_y,
  1729.         w,
  1730.         h,
  1731.         (UI_string_type) b1,
  1732.         IP4_INPUT_FIELD_BUFFER_LENGTH,
  1733.         (l + 1) * ENCODING_LENGTH,
  1734.         0);
  1735.     d->field_input_box1.flags |=
  1736.         (UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE | UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR |
  1737.          UI_SINGLE_LINE_INPUT_BOX_NO_BORDER);
  1738.     gui_single_line_input_box_goto_first_character(&d->field_input_box1);
  1739.     l = gui_strlen((UI_string_type) b2) /* +1 */ ;
  1740.     /* craete single inpyut box of field2 */
  1741.     gui_create_single_line_input_box_set_buffer(
  1742.         &d->field_input_box2,
  1743.         x + d->field2_x,
  1744.         y + d->field2_y,
  1745.         w,
  1746.         h,
  1747.         (UI_string_type) b2,
  1748.         IP4_INPUT_FIELD_BUFFER_LENGTH,
  1749.         (l + 1) * ENCODING_LENGTH,
  1750.         0);
  1751.     d->field_input_box2.flags |=
  1752.         (UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE | UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR |
  1753.          UI_SINGLE_LINE_INPUT_BOX_NO_BORDER);
  1754.     gui_single_line_input_box_goto_first_character(&d->field_input_box2);
  1755.     l = gui_strlen((UI_string_type) b3) /* +1 */ ;
  1756.     /* craete single inpyut box of field3 */
  1757.     gui_create_single_line_input_box_set_buffer(
  1758.         &d->field_input_box3,
  1759.         x + d->field3_x,
  1760.         y + d->field3_y,
  1761.         w,
  1762.         h,
  1763.         (UI_string_type) b3,
  1764.         IP4_INPUT_FIELD_BUFFER_LENGTH,
  1765.         (l + 1) * ENCODING_LENGTH,
  1766.         0);
  1767.     d->field_input_box3.flags |=
  1768.         (UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE | UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR |
  1769.          UI_SINGLE_LINE_INPUT_BOX_NO_BORDER);
  1770.     gui_single_line_input_box_goto_first_character(&d->field_input_box3);
  1771.     l = gui_strlen((UI_string_type) b4) /* +1 */ ;
  1772.     /* craete single inpyut box of field4 */
  1773.     gui_create_single_line_input_box_set_buffer(
  1774.         &d->field_input_box4,
  1775.         x + d->field4_x,
  1776.         y + d->field4_y,
  1777.         w,
  1778.         h,
  1779.         (UI_string_type) b4,
  1780.         IP4_INPUT_FIELD_BUFFER_LENGTH,
  1781.         (l + 1) * ENCODING_LENGTH,
  1782.         0);
  1783.     d->field_input_box4.flags |=
  1784.         (UI_SINGLE_LINE_INPUT_BOX_OVERWRITE_MODE | UI_SINGLE_LINE_INPUT_BOX_SHOW_BLOCK_CURSOR |
  1785.          UI_SINGLE_LINE_INPUT_BOX_NO_BORDER);
  1786.     gui_single_line_input_box_goto_first_character(&d->field_input_box4);
  1787.     IP4_input_reset_focus(d);
  1788.     IP4_input_set_default_focus(d);
  1789.     IP4_input_set_focus(d);
  1790.     current_single_line_input_box_theme = t;
  1791.     /* MTK end */
  1792.     /* Setup default validation functions  */
  1793.     d->field_input_box1.validation_callback = default_inline_IP_field_validation;
  1794.     d->field_input_box2.validation_callback = default_inline_IP_field_validation;
  1795.     d->field_input_box3.validation_callback = default_inline_IP_field_validation;
  1796.     d->field_input_box4.validation_callback = default_inline_IP_field_validation;
  1797. }
  1798. /*****************************************************************************
  1799.  * FUNCTION
  1800.  *  show_IP4_input
  1801.  * DESCRIPTION
  1802.  *  show Ip4 input box
  1803.  * PARAMETERS
  1804.  *  d       [IN]        
  1805.  * RETURNS
  1806.  *  void
  1807.  *****************************************************************************/
  1808. void show_IP4_input(IP4_input *d)
  1809. {
  1810.     /*----------------------------------------------------------------*/
  1811.     /* Local Variables                                                */
  1812.     /*----------------------------------------------------------------*/
  1813.     S32 sw = 0;
  1814.     /*----------------------------------------------------------------*/
  1815.     /* Code Body                                                      */
  1816.     /*----------------------------------------------------------------*/
  1817.     /* show single input box  field1 */
  1818.     gui_show_single_line_input_box(&d->field_input_box1);
  1819.     /* show single input box  field2 */
  1820.     gui_show_single_line_input_box(&d->field_input_box2);
  1821.     /* show single input box  field3 */
  1822.     gui_show_single_line_input_box(&d->field_input_box3);
  1823.     /* show single input box  field4 */
  1824.     gui_show_single_line_input_box(&d->field_input_box4);
  1825.     gdi_layer_reset_clip();
  1826.     gui_set_font(d->field_input_box1.text_font);
  1827.     gui_set_text_color(d->field_input_box1.normal_text_color);
  1828.     if (r2lMMIFlag)
  1829.     {
  1830.         gui_set_font(d->field_input_box1.text_font);
  1831.         sw = gui_get_character_width(d->seperator);
  1832.         gui_move_text_cursor(d->s1_x + sw, d->s1_y + d->y);
  1833.     }
  1834.     else
  1835.     {
  1836.         gui_move_text_cursor(d->s1_x, d->s1_y + d->y);
  1837.     }
  1838.     gui_print_character(d->seperator);
  1839.     if (r2lMMIFlag)
  1840.     {
  1841.         gui_move_text_cursor(d->s2_x + sw, d->s2_y + d->y);
  1842.     }
  1843.     else
  1844.     {
  1845.         gui_move_text_cursor(d->s2_x, d->s2_y + d->y);
  1846.     }
  1847.     gui_print_character(d->seperator);
  1848.     if (r2lMMIFlag)
  1849.     {
  1850.         gui_move_text_cursor(d->s3_x + sw, d->s3_y + d->y);
  1851.     }
  1852.     else
  1853.     {
  1854.         gui_move_text_cursor(d->s3_x, d->s3_y + d->y);
  1855.     }
  1856.     gui_print_character(d->seperator);
  1857.     gdi_layer_blt_previous(d->x, d->y, d->x + d->width - 1, d->y + d->height - 1);
  1858. }
  1859. /*****************************************************************************
  1860.  * FUNCTION
  1861.  *  IP4_input_set_next_focus
  1862.  * DESCRIPTION
  1863.  *  set focus to next  character
  1864.  * PARAMETERS
  1865.  *  d       [IN]        
  1866.  * RETURNS
  1867.  *  void
  1868.  *****************************************************************************/
  1869. U8 IP4_input_set_next_focus(IP4_input *d)
  1870. {
  1871.     /*----------------------------------------------------------------*/
  1872.     /* Local Variables                                                */
  1873.     /*----------------------------------------------------------------*/
  1874.     /*----------------------------------------------------------------*/
  1875.     /* Code Body                                                      */
  1876.     /*----------------------------------------------------------------*/
  1877.     if (d->focus_list[d->current_focus + 1] == IP4_INPUT_FOCUS_NONE)
  1878.     {
  1879.         return (0);
  1880.     }
  1881.     else
  1882.     {
  1883.         IP4_input_reset_focus(d);
  1884.         d->current_focus++;
  1885.         IP4_input_set_focus(d);
  1886.     #if defined(__MMI_TOUCH_SCREEN__)
  1887.         gui_single_line_input_box_goto_first_character(d->focus_input_box);
  1888.     #endif 
  1889.         return (1);
  1890.     }
  1891. }
  1892. /*****************************************************************************
  1893.  * FUNCTION
  1894.  *  IP4_input_set_previous_focus
  1895.  * DESCRIPTION
  1896.  *  set focus to previous character
  1897.  * PARAMETERS
  1898.  *  d       [IN]        
  1899.  * RETURNS
  1900.  *  void
  1901.  *****************************************************************************/
  1902. U8 IP4_input_set_previous_focus(IP4_input *d)
  1903. {
  1904.     /*----------------------------------------------------------------*/
  1905.     /* Local Variables                                                */
  1906.     /*----------------------------------------------------------------*/
  1907.     /*----------------------------------------------------------------*/
  1908.     /* Code Body                                                      */
  1909.     /*----------------------------------------------------------------*/
  1910.     if (d->focus_list[d->current_focus - 1] == IP4_INPUT_FOCUS_NONE)
  1911.     {
  1912.         return (0);
  1913.     }
  1914.     else
  1915.     {
  1916.         IP4_input_reset_focus(d);
  1917.         d->current_focus--;
  1918.         IP4_input_set_focus(d);
  1919.     #if defined(__MMI_TOUCH_SCREEN__)
  1920.         gui_single_line_input_box_goto_last_character(d->focus_input_box);
  1921.         gui_single_line_input_box_previous(d->focus_input_box);
  1922.     #endif /* defined(__MMI_TOUCH_SCREEN__) */ 
  1923.         return (1);
  1924.     }
  1925. }
  1926. #if defined (__MMI_TOUCH_SCREEN__)
  1927. /*****************************************************************************
  1928.  * FUNCTION
  1929.  *  IP4_input_move_to_x_y
  1930.  * DESCRIPTION
  1931.  *  set the cursor position to (x,y) position
  1932.  * PARAMETERS
  1933.  *  ip4     [IN]        IP4 input box S32 x S32 y
  1934.  *  x       [IN]        
  1935.  *  y       [IN]        
  1936.  * RETURNS
  1937.  *  void
  1938.  *****************************************************************************/
  1939. void IP4_input_move_to_x_y(IP4_input *ip4, S32 x, S32 y)
  1940. {
  1941.     /*----------------------------------------------------------------*/
  1942.     /* Local Variables                                                */
  1943.     /*----------------------------------------------------------------*/
  1944.     int i = 1;
  1945.     /*----------------------------------------------------------------*/
  1946.     /* Code Body                                                      */
  1947.     /*----------------------------------------------------------------*/
  1948.     if (PEN_CHECK_BOUND(x, y, ip4->x, ip4->y, ip4->width, ip4->height))
  1949.     {
  1950.         if (PEN_CHECK_BOUND
  1951.             (x, y, ip4->field_input_box1.x, ip4->field_input_box1.y, ip4->field_input_box1.width,
  1952.              ip4->field_input_box1.height))
  1953.         {
  1954.             gui_single_line_input_box_goto_first_character(ip4->focus_input_box);
  1955.             IP4_input_reset_focus(ip4);
  1956.             for (;; i++)
  1957.             {
  1958.                 if (ip4->focus_list[i] == IP4_INPUT_FOCUS_FIELD1)
  1959.                 {
  1960.                     ip4->current_focus = i;
  1961.                     break;
  1962.                 }
  1963.             }
  1964.             IP4_input_set_focus(ip4);
  1965.         }
  1966.         else if (PEN_CHECK_BOUND
  1967.                  (x, y, ip4->field_input_box2.x, ip4->field_input_box2.y, ip4->field_input_box2.width,
  1968.                   ip4->field_input_box2.height))
  1969.         {
  1970.             gui_single_line_input_box_goto_first_character(ip4->focus_input_box);
  1971.             IP4_input_reset_focus(ip4);
  1972.             for (;; i++)
  1973.             {
  1974.                 if (ip4->focus_list[i] == IP4_INPUT_FOCUS_FIELD2)
  1975.                 {
  1976.                     ip4->current_focus = i;
  1977.                     break;
  1978.                 }
  1979.             }
  1980.             IP4_input_set_focus(ip4);
  1981.         }
  1982.         else if (PEN_CHECK_BOUND
  1983.                  (x, y, ip4->field_input_box3.x, ip4->field_input_box3.y, ip4->field_input_box3.width,
  1984.                   ip4->field_input_box3.height))
  1985.         {
  1986.             gui_single_line_input_box_goto_first_character(ip4->focus_input_box);
  1987.             IP4_input_reset_focus(ip4);
  1988.             for (;; i++)
  1989.             {
  1990.                 if (ip4->focus_list[i] == IP4_INPUT_FOCUS_FIELD3)
  1991.                 {
  1992.                     ip4->current_focus = i;
  1993.                     break;
  1994.                 }
  1995.             }
  1996.             IP4_input_set_focus(ip4);
  1997.         }
  1998.         else if (PEN_CHECK_BOUND
  1999.                  (x, y, ip4->field_input_box4.x, ip4->field_input_box4.y, ip4->field_input_box4.width,
  2000.                   ip4->field_input_box4.height))
  2001.         {
  2002.             gui_single_line_input_box_goto_first_character(ip4->focus_input_box);
  2003.             IP4_input_reset_focus(ip4);
  2004.             for (;; i++)
  2005.             {
  2006.                 if (ip4->focus_list[i] == IP4_INPUT_FOCUS_FIELD4)
  2007.                 {
  2008.                     ip4->current_focus = i;
  2009.                     break;
  2010.                 }
  2011.             }
  2012.             IP4_input_set_focus(ip4);
  2013.         }
  2014.         else
  2015.         {
  2016.             /*
  2017.              * for(;;i++)
  2018.              * {
  2019.              * if (ip4->focus_list[i]==IP4_INPUT_FOCUS_NONE)
  2020.              * {
  2021.              * ip4->current_focus = i-1;
  2022.              * break;
  2023.              * }
  2024.              * }
  2025.              * IP4_input_set_focus(ip4);
  2026.              */
  2027.             return;
  2028.         }
  2029.         gui_show_single_line_input_box_ext(ip4->focus_input_box, x, y);
  2030.         if (gui_single_line_input_box_test_last_character_position(ip4->focus_input_box))
  2031.         {
  2032.             gui_single_line_input_box_goto_last_character(ip4->focus_input_box);
  2033.             gui_single_line_input_box_previous(ip4->focus_input_box);
  2034.         }
  2035.         show_IP4_input(ip4);
  2036.     }
  2037. }
  2038. #endif /* defined (__MMI_TOUCH_SCREEN__) */ 
  2039. /*****************************************************************************
  2040.  * FUNCTION
  2041.  *  IP4_input_set_seperator
  2042.  * DESCRIPTION
  2043.  *  
  2044.  * PARAMETERS
  2045.  *  d               [IN]        
  2046.  *  seperator       [IN]        
  2047.  * RETURNS
  2048.  *  void
  2049.  *****************************************************************************/
  2050. void IP4_input_set_seperator(IP4_input *d, UI_character_type seperator)
  2051. {
  2052.     /*----------------------------------------------------------------*/
  2053.     /* Local Variables                                                */
  2054.     /*----------------------------------------------------------------*/
  2055.     S32 sw, x1, x2;
  2056.     /*----------------------------------------------------------------*/
  2057.     /* Code Body                                                      */
  2058.     /*----------------------------------------------------------------*/
  2059.     d->seperator = seperator;
  2060.     gui_set_font(d->field_input_box1.text_font);
  2061.     sw = gui_get_character_width(d->seperator);
  2062.     x1 = d->field_input_box1.x + d->field_input_box1.width - 1;
  2063.     x2 = d->field_input_box2.x;
  2064.     d->s1_x = x1 + ((x2 - x1) >> 1) - (sw >> 1);
  2065.     x1 = d->field_input_box2.x + d->field_input_box2.width - 1;
  2066.     x2 = d->field_input_box3.x;
  2067.     d->s2_x = x1 + ((x2 - x1) >> 1) - (sw >> 1);
  2068.     x1 = d->field_input_box3.x + d->field_input_box3.width - 1;
  2069.     x2 = d->field_input_box4.x;
  2070.     d->s3_x = x1 + ((x2 - x1) >> 1) - (sw >> 1);
  2071. }
  2072. /* a global variabel o ftype IP4_input */
  2073. IP4_input *current_IP4_input = NULL;
  2074. /*----------------------------------------------------------------------------
  2075. Function:         current_IP4_input_callback
  2076. Description:      a function pointer store the address of function 
  2077.                of I4 input callback 
  2078. Input Parameters: none
  2079.                
  2080. Output Parameters:   none
  2081. Returns:       void
  2082. ----------------------------------------------------------------------------*/
  2083. void (*current_IP4_input_callback) (void) = UI_dummy_function;
  2084. /*****************************************************************************
  2085.  * FUNCTION
  2086.  *  set_current_IP4_input
  2087.  * DESCRIPTION
  2088.  *  Set the global variable of IP4_input equal to valeu pass as parameter
  2089.  * PARAMETERS
  2090.  *  d       [IN]        
  2091.  * RETURNS
  2092.  *  void
  2093.  *****************************************************************************/
  2094. void set_current_IP4_input(IP4_input *d)
  2095. {
  2096.     /*----------------------------------------------------------------*/
  2097.     /* Local Variables                                                */
  2098.     /*----------------------------------------------------------------*/
  2099.     /*----------------------------------------------------------------*/
  2100.     /* Code Body                                                      */
  2101.     /*----------------------------------------------------------------*/
  2102.     current_IP4_input = d;
  2103. }
  2104. /*****************************************************************************
  2105.  * FUNCTION
  2106.  *  IP4_input_direct_input
  2107.  * DESCRIPTION
  2108.  *  append the currentinsert character to IP4 text and show the Ip4 text box
  2109.  * PARAMETERS
  2110.  *  c       [IN]        
  2111.  * RETURNS
  2112.  *  void
  2113.  *****************************************************************************/
  2114. void IP4_input_direct_input(UI_character_type c)
  2115. {
  2116.     /*----------------------------------------------------------------*/
  2117.     /* Local Variables                                                */
  2118.     /*----------------------------------------------------------------*/
  2119.     /*----------------------------------------------------------------*/
  2120.     /* Code Body                                                      */
  2121.     /*----------------------------------------------------------------*/
  2122.     if (current_IP4_input == NULL)
  2123.     {
  2124.         return;
  2125.     }
  2126.     if (current_IP4_input->focus_input_box == NULL)
  2127.     {
  2128.         return;
  2129.     }
  2130.     if (gui_single_line_input_box_test_last_position_overflow(current_IP4_input->focus_input_box))
  2131.     {
  2132.         if (IP4_input_set_next_focus(current_IP4_input))
  2133.         {
  2134.             gui_single_line_input_box_insert_character(current_IP4_input->focus_input_box, c);
  2135.         }
  2136.     }
  2137.     else
  2138.     {
  2139.         gui_single_line_input_box_insert_character(current_IP4_input->focus_input_box, c);
  2140.         if (gui_single_line_input_box_test_last_position_overflow(current_IP4_input->focus_input_box))
  2141.         {
  2142.             if (!IP4_input_set_next_focus(current_IP4_input))
  2143.             {
  2144.                 gui_single_line_input_box_previous(current_IP4_input->focus_input_box);
  2145.             }
  2146.         }
  2147.     }
  2148.     /* show IP4 input box */
  2149.     show_IP4_input(current_IP4_input);
  2150.     current_IP4_input_callback();
  2151. }
  2152. /*****************************************************************************
  2153.  * FUNCTION
  2154.  *  IP4_input_direct_input_nodraw
  2155.  * DESCRIPTION
  2156.  *  insert the character in date input box and redraw date input box
  2157.  * PARAMETERS
  2158.  *  c       [IN]        
  2159.  * RETURNS
  2160.  *  void
  2161.  *****************************************************************************/
  2162. void IP4_input_direct_input_nodraw(UI_character_type c)
  2163. {
  2164.     /*----------------------------------------------------------------*/
  2165.     /* Local Variables                                                */
  2166.     /*----------------------------------------------------------------*/
  2167.     /*----------------------------------------------------------------*/
  2168.     /* Code Body                                                      */
  2169.     /*----------------------------------------------------------------*/
  2170.     if (current_IP4_input == NULL)
  2171.     {
  2172.         return;
  2173.     }
  2174.     if (current_IP4_input->focus_input_box == NULL)
  2175.     {
  2176.         return;
  2177.     }
  2178.     if (gui_single_line_input_box_test_last_position_overflow(current_IP4_input->focus_input_box))
  2179.     {
  2180.         if (IP4_input_set_next_focus(current_IP4_input))
  2181.         {
  2182.             gui_single_line_input_box_insert_character(current_IP4_input->focus_input_box, c);
  2183.         }
  2184.     }
  2185.     else
  2186.     {
  2187.         gui_single_line_input_box_insert_character(current_IP4_input->focus_input_box, c);
  2188.         if (gui_single_line_input_box_test_last_position_overflow(current_IP4_input->focus_input_box))
  2189.         {
  2190.             if (!IP4_input_set_next_focus(current_IP4_input))
  2191.             {
  2192.                 gui_single_line_input_box_previous(current_IP4_input->focus_input_box);
  2193.             }
  2194.         }
  2195.     }
  2196.     current_IP4_input_callback();
  2197. }
  2198. /*****************************************************************************
  2199.  * FUNCTION
  2200.  *  IP4_input_test_last_position
  2201.  * DESCRIPTION
  2202.  *  test current position is the last position or not
  2203.  * PARAMETERS
  2204.  *  ip4     [IN]        
  2205.  * RETURNS
  2206.  *  S32
  2207.  *****************************************************************************/
  2208. S32 IP4_input_test_last_position(IP4_input *ip4)
  2209. {
  2210.     /*----------------------------------------------------------------*/
  2211.     /* Local Variables                                                */
  2212.     /*----------------------------------------------------------------*/
  2213.     /*----------------------------------------------------------------*/
  2214.     /* Code Body                                                      */
  2215.     /*----------------------------------------------------------------*/
  2216.     if (ip4->focus_list[ip4->current_focus + 1] != IP4_INPUT_FOCUS_NONE)
  2217.     {
  2218.         return 0;
  2219.     }
  2220.     else
  2221.     {
  2222.         if (gui_single_line_input_box_test_last_character_position(ip4->focus_input_box))
  2223.         {
  2224.             return 1;
  2225.         }
  2226.         else
  2227.         {
  2228.             return 0;
  2229.         }
  2230.     }
  2231. }
  2232. /*****************************************************************************
  2233.  * FUNCTION
  2234.  *  IP4_input_delete_character
  2235.  * DESCRIPTION
  2236.  *  delete character of IP4 input box
  2237.  * PARAMETERS
  2238.  *  void
  2239.  * RETURNS
  2240.  *  void
  2241.  *****************************************************************************/
  2242. void IP4_input_delete_character(void)
  2243. {
  2244.     /*----------------------------------------------------------------*/
  2245.     /* Local Variables                                                */
  2246.     /*----------------------------------------------------------------*/
  2247.     /*----------------------------------------------------------------*/
  2248.     /* Code Body                                                      */
  2249.     /*----------------------------------------------------------------*/
  2250.     if (current_IP4_input == NULL)
  2251.     {
  2252.         return;
  2253.     }
  2254.     if (current_IP4_input->focus_input_box == NULL)
  2255.     {
  2256.         return;
  2257.     }
  2258.     if (gui_single_line_input_box_test_first_position(current_IP4_input->focus_input_box))
  2259.     {
  2260.         IP4_input_set_previous_focus(current_IP4_input);
  2261.     }
  2262.     else
  2263.     {
  2264.         gui_single_line_input_box_delete_character(current_IP4_input->focus_input_box);
  2265.         if (gui_single_line_input_box_test_first_position(current_IP4_input->focus_input_box))
  2266.         {
  2267.             IP4_input_set_previous_focus(current_IP4_input);
  2268.         }
  2269.     }
  2270.     /* show IP4 input box */
  2271.     show_IP4_input(current_IP4_input);
  2272.     current_IP4_input_callback();
  2273. }
  2274. /*****************************************************************************
  2275.  * FUNCTION
  2276.  *  IP4_input_previous_character
  2277.  * DESCRIPTION
  2278.  *  set focus to previous character
  2279.  * PARAMETERS
  2280.  *  void
  2281.  * RETURNS
  2282.  *  void
  2283.  *****************************************************************************/
  2284. void IP4_input_previous_character(void)
  2285. {
  2286.     /*----------------------------------------------------------------*/
  2287.     /* Local Variables                                                */
  2288.     /*----------------------------------------------------------------*/
  2289.     /*----------------------------------------------------------------*/
  2290.     /* Code Body                                                      */
  2291.     /*----------------------------------------------------------------*/
  2292.     if (current_IP4_input == NULL)
  2293.     {
  2294.         return;
  2295.     }
  2296.     if (current_IP4_input->focus_input_box == NULL)
  2297.     {
  2298.         return;
  2299.     }
  2300.     if (gui_single_line_input_box_test_first_position(current_IP4_input->focus_input_box))
  2301.     {
  2302.         if (IP4_input_set_previous_focus(current_IP4_input))
  2303.         {
  2304.             gui_single_line_input_box_goto_last_character(current_IP4_input->focus_input_box);
  2305.             gui_single_line_input_box_previous(current_IP4_input->focus_input_box);
  2306.         }
  2307.     }
  2308.     else
  2309.     {
  2310.         gui_single_line_input_box_previous(current_IP4_input->focus_input_box);
  2311.     }
  2312.     /* show IP4 input box */
  2313.     show_IP4_input(current_IP4_input);
  2314. }
  2315. /*****************************************************************************
  2316.  * FUNCTION
  2317.  *  IP4_input_next_character
  2318.  * DESCRIPTION
  2319.  *  set focus to next caharacter
  2320.  * PARAMETERS
  2321.  *  void
  2322.  * RETURNS
  2323.  *  void
  2324.  *****************************************************************************/
  2325. void IP4_input_next_character(void)
  2326. {
  2327.     /*----------------------------------------------------------------*/
  2328.     /* Local Variables                                                */
  2329.     /*----------------------------------------------------------------*/
  2330.     /*----------------------------------------------------------------*/
  2331.     /* Code Body                                                      */
  2332.     /*----------------------------------------------------------------*/
  2333.     if (current_IP4_input == NULL)
  2334.     {
  2335.         return;
  2336.     }
  2337.     if (current_IP4_input->focus_input_box == NULL)
  2338.     {
  2339.         return;
  2340.     }
  2341.     if (gui_single_line_input_box_test_last_character_position(current_IP4_input->focus_input_box))
  2342.     {
  2343.         IP4_input_set_next_focus(current_IP4_input);
  2344.     }
  2345.     else
  2346.     {
  2347.         gui_single_line_input_box_next(current_IP4_input->focus_input_box);
  2348.     }
  2349.     /* show IP4 input box */
  2350.     show_IP4_input(current_IP4_input);
  2351. }
  2352. /*****************************************************************************
  2353.  * FUNCTION
  2354.  *  IP4_input_toggle_insert_mode
  2355.  * DESCRIPTION
  2356.  *  
  2357.  * PARAMETERS
  2358.  *  void
  2359.  * RETURNS
  2360.  *  void
  2361.  *****************************************************************************/
  2362. void IP4_input_toggle_insert_mode(void)
  2363. {
  2364.     /*----------------------------------------------------------------*/
  2365.     /* Local Variables                                                */
  2366.     /*----------------------------------------------------------------*/
  2367.     /*----------------------------------------------------------------*/
  2368.     /* Code Body                                                      */
  2369.     /*----------------------------------------------------------------*/
  2370.     if (current_IP4_input == NULL)
  2371.     {
  2372.         return;
  2373.     }
  2374.     if (current_IP4_input->focus_input_box == NULL)
  2375.     {
  2376.         return;
  2377.     }
  2378.     gui_single_line_input_box_toggle_insert_mode(current_IP4_input->focus_input_box);
  2379.     /* show IP4 input box */
  2380.     show_IP4_input(current_IP4_input);
  2381. }
  2382. /*****************************************************************************
  2383.  * FUNCTION
  2384.  *  IP4_input_delete_current_character
  2385.  * DESCRIPTION
  2386.  *  delete current charactert of IP4 input box
  2387.  * PARAMETERS
  2388.  *  void
  2389.  * RETURNS
  2390.  *  void
  2391.  *****************************************************************************/
  2392. void IP4_input_delete_current_character(void)
  2393. {
  2394.     /*----------------------------------------------------------------*/
  2395.     /* Local Variables                                                */
  2396.     /*----------------------------------------------------------------*/
  2397.     /*----------------------------------------------------------------*/
  2398.     /* Code Body                                                      */
  2399.     /*----------------------------------------------------------------*/
  2400.     if (current_IP4_input == NULL)
  2401.     {
  2402.         return;
  2403.     }
  2404.     if (current_IP4_input->focus_input_box == NULL)
  2405.     {
  2406.         return;
  2407.     }
  2408.     /* delete current caharcter of IP4 input box */
  2409.     gui_single_line_input_box_delete_current_character(current_IP4_input->focus_input_box);
  2410.     /* show IP4 input box */
  2411.     show_IP4_input(current_IP4_input);
  2412.     current_IP4_input_callback();
  2413. }
  2414. /*****************************************************************************
  2415.  * FUNCTION
  2416.  *  IP4_input_delete_all_characters
  2417.  * DESCRIPTION
  2418.  *  delete all characterts of IP4 input box
  2419.  * PARAMETERS
  2420.  *  void
  2421.  * RETURNS
  2422.  *  void
  2423.  *****************************************************************************/
  2424. void IP4_input_delete_all_characters(void)
  2425. {
  2426.     /*----------------------------------------------------------------*/
  2427.     /* Local Variables                                                */
  2428.     /*----------------------------------------------------------------*/
  2429.     /*----------------------------------------------------------------*/
  2430.     /* Code Body                                                      */
  2431.     /*----------------------------------------------------------------*/
  2432.     if (current_IP4_input == NULL)
  2433.     {
  2434.         return;
  2435.     }
  2436.     if (current_IP4_input->focus_input_box == NULL)
  2437.     {
  2438.         return;
  2439.     }
  2440.     /* delete all charcters of IP4 input box */
  2441.     gui_single_line_input_box_delete_all(current_IP4_input->focus_input_box);
  2442.     /* show IP4 input box */
  2443.     show_IP4_input(current_IP4_input);
  2444.     current_IP4_input_callback();
  2445. }
  2446. /*****************************************************************************
  2447.  * FUNCTION
  2448.  *  IP4_input_numeric_keyboard_input_handler
  2449.  * DESCRIPTION
  2450.  *  handle numeric key input of IP4 input box
  2451.  * PARAMETERS
  2452.  *  keyc        [IN]        
  2453.  * RETURNS
  2454.  *  void
  2455.  *****************************************************************************/
  2456. void IP4_input_numeric_keyboard_input_handler(S32 keyc)
  2457. {
  2458.     /*----------------------------------------------------------------*/
  2459.     /* Local Variables                                                */
  2460.     /*----------------------------------------------------------------*/
  2461.     /*----------------------------------------------------------------*/
  2462.     /* Code Body                                                      */
  2463.     /*----------------------------------------------------------------*/
  2464.     if (keyc >= '0' && keyc <= '9')
  2465.     {
  2466.         IP4_input_direct_input((U8) keyc);
  2467.     }
  2468.     else if (keyc == 0x08)
  2469.     {
  2470.         IP4_input_delete_character();
  2471.     }
  2472.     else if (keyc == 0x1b)
  2473.     {
  2474.         IP4_input_delete_all_characters();
  2475.     }
  2476.     else if (keyc == 0x0d);
  2477. }
  2478. /*****************************************************************************
  2479.  * FUNCTION
  2480.  *  IP4_input_handle_key_down
  2481.  * DESCRIPTION
  2482.  *  funtion handle key down event of IP4 input box
  2483.  * PARAMETERS
  2484.  *  k       [IN]        
  2485.  * RETURNS
  2486.  *  void
  2487.  *****************************************************************************/
  2488. void IP4_input_handle_key_down(MMI_key_code_type k)
  2489. {
  2490.     /*----------------------------------------------------------------*/
  2491.     /* Local Variables                                                */
  2492.     /*----------------------------------------------------------------*/
  2493.     /*----------------------------------------------------------------*/
  2494.     /* Code Body                                                      */
  2495.     /*----------------------------------------------------------------*/
  2496.     IP4_input_direct_input((UI_character_type) ('0' + k));
  2497. }
  2498. /*****************************************************************************
  2499.  * FUNCTION
  2500.  *  IP4_input_key_handler
  2501.  * DESCRIPTION
  2502.  *  regsiter key handlers of IP4 input box
  2503.  * PARAMETERS
  2504.  *  vkey_code       [IN]        
  2505.  *  key_state       [IN]        
  2506.  * RETURNS
  2507.  *  void
  2508.  *****************************************************************************/
  2509. void IP4_input_key_handler(S32 vkey_code, S32 key_state)
  2510. {
  2511. #if(MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32)
  2512.     /*----------------------------------------------------------------*/
  2513.     /* Local Variables                                                */
  2514.     /*----------------------------------------------------------------*/
  2515.     /*----------------------------------------------------------------*/
  2516.     /* Code Body                                                      */
  2517.     /*----------------------------------------------------------------*/
  2518.     if (key_state)
  2519.     {
  2520.         switch (vkey_code)
  2521.         {
  2522.             case 37:
  2523.                 IP4_input_previous_character();
  2524.                 break;
  2525.             case 38:    /* up */
  2526.                 break;
  2527.             case 39:
  2528.                 IP4_input_next_character();
  2529.                 break;
  2530.             case 40:    /* down */
  2531.                 break;
  2532.             case 36:    /* home */
  2533.                 break;
  2534.             case 35:    /* end */
  2535.                 break;
  2536.             case 33:    /* page up */
  2537.                 break;
  2538.             case 34:    /* page down */
  2539.                 break;
  2540.             case 45:
  2541.                 IP4_input_toggle_insert_mode();
  2542.                 break;
  2543.             case 46:
  2544.                 IP4_input_delete_current_character();
  2545.                 break;
  2546.         }
  2547.     }
  2548. #else /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  2549.     UI_UNUSED_PARAMETER(vkey_code);
  2550.     UI_UNUSED_PARAMETER(key_state);
  2551. #endif /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  2552. }
  2553. /*****************************************************************************
  2554.  * FUNCTION
  2555.  *  IP4_input_register_keys
  2556.  * DESCRIPTION
  2557.  *  regsiter key handlers of IP4 input box
  2558.  * PARAMETERS
  2559.  *  void
  2560.  * RETURNS
  2561.  *  void
  2562.  *****************************************************************************/
  2563. void IP4_input_register_keys(void)
  2564. {
  2565.     /*----------------------------------------------------------------*/
  2566.     /* Local Variables                                                */
  2567.     /*----------------------------------------------------------------*/
  2568.     /*----------------------------------------------------------------*/
  2569.     /* Code Body                                                      */
  2570.     /*----------------------------------------------------------------*/
  2571.     register_MMI_key_input_handler();
  2572.     register_key_down_handler(IP4_input_handle_key_down);
  2573.     register_keyboard_input_handler(IP4_input_numeric_keyboard_input_handler);
  2574.     SetKeyHandler(IP4_input_previous_character, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2575.     SetKeyHandler(IP4_input_next_character, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  2576.     register_keyboard_key_handler(IP4_input_key_handler);
  2577. }
  2578. /*****************************************************************************
  2579.  * FUNCTION
  2580.  *  IP4_input_clear_keys
  2581.  * DESCRIPTION
  2582.  *  clear all key events of IP4 input
  2583.  * PARAMETERS
  2584.  *  void
  2585.  * RETURNS
  2586.  *  void
  2587.  *****************************************************************************/
  2588. void IP4_input_clear_keys(void)
  2589. {
  2590.     /*----------------------------------------------------------------*/
  2591.     /* Local Variables                                                */
  2592.     /*----------------------------------------------------------------*/
  2593.     /*----------------------------------------------------------------*/
  2594.     /* Code Body                                                      */
  2595.     /*----------------------------------------------------------------*/
  2596.     clear_MMI_key_input_handler();
  2597.     clear_key_down_handler();
  2598.     clear_keyboard_input_handler();
  2599.     ClearKeyHandler(KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  2600.     ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  2601.     clear_keyboard_key_handler();
  2602. }
  2603. /*****************************************************************************
  2604.  * FUNCTION
  2605.  *  register_IP4_input_callback
  2606.  * DESCRIPTION
  2607.  *  registe IP4 input callback function
  2608.  * PARAMETERS
  2609.  *  f               [IN]        
  2610.  *  function(?)     [IN]        Pointer
  2611.  * RETURNS
  2612.  *  void
  2613.  *****************************************************************************/
  2614. void register_IP4_input_callback(void (*f) (void))
  2615. {
  2616.     /*----------------------------------------------------------------*/
  2617.     /* Local Variables                                                */
  2618.     /*----------------------------------------------------------------*/
  2619.     /*----------------------------------------------------------------*/
  2620.     /* Code Body                                                      */
  2621.     /*----------------------------------------------------------------*/
  2622.     current_IP4_input_callback = f;
  2623. }
  2624. /*****************************************************************************
  2625.  * FUNCTION
  2626.  *  clear_IP4_input_callback
  2627.  * DESCRIPTION
  2628.  *  clear ip4 input callback to dummy function
  2629.  * PARAMETERS
  2630.  *  void
  2631.  * RETURNS
  2632.  *  void
  2633.  *****************************************************************************/
  2634. void clear_IP4_input_callback(void)
  2635. {
  2636.     /*----------------------------------------------------------------*/
  2637.     /* Local Variables                                                */
  2638.     /*----------------------------------------------------------------*/
  2639.     /*----------------------------------------------------------------*/
  2640.     /* Code Body                                                      */
  2641.     /*----------------------------------------------------------------*/
  2642.     current_IP4_input_callback = UI_dummy_function;
  2643. }
  2644. /* global variable of main lcd time objet */
  2645. UI_date_time_display main_LCD_time_object;
  2646. void (*MMI_main_LCD_time_duration_hide_function) (S32 x1, S32 y1, S32 x2, S32 y2) = UI_dummy_hide_function;
  2647. /*****************************************************************************
  2648.  * FUNCTION
  2649.  *  set_main_LCD_time_duration_hide_function
  2650.  * DESCRIPTION
  2651.  *  set hide time duration function for main lcd
  2652.  * PARAMETERS
  2653.  *  f               [IN]        
  2654.  *  function(?)     [IN]        Ptr f
  2655.  * RETURNS
  2656.  *  void
  2657.  *****************************************************************************/
  2658. void set_main_LCD_time_duration_hide_function(void (*f) (S32 x1, S32 y1, S32 x2, S32 y2))
  2659. {
  2660.     /*----------------------------------------------------------------*/
  2661.     /* Local Variables                                                */
  2662.     /*----------------------------------------------------------------*/
  2663.     /*----------------------------------------------------------------*/
  2664.     /* Code Body                                                      */
  2665.     /*----------------------------------------------------------------*/
  2666.     MMI_main_LCD_time_duration_hide_function = f;
  2667. }
  2668. /*****************************************************************************
  2669.  * FUNCTION
  2670.  *  set_time_duration
  2671.  * DESCRIPTION
  2672.  *  set main lcd time duration object
  2673.  * PARAMETERS
  2674.  *  t               [IN]        
  2675.  *  duration        [IN]        
  2676.  * RETURNS
  2677.  *  void
  2678.  *****************************************************************************/
  2679. void set_time_duration(UI_time *t, U32 duration)
  2680. {
  2681.     /*----------------------------------------------------------------*/
  2682.     /* Local Variables                                                */
  2683.     /*----------------------------------------------------------------*/
  2684.     /*----------------------------------------------------------------*/
  2685.     /* Code Body                                                      */
  2686.     /*----------------------------------------------------------------*/
  2687.     main_LCD_time_object.duration.t = *t;   /* set the duration value */
  2688.     kal_get_time(&last_duration_ticks);
  2689.     last_duration = duration;
  2690. }
  2691. /*****************************************************************************
  2692.  * FUNCTION
  2693.  *  get_time_duration
  2694.  * DESCRIPTION
  2695.  *  get main lcd time duration object
  2696.  * PARAMETERS
  2697.  *  t       [IN]        
  2698.  * RETURNS
  2699.  *  void
  2700.  *****************************************************************************/
  2701. void get_time_duration(UI_time *t)
  2702. {
  2703.     /*----------------------------------------------------------------*/
  2704.     /* Local Variables                                                */
  2705.     /*----------------------------------------------------------------*/
  2706.     /*----------------------------------------------------------------*/
  2707.     /* Code Body                                                      */
  2708.     /*----------------------------------------------------------------*/
  2709.     *t = main_LCD_time_object.duration.t;   /* get the duration value */
  2710. }
  2711. /*****************************************************************************
  2712.  * FUNCTION
  2713.  *  get_duration_string
  2714.  * DESCRIPTION
  2715.  *  get main lcd time duration string
  2716.  * PARAMETERS
  2717.  *  t           [IN]        
  2718.  *  s           [IN]        
  2719.  *  flags       [IN]        
  2720.  * RETURNS
  2721.  *  void
  2722.  *****************************************************************************/
  2723. void get_duration_string(UI_time *t, UI_string_type s, U32 flags)
  2724. {
  2725.     /*----------------------------------------------------------------*/
  2726.     /* Local Variables                                                */
  2727.     /*----------------------------------------------------------------*/
  2728.     U16 hours, minutes, seconds;
  2729.     S8 ts[32];
  2730.     /*----------------------------------------------------------------*/
  2731.     /* Code Body                                                      */
  2732.     /*----------------------------------------------------------------*/
  2733.     hours = get_hours(t);
  2734.     minutes = get_minutes(t);
  2735.     seconds = get_seconds(t);
  2736.     sprintf((S8*) ts, "%02d:%02d:%02d", hours, minutes, seconds);
  2737.     AnsiiToUnicodeString((S8*) s, ts);
  2738. }
  2739. /*****************************************************************************
  2740.  * FUNCTION
  2741.  *  time_display_duration
  2742.  * DESCRIPTION
  2743.  *  display time duration
  2744.  * PARAMETERS
  2745.  *  void
  2746.  * RETURNS
  2747.  *  void
  2748.  *****************************************************************************/
  2749. void time_display_duration(void)
  2750. {
  2751.     /*----------------------------------------------------------------*/
  2752.     /* Local Variables                                                */
  2753.     /*----------------------------------------------------------------*/
  2754.     UI_character_type s[64];
  2755.     S32 x1, y1, x2, y2;
  2756.     S32 w;
  2757.     /*----------------------------------------------------------------*/
  2758.     /* Code Body                                                      */
  2759.     /*----------------------------------------------------------------*/
  2760.     x1 = main_LCD_time_object.duration.x;
  2761.     y1 = main_LCD_time_object.duration.y;
  2762.     x2 = main_LCD_time_object.duration.width + x1 - 1;
  2763.     y2 = main_LCD_time_object.duration.height + y1 - 1;
  2764.     main_LCD_time_object.duration.hide_function(x1, y1, x2, y2);        /* call hide function of call duration */
  2765.     gui_set_font(main_LCD_time_object.duration.font);
  2766.     /* get call duration in string fromat */
  2767.     get_duration_string(&main_LCD_time_object.duration.t, (UI_string_type) s, main_LCD_time_object.flags);
  2768.     gui_set_text_color(main_LCD_time_object.duration.text_color);
  2769.     w = gui_get_string_width(s);
  2770.     if (r2lMMIFlag)
  2771.     {
  2772.         //gui_move_text_cursor(x1 + w, y1);
  2773.         gui_move_text_cursor(x1+((main_LCD_time_object.duration.width-w)>>1)+w, y1);
  2774.     }
  2775.     else
  2776.     {
  2777.         //gui_move_text_cursor(x1, y1);
  2778.         gui_move_text_cursor(x1+((main_LCD_time_object.duration.width-w)>>1), y1);
  2779.     }
  2780.     gui_set_text_clip(x1, y1, x2, y2);
  2781.     /* print call duration */
  2782.     gui_print_text(s);
  2783.     gdi_layer_blt_previous(x1, y1, x2, y2);
  2784. }
  2785. /*****************************************************************************
  2786.  * FUNCTION
  2787.  *  time_update_duration
  2788.  * DESCRIPTION
  2789.  *  update time duration
  2790.  * PARAMETERS
  2791.  *  void
  2792.  * RETURNS
  2793.  *  void
  2794.  *****************************************************************************/
  2795. void time_update_duration(void)
  2796. {
  2797.     /*----------------------------------------------------------------*/
  2798.     /* Local Variables                                                */
  2799.     /*----------------------------------------------------------------*/
  2800.     /*----------------------------------------------------------------*/
  2801.     /* Code Body                                                      */
  2802.     /*----------------------------------------------------------------*/
  2803.     increment_ticks(&main_LCD_time_object.duration.t);  /* increment secods by 1 */
  2804.     time_display_duration();
  2805.     gui_start_timer(300, time_update_duration);
  2806. }
  2807. /*****************************************************************************
  2808.  * FUNCTION
  2809.  *  set_time_display
  2810.  * DESCRIPTION
  2811.  *  set time duration object properties
  2812.  * PARAMETERS
  2813.  *  flags       [IN]        
  2814.  *  x           [IN]        
  2815.  *  y           [IN]        
  2816.  *  width       [IN]        
  2817.  *  height      [IN]        
  2818.  * RETURNS
  2819.  *  void
  2820.  *****************************************************************************/
  2821. void set_time_display(U32 flags, S32 x, S32 y, S32 width, S32 height)
  2822. {
  2823.     /*----------------------------------------------------------------*/
  2824.     /* Local Variables                                                */
  2825.     /*----------------------------------------------------------------*/
  2826.     /*----------------------------------------------------------------*/
  2827.     /* Code Body                                                      */
  2828.     /*----------------------------------------------------------------*/
  2829.     gdi_layer_lock_frame_buffer();
  2830.     main_LCD_time_object.flags = (flags & DT_FLAGS_TYPE);
  2831.     main_LCD_time_object.duration.hide_function = MMI_main_LCD_time_duration_hide_function;
  2832.     main_LCD_time_object.duration.font = &MMI_large_font;
  2833. main_LCD_time_object.duration.text_color = *current_MMI_theme->datetime_bar_duration_text_color;
  2834.     main_LCD_time_object.duration.x = x;
  2835.     main_LCD_time_object.duration.y = y;
  2836.     main_LCD_time_object.duration.width = width;
  2837.     main_LCD_time_object.duration.height = height;
  2838.     gui_cancel_timer(time_update_duration);
  2839.     if (flags != 0)
  2840.     {
  2841.         gui_start_timer(300, time_update_duration);
  2842.     }
  2843.     gdi_layer_unlock_frame_buffer();
  2844. }
  2845. /*****************************************************************************
  2846.  * FUNCTION
  2847.  *  close_main_LCD_time_display
  2848.  * DESCRIPTION
  2849.  *  disable main lcd time display
  2850.  * PARAMETERS
  2851.  *  void
  2852.  * RETURNS
  2853.  *  void
  2854.  *****************************************************************************/
  2855. void close_main_LCD_time_display(void)
  2856. {
  2857.     /*----------------------------------------------------------------*/
  2858.     /* Local Variables                                                */
  2859.     /*----------------------------------------------------------------*/
  2860.     /*----------------------------------------------------------------*/
  2861.     /* Code Body                                                      */
  2862.     /*----------------------------------------------------------------*/
  2863.     gui_cancel_timer(time_update_duration);
  2864. }
  2865. /*****************************************************************************
  2866.  * FUNCTION
  2867.  *  enactive_main_lcd_update_date_time
  2868.  * DESCRIPTION
  2869.  *  enable update date time for main lcd
  2870.  * PARAMETERS
  2871.  *  void
  2872.  * RETURNS
  2873.  *  void
  2874.  *****************************************************************************/
  2875. void enactive_main_lcd_update_date_time(void)
  2876. {
  2877.     /*----------------------------------------------------------------*/
  2878.     /* Local Variables                                                */
  2879.     /*----------------------------------------------------------------*/
  2880.     /*----------------------------------------------------------------*/
  2881.     /* Code Body                                                      */
  2882.     /*----------------------------------------------------------------*/
  2883.     main_lcd_update_date_time = MMI_TRUE;
  2884. }
  2885. /*****************************************************************************
  2886.  * FUNCTION
  2887.  *  deactive_main_lcd_update_date_time
  2888.  * DESCRIPTION
  2889.  *  disable update date time for main lcd
  2890.  * PARAMETERS
  2891.  *  void
  2892.  * RETURNS
  2893.  *  void
  2894.  *****************************************************************************/
  2895. void deactive_main_lcd_update_date_time(void)
  2896. {
  2897.     /*----------------------------------------------------------------*/
  2898.     /* Local Variables                                                */
  2899.     /*----------------------------------------------------------------*/
  2900.     /*----------------------------------------------------------------*/
  2901.     /* Code Body                                                      */
  2902.     /*----------------------------------------------------------------*/
  2903.     main_lcd_update_date_time = MMI_FALSE;
  2904. }
  2905. #ifdef __MMI_SUBLCD__
  2906. /*****************************************************************************
  2907.  * FUNCTION
  2908.  *  enactive_sub_lcd_update_date_time
  2909.  * DESCRIPTION
  2910.  *  enable update date time display for sublcd
  2911.  * PARAMETERS
  2912.  *  void
  2913.  * RETURNS
  2914.  *  void
  2915.  *****************************************************************************/
  2916. void enactive_sub_lcd_update_date_time(void)
  2917. {
  2918.     /*----------------------------------------------------------------*/
  2919.     /* Local Variables                                                */
  2920.     /*----------------------------------------------------------------*/
  2921.     /*----------------------------------------------------------------*/
  2922.     /* Code Body                                                      */
  2923.     /*----------------------------------------------------------------*/
  2924.     sub_lcd_update_date_time = MMI_TRUE;
  2925. }
  2926. /*****************************************************************************
  2927.  * FUNCTION
  2928.  *  deactive_sub_lcd_update_date_time
  2929.  * DESCRIPTION
  2930.  *  disable update date time display for sublcd
  2931.  * PARAMETERS
  2932.  *  void
  2933.  * RETURNS
  2934.  *  void
  2935.  *****************************************************************************/
  2936. void deactive_sub_lcd_update_date_time(void)
  2937. {
  2938.     /*----------------------------------------------------------------*/
  2939.     /* Local Variables                                                */
  2940.     /*----------------------------------------------------------------*/
  2941.     /*----------------------------------------------------------------*/
  2942.     /* Code Body                                                      */
  2943.     /*----------------------------------------------------------------*/
  2944.     sub_lcd_update_date_time = MMI_FALSE;
  2945. }
  2946. #endif /* __MMI_SUBLCD__ */ 
  2947. /*****************************************************************************
  2948.  * FUNCTION
  2949.  *  set_main_lcd_duration_position
  2950.  * DESCRIPTION
  2951.  *  set the position of duration display on main lcd
  2952.  * PARAMETERS
  2953.  *  x       [IN]        
  2954.  *  y       [IN]        
  2955.  * RETURNS
  2956.  *  void
  2957.  *****************************************************************************/
  2958. void set_main_lcd_duration_position(U16 x, U16 y)
  2959. {
  2960.     /*----------------------------------------------------------------*/
  2961.     /* Local Variables                                                */
  2962.     /*----------------------------------------------------------------*/
  2963.     /*----------------------------------------------------------------*/
  2964.     /* Code Body                                                      */
  2965.     /*----------------------------------------------------------------*/
  2966.     main_LCD_dt_object.duration.x = x;
  2967.     main_LCD_dt_object.duration.y = y;
  2968. }
  2969. /* PMT HIMANSHU START 20050721 */
  2970. #ifdef __MMI_UI_TECHNO_IDLESCREEN_BAR__
  2971. /*****************************************************************************
  2972.  * FUNCTION
  2973.  *  wgui_set_clock_type
  2974.  * DESCRIPTION
  2975.  *  set the value of the current clock to be displayed.
  2976.  * PARAMETERS
  2977.  *  clock_type      [IN]        
  2978.  * RETURNS
  2979.  *  void
  2980.  *****************************************************************************/
  2981. void wgui_set_clock_type(U8 clock_type)
  2982. {
  2983.     /*----------------------------------------------------------------*/
  2984.     /* Local Variables                                                */
  2985.     /*----------------------------------------------------------------*/
  2986.     /*----------------------------------------------------------------*/
  2987.     /* Code Body                                                      */
  2988.     /*----------------------------------------------------------------*/
  2989.     switch (clock_type)
  2990.     {
  2991.         case ANALOG:
  2992.             g_clock_type = ANALOG;
  2993.             //idlescreen_bar_id = IMG_TECHNO_ANALOG_CLOCK;//070306 Alpha layer       //KP Jerry disable for separate display IMG_TECHNO_IDLESCREEN_BAR and IMG_TECHNO_ANALOG_CLOCK/IMG_TECHNO_DIGITAL_CLOCK  on 2007-3-9
  2994.             break;
  2995.         case DIGITAL:
  2996.             g_clock_type = DIGITAL;
  2997.             //idlescreen_bar_id = IMG_TECHNO_DIGITAL_CLOCK;       //KP Jerry disable for separate display IMG_TECHNO_IDLESCREEN_BAR and IMG_TECHNO_ANALOG_CLOCK/IMG_TECHNO_DIGITAL_CLOCK  on 2007-3-9
  2998.             break;
  2999.     }
  3000. }
  3001. /*****************************************************************************
  3002.  * FUNCTION
  3003.  *  set_day_display
  3004.  * DESCRIPTION
  3005.  *  set the pointer to point to the current day string
  3006.  * PARAMETERS
  3007.  *  void
  3008.  * RETURNS
  3009.  *  void
  3010.  *****************************************************************************/
  3011. void set_day_display(void)
  3012. {
  3013.     /*----------------------------------------------------------------*/
  3014.     /* Local Variables                                                */
  3015.     /*----------------------------------------------------------------*/
  3016.     /*----------------------------------------------------------------*/
  3017.     /* Code Body                                                      */
  3018.     /*----------------------------------------------------------------*/
  3019.     day_string = get_string((U16) (STR_IDLESCREEN_SUNDAY + main_LCD_dt_object.date.t.DayIndex));
  3020. }
  3021. /*****************************************************************************
  3022.  * FUNCTION
  3023.  *  show_main_LCD_day_display
  3024.  * DESCRIPTION
  3025.  *  show the day string on main lcd in techon idlescreeen
  3026.  *  bar
  3027.  * PARAMETERS
  3028.  *  void
  3029.  * RETURNS
  3030.  *  void
  3031.  *****************************************************************************/
  3032. void show_main_LCD_day_display(void)
  3033. {
  3034.     /*----------------------------------------------------------------*/
  3035.     /* Local Variables                                                */
  3036.     /*----------------------------------------------------------------*/
  3037.     U32 x1, y1, x2, y2;
  3038.     S32 w, h;
  3039.     stFontAttribute *font;
  3040.     color text_color, text_border_color;
  3041.     /*----------------------------------------------------------------*/
  3042.     /* Code Body                                                      */
  3043.     /*----------------------------------------------------------------*/
  3044.     text_color = gui_color(255, 255, 255);
  3045. #ifdef __MMI_MAINLCD_240X320__
  3046.     font = (&MMI_medium_font);
  3047.     text_border_color = gui_color(18, 114, 175);
  3048. #else /* __MMI_MAINLCD_240X320__ */ 
  3049.     font = (&MMI_small_font);
  3050.     text_border_color = gui_color(0, 0, 0);
  3051. #endif /* __MMI_MAINLCD_240X320__ */ 
  3052.     gui_set_font(font);
  3053.     gui_measure_string(day_string, &w, &h);
  3054.     gui_set_text_color(text_color);
  3055.     gui_set_text_border_color(text_border_color);
  3056.     x1 = ANALOG_BACKGROUND_X + ANALOG_BACKGROUND_WIDTH +1;
  3057.     y1 = MMI_status_bar_height + ((MMI_IDLESCREEN_BAR_HEIGHT + (MMI_IDLESCREEN_BAR_HEIGHT >> 1) - h) >> 1)-30; //设置星期几显示y位置
  3058.     x2 = UI_device_width - MMI_SIGNAL_WIDTH;
  3059.     y2 = y1 + h - 1;
  3060.     gdi_layer_push_clip();
  3061.     gui_set_clip(x1, y1-1, x2, y2+1);//091206 idlescreen day
  3062.     /* PMT HIMANSHU START 20051012 */
  3063.     /* Day string is not coming at right location in case of r2lMMIFlag is ON.
  3064.        So move the cursor at correct position. */
  3065.  
  3066.     if (r2lMMIFlag)
  3067.     {
  3068.         gui_move_text_cursor(x2 - 2, y1);
  3069.     }
  3070.     else
  3071.     {
  3072.         gui_move_text_cursor(((x2 - 2) - w)-15, y1);
  3073.     }
  3074.     /* PMT HIMANSHU END 20051012 */
  3075.     gui_print_bordered_text(day_string);
  3076.     gdi_layer_pop_clip();
  3077. }
  3078. #endif /* __MMI_UI_TECHNO_IDLESCREEN_BAR__ */ 
  3079. /* PMT HIMANSHU END 20050721 */