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

MTK

开发平台:

C/C++

  1.     /*----------------------------------------------------------------*/
  2.     /* Code Body                                                      */
  3.     /*----------------------------------------------------------------*/
  4.     s->n_columns = s->displayed_columns;
  5.     if (s->displayed_rows == 1)
  6.     {
  7.         s->n_columns = s->n_images;
  8.         s->n_rows = 1;
  9.     }
  10.     else if (s->displayed_columns == 1)
  11.     {
  12.         s->n_columns = 1;
  13.         s->n_rows = s->n_images;
  14.     }
  15.     else
  16.     {
  17.         s->n_rows = pixtel_highdivide(s->n_images, s->n_columns);
  18.     }
  19. }
  20. /*****************************************************************************
  21.  * FUNCTION
  22.  *  small_image_selector_auto_configure
  23.  * DESCRIPTION
  24.  *  Function used to auto configure the no. of rows and columns to be displayed depending upon the display area.
  25.  * PARAMETERS
  26.  *  s       [IN]        Small image sleector structure
  27.  * RETURNS
  28.  *  void
  29.  *****************************************************************************/
  30. void small_image_selector_auto_configure(small_image_selector_struct *s)
  31. {
  32.     /*----------------------------------------------------------------*/
  33.     /* Local Variables                                                */
  34.     /*----------------------------------------------------------------*/
  35.     U8 show_vbar = 0, show_hbar = 0;
  36.     /*----------------------------------------------------------------*/
  37.     /* Code Body                                                      */
  38.     /*----------------------------------------------------------------*/
  39.     if ((s->n_columns <= 0) && (s->image_width <= 0))
  40.     {
  41.         return;
  42.     }
  43.     if ((s->n_rows <= 0) && (s->image_height <= 0))
  44.     {
  45.         return;
  46.     }
  47.     if (s->n_images == 0)
  48.     {
  49.         return;
  50.     }
  51.     /* Calculate the number of displayed rows and columns    */
  52.     s->displayed_rows = s->height / s->image_height;
  53.     s->displayed_columns = s->width / s->image_width;
  54.     small_image_selector_auto_calculate(s);
  55.     if (s->displayed_rows < s->n_rows)
  56.     {
  57.         small_image_selector_auto_calculate(s);
  58.     }
  59.     if ((s->n_rows > s->displayed_rows))
  60.     {
  61.         show_vbar = 1;
  62.         s->flags |= UI_SMALL_IMAGE_SELECTOR_SHOW_VERTICAL_SCROLLBAR;
  63.     }
  64.     if ((s->n_columns > s->displayed_columns))
  65.     {
  66.         show_hbar = 1;
  67.         s->flags |= UI_SMALL_IMAGE_SELECTOR_SHOW_HORIZONTAL_SCROLLBAR;
  68.     }
  69.     if (show_vbar)
  70.     {
  71.         s->width = s->width - s->vbar.width + 1;
  72.     }
  73.     if (show_hbar)
  74.     {
  75.         s->height = s->height - s->hbar.height + 1;
  76.     }
  77.     /* Recalculate the number of rows that can be displayed  */
  78.     s->displayed_rows = s->height / s->image_height;
  79.     s->displayed_columns = s->width / s->image_width;
  80.     /* Fix the number of displayed rows and columns       */
  81.     if (s->displayed_columns > s->n_columns)
  82.     {
  83.         s->displayed_columns = s->n_columns;
  84.     }
  85.     if (s->displayed_rows > s->n_rows)
  86.     {
  87.         s->displayed_rows = s->n_rows;
  88.     }
  89.     s->h_gap = (s->width - s->displayed_columns * s->image_width) / (s->displayed_columns + 1);
  90.     s->v_gap = (s->height - s->displayed_rows * s->image_height) / (s->displayed_rows + 1);
  91.     if (show_vbar && (!show_hbar))
  92.     {
  93.         gui_resize_vertical_scrollbar(&s->vbar, s->vbar.width, s->height);
  94.     }
  95.     if (show_hbar && (!show_vbar))
  96.     {
  97.         gui_resize_horizontal_scrollbar(&s->hbar, s->width, s->hbar.height);
  98.     }
  99.     if (show_vbar && show_hbar)
  100.     {
  101.         gui_resize_vertical_scrollbar(&s->vbar, s->vbar.width, s->height - s->hbar.height);
  102.         gui_resize_horizontal_scrollbar(&s->hbar, s->width - s->vbar.width, s->hbar.height);
  103.     }
  104.     gui_move_vertical_scrollbar(&s->vbar, s->x + s->width, s->y);
  105.     gui_move_horizontal_scrollbar(&s->hbar, s->x, s->y + s->height);
  106. }
  107. /*****************************************************************************
  108.  * FUNCTION
  109.  *  small_image_selector_set_up
  110.  * DESCRIPTION
  111.  *  set up function for small image selector
  112.  * PARAMETERS
  113.  *  s               [IN]        Small image sleector structure
  114.  *  n_images        [IN]        Total no. of images
  115.  * RETURNS
  116.  *  void
  117.  *****************************************************************************/
  118. void small_image_selector_set_up(small_image_selector_struct *s, S32 n_images)
  119. {
  120.     /*----------------------------------------------------------------*/
  121.     /* Local Variables                                                */
  122.     /*----------------------------------------------------------------*/
  123.     S32 x1, x2, y1, y2;
  124.     S32 w, h;
  125.     /*----------------------------------------------------------------*/
  126.     /* Code Body                                                      */
  127.     /*----------------------------------------------------------------*/
  128.     x1 = MMI_SMALL_SCREEN_X_OFFSET;
  129.     x2 = UI_device_width - MMI_SMALL_SCREEN_X_OFFSET;
  130.     y1 = MMI_title_y + MMI_title_height;
  131.     y2 = UI_device_height - (MMI_button_bar_height + MMI_SMALL_SCREEN_Y_OFFSET);
  132.     category_144_load_object(0);
  133.     gui_EMS_input_box_measure_object(&category_144_current_object, &w, &h);
  134.     s->x = x1;
  135.     s->y = y1;
  136.     s->height = y2 - y1;
  137.     s->width = x2 - x1;
  138.     s->image_height = h;
  139.     s->image_width = w;
  140.     s->n_images = n_images;
  141.     gui_create_vertical_scrollbar(
  142.         &s->vbar,
  143.         s->x + s->width - current_MMI_theme->scrollbar_size - 1,
  144.         s->y + 2,
  145.         current_MMI_theme->scrollbar_size,
  146.         s->height - current_MMI_theme->scrollbar_size - 3);
  147.     gui_create_horizontal_scrollbar(
  148.         &s->hbar,
  149.         s->x + 2,
  150.         s->y + s->height - current_MMI_theme->scrollbar_size - 1,
  151.         s->width - current_MMI_theme->scrollbar_size - 3,
  152.         current_MMI_theme->scrollbar_size);
  153.     small_image_selector_auto_configure(s);
  154. }
  155. /* PMT VIKAS END 20051217 */
  156. /*****************************************************************************
  157.  * FUNCTION
  158.  *  redraw_small_image_selector_images
  159.  * DESCRIPTION
  160.  *  redraw function for the small image selector screen
  161.  * PARAMETERS
  162.  *  void
  163.  * RETURNS
  164.  *  void
  165.  *****************************************************************************/
  166. void redraw_small_image_selector_images(void)
  167. {
  168.     /*----------------------------------------------------------------*/
  169.     /* Local Variables                                                */
  170.     /*----------------------------------------------------------------*/
  171.     /* PMT VIKAS START 20051217 */
  172.     S32 i, x, y, w, h, start_x, end_x, end_y, row, col, displayed_column;
  173.     S32 current_row = 0;
  174.     small_image_selector_struct *s = &small_image_selector;
  175.     /*----------------------------------------------------------------*/
  176.     /* Code Body                                                      */
  177.     /*----------------------------------------------------------------*/
  178.     /* PMT VIKAS END 20051217 */
  179.     gui_lock_double_buffer();
  180.     gui_draw_filled_area(
  181.         MMI_title_x - 1,
  182.         MMI_title_y-1,//101706 image select
  183.         UI_device_width - MMI_SMALL_SCREEN_X_OFFSET,
  184.         UI_device_height - MMI_button_bar_height - MMI_SMALL_SCREEN_Y_OFFSET + 2,
  185.         /* &small_image_selector_filler */ current_UI_theme->EMS_inputbox_theme->disabled_filler);
  186.     /* PMT VIKAS START 20051217 */
  187.     x = s->x + s->h_gap;
  188.     y = s->y + s->v_gap;
  189.     end_x = s->x + s->width - 1;
  190.     end_y = s->y + s->height - 1;
  191.     /* PMT VIKAS END 20051217 */
  192.     start_x = x;
  193.     /* PMT VIKAS START 20051217 */
  194.     for (row = 0; row < s->n_rows; row++)
  195.     {
  196.         for (col = 0; col < s->n_columns; col++)
  197.         {
  198.             small_image_selector_index[row][col] = col + row * s->n_columns;
  199.         }
  200.     }
  201.     i = s->first_displayed_image;
  202.     row = s->first_displayed_row;
  203.     col = s->first_displayed_column;
  204.     displayed_column = s->displayed_columns;
  205.     for (; i < category_144_object_list_n_items; i = col + row * displayed_column)
  206.         /* PMT VIKAS END 20051217 */
  207.     {
  208.         category_144_goto_item(i);
  209.         gui_EMS_input_box_measure_object(&category_144_current_object, &w, &h);
  210.         /* PMT VIKAS START 20051217 */
  211.         start_x += w;
  212.         /* PMT VIKAS END 20051217 */
  213.         if (start_x > end_x)
  214.         {
  215.             /* PMT VIKAS START 20051217 */
  216.             y += h + s->v_gap;
  217.             current_row++;
  218.             if (y >= end_y || current_row >= s->displayed_rows)
  219.                 /* PMT VIKAS END 20051217 */
  220.             {
  221.                 break;
  222.             }
  223.             /* PMT VIKAS START 20051217 */
  224.             x = MMI_SMALL_SCREEN_X_OFFSET + s->h_gap;
  225.             /* PMT VIKAS END 20051217 */
  226.             start_x = x + w;
  227.             row++;
  228.             /* PMT VIKAS START 20051217 */
  229.             col = s->first_displayed_column;
  230.             /* PMT VIKAS END 20051217 */
  231.             col++;
  232.         }
  233.         else
  234.         {
  235.             /* PMT VIKAS START 20051217 */
  236.             start_x += s->h_gap;
  237.             /* PMT VIKAS END 20051217 */
  238.             col++;
  239.         }
  240.         if (i == *category_144_object_list_index)
  241.         {
  242.             /* highlight currently selected item */
  243.             gui_draw_rectangle(x - 1, y - 1, x + w, y + h, UI_COLOR_BLACK);
  244.             /* show animation only when the highlight is on it */
  245.             gui_EMS_input_box_display_object(x, y, &category_144_current_object, 1);
  246.         }
  247.         else
  248.         {
  249.             /* show single frame for animation when the highlight is not on it */
  250.             gui_EMS_input_box_display_object(x, y, &category_144_current_object, 0);
  251.         }
  252.         /* PMT VIKAS START 20051217 */
  253.         x += w + s->h_gap;
  254.         /* PMT VIKAS END 20051217 */
  255.     }
  256.     category_144_goto_item(*category_144_object_list_index);
  257.     /* PMT VIKAS START 20051217 */
  258.     if (s->flags & UI_SMALL_IMAGE_SELECTOR_SHOW_VERTICAL_SCROLLBAR)
  259.     {
  260.         gui_set_vertical_scrollbar_range(&s->vbar, s->n_rows);
  261.         gui_set_vertical_scrollbar_scale(&s->vbar, s->displayed_rows);
  262.         gui_set_vertical_scrollbar_value(&s->vbar, s->first_displayed_row);
  263.         gui_show_vertical_scrollbar(&s->vbar);
  264.     }
  265.     if (s->flags & UI_SMALL_IMAGE_SELECTOR_SHOW_HORIZONTAL_SCROLLBAR)
  266.     {
  267.         gui_set_horizontal_scrollbar_range(&s->hbar, s->n_columns);
  268.         gui_set_horizontal_scrollbar_scale(&s->hbar, s->displayed_columns);
  269.         gui_set_horizontal_scrollbar_value(&s->hbar, s->first_displayed_column);
  270.         gui_show_horizontal_scrollbar(&s->hbar);
  271.     }
  272.     /* PMT VIKAS END 20051217 */
  273.     gui_unlock_double_buffer();
  274.     gui_BLT_double_buffer(
  275.         MMI_SMALL_SCREEN_X_OFFSET,
  276.         MMI_title_y,
  277.         UI_device_width - MMI_SMALL_SCREEN_X_OFFSET,
  278.         UI_device_height - MMI_button_bar_height - 5);
  279. }
  280. /*****************************************************************************
  281.  * FUNCTION
  282.  *  small_image_selector_goto_previous_item
  283.  * DESCRIPTION
  284.  *  Selects the previous image in the image selector screen
  285.  * PARAMETERS
  286.  *  void
  287.  * RETURNS
  288.  *  void
  289.  *****************************************************************************/
  290. void small_image_selector_goto_previous_item(void)
  291. {
  292.     /*----------------------------------------------------------------*/
  293.     /* Local Variables                                                */
  294.     /*----------------------------------------------------------------*/
  295.     S32 index = *category_144_object_list_index;
  296.     /*----------------------------------------------------------------*/
  297.     /* Code Body                                                      */
  298.     /*----------------------------------------------------------------*/
  299.     index--;
  300.     if (index < 0)
  301.     {
  302.         index = category_144_object_list_n_items - 1;
  303.     }
  304.     *category_144_object_list_index = index;
  305.     redraw_small_image_selector_images();
  306.     category_144_highlight_handler(index);
  307. }
  308. /*****************************************************************************
  309.  * FUNCTION
  310.  *  small_image_selector_goto_next_item
  311.  * DESCRIPTION
  312.  *  Selects the next image in the image selector screen
  313.  * PARAMETERS
  314.  *  void
  315.  * RETURNS
  316.  *  void
  317.  *****************************************************************************/
  318. void small_image_selector_goto_next_item(void)
  319. {
  320.     /*----------------------------------------------------------------*/
  321.     /* Local Variables                                                */
  322.     /*----------------------------------------------------------------*/
  323.     S32 index = *category_144_object_list_index;
  324.     /*----------------------------------------------------------------*/
  325.     /* Code Body                                                      */
  326.     /*----------------------------------------------------------------*/
  327.     index++;
  328.     if (index > (category_144_object_list_n_items - 1))
  329.     {
  330.         index = 0;
  331.     }
  332.     *category_144_object_list_index = index;
  333.     redraw_small_image_selector_images();
  334. }
  335. /*****************************************************************************
  336.  * FUNCTION
  337.  *  small_image_selector_compute_row_col
  338.  * DESCRIPTION
  339.  *  Calculates the row and column number of the image in the list
  340.  * PARAMETERS
  341.  *  index       [IN]        
  342.  *  row         [?]         
  343.  *  col         [?]         
  344.  * RETURNS
  345.  *  void
  346.  *****************************************************************************/
  347. void small_image_selector_compute_row_col(S32 index, S32 *row, S32 *col)
  348. {
  349.     /*----------------------------------------------------------------*/
  350.     /* Local Variables                                                */
  351.     /*----------------------------------------------------------------*/
  352.     S32 r, c;
  353.     /*----------------------------------------------------------------*/
  354.     /* Code Body                                                      */
  355.     /*----------------------------------------------------------------*/
  356.     *row = -1;
  357.     *col = -1;
  358.     MMI_ASSERT(index >= 0 && index < category_144_object_list_n_items);
  359.     /* PMT VIKAS START 20051217 */
  360.     for (r = 0; r < small_image_selector.n_rows; r++)
  361.     {
  362.         for (c = 0; c < small_image_selector.n_columns; c++)
  363.             /* PMT VIKAS END 20051217 */
  364.         {
  365.             if (small_image_selector_index[r][c] == index)
  366.             {
  367.                 *row = r;
  368.                 *col = c;
  369.                 return;
  370.             }
  371.         }
  372.     }
  373. }
  374. /*****************************************************************************
  375.  * FUNCTION
  376.  *  small_image_selector_compute_previous_row_image_index
  377.  * DESCRIPTION
  378.  *  Calculates the actual index of the image in the list
  379.  * PARAMETERS
  380.  *  index       [IN]        
  381.  * RETURNS
  382.  *  S32
  383.  *****************************************************************************/
  384. S32 small_image_selector_compute_previous_row_image_index(S32 index)
  385. {
  386.     /*----------------------------------------------------------------*/
  387.     /* Local Variables                                                */
  388.     /*----------------------------------------------------------------*/
  389.     S32 row, col, new_index;
  390.     /*----------------------------------------------------------------*/
  391.     /* Code Body                                                      */
  392.     /*----------------------------------------------------------------*/
  393.     MMI_ASSERT(index >= 0 && index < category_144_object_list_n_items);
  394.     small_image_selector_compute_row_col(index, &row, &col);
  395.     MMI_ASSERT(row != -1 || col != -1);
  396.     if (row == 0)
  397.     {
  398.         /* PMT VIKAS START 20051217 */
  399.         if (col + (small_image_selector.n_rows - 1) * small_image_selector.n_columns >= small_image_selector.n_images)
  400.         {
  401.             new_index = small_image_selector.n_images - 1;
  402.         }
  403.         else
  404.         {
  405.             new_index = small_image_selector_index[small_image_selector.n_rows - 1][col];
  406.         }
  407.         if (new_index == -1)
  408.         {
  409.             new_index = small_image_selector_index[small_image_selector.n_rows - 2][col];
  410.         }
  411.         /* PMT VIKAS END 20051217 */
  412.     }
  413.     else
  414.     {
  415.         new_index = small_image_selector_index[row - 1][col];
  416.     }
  417.     return new_index;
  418. }
  419. /*****************************************************************************
  420.  * FUNCTION
  421.  *  small_image_selector_compute_next_row_image_index
  422.  * DESCRIPTION
  423.  *  Calculates the actual index of the image in the list
  424.  * PARAMETERS
  425.  *  index       [IN]        
  426.  * RETURNS
  427.  *  S32
  428.  *****************************************************************************/
  429. S32 small_image_selector_compute_next_row_image_index(S32 index)
  430. {
  431.     /*----------------------------------------------------------------*/
  432.     /* Local Variables                                                */
  433.     /*----------------------------------------------------------------*/
  434.     S32 row, col, new_index;
  435.     /*----------------------------------------------------------------*/
  436.     /* Code Body                                                      */
  437.     /*----------------------------------------------------------------*/
  438.     MMI_ASSERT(index >= 0 && index < category_144_object_list_n_items);
  439.     small_image_selector_compute_row_col(index, &row, &col);
  440.     MMI_ASSERT(row != -1 || col != -1);
  441.     /* PMT VIKAS START 20051217 */
  442.     if (row == small_image_selector.n_rows - 1)
  443.         /* PMT VIKAS END 20051217 */
  444.     {
  445.         new_index = small_image_selector_index[0][col];
  446.         if (new_index == -1)
  447.         {
  448.             new_index = small_image_selector_index[1][col];
  449.         }
  450.     }
  451.     else
  452.     {
  453.         /* PMT VIKAS START 20051217 */
  454.         if ((col + (row + 1) * small_image_selector.n_columns) >= small_image_selector.n_images)
  455.         {
  456.             new_index = small_image_selector.n_images - 1;
  457.         }
  458.         else
  459.             /* PMT VIKAS END 20051217 */
  460.         {
  461.             new_index = small_image_selector_index[row + 1][col];
  462.         }
  463.         if (new_index == -1)
  464.         {
  465.             new_index = small_image_selector_index[0][col];
  466.         }
  467.     }
  468.     return new_index;
  469. }
  470. /*****************************************************************************
  471.  * FUNCTION
  472.  *  small_image_selector_goto_previous_row
  473.  * DESCRIPTION
  474.  *  Calculates the previous row
  475.  * PARAMETERS
  476.  *  void
  477.  * RETURNS
  478.  *  void
  479.  *****************************************************************************/
  480. void small_image_selector_goto_previous_row(void)
  481. {
  482.     /*----------------------------------------------------------------*/
  483.     /* Local Variables                                                */
  484.     /*----------------------------------------------------------------*/
  485.     S32 index = *category_144_object_list_index, new_index;
  486.     /*----------------------------------------------------------------*/
  487.     /* Code Body                                                      */
  488.     /*----------------------------------------------------------------*/
  489.     new_index = small_image_selector_compute_previous_row_image_index(index);
  490.     if (new_index < 0)
  491.     {
  492.         new_index = category_144_object_list_n_items - 1;
  493.     }
  494.     *category_144_object_list_index = new_index;
  495.     /* PMT VIKAS START 20051217 */
  496.     small_image_selector_configure_current_display(&small_image_selector, *category_144_object_list_index);
  497.     /* PMT VIKAS END 20051217 */
  498.     redraw_small_image_selector_images();
  499.     category_144_highlight_handler(new_index);
  500. }
  501. /*****************************************************************************
  502.  * FUNCTION
  503.  *  small_image_selector_goto_next_row
  504.  * DESCRIPTION
  505.  *  Calculates the next row
  506.  * PARAMETERS
  507.  *  void
  508.  * RETURNS
  509.  *  void
  510.  *****************************************************************************/
  511. void small_image_selector_goto_next_row(void)
  512. {
  513.     /*----------------------------------------------------------------*/
  514.     /* Local Variables                                                */
  515.     /*----------------------------------------------------------------*/
  516.     S32 index = *category_144_object_list_index, new_index;
  517.     /*----------------------------------------------------------------*/
  518.     /* Code Body                                                      */
  519.     /*----------------------------------------------------------------*/
  520.     new_index = small_image_selector_compute_next_row_image_index(index);
  521.     if (new_index > (category_144_object_list_n_items - 1))
  522.     {
  523.         new_index = 0;
  524.     }
  525.     *category_144_object_list_index = new_index;
  526.     /* PMT VIKAS START 20051217 */
  527.     small_image_selector_configure_current_display(&small_image_selector, *category_144_object_list_index);
  528.     /* PMT VIKAS END 20051217 */
  529.     redraw_small_image_selector_images();
  530.     category_144_highlight_handler(new_index);
  531. }
  532. /*****************************************************************************
  533.  * FUNCTION
  534.  *  small_image_selector_key_handler
  535.  * DESCRIPTION
  536.  *  Executes the function depending upon the key pressed
  537.  * PARAMETERS
  538.  *  vkey_code       [IN]        
  539.  *  key_state       [IN]        
  540.  * RETURNS
  541.  *  void
  542.  *****************************************************************************/
  543. void small_image_selector_key_handler(S32 vkey_code, S32 key_state)
  544. {
  545. #if(MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32)
  546.     /*----------------------------------------------------------------*/
  547.     /* Local Variables                                                */
  548.     /*----------------------------------------------------------------*/
  549.     /*----------------------------------------------------------------*/
  550.     /* Code Body                                                      */
  551.     /*----------------------------------------------------------------*/
  552.     if (key_state)
  553.     {
  554.         switch (vkey_code)
  555.         {
  556.             case 37:
  557.                 category_144_goto_previous_item();  /* left */
  558.                 break;
  559.             case 39:
  560.                 category_144_goto_next_item();      /* right */
  561.                 break;
  562.             case 38:
  563.                 small_image_selector_goto_next_row();
  564.                 break;
  565.             case 40:
  566.                 small_image_selector_goto_previous_row();
  567.                 break;
  568.         }
  569.     }
  570. #else /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  571.     UI_UNUSED_PARAMETER(vkey_code);
  572.     UI_UNUSED_PARAMETER(key_state);
  573. #endif /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  574. }
  575. /*****************************************************************************
  576.  * FUNCTION
  577.  *  small_image_selector_goto_item
  578.  * DESCRIPTION
  579.  *  Calculates the item based on the index passed
  580.  * PARAMETERS
  581.  *  index       [IN]        
  582.  * RETURNS
  583.  *  void
  584.  *****************************************************************************/
  585. void small_image_selector_goto_item(S32 index)
  586. {
  587.     /*----------------------------------------------------------------*/
  588.     /* Local Variables                                                */
  589.     /*----------------------------------------------------------------*/
  590.     /*----------------------------------------------------------------*/
  591.     /* Code Body                                                      */
  592.     /*----------------------------------------------------------------*/
  593.     if (index < 0)
  594.     {
  595.         return;
  596.     }
  597.     if (index > (category_144_object_list_n_items - 1))
  598.     {
  599.         return;
  600.     }
  601.     category_144_load_object(index);
  602.     category_144_highlight_handler(index);
  603. }
  604. /*****************************************************************************
  605.  * FUNCTION
  606.  *  ExitSmallImageSelectorScreen
  607.  * DESCRIPTION
  608.  *  Exit the small image selector screen
  609.  * PARAMETERS
  610.  *  void
  611.  * RETURNS
  612.  *  void
  613.  *****************************************************************************/
  614. void ExitSmallImageSelectorScreen(void)
  615. {
  616.     /*----------------------------------------------------------------*/
  617.     /* Local Variables                                                */
  618.     /*----------------------------------------------------------------*/
  619.     /*----------------------------------------------------------------*/
  620.     /* Code Body                                                      */
  621.     /*----------------------------------------------------------------*/
  622.     EMS_cancel_object_focus();
  623.     close_EMS_objects();
  624.     EMS_view_mode = 0;
  625. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  626.     reset_small_screen();
  627. #endif 
  628. //#ifdef __MMI_WALLPAPER_ON_BOTTOM__//111306 popup title
  629.     title_bg_id = 0;
  630. //#endif
  631.     show_status_icon_bar(0);//052906 early status icon
  632.     MMI_title_x = MMI_TITLE_X;
  633.     MMI_title_y = MMI_TITLE_Y;
  634.     MMI_title_width = UI_device_width;
  635.     category_144_object_list_index = NULL;
  636.     category_144_object_list_n_items = 0;
  637.     category_144_list_of_titles = NULL;
  638.     category_144_object_list_flags = 0;
  639.     ExitCategoryFunction = MMI_dummy_function;
  640.     RedrawCategoryFunction = MMI_dummy_function;
  641.     GetCategoryHistory = dummy_get_history;
  642.     GetCategoryHistorySize = dummy_get_history_size;
  643.     load_EMS_object_file = NULL;
  644.     entry_full_screen();
  645.     
  646.     /* 062206 EMS category Start */
  647.     if (category_144_file_data!=NULL)
  648.     {
  649.         mmi_frm_scrmem_free(category_144_file_data);
  650.         category_144_file_data = NULL;
  651.     }
  652.     /* 062206 EMS category Start */
  653. }
  654. #ifdef __MMI_TOUCH_SCREEN__
  655. /*****************************************************************************
  656. * FUNCTION
  657. *  small_image_selector_pen_down_hdlr
  658. *
  659. * DESCRIPTION
  660. *   This is the pen event down handler.
  661. *
  662. * PARAMETERS
  663. * co-ordinates to the point of contact of pen on LCD.
  664. *  
  665. * RETURNS                 
  666. * BOOL
  667. *
  668. * GLOBALS AFFECTED        
  669. *   
  670. *****************************************************************************/
  671. MMI_BOOL small_image_selector_pen_down_hdlr(mmi_pen_point_struct pos)
  672. {
  673. if(PEN_CHECK_BOUND(pos.x,pos.y, small_image_selector.x, small_image_selector.y,small_image_selector.width, small_image_selector.height))
  674. {
  675. S32 i,x,y,w,h,start_x,end_x,end_y,row,col,displayed_column;
  676. S32 current_row=0;
  677. small_image_selector_struct *s = &small_image_selector;
  678. x = s->x + s->h_gap;
  679. y = s->y + s->v_gap;
  680. end_x = s->x + s->width -1;
  681. end_y = s->y + s->height -1;
  682. start_x = x;
  683. i = s->first_displayed_image;
  684. row = s->first_displayed_row;
  685. col = s->first_displayed_column;
  686. displayed_column = s->displayed_columns;
  687. for(;i<category_144_object_list_n_items;i = col+row*displayed_column)
  688. {
  689. /*
  690.             *category_144_object_list_index=i;
  691. category_144_load_object(i);
  692. gui_EMS_input_box_measure_object(&category_144_current_object,&w,&h);
  693.             */
  694.             w = s->image_width;
  695.             h = s->image_height; 
  696. start_x+=w;
  697. if(start_x > end_x)
  698. {
  699. y+=h+s->v_gap;
  700. current_row++;
  701. if(y>=end_y || current_row>=s->displayed_rows)
  702. break;
  703. x = MMI_SMALL_SCREEN_X_OFFSET  + s->h_gap;
  704. start_x = x + w;
  705. row++;
  706. col = s->first_displayed_column;
  707. col++;
  708. }
  709. else
  710. {
  711. start_x+=s->h_gap;
  712. col++;
  713. }
  714. if(PEN_CHECK_BOUND(pos.x,pos.y,x,y,w,h))
  715. {
  716. *category_144_object_list_index = i;
  717. small_image_selector_configure_current_display(&small_image_selector,*category_144_object_list_index);
  718. redraw_small_image_selector_images();
  719. return MMI_TRUE;
  720. }
  721. x+=w+s->h_gap;
  722. }
  723. }
  724. return MMI_FALSE;
  725. }
  726. /*****************************************************************************
  727. * FUNCTION
  728. *  small_image_selector_pen_up_hdlr
  729. *
  730. * DESCRIPTION
  731. *   This is the pen event up handler.
  732. *
  733. * PARAMETERS
  734. * co-ordinates to the point of contact of pen on LCD.
  735. *  
  736. * RETURNS                 
  737. * BOOL
  738. *
  739. * GLOBALS AFFECTED        
  740. *   
  741. *****************************************************************************/
  742. MMI_BOOL small_image_selector_pen_up_hdlr(mmi_pen_point_struct pos)
  743. {
  744.     if(PEN_CHECK_BOUND(pos.x,pos.y, small_image_selector.x, small_image_selector.y,small_image_selector.width, small_image_selector.height))
  745. {
  746. S32 i,x,y,w,h,start_x,end_x,end_y,row,col,displayed_column;
  747. S32 current_row=0;
  748. small_image_selector_struct *s = &small_image_selector;
  749. x = s->x + s->h_gap;
  750. y = s->y + s->v_gap;
  751. end_x = s->x + s->width -1;
  752. end_y = s->y + s->height -1;
  753. start_x = x;
  754. i = s->first_displayed_image;
  755. row = s->first_displayed_row;
  756. col = s->first_displayed_column;
  757. displayed_column = s->displayed_columns;
  758. for(;i<category_144_object_list_n_items;i = col+row*displayed_column)
  759. {
  760. /*
  761.             *category_144_object_list_index=i;
  762. category_144_load_object(i);
  763. gui_EMS_input_box_measure_object(&category_144_current_object,&w,&h);
  764.             */
  765.             w = s->image_width;
  766.             h = s->image_height;
  767. start_x+=w;
  768. if(start_x > end_x)
  769. {
  770. y+=h+s->v_gap;
  771. current_row++;
  772. if(y>=end_y || current_row>=s->displayed_rows)
  773. break;
  774. x = MMI_SMALL_SCREEN_X_OFFSET  + s->h_gap;
  775. start_x = x + w;
  776. row++;
  777. col = s->first_displayed_column;
  778. col++;
  779. }
  780. else
  781. {
  782. start_x+=s->h_gap;
  783. col++;
  784. }
  785. if(PEN_CHECK_BOUND(pos.x,pos.y,x,y,w,h))
  786. {
  787. *category_144_object_list_index = i;
  788. small_image_selector_configure_current_display(&small_image_selector,*category_144_object_list_index);
  789.                 PreviewEmsObjectIsDone();
  790. return MMI_TRUE;
  791. }
  792. x+=w+s->h_gap;
  793. }
  794. }
  795. return MMI_FALSE;
  796. }
  797. /*****************************************************************************
  798. * FUNCTION
  799. *  small_image_selector_pen_move_hdlr
  800. *
  801. * DESCRIPTION
  802. *   This is the pen event move handler.
  803. *
  804. * PARAMETERS
  805. * co-ordinates to the point of contact of pen on LCD.
  806. *  
  807. * RETURNS                 
  808. * BOOL
  809. *
  810. * GLOBALS AFFECTED        
  811. *   
  812. *****************************************************************************/
  813. MMI_BOOL small_image_selector_pen_move_hdlr(mmi_pen_point_struct pos)
  814. {
  815. if(PEN_CHECK_BOUND(pos.x,pos.y, small_image_selector.x, small_image_selector.y,small_image_selector.width, small_image_selector.height))
  816. {
  817. S32 i,x,y,w,h,start_x,end_x,end_y,row,col,displayed_column;
  818. S32 current_row=0;
  819. small_image_selector_struct *s = &small_image_selector;
  820. x = s->x + s->h_gap;
  821. y = s->y + s->v_gap;
  822. end_x = s->x + s->width -1;
  823. end_y = s->y + s->height -1;
  824. start_x = x;
  825. i = s->first_displayed_image;
  826. row = s->first_displayed_row;
  827. col = s->first_displayed_column;
  828. displayed_column = s->displayed_columns;
  829. for(;i<category_144_object_list_n_items;i = col+row*displayed_column)
  830. {
  831. /*
  832.             *category_144_object_list_index=i;
  833. category_144_load_object(i);
  834. gui_EMS_input_box_measure_object(&category_144_current_object,&w,&h);
  835.             */
  836.             w = s->image_width;
  837.             h = s->image_height;
  838. start_x+=w;
  839. if(start_x > end_x)
  840. {
  841. y+=h+s->v_gap;
  842. current_row++;
  843. if(y>=end_y || current_row>=s->displayed_rows)
  844. break;
  845. x = MMI_SMALL_SCREEN_X_OFFSET  + s->h_gap;
  846. start_x = x + w;
  847. row++;
  848. col = s->first_displayed_column;
  849. col++;
  850. }
  851. else
  852. {
  853. start_x+=s->h_gap;
  854. col++;
  855. }
  856. if(PEN_CHECK_BOUND(pos.x,pos.y,x,y,w,h))
  857. {
  858. *category_144_object_list_index = i;
  859. small_image_selector_configure_current_display(&small_image_selector,*category_144_object_list_index);
  860. redraw_small_image_selector_images();
  861. return MMI_TRUE;
  862. }
  863. x+=w+s->h_gap;
  864. }
  865. }
  866. return MMI_FALSE;
  867. }
  868. #endif
  869. /*****************************************************************************
  870.  * FUNCTION
  871.  *  RedrawSmallImageSelectorScreen
  872.  * DESCRIPTION
  873.  *  Redraws the image selector screen for the small screen
  874.  * PARAMETERS
  875.  *  void
  876.  * RETURNS
  877.  *  void
  878.  *****************************************************************************/
  879. void RedrawSmallImageSelectorScreen(void)
  880. {
  881.     /*----------------------------------------------------------------*/
  882.     /* Local Variables                                                */
  883.     /*----------------------------------------------------------------*/
  884.     //color c = {200, 200, 200, 100};//120406 warning remove
  885.     /*----------------------------------------------------------------*/
  886.     /* Code Body                                                      */
  887.     /*----------------------------------------------------------------*/
  888.     gui_greyscale_rectangle(
  889.         0,
  890.         0,
  891.         UI_device_width - 1,
  892.         UI_device_height - 1,
  893.         MMI_BG_GREYSCALE_VALUE,
  894.         MMI_BG_GREYSCALE_BLACK_VALUE);
  895.     gui_set_clip(0, MMI_title_y, UI_device_width - 1, UI_device_height - 1);
  896.     gui_lock_double_buffer();
  897.     gui_hide_animations();
  898.     draw_title();
  899.     show_softkey_background();
  900.     show_left_softkey();
  901.     show_right_softkey();
  902.     /* PMT VIKAS START 20051217 */
  903.     small_image_selector_set_up(&small_image_selector, category_144_object_list_n_items);
  904.     /* PMT VIKAS END 20051217 */
  905.     redraw_small_image_selector_images();
  906.     gui_unlock_double_buffer();
  907.     gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
  908. }
  909. /*----------------------------------------------------------------------------
  910. Function:         ShowImageSelectorScreen
  911. Description:      Displays the object list screen
  912. Input Parameters:[1] S8*      title,            Title for the screen
  913.                [2]   U16   title_icon           Icon shown with the title
  914.                [3]   U16   left_softkey,        Left softkey label
  915.                [4]   U16   left_softkey_icon,   Icon for the left softkey
  916.                [5]   U16   right_softkey,       Right softkey label
  917.                [6]   U16   right_softkey_icon,  Icon for the right softkey
  918.                [7]   U32   object type flags
  919.                [8]   S32   number of objects in the list
  920.                [9]   U8**  list of object titles
  921.                [10]  U16*  ist of predefined objects (EMS specific IDs)
  922.                [11]  U8**  list of user defined objects (list of EMS data)
  923.                [12]  S32 * index                highlighted item index
  924.                [13]  U8*   history_buffer       history buffer
  925. Output Parameters:   none
  926. Returns:       void
  927. ----------------------------------------------------------------------------*/
  928. /*****************************************************************************
  929.  * FUNCTION
  930.  *  dm_category_144_controlled_area
  931.  * DESCRIPTION
  932.  *  This function is used to draw the category controlled area of idle screen
  933.  * PARAMETERS
  934.  *  coordinate      [IN/OUT]        Coordinates of category controlled area.
  935.  * RETURNS
  936.  *  void
  937.  *****************************************************************************/
  938. void dm_category_144_controlled_area(dm_coordinates *coordinate)
  939. {
  940.     /*----------------------------------------------------------------*/
  941.     /* Local Variables                                                */
  942.     /*----------------------------------------------------------------*/
  943.     /*----------------------------------------------------------------*/
  944.     /* Code Body                                                      */
  945.     /*----------------------------------------------------------------*/
  946.     /* PMT VIKAS START 20051217 */
  947.     small_image_selector_set_up(&small_image_selector, category_144_object_list_n_items);
  948.     /* PMT VIKAS END 20051217 */
  949.     redraw_small_image_selector_images();
  950. }
  951. /*****************************************************************************
  952.  * FUNCTION
  953.  *  ShowImageSelectorScreen
  954.  * DESCRIPTION
  955.  *  
  956.  * PARAMETERS
  957.  *  title                   [?]         
  958.  *  title_icon              [IN]        
  959.  *  left_softkey            [IN]        
  960.  *  left_softkey_icon       [IN]        
  961.  *  right_softkey           [IN]        
  962.  *  right_softkey_icon      [IN]        
  963.  *  object_type             [IN]        
  964.  *  n_items                 [IN]        
  965.  *  object_titles           [IN]        
  966.  *  predefined_objects      [?]         
  967.  *  userdefined_objects     [IN]        
  968.  *  index                   [?]         
  969.  *  history_buffer          [?]         
  970.  * RETURNS
  971.  *  void
  972.  *****************************************************************************/
  973. void ShowImageSelectorScreen(
  974.         S8 *title,
  975.         U16 title_icon,
  976.         U16 left_softkey,
  977.         U16 left_softkey_icon,
  978.         U16 right_softkey,
  979.         U16 right_softkey_icon,
  980.         U32 object_type,
  981.         S32 n_items,
  982.         U8 **object_titles,
  983.         U16 *predefined_objects,
  984.         U8 **userdefined_objects,
  985.         S32 *index,
  986.         U8 *history_buffer)
  987. {
  988.     /*----------------------------------------------------------------*/
  989.     /* Local Variables                                                */
  990.     /*----------------------------------------------------------------*/
  991.     dm_data_struct dm_data;
  992.     color c = *(current_MMI_theme->UI_black_color);
  993.     U8 h_flag;
  994.     MMI_disable_title_shortcut_display = 1;
  995.     /*----------------------------------------------------------------*/
  996.     /* Code Body                                                      */
  997.     /*----------------------------------------------------------------*/
  998.     MMI_title_x = MMI_SMALL_SCREEN_X_OFFSET + 1;
  999.     MMI_title_y = MMI_title_y + MMI_title_height + MMI_SMALL_SCREEN_Y_OFFSET;
  1000.     MMI_title_width = UI_device_width - 2 * MMI_SMALL_SCREEN_X_OFFSET - 1;
  1001. #ifdef __MMI_UI_SMALL_SCREEN_SUPPORT__
  1002.     set_small_screen();
  1003.     gui_add_cleanup_hook(disable_resized_small_screen);
  1004. #endif /* __MMI_UI_SMALL_SCREEN_SUPPORT__ */ 
  1005.     hide_status_icon_bar(0);//052906 early status icon
  1006.     
  1007. #if (defined(MMI_ON_HARDWARE_P) && defined(__MMI_FILE_MANAGER__))
  1008.     if (object_type & CATEGORY144_FMGR_PREVIEW)
  1009.     {
  1010.         S32 str_len;
  1011.         S32 i;
  1012.         S8 buf_filename_no_ext[(FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH];
  1013.         MMI_disable_title_shortcut_display = 1;
  1014.         index = &category_144_object_list_default_index;
  1015.         if (predefined_objects == NULL)
  1016.         {
  1017.             GoBackToHistory(SCR_ID_MSG_EMS_INSERT_OBJECT);
  1018.             return;
  1019.         }
  1020.         else
  1021.         {
  1022.             U32 errorCode = 0;
  1023.             FILE_HANDLE emsObjectFilePtr = NULL;
  1024.             U32 filesize = 0;
  1025.             S8 *filename = (S8*) predefined_objects;
  1026.             str_len = pfnUnicodeStrlen((S8*) filename);
  1027.             /* find file name - by finding "\" */
  1028.             for (i = str_len * 2 - 2; i >= 2; i -= 2)
  1029.             {
  1030.                 if (pfnUnicodeStrncmp((PS8) & filename[i], (PS8) L"\", 1) == 0)
  1031.                 {
  1032.                     i += 2;
  1033.                     break;
  1034.                 }
  1035.             }
  1036.             pfnUnicodeStrcpy((PS8) buf_filename_no_ext, (PS8) (&(filename[i])));
  1037.             ChangeTitle(title_icon, (PU8) (buf_filename_no_ext));
  1038.             userdefined_objects = category_144_data_ptr;
  1039.             /* 062206 EMS category Start */
  1040.             category_144_file_data = mmi_frm_scrmem_alloc(CAT_144_DATA_FILE_SIZE);
  1041.             MMI_ASSERT(category_144_file_data != NULL);
  1042.             //memset(&category_144_file_data, 0, 1600);
  1043.             memset(category_144_file_data, 0, CAT_144_DATA_FILE_SIZE);
  1044.             /* 062206 EMS category Start */
  1045.             emsObjectFilePtr = pfopen((S8*) predefined_objects, PFS_READ);
  1046.             if (!pfOpenError(emsObjectFilePtr))
  1047.             {
  1048.                 filesize = GetFSFileSize(emsObjectFilePtr);
  1049.                 if (filesize > 1600 /* bytes */ )
  1050.                 {
  1051.                     pfclose(emsObjectFilePtr);
  1052.                     userdefined_objects[0] = NULL;
  1053.                 }
  1054.                 pfread(category_144_file_data, 1, filesize, emsObjectFilePtr, &errorCode);
  1055.                 pfclose(emsObjectFilePtr);
  1056.                 if (pfError(errorCode))
  1057.                 {
  1058.                     userdefined_objects[0] = NULL;
  1059.                 }
  1060.                 else
  1061.                 {
  1062.                     userdefined_objects[0] = category_144_file_data;
  1063.                 }
  1064.             }
  1065.             else
  1066.             {
  1067.                 userdefined_objects[0] = NULL;
  1068.             }
  1069.         }
  1070.     }
  1071. #endif /* (defined(MMI_ON_HARDWARE_P) && defined(__MMI_FILE_MANAGER__)) */ 
  1072.     /* PMT VIKAS START 20051217 */
  1073.     if (!history_buffer)
  1074.     {
  1075.         associate_small_image_selector(&small_image_selector);
  1076.     }
  1077.     /* PMT VIKAS END 20051217 */
  1078.     gdi_layer_lock_frame_buffer();
  1079.     initialize_EMS_objects();
  1080.     EMS_view_mode = 1;
  1081.     category_144_object_file_flag = 0;
  1082.     category_144_object_list_flags = object_type;
  1083.     category_144_current_object.data = &category_144_current_object_data;
  1084.     category_144_autodetect_object_type = 0;
  1085.     switch (object_type & 0x0f)
  1086.     {
  1087.             /* small screen is only applicable to picture and animation */
  1088.         case EMS_PREDEFINED_PICTURE:
  1089.             category_144_current_object.Type = EMS_TYPE_PIC;
  1090.             category_144_object_file_flag = 1;
  1091.             break;
  1092.         case EMS_USERDEFINED_PICTURE:
  1093.             category_144_current_object.Type = EMS_TYPE_PIC;
  1094.             category_144_object_file_flag = 1;
  1095.             break;
  1096.         case EMS_PREDEFINED_ANIMATION:
  1097.             category_144_current_object.Type = EMS_TYPE_PREDEF_ANM;
  1098.             break;
  1099.         case EMS_USERDEFINED_ANIMATION:
  1100.             category_144_current_object.Type = EMS_TYPE_USERDEF_ANM;
  1101.             category_144_object_file_flag = 1;
  1102.             break;
  1103.         default:
  1104.             MMI_ASSERT(0);
  1105.             break;
  1106.     }
  1107.     clear_left_softkey();
  1108.     clear_right_softkey();
  1109.     SetupCategoryKeyHandlers();
  1110.     change_left_softkey(left_softkey, left_softkey_icon);
  1111.     change_right_softkey(right_softkey, right_softkey_icon);
  1112.     MMI_title_icon = get_image(title_icon);
  1113.     if (!((object_type & CATEGORY144_FMGR_PREVIEW) && (!(object_type & CATEGORY144_EMAIL_PREVIEW))))
  1114.     {
  1115.         MMI_title_string = (UI_string_type) title;
  1116.     }
  1117.     category_144_object_list_index = index;
  1118.     category_144_userdefined_objects = userdefined_objects;
  1119.     category_144_predefined_objects = predefined_objects;
  1120.     h_flag = set_object_list_category_history(MMI_CATEGORY146_ID, history_buffer, category_144_object_list_index);
  1121.     if (h_flag)
  1122.     {
  1123.         *index = *category_144_object_list_index;
  1124.     }
  1125.     category_144_object_list_n_items = n_items;
  1126.     if (*index < 0)
  1127.     {
  1128.         *index = 0;
  1129.     }
  1130.     if (*index >= n_items)
  1131.     {
  1132.         *index = n_items - 1;
  1133.     }
  1134.     if ((!(object_type & CATEGORY144_DISABLE_PREVIEW)) && (!(object_type & CATEGORY144_FMGR_PREVIEW)))
  1135.     {
  1136.         register_keyboard_key_handler(small_image_selector_key_handler);
  1137.         SetKeyHandler(small_image_selector_goto_previous_row, KEY_UP_ARROW, KEY_EVENT_DOWN);
  1138.         SetKeyHandler(small_image_selector_goto_next_row, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  1139.         SetKeyHandler(category_144_goto_previous_item, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
  1140.         SetKeyHandler(category_144_goto_next_item, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  1141.         SetKeyHandler(small_image_selector_goto_previous_row, KEY_VOL_UP, KEY_EVENT_DOWN);
  1142.         SetKeyHandler(small_image_selector_goto_next_row, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1143.     }
  1144. //#ifdef __MMI_WALLPAPER_ON_BOTTOM__//110306 popup title
  1145.     title_bg_id = IMG_FLEXIBLE_TITLEBAR_BG;
  1146. //#endif
  1147.     gdi_layer_unlock_frame_buffer();
  1148.     if (!(object_type & CATEGORY144_DISABLE_PREVIEW))
  1149.     {
  1150.         ExitCategoryFunction = ExitSmallImageSelectorScreen;
  1151.         dm_setup_category_functions(dm_redraw_category_screen, GetCategory146History, GetCategory144HistorySize);
  1152.         dm_register_category_controlled_callback(DrawCate144CategoryControlArea);
  1153.         dm_data.s32ScrId = (S32) GetActiveScreenId();
  1154.         dm_data.s32CatId = MMI_CATEGORY146_ID;
  1155.         dm_data.s32flags = DM_NO_FLAGS /* DM_CLEAR_SCREEN_BACKGROUND */ ;
  1156.         dm_add_rectangle(c, DM_RECTANGLE_FILL_GRAYSCALE);
  1157.         dm_setup_data(&dm_data);
  1158.         dm_register_category_controlled_callback(dm_category_144_controlled_area);
  1159.         dm_redraw_category_screen();
  1160.     }
  1161. #ifdef __MMI_TOUCH_SCREEN__
  1162.     wgui_register_category_screen_control_area_pen_handlers(small_image_selector_pen_down_hdlr, MMI_PEN_EVENT_DOWN);
  1163.     wgui_register_category_screen_control_area_pen_handlers(small_image_selector_pen_up_hdlr, MMI_PEN_EVENT_UP);
  1164.     wgui_register_category_screen_control_area_pen_handlers(small_image_selector_pen_move_hdlr, MMI_PEN_EVENT_MOVE);
  1165. #endif
  1166. }
  1167. #endif /* UI_SMALL_IMAGE_SELECTOR_SCREEN */ 
  1168. /* END VIJAY PMT 20050930 */
  1169. /*****************************************************************************
  1170.  * FUNCTION
  1171.  *  ShowCategory144Screen
  1172.  * DESCRIPTION
  1173.  *  Displays the object list screen
  1174.  * PARAMETERS
  1175.  *  title                   [IN]        Title for the screen
  1176.  *  title_icon              [IN]        Icon shown with the title
  1177.  *  left_softkey            [IN]        Left softkey label
  1178.  *  left_softkey_icon       [IN]        Icon for the left softkey
  1179.  *  right_softkey           [IN]        Right softkey label
  1180.  *  right_softkey_icon      [IN]        Icon for the right softkey
  1181.  *  object_type             [IN]        
  1182.  *  n_items                 [IN]        
  1183.  *  object_titles           [IN]        
  1184.  *  predefined_objects      [?]         
  1185.  *  is_short_name           [IN]        
  1186.  *  userdefined_objects     [IN]        
  1187.  *  index                   [?]         
  1188.  *  history_buffer          [IN]        History buffer
  1189.  *  INT(?)                  [IN]        *      highlighted item index
  1190.  *  STRING(?)               [IN]        *    list of object titles
  1191.  *  list(?)                 [IN]        Of user defined objects (list of EMS data)
  1192.  * RETURNS
  1193.  *  void
  1194.  *****************************************************************************/
  1195. void ShowCategory144Screen(
  1196.         U8 *title,
  1197.         U16 title_icon,
  1198.         U16 left_softkey,
  1199.         U16 left_softkey_icon,
  1200.         U16 right_softkey,
  1201.         U16 right_softkey_icon,
  1202.         U32 object_type,
  1203.         S32 n_items,
  1204.         U8 **object_titles,
  1205.         U16 *predefined_objects,
  1206.         MMI_BOOL is_short_name,
  1207.         U8 **userdefined_objects,
  1208.         S32 *index,
  1209.         U8 *history_buffer)
  1210. {
  1211.     /*----------------------------------------------------------------*/
  1212.     /* Local Variables                                                */
  1213.     /*----------------------------------------------------------------*/
  1214.     dm_data_struct dm_data;
  1215.     S32 shortcut_width;
  1216.     U8 h_flag;
  1217.     MMI_menu_shortcut_number = -1;
  1218.     MMI_disable_title_shortcut_display = 0;
  1219.     /*----------------------------------------------------------------*/
  1220.     /* Code Body                                                      */
  1221.     /*----------------------------------------------------------------*/
  1222. #if (defined(MMI_ON_HARDWARE_P) && defined(__MMI_FILE_MANAGER__))
  1223.     if (object_type & CATEGORY144_FMGR_PREVIEW)
  1224.     {
  1225.         S32 str_len;
  1226.         S32 i;
  1227.         S8 buf_filename_no_ext[(FMGR_MAX_FILE_LEN + 1) * ENCODING_LENGTH];
  1228.         MMI_disable_title_shortcut_display = 1;
  1229.         index = &category_144_object_list_default_index;
  1230.         if (predefined_objects == NULL)
  1231.         {
  1232.             GoBackToHistory(SCR_ID_MSG_EMS_INSERT_OBJECT);
  1233.             return;
  1234.         }
  1235.         else
  1236.         {
  1237.             U32 errorCode = 0;
  1238.             FILE_HANDLE emsObjectFilePtr = NULL;
  1239.             U32 filesize = 0;
  1240.             S8 *filename = (S8*) predefined_objects;
  1241.             str_len = pfnUnicodeStrlen((S8*) filename);
  1242.             /* find file name - by finding "\" */
  1243.             for (i = str_len * 2 - 2; i >= 2; i -= 2)
  1244.             {
  1245.                 if (pfnUnicodeStrncmp((PS8) & filename[i], (PS8) L"\", 1) == 0)
  1246.                 {
  1247.                     i += 2;
  1248.                     break;
  1249.                 }
  1250.             }
  1251.         #ifdef MMI_ON_HARDWARE_P
  1252.             if (is_short_name)
  1253.             {
  1254.                 mmi_chset_mixed_text_to_ucs2_str(
  1255.                     (U8*) buf_filename_no_ext,
  1256.                     (MAX_SUBMENU_CHARACTERS - 1) * ENCODING_LENGTH,
  1257.                     (U8*) & filename[i],
  1258.                     PhnsetGetDefEncodingType());
  1259.             }
  1260.             else
  1261.         #endif /* MMI_ON_HARDWARE_P */ 
  1262.                 pfnUnicodeStrcpy((PS8) buf_filename_no_ext, (PS8) (&(filename[i])));
  1263.             ChangeTitle(title_icon, (PU8) (buf_filename_no_ext));
  1264.             userdefined_objects = category_144_data_ptr;
  1265.             /* 062206 EMS category Start */
  1266.             category_144_file_data = mmi_frm_scrmem_alloc(CAT_144_DATA_FILE_SIZE);
  1267.             MMI_ASSERT(category_144_file_data != NULL);
  1268.             //memset(&category_144_file_data, 0, 1600);
  1269.             memset(category_144_file_data, 0, CAT_144_DATA_FILE_SIZE);
  1270.             /* 062206 EMS category Start */
  1271.             emsObjectFilePtr = pfopen((S8*) predefined_objects, PFS_READ);
  1272.             if (!pfOpenError(emsObjectFilePtr))
  1273.             {
  1274.                 filesize = GetFSFileSize(emsObjectFilePtr);
  1275.                 if (filesize > 1600 /* bytes */ )
  1276.                 {
  1277.                     pfclose(emsObjectFilePtr);
  1278.                     userdefined_objects[0] = NULL;
  1279.                 }
  1280.                 pfread(category_144_file_data, 1, filesize, emsObjectFilePtr, &errorCode);
  1281.                 pfclose(emsObjectFilePtr);
  1282.                 if (pfError(errorCode))
  1283.                 {
  1284.                     userdefined_objects[0] = NULL;
  1285.                 }
  1286.                 else
  1287.                 {
  1288.                     userdefined_objects[0] = category_144_file_data;
  1289.                 }
  1290.             }
  1291.             else
  1292.             {
  1293.                 userdefined_objects[0] = NULL;
  1294.             }
  1295.         }
  1296.     }
  1297. #endif /* (defined(MMI_ON_HARDWARE_P) && defined(__MMI_FILE_MANAGER__)) */ 
  1298.     gdi_layer_lock_frame_buffer();
  1299.     initialize_EMS_objects();
  1300.     EMS_view_mode = 1;
  1301.     category_144_object_file_flag = 0;
  1302.     category_144_object_list_flags = object_type;
  1303.     category_144_current_object.data = &category_144_current_object_data;
  1304.     category_144_autodetect_object_type = 0;
  1305.     switch (object_type & 0x0f)
  1306.     {
  1307.         case EMS_PREDEFINED_PICTURE:
  1308.             category_144_current_object.Type = EMS_TYPE_PIC;
  1309.             category_144_object_file_flag = 1;
  1310.             break;
  1311.         case EMS_USERDEFINED_PICTURE:
  1312.             category_144_current_object.Type = EMS_TYPE_PIC;
  1313.             category_144_object_file_flag = 1;
  1314.             break;
  1315.         case EMS_PREDEFINED_ANIMATION:
  1316.             category_144_current_object.Type = EMS_TYPE_PREDEF_ANM;
  1317.             break;
  1318.         case EMS_USERDEFINED_ANIMATION:
  1319.             category_144_current_object.Type = EMS_TYPE_USERDEF_ANM;
  1320.             category_144_object_file_flag = 1;
  1321.             break;
  1322.         case EMS_PREDEFINED_SOUND:
  1323.             category_144_current_object.Type = EMS_TYPE_PREDEF_SND;
  1324.             break;
  1325.             /* MTK Joy added for customization, 1014 */
  1326.     #if defined(__MMI_IMELODY_SUPPORT__)
  1327.         case EMS_PREDEFINED_MELODY:
  1328.             category_144_current_object.Type = EMS_TYPE_USERDEF_SND;
  1329.             category_144_object_file_flag = 1;
  1330.             break;
  1331.         case EMS_USERDEFINED_MELODY:
  1332.             category_144_current_object.Type = EMS_TYPE_USERDEF_SND;
  1333.             category_144_object_file_flag = 1;
  1334.             break;
  1335.     #endif /* defined(__MMI_IMELODY_SUPPORT__) */ 
  1336.             /* MTK end */
  1337.         default:
  1338.             category_144_autodetect_object_type = 1;
  1339.             break;
  1340.     }
  1341.     clear_left_softkey();
  1342.     clear_right_softkey();
  1343.     change_left_softkey(left_softkey, left_softkey_icon);
  1344.     change_right_softkey(right_softkey, right_softkey_icon);
  1345.     SetupCategoryKeyHandlers();
  1346.     MMI_title_icon = get_image(title_icon);
  1347.     if (!((object_type & CATEGORY144_FMGR_PREVIEW) && (!(object_type & CATEGORY144_EMAIL_PREVIEW))))
  1348.     {
  1349.         MMI_title_string = (UI_string_type) title;
  1350.     }
  1351.     category_144_object_list_index = index;
  1352.     category_144_userdefined_objects = userdefined_objects;
  1353.     category_144_predefined_objects = predefined_objects;
  1354.     h_flag = set_object_list_category_history(MMI_CATEGORY144_ID, history_buffer, category_144_object_list_index);
  1355.     if (h_flag)
  1356.     {
  1357.         *index = *category_144_object_list_index;
  1358.     }
  1359.     category_144_object_list_n_items = n_items;
  1360.     if (*index < 0)
  1361.     {
  1362.         *index = 0;
  1363.     }
  1364.     if (*index >= n_items)
  1365.     {
  1366.         *index = n_items - 1;
  1367.     }
  1368.     category_144_load_object(*index);
  1369.     MMI_menu_shortcut_number = *index + 1;
  1370.     category_144_object_list_index = index;
  1371.     if ((!(object_type & CATEGORY144_DISABLE_PREVIEW)) && (!(object_type & CATEGORY144_FMGR_PREVIEW)))
  1372.     {
  1373.         gui_create_vertical_scrollbar(
  1374.             &category144_vbar,
  1375.             UI_device_width - current_MMI_theme->scrollbar_size,
  1376.             (MMI_title_y + MMI_title_height),
  1377.             current_MMI_theme->scrollbar_size,
  1378.             MMI_content_height);
  1379.         register_fixed_list_shortcut_handler();
  1380.         shortcut_width = set_menu_item_count(n_items) + 7;
  1381.         resize_menu_shortcut_handler(shortcut_width, (MMI_title_height));
  1382.         move_menu_shortcut_handler(UI_device_width - MMI_menu_shortcut_box.width, MMI_title_y);
  1383.         register_hide_menu_shortcut(draw_title);
  1384.         register_keyboard_key_handler(category_144_key_handler);
  1385.         register_menu_shortcut_keys();
  1386.         register_menu_shortcut_handler(category_144_goto_item);
  1387.         SetKeyHandler(category_144_goto_previous_item, KEY_UP_ARROW, KEY_EVENT_DOWN);
  1388.         SetKeyHandler(category_144_goto_next_item, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  1389.         SetKeyHandler(category_144_goto_previous_item, KEY_VOL_UP, KEY_EVENT_DOWN);
  1390.         SetKeyHandler(category_144_goto_next_item, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1391.     }
  1392.     gdi_layer_unlock_frame_buffer();
  1393.     if (!(object_type & CATEGORY144_DISABLE_PREVIEW))
  1394.     {
  1395.         ExitCategoryFunction = ExitCategory144Screen;
  1396.         dm_setup_category_functions(dm_redraw_category_screen, GetCategory144History, GetCategory144HistorySize);
  1397.         dm_register_category_controlled_callback(DrawCate144CategoryControlArea);
  1398.     #ifdef __MMI_TOUCH_SCREEN__
  1399.         wgui_register_category_screen_control_area_pen_handlers(category_144_pen_down_hdlr, MMI_PEN_EVENT_DOWN);
  1400.         wgui_register_category_screen_control_area_pen_handlers(category_144_pen_up_hdlr, MMI_PEN_EVENT_UP);
  1401.         wgui_register_category_screen_control_area_pen_handlers(category_144_pen_move_hdlr, MMI_PEN_EVENT_MOVE);
  1402.         wgui_register_category_screen_control_area_pen_handlers(category_144_pen_repeat_hdlr, MMI_PEN_EVENT_REPEAT);
  1403.     #endif /* __MMI_TOUCH_SCREEN__ */ 
  1404.         dm_data.s32ScrId = (S32) GetActiveScreenId();
  1405.         dm_data.s32CatId = MMI_CATEGORY144_ID;
  1406.         dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND;
  1407.         dm_setup_data(&dm_data);
  1408.         dm_redraw_category_screen();
  1409.     }
  1410. }
  1411. /*****************************************************************************
  1412.  * FUNCTION
  1413.  *  ExitCategory144Screen
  1414.  * DESCRIPTION
  1415.  *  Exits the object list screen
  1416.  * PARAMETERS
  1417.  *  void
  1418.  * RETURNS
  1419.  *  void
  1420.  *****************************************************************************/
  1421. void ExitCategory144Screen(void)
  1422. {
  1423.     /*----------------------------------------------------------------*/
  1424.     /* Local Variables                                                */
  1425.     /*----------------------------------------------------------------*/
  1426.     /*----------------------------------------------------------------*/
  1427.     /* Code Body                                                      */
  1428.     /*----------------------------------------------------------------*/
  1429.     EMS_cancel_object_focus();
  1430.     close_EMS_objects();
  1431.     reset_menu_shortcut_handler();
  1432.     EMS_view_mode = 0;
  1433.     category_144_object_list_index = NULL;
  1434.     category_144_object_list_n_items = 0;
  1435.     category_144_list_of_titles = NULL;
  1436.     category_144_object_list_flags = 0;
  1437.     ExitCategoryFunction = MMI_dummy_function;
  1438.     RedrawCategoryFunction = MMI_dummy_function;
  1439.     GetCategoryHistory = dummy_get_history;
  1440.     GetCategoryHistorySize = dummy_get_history_size;
  1441.     load_EMS_object_file = NULL;
  1442.     
  1443.     /* 062206 EMS category Start */
  1444.     if (category_144_file_data!=NULL)
  1445.     {
  1446.         mmi_frm_scrmem_free(category_144_file_data);
  1447.         category_144_file_data = NULL;
  1448.     }
  1449.     /* 062206 EMS category Start */
  1450. }
  1451. /*****************************************************************************
  1452.  * FUNCTION
  1453.  *  GetCategory144HistorySize
  1454.  * DESCRIPTION
  1455.  *  Gets the history buffer size for the object list screen
  1456.  * PARAMETERS
  1457.  *  void
  1458.  * RETURNS
  1459.  *  size in U8s of the history buffer
  1460.  *****************************************************************************/
  1461. S32 GetCategory144HistorySize(void)
  1462. {
  1463.     /*----------------------------------------------------------------*/
  1464.     /* Local Variables                                                */
  1465.     /*----------------------------------------------------------------*/
  1466.     /*----------------------------------------------------------------*/
  1467.     /* Code Body                                                      */
  1468.     /*----------------------------------------------------------------*/
  1469.     return (sizeof(object_list_category_history));
  1470. }
  1471. /*****************************************************************************
  1472.  * FUNCTION
  1473.  *  GetCategory144History
  1474.  * DESCRIPTION
  1475.  *  Gets the history buffer for the object list screen
  1476.  * PARAMETERS
  1477.  *  history_buffer      [IN]        Is the buffer into which the history data is stored
  1478.  * RETURNS
  1479.  *  pointer to the history buffer
  1480.  *****************************************************************************/
  1481. U8 *GetCategory144History(U8 *history_buffer)
  1482. {
  1483.     /*----------------------------------------------------------------*/
  1484.     /* Local Variables                                                */
  1485.     /*----------------------------------------------------------------*/
  1486.     /*----------------------------------------------------------------*/
  1487.     /* Code Body                                                      */
  1488.     /*----------------------------------------------------------------*/
  1489.     get_object_list_category_history(MMI_CATEGORY144_ID, history_buffer, category_144_object_list_index);
  1490.     return (history_buffer);
  1491. }
  1492. #if defined UI_SMALL_IMAGE_SELECTOR_SCREEN
  1493. /*****************************************************************************
  1494.  * FUNCTION
  1495.  *  GetCategory146History
  1496.  * DESCRIPTION
  1497.  *  Gets the history buffer for the object list screen
  1498.  * PARAMETERS
  1499.  *  history_buffer      [IN]        Is the buffer into which the history data is stored
  1500.  * RETURNS
  1501.  *  pointer to the history buffer
  1502.  *****************************************************************************/
  1503. U8 *GetCategory146History(U8 *history_buffer)
  1504. {
  1505.     /*----------------------------------------------------------------*/
  1506.     /* Local Variables                                                */
  1507.     /*----------------------------------------------------------------*/
  1508.     /*----------------------------------------------------------------*/
  1509.     /* Code Body                                                      */
  1510.     /*----------------------------------------------------------------*/
  1511.     get_object_list_category_history(MMI_CATEGORY146_ID, history_buffer, category_144_object_list_index);
  1512.     return (history_buffer);
  1513. }
  1514. #endif /* defined UI_SMALL_IMAGE_SELECTOR_SCREEN */ 
  1515. EMSObjData EMS_playback_object_data;
  1516. EMSObject EMS_playback_object;
  1517. /*****************************************************************************
  1518.  * FUNCTION
  1519.  *  EMSObjectPlayback
  1520.  * DESCRIPTION
  1521.  *  
  1522.  * PARAMETERS
  1523.  *  object_type     [IN]        
  1524.  *  data            [?]         
  1525.  *  index           [IN]        
  1526.  * RETURNS
  1527.  *  
  1528.  *****************************************************************************/
  1529. EMSTATUS EMSObjectPlayback(U32 object_type, U8 *data, S32 index)
  1530. {
  1531.     /*----------------------------------------------------------------*/
  1532.     /* Local Variables                                                */
  1533.     /*----------------------------------------------------------------*/
  1534.     EMSTATUS r = EMS_load_object(object_type, data, index, &EMS_playback_object_data);
  1535.     /*----------------------------------------------------------------*/
  1536.     /* Code Body                                                      */
  1537.     /*----------------------------------------------------------------*/
  1538.     EMS_cancel_object_focus();
  1539.     if (r != EMS_OK)
  1540.     {
  1541.         return (r);
  1542.     }
  1543.     EMS_playback_object.data = &EMS_playback_object_data;
  1544.     EMS_playback_object.prev = NULL;
  1545.     EMS_playback_object.next = NULL;
  1546.     EMS_playback_object.OffsetToText = 0;
  1547.     EMS_playback_object.PredefNo = (U8) index;
  1548.     switch (object_type & 0xff)
  1549.     {
  1550.         case EMS_PREDEFINED_SOUND:
  1551.             EMS_playback_object.Type = EMS_TYPE_PREDEF_SND;
  1552.             gui_EMS_playback_object(&EMS_playback_object);
  1553.             break;
  1554.             /* MTK Joy added for customization, 1014 */
  1555.     #if defined(__MMI_IMELODY_SUPPORT__)
  1556.         case EMS_PREDEFINED_MELODY:
  1557.             EMS_playback_object.Type = EMS_TYPE_USERDEF_SND;
  1558.             gui_EMS_playback_object(&EMS_playback_object);
  1559.             break;
  1560.         case EMS_USERDEFINED_MELODY:
  1561.             EMS_playback_object.Type = EMS_TYPE_USERDEF_SND;
  1562.             gui_EMS_playback_object(&EMS_playback_object);
  1563.             break;
  1564.     #endif /* defined(__MMI_IMELODY_SUPPORT__) */ 
  1565.             /* MTK end */
  1566.     }
  1567.     return (EMS_OK);
  1568. }
  1569. /*****************************************************************************
  1570.  * FUNCTION
  1571.  *  EMSObjectStopPlayBack
  1572.  * DESCRIPTION
  1573.  *  
  1574.  * PARAMETERS
  1575.  *  void
  1576.  * RETURNS
  1577.  *  void
  1578.  *****************************************************************************/
  1579. void EMSObjectStopPlayBack(void)
  1580. {
  1581.     /*----------------------------------------------------------------*/
  1582.     /* Local Variables                                                */
  1583.     /*----------------------------------------------------------------*/
  1584.     /*----------------------------------------------------------------*/
  1585.     /* Code Body                                                      */
  1586.     /*----------------------------------------------------------------*/
  1587.     EMS_cancel_object_focus();
  1588. }
  1589. #endif /* __MMI_MESSAGES_EMS__ */ 
  1590. #define CAT145_SCROLL_DY   20
  1591. color cat145_message_title_color;
  1592. vertical_scrollbar cat145_vbar;
  1593. S32 cat145_h1, cat145_h2, cat145_h3, cat145_total_height, cat145_available_height;
  1594. S32 cat145_y = 0, cat145_image_x, cat145_message_title_x;
  1595. S32 cat145_clip_x1, cat145_clip_y1, cat145_clip_x2, cat145_clip_y2;
  1596. U32 cat145_flags;
  1597. U8 cat145_scrollbar_flag = 0;
  1598. /*****************************************************************************
  1599.  * FUNCTION
  1600.  *  cat145_display
  1601.  * DESCRIPTION
  1602.  *  
  1603.  * PARAMETERS
  1604.  *  void
  1605.  * RETURNS
  1606.  *  void
  1607.  *****************************************************************************/
  1608. void cat145_display(void)
  1609. {
  1610.     /*----------------------------------------------------------------*/
  1611.     /* Local Variables                                                */
  1612.     /*----------------------------------------------------------------*/
  1613.     S32 y = cat145_y + (MMI_title_y + MMI_title_height) + 2;
  1614.     color text_color;
  1615.     /*----------------------------------------------------------------*/
  1616.     /* Code Body                                                      */
  1617.     /*----------------------------------------------------------------*/
  1618.     gdi_layer_push_clip();
  1619.     gdi_layer_set_clip(cat145_clip_x1, cat145_clip_y1, cat145_clip_x2, cat145_clip_y2);
  1620.     gdi_image_draw(cat145_image_x, y, (U8*) MMI_message_icon);
  1621.     y += cat145_h1 + 2;
  1622.     switch (cat145_flags & 0xff)
  1623.     {
  1624.         case CAT145_BLACK_TITLE:
  1625.             text_color = gui_color(0, 0, 0);
  1626.             break;
  1627.         case CAT145_BLUE_TITLE:
  1628.             text_color = gui_color(0, 0, 196);
  1629.             break;
  1630.         case CAT145_RED_TITLE:
  1631.             text_color = gui_color(196, 0, 0);
  1632.             break;
  1633.         case CAT145_GREEN_TITLE:
  1634.             text_color = gui_color(0, 196, 0);
  1635.             break;
  1636.         default:
  1637.             text_color = gui_color(0, 0, 0);
  1638.     }
  1639.     gui_set_font(&MMI_default_font);
  1640.     gui_set_text_color(text_color);
  1641.     /* MTK Elvis for R2L characters */
  1642.     if (r2lMMIFlag)
  1643.     {
  1644.         gui_move_text_cursor(cat145_message_title_x + gui_get_string_width((UI_string_type) MMI_message_string), y);
  1645.     }
  1646.     else
  1647.     {
  1648.         gui_move_text_cursor(cat145_message_title_x, y);
  1649.     }
  1650.     /* MTk end */
  1651.     gui_print_text(MMI_message_string);
  1652.     y += cat145_h2;
  1653.     gui_move_multi_line_input_box(&MMI_multiline_inputbox, MMI_multiline_inputbox.x, y);
  1654.     gui_show_multi_line_input_box(&MMI_multiline_inputbox);
  1655.     gdi_layer_pop_clip();
  1656. }
  1657. /*****************************************************************************
  1658.  * FUNCTION
  1659.  *  cat145_previous_line
  1660.  * DESCRIPTION
  1661.  *  
  1662.  * PARAMETERS
  1663.  *  void
  1664.  * RETURNS
  1665.  *  void
  1666.  *****************************************************************************/
  1667. void cat145_previous_line(void)
  1668. {
  1669.     /*----------------------------------------------------------------*/
  1670.     /* Local Variables                                                */
  1671.     /*----------------------------------------------------------------*/
  1672.     S32 vbar_x = 0, vbar_button_x = 0;
  1673.     /*----------------------------------------------------------------*/
  1674.     /* Code Body                                                      */
  1675.     /*----------------------------------------------------------------*/
  1676.     gui_set_clip(0, cat145_clip_y1, UI_device_width - 1, cat145_clip_y2);
  1677.     gui_draw_filled_area(0, 0, UI_device_width - 1, UI_device_height - 1, current_MMI_theme->general_background_filler);
  1678.     cat145_y += CAT145_SCROLL_DY;
  1679.     if (cat145_y > 0)
  1680.     {
  1681.         cat145_y = 0;
  1682.     }
  1683.     gui_set_vertical_scrollbar_value(&cat145_vbar, -cat145_y);
  1684.     /* MTK Elvis for R2L characters */
  1685.     if (r2lMMIFlag)
  1686.     {
  1687.         vbar_x = cat145_vbar.x;
  1688.         vbar_button_x = cat145_vbar.scroll_button.x;
  1689.         cat145_vbar.x = cat145_vbar.x + cat145_vbar.width - (UI_device_width - 1);
  1690.         cat145_vbar.scroll_button.x =
  1691.             cat145_vbar.scroll_button.x + cat145_vbar.scroll_button.width - (UI_device_width - 1);
  1692.         gui_show_vertical_scrollbar(&cat145_vbar);
  1693.     }
  1694.     else
  1695.     {
  1696.         gui_show_vertical_scrollbar(&cat145_vbar);
  1697.     }
  1698.     /* MTK end */
  1699.     if (r2lMMIFlag)
  1700.     {
  1701.         cat145_vbar.x = vbar_x;
  1702.         cat145_vbar.scroll_button.x = vbar_button_x;
  1703.     }
  1704.     cat145_display();
  1705.     gdi_layer_blt_previous(0, cat145_clip_y1, UI_device_width - 1, cat145_clip_y2);
  1706. }
  1707. /*****************************************************************************
  1708.  * FUNCTION
  1709.  *  cat145_next_line
  1710.  * DESCRIPTION
  1711.  *  
  1712.  * PARAMETERS
  1713.  *  void
  1714.  * RETURNS
  1715.  *  void
  1716.  *****************************************************************************/
  1717. void cat145_next_line(void)
  1718. {
  1719.     /*----------------------------------------------------------------*/
  1720.     /* Local Variables                                                */
  1721.     /*----------------------------------------------------------------*/
  1722.     S32 vbar_x = 0, vbar_button_x = 0;
  1723.     /*----------------------------------------------------------------*/
  1724.     /* Code Body                                                      */
  1725.     /*----------------------------------------------------------------*/
  1726.     gui_set_clip(0, cat145_clip_y1, UI_device_width - 1, cat145_clip_y2);
  1727.     gui_draw_filled_area(0, 0, UI_device_width - 1, UI_device_height - 1, current_MMI_theme->general_background_filler);
  1728.     cat145_y -= CAT145_SCROLL_DY;
  1729.     if (cat145_y < -(cat145_total_height - cat145_available_height))
  1730.     {
  1731.         cat145_y = -(cat145_total_height - cat145_available_height);
  1732.     }
  1733.     gui_set_vertical_scrollbar_value(&cat145_vbar, -cat145_y);
  1734.     /* MTK Elvis for R2L characters */
  1735.     if (r2lMMIFlag)
  1736.     {
  1737.         vbar_x = cat145_vbar.x;
  1738.         vbar_button_x = cat145_vbar.scroll_button.x;
  1739.         cat145_vbar.x = cat145_vbar.x + cat145_vbar.width - (UI_device_width - 1);
  1740.         cat145_vbar.scroll_button.x =
  1741.             cat145_vbar.scroll_button.x + cat145_vbar.scroll_button.width - (UI_device_width - 1);
  1742.         gui_show_vertical_scrollbar(&cat145_vbar);
  1743.     }
  1744.     else
  1745.     {
  1746.         gui_show_vertical_scrollbar(&cat145_vbar);
  1747.     }
  1748.     /* MTK end */
  1749.     if (r2lMMIFlag)
  1750.     {
  1751.         cat145_vbar.x = vbar_x;
  1752.         cat145_vbar.scroll_button.x = vbar_button_x;
  1753.     }
  1754.     cat145_display();
  1755.     gdi_layer_blt_previous(0, cat145_clip_y1, UI_device_width - 1, cat145_clip_y2);
  1756. }
  1757. /*****************************************************************************
  1758.  * FUNCTION
  1759.  *  cat145_keyboard_key_handler
  1760.  * DESCRIPTION
  1761.  *  
  1762.  * PARAMETERS
  1763.  *  vkey_code       [IN]        
  1764.  *  key_state       [IN]        
  1765.  * RETURNS
  1766.  *  void
  1767.  *****************************************************************************/
  1768. void cat145_keyboard_key_handler(S32 vkey_code, S32 key_state)
  1769. {
  1770. #if(MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32)
  1771.     /*----------------------------------------------------------------*/
  1772.     /* Local Variables                                                */
  1773.     /*----------------------------------------------------------------*/
  1774.     /*----------------------------------------------------------------*/
  1775.     /* Code Body                                                      */
  1776.     /*----------------------------------------------------------------*/
  1777.     if (key_state)
  1778.     {
  1779.         switch (vkey_code)
  1780.         {
  1781.             case 38:    /* up */
  1782.                 cat145_previous_line();
  1783.                 break;
  1784.             case 40:    /* down */
  1785.                 cat145_next_line();
  1786.                 break;
  1787.         }
  1788.     }
  1789. #else /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  1790.     UI_UNUSED_PARAMETER(vkey_code);
  1791.     UI_UNUSED_PARAMETER(key_state);
  1792. #endif /* (MMI_BUILD_TYPE == BUILD_TYPE_X86WIN32) */ 
  1793. }
  1794. /*****************************************************************************
  1795.  * FUNCTION
  1796.  *  DrawCate145CategoryControlArea
  1797.  * DESCRIPTION
  1798.  *  Draws the category145 category control area
  1799.  * PARAMETERS
  1800.  *  coordinate      [IN/OUT]        Coordinates of category controlled area.
  1801.  * RETURNS
  1802.  *  void
  1803.  *****************************************************************************/
  1804. void DrawCate145CategoryControlArea(dm_coordinates *coordinate)
  1805. {
  1806.     /*----------------------------------------------------------------*/
  1807.     /* Local Variables                                                */
  1808.     /*----------------------------------------------------------------*/
  1809.     /*----------------------------------------------------------------*/
  1810.     /* Code Body                                                      */
  1811.     /*----------------------------------------------------------------*/
  1812.     RedrawCategory145Screen();
  1813. }
  1814. /*****************************************************************************
  1815.  * FUNCTION
  1816.  *  RedrawCategory145Screen
  1817.  * DESCRIPTION
  1818.  *  Redraws the Delivery report screen
  1819.  * PARAMETERS
  1820.  *  void
  1821.  * RETURNS
  1822.  *  void
  1823.  *****************************************************************************/
  1824. void RedrawCategory145Screen(void)
  1825. {
  1826.     /*----------------------------------------------------------------*/
  1827.     /* Local Variables                                                */
  1828.     /*----------------------------------------------------------------*/
  1829.     S32 vbar_x = 0, vbar_button_x = 0;
  1830.     /*----------------------------------------------------------------*/
  1831.     /* Code Body                                                      */
  1832.     /*----------------------------------------------------------------*/
  1833.     if (cat145_scrollbar_flag)
  1834.     {
  1835.         /* MTK Elvis for R2L characters */
  1836.         if (r2lMMIFlag)
  1837.         {
  1838.             vbar_x = cat145_vbar.x;
  1839.             vbar_button_x = cat145_vbar.scroll_button.x;
  1840.             cat145_vbar.x = cat145_vbar.x + cat145_vbar.width - (UI_device_width - 1);
  1841.             cat145_vbar.scroll_button.x =
  1842.                 cat145_vbar.scroll_button.x + cat145_vbar.scroll_button.width - (UI_device_width - 1);
  1843.             gui_show_vertical_scrollbar(&cat145_vbar);
  1844.         }
  1845.         else
  1846.         {
  1847.             gui_show_vertical_scrollbar(&cat145_vbar);
  1848.         }
  1849.         /* MTK end */
  1850.         if (r2lMMIFlag)
  1851.         {
  1852.             cat145_vbar.x = vbar_x;
  1853.             cat145_vbar.scroll_button.x = vbar_button_x;
  1854.         }
  1855.     }
  1856.     cat145_display();
  1857. }
  1858. /*****************************************************************************
  1859.  * FUNCTION
  1860.  *  ChangeCategory145MessageString
  1861.  * DESCRIPTION
  1862.  *  
  1863.  * PARAMETERS
  1864.  *  new_string      [?]     
  1865.  * RETURNS
  1866.  *  void
  1867.  *****************************************************************************/
  1868. void ChangeCategory145MessageString(U8 *new_string)
  1869. {
  1870.     /*----------------------------------------------------------------*/
  1871.     /* Local Variables                                                */
  1872.     /*----------------------------------------------------------------*/
  1873.     /*----------------------------------------------------------------*/
  1874.     /* Code Body                                                      */
  1875.     /*----------------------------------------------------------------*/
  1876.     MMI_multiline_inputbox.text = (UI_buffer_type) new_string;
  1877.     MMI_multiline_inputbox.cursor_p = new_string;
  1878.     MMI_multiline_inputbox.flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1879.     gui_show_multi_line_input_box(&MMI_multiline_inputbox);
  1880.     MMI_multiline_inputbox.flags &= ~UI_MULTI_LINE_INPUT_BOX_DISABLE_DRAW;
  1881. }
  1882. /*****************************************************************************
  1883.  * FUNCTION
  1884.  *  ShowCategory145Screen
  1885.  * DESCRIPTION
  1886.  *  Displays the Delivery report screen
  1887.  * PARAMETERS
  1888.  *  title                   [IN]        Title for the screen
  1889.  *  title_icon              [IN]        Icon displayed with the title
  1890.  *  left_softkey            [IN]        Left softkey label
  1891.  *  left_softkey_icon       [IN]        Left softkey icon
  1892.  *  right_softkey           [IN]        Right softkey label
  1893.  *  right_softkey_icon      [IN]        Right softkey icon
  1894.  *  message_icon            [IN]        Icon displayed with the message
  1895.  *  message_title           [IN]        Colored text that appears above the message
  1896.  *  message                 [IN]        Message
  1897.  *  flags                   [IN]        Flags
  1898.  *  history_buffer          [IN]        History buffer
  1899.  * RETURNS
  1900.  *  void
  1901.  *****************************************************************************/
  1902. void ShowCategory145Screen(
  1903.         U8 *title,
  1904.         U16 title_icon,
  1905.         U16 left_softkey,
  1906.         U16 left_softkey_icon,
  1907.         U16 right_softkey,
  1908.         U16 right_softkey_icon,
  1909.         U16 message_icon,
  1910.         U8 *message_title,
  1911.         U8 *message,
  1912.         U32 flags,
  1913.         U8 *history_buffer)
  1914. {
  1915.     /*----------------------------------------------------------------*/
  1916.     /* Local Variables                                                */
  1917.     /*----------------------------------------------------------------*/
  1918.     dm_data_struct dm_data;
  1919.     S32 l, width, height, content_width;
  1920.     /*----------------------------------------------------------------*/
  1921.     /* Code Body                                                      */
  1922.     /*----------------------------------------------------------------*/
  1923.     gdi_layer_lock_frame_buffer();
  1924.     MMI_menu_shortcut_number = -1;
  1925.     MMI_disable_title_shortcut_display = 1;
  1926.     change_left_softkey(left_softkey, left_softkey_icon);
  1927.     change_right_softkey(right_softkey, right_softkey_icon);
  1928.     change_left_softkey(left_softkey, left_softkey_icon);
  1929.     change_right_softkey(right_softkey, right_softkey_icon);
  1930.     SetupCategoryKeyHandlers();
  1931.     cat145_scrollbar_flag = 0;
  1932.     gui_create_vertical_scrollbar(
  1933.         &cat145_vbar,
  1934.         UI_device_width - current_MMI_theme->scrollbar_size,
  1935.         (MMI_title_y + MMI_title_height),
  1936.         current_MMI_theme->scrollbar_size,
  1937.         (UI_device_height - (MMI_title_y + MMI_title_height) - MMI_button_bar_height + 1));
  1938.     content_width = UI_device_width;
  1939.     l = gui_strlen((UI_string_type) message);
  1940.     create_multiline_inputbox_set_buffer((UI_string_type) message, l, l, 0);
  1941.     resize_multiline_inputbox(content_width, MMI_content_height);
  1942.     show_multiline_inputbox_no_draw();
  1943.     resize_multiline_inputbox(MMI_multiline_inputbox.width, MMI_multiline_inputbox.text_height + 6);
  1944.     cat145_h3 = MMI_multiline_inputbox.height;
  1945.     MMI_multiline_inputbox.flags |= UI_MULTI_LINE_INPUT_BOX_DISABLE_CURSOR_DRAW
  1946.         | UI_MULTI_LINE_INPUT_BOX_VIEW_MODE
  1947.         | UI_MULTI_LINE_INPUT_BOX_DISABLE_BACKGROUND
  1948.         | UI_MULTI_LINE_INPUT_BOX_DISABLE_SCROLLBAR
  1949.         | UI_MULTI_LINE_INPUT_BOX_USE_PRESET_CLIPPING | UI_MULTI_LINE_INPUT_BOX_CENTER_JUSTIFY;
  1950.     MMI_message_string = (UI_string_type) message_title;
  1951.     gui_set_font(&MMI_default_font);
  1952.     gui_measure_string(MMI_message_string, &width, &height);
  1953.     cat145_h2 = height;
  1954.     cat145_message_title_x = (content_width >> 1) - (width >> 1);
  1955.     MMI_title_string = (UI_string_type) title;
  1956.     MMI_title_icon = (PU8) get_image(title_icon);
  1957.     MMI_message_icon = (PU8) get_image(message_icon);
  1958.     gui_measure_image(MMI_message_icon, &width, &height);
  1959.     cat145_h1 = height + 4;
  1960.     cat145_image_x = (content_width >> 1) - (width >> 1);
  1961.     cat145_flags = flags;
  1962.     cat145_y = 0;
  1963.     cat145_clip_x1 = 0;
  1964.     cat145_clip_x2 = content_width;
  1965.     cat145_clip_y1 = (MMI_title_y + MMI_title_height);
  1966.     cat145_clip_y2 = UI_device_height - MMI_button_bar_height - 1;
  1967.     cat145_total_height = (cat145_h1 + cat145_h2 + cat145_h3);
  1968.     cat145_available_height = cat145_clip_y2 - cat145_clip_y1 + 1;
  1969.     if (cat145_total_height > cat145_available_height)
  1970.     {
  1971.         cat145_scrollbar_flag = 1;
  1972.         register_keyboard_key_handler(cat145_keyboard_key_handler);
  1973.         SetKeyHandler(cat145_previous_line, KEY_UP_ARROW, KEY_EVENT_DOWN);
  1974.         SetKeyHandler(cat145_next_line, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
  1975.         SetKeyHandler(cat145_previous_line, KEY_VOL_UP, KEY_EVENT_DOWN);
  1976.         SetKeyHandler(cat145_next_line, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1977.         gui_set_vertical_scrollbar_range(&cat145_vbar, cat145_total_height);
  1978.         gui_set_vertical_scrollbar_scale(&cat145_vbar, cat145_available_height);
  1979.         gui_set_vertical_scrollbar_value(&cat145_vbar, -cat145_y);
  1980.     }
  1981.     else
  1982.     {
  1983.         cat145_y = (cat145_available_height >> 1) - (cat145_total_height >> 1);
  1984.     }
  1985.     gdi_layer_unlock_frame_buffer();
  1986.     ExitCategoryFunction = ExitCategory145Screen;
  1987.     dm_setup_category_functions(dm_redraw_category_screen, dummy_get_history, dummy_get_history_size);
  1988.     dm_register_category_controlled_callback(DrawCate145CategoryControlArea);
  1989.     dm_data.s32ScrId = (S32) GetActiveScreenId();
  1990.     dm_data.s32CatId = MMI_CATEGORY145_ID;
  1991.     dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND;
  1992.     dm_setup_data(&dm_data);
  1993.     dm_redraw_category_screen();
  1994. }
  1995. /*****************************************************************************
  1996.  * FUNCTION
  1997.  *  ExitCategory145Screen
  1998.  * DESCRIPTION
  1999.  *  Exits the Delivery report screen
  2000.  * PARAMETERS
  2001.  *  void
  2002.  * RETURNS
  2003.  *  void
  2004.  *****************************************************************************/
  2005. void ExitCategory145Screen(void)
  2006. {
  2007.     /*----------------------------------------------------------------*/
  2008.     /* Local Variables                                                */
  2009.     /*----------------------------------------------------------------*/
  2010.     /*----------------------------------------------------------------*/
  2011.     /* Code Body                                                      */
  2012.     /*----------------------------------------------------------------*/
  2013.     cat145_scrollbar_flag = 0;
  2014.     reset_softkeys();
  2015.     reset_multiline_inputbox();
  2016.     ExitCategoryFunction = MMI_dummy_function;
  2017.     RedrawCategoryFunction = MMI_dummy_function;
  2018.     GetCategoryHistory = dummy_get_history;
  2019.     GetCategoryHistorySize = dummy_get_history_size;
  2020. }
  2021. /*****************************************************************************
  2022.  * FUNCTION
  2023.  *  GetCategory145HistorySize
  2024.  * DESCRIPTION
  2025.  *  Gets the size of the history buffer for the Delivery report screen
  2026.  * PARAMETERS
  2027.  *  void
  2028.  * RETURNS
  2029.  *  size in U8s of the history buffer
  2030.  *****************************************************************************/
  2031. S32 GetCategory145HistorySize(void)
  2032. {
  2033.     /*----------------------------------------------------------------*/
  2034.     /* Local Variables                                                */
  2035.     /*----------------------------------------------------------------*/
  2036.     /*----------------------------------------------------------------*/
  2037.     /* Code Body                                                      */
  2038.     /*----------------------------------------------------------------*/
  2039.     return (0);
  2040. }
  2041. /*****************************************************************************
  2042.  * FUNCTION
  2043.  *  GetCategory145History
  2044.  * DESCRIPTION
  2045.  *  Gets the history buffer for the Delivery report screen
  2046.  * PARAMETERS
  2047.  *  history_buffer      [IN]        Is the buffer into which the history data is stored (pre-allocated)
  2048.  * RETURNS
  2049.  *  Pointer to the history buffer
  2050.  *****************************************************************************/
  2051. U8 *GetCategory145History(U8 *history_buffer)
  2052. {
  2053.     /*----------------------------------------------------------------*/
  2054.     /* Local Variables                                                */
  2055.     /*----------------------------------------------------------------*/
  2056.     /*----------------------------------------------------------------*/
  2057.     /* Code Body                                                      */
  2058.     /*----------------------------------------------------------------*/
  2059.     return (history_buffer);
  2060. }