gui_fixed_menus.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:255k
源码类别:
MTK
开发平台:
C/C++
- /* Menu rotation */
- if ((m->flags & UI_MATRIX_MENU_VERTICAL_TRIGGER) && m->highlighted_row <= 0)
- {
- if (m->trigger_top_function)
- {
- m->trigger_top_function();
- }
- return; /* exit point */
- }
- else if (m->highlighted_row <= 0)
- {
- m->highlighted_row = m->n_rows - 1;
- /* matrix mainmenu vertical loop 1<->4<->7<->2<->5<->8... */
- if (m->flags & UI_MATRIX_MENU_VERTICAL_LOOP)
- {
- if (m->highlighted_column == 0)
- {
- m->highlighted_column = m->displayed_columns - 1;
- }
- else
- {
- m->highlighted_column -= 1;
- }
- }
- /* To avoid the blcok cursor go to non-existed item. */
- m->highlighted_item = (m->highlighted_row * m->n_columns) + m->highlighted_column;
- /* To support that a row is not full of items */
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- if (m->highlighted_item > (m->n_items - 1))
- {
- m->highlighted_row -= 1;
- m->highlighted_item -= m->n_columns;
- }
- m->first_displayed_row = m->highlighted_row - m->displayed_rows + 1;
- if (m->first_displayed_row < 0)
- {
- m->first_displayed_row = 0;
- }
- }
- else
- {
- m->highlighted_row--;
- if (m->highlighted_row < m->first_displayed_row)
- {
- m->first_displayed_row = m->highlighted_row;
- }
- }
- m->highlighted_item = (m->highlighted_row * m->n_columns) + m->highlighted_column;
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_next_row
- * DESCRIPTION
- * Highlights an item in the next row
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_next_row(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item;
- S32 old_highlighted_row;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- old_highlighted_row = m->highlighted_row;
- old_highlighted_item = m->highlighted_item;
- /* Menu rotation */
- if ((m->flags & UI_MATRIX_MENU_VERTICAL_TRIGGER) && m->highlighted_row >= (m->n_rows - 1))
- {
- if (m->trigger_bottom_function)
- {
- m->trigger_bottom_function();
- }
- return; /* exit point */
- }
- else if (m->highlighted_row >= (m->n_rows - 1))
- {
- m->highlighted_row = 0;
- m->first_displayed_row = 0;
- /* matrix mainmenu vertical loop 1<->4<->7<->2<->5<->8... */
- if (m->flags & UI_MATRIX_MENU_VERTICAL_LOOP)
- {
- m->highlighted_column += 1;
- if (m->highlighted_column >= m->displayed_columns)
- {
- m->highlighted_column = 0;
- }
- }
- }
- else
- {
- m->highlighted_row++;
- if (m->highlighted_row > (m->first_displayed_row + m->displayed_rows - 1))
- {
- m->first_displayed_row = (m->highlighted_row - m->displayed_rows + 1);
- if (m->first_displayed_row > (m->n_rows - m->displayed_rows))
- {
- m->first_displayed_row = (m->n_rows - m->displayed_rows);
- }
- }
- }
- m->highlighted_item = (m->highlighted_row * m->n_columns) + m->highlighted_column;
- /* to support that a row is not full of items */
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- if (m->highlighted_item > (m->n_items - 1)) /* revert */
- {
- m->highlighted_row = 0;
- /* matrix mainmenu vertical loop 1<->4<->7<->2<->5<->8... */
- if (m->flags & UI_MATRIX_MENU_VERTICAL_LOOP)
- {
- m->highlighted_column += 1;
- if (m->highlighted_column >= m->displayed_columns)
- {
- m->highlighted_column = 0;
- }
- }
- m->highlighted_item = m->highlighted_column;
- m->first_displayed_row = 0;
- }
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_row
- * DESCRIPTION
- * Highlights an row
- *
- * Does not redraw the fixed matrix menu
- * Used in touch screen
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * r [IN] Row index
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_row(fixed_matrix_menu *m, S32 r)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item = m->highlighted_item;
- S32 highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((r < 0) || (r > (m->n_rows - 1)) || (r == m->highlighted_row))
- {
- return;
- }
- highlighted_item = m->highlighted_item;
- highlighted_item += (r - m->highlighted_row) * m->n_columns;
- if (highlighted_item >= m->n_items)
- {
- highlighted_item = m->n_items - 1;
- }
- m->highlighted_item = highlighted_item;
- gui_fixed_matrix_menu_locate_highlighted_item(m);
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_previous_column
- * DESCRIPTION
- * Highlights an item in the previous column
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_previous_column(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item = m->highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* For menu rotation */
- if (m->highlighted_column <= 0)
- {
- m->highlighted_column = m->n_columns - 1;
- m->first_displayed_column = m->highlighted_column - m->displayed_columns + 1;
- }
- else
- {
- m->highlighted_column--;
- if (m->highlighted_column < m->first_displayed_column)
- {
- m->first_displayed_column = m->highlighted_column;
- }
- }
- m->highlighted_item = (m->highlighted_row * m->n_columns) + m->highlighted_column;
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_next_column
- * DESCRIPTION
- * Highlights an item in the next column
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_next_column(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item;
- S32 old_highlighted_column;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- old_highlighted_column = m->highlighted_column;
- old_highlighted_item = m->highlighted_item;
- /* for menu rotation */
- if (m->highlighted_column >= (m->n_columns - 1))
- {
- m->highlighted_column = 0;
- m->first_displayed_column = 0;
- }
- else
- {
- m->highlighted_column++;
- if (m->highlighted_column > (m->first_displayed_column + m->displayed_columns - 1))
- {
- m->first_displayed_column = (m->highlighted_column - m->displayed_columns + 1);
- if (m->first_displayed_column > (m->n_columns - m->displayed_columns))
- {
- m->first_displayed_column = (m->n_columns - m->displayed_columns);
- }
- }
- }
- m->highlighted_item = (m->highlighted_row * m->n_columns) + m->highlighted_column;
- if (m->highlighted_item > (m->n_items - 1)) /* revert */
- {
- m->highlighted_column = old_highlighted_column;
- m->highlighted_item = old_highlighted_item;
- }
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_column
- * DESCRIPTION
- * Highlights an column
- *
- * Does not redraw the fixed matrix menu
- * Used in touch screen
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * c [IN] Column index
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_column(fixed_matrix_menu *m, S32 c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item = m->highlighted_item;
- S32 highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((c < 0) || (c > (m->n_columns - 1)) || (c == m->highlighted_column))
- {
- return;
- }
- highlighted_item = m->highlighted_item;
- highlighted_item += c - m->highlighted_column;
- if (highlighted_item >= m->n_items)
- {
- highlighted_item = m->n_items - 1;
- }
- m->highlighted_item = highlighted_item;
- gui_fixed_matrix_menu_locate_highlighted_item(m);
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_first_item
- * DESCRIPTION
- * Highlights the first item
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_first_item(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item = m->highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->highlighted_column = 0;
- m->highlighted_row = 0;
- m->first_displayed_column = 0;
- m->first_displayed_row = 0;
- m->highlighted_item = 0;
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_last_item
- * DESCRIPTION
- * Highlights the last item
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_last_item(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item = m->highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->highlighted_item = m->n_items - 1;
- gui_fixed_matrix_menu_locate_highlighted_item(m);
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_next_page
- * DESCRIPTION
- * Highlights an item in the next page
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_next_page(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item;
- S32 old_highlighted_row;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- old_highlighted_row = m->highlighted_row;
- old_highlighted_item = m->highlighted_item;
- if (m->highlighted_row >= (m->n_rows - 1))
- {
- return;
- }
- m->first_displayed_row += m->displayed_rows;
- if (m->first_displayed_row > (m->n_rows - m->displayed_rows))
- {
- m->first_displayed_row = (m->n_rows - m->displayed_rows);
- }
- m->highlighted_row = m->first_displayed_row + m->displayed_rows - 1;
- m->highlighted_item = (m->highlighted_row * m->n_columns) + m->highlighted_column;
- if (m->highlighted_item > (m->n_items - 1)) /* revert */
- {
- m->highlighted_row = old_highlighted_row;
- m->highlighted_item = old_highlighted_item;
- }
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_previous_page
- * DESCRIPTION
- * Highlights an item in the previous page
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_previous_page(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- old_highlighted_item = m->highlighted_item;
- if (m->highlighted_row <= 0)
- {
- return;
- }
- m->first_displayed_row -= m->displayed_rows;
- if (m->first_displayed_row < 0)
- {
- m->first_displayed_row = 0;
- }
- m->highlighted_row = m->first_displayed_row;
- m->highlighted_item = (m->highlighted_row * m->n_columns) + m->highlighted_column;
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_goto_item
- * DESCRIPTION
- * Highlights a particular item
- *
- * Does not redraw the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * i [IN] Is the index of the item to be highlighted (zero based)
- * RETURNS
- * void
- *****************************************************************************/
- void gui_fixed_matrix_menu_goto_item(fixed_matrix_menu *m, S32 i)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 old_highlighted_item = m->highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((i < 0) || (i > (m->n_items - 1)))
- {
- return;
- }
- m->highlighted_item = i;
- gui_fixed_matrix_menu_locate_highlighted_item(m);
- if (old_highlighted_item != m->highlighted_item)
- {
- if ((old_highlighted_item >= 0) && (old_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[old_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(old_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_reset_fixed_matrix_col_rows
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_reset_fixed_matrix_col_rows(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* m->n_columns=0; */
- m->n_rows = 0;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_auto_disable_scrollbar
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * RETURNS
- *
- *****************************************************************************/
- S32 gui_fixed_matrix_auto_disable_scrollbar(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (!(m->flags & UI_MATRIX_MENU_DISABLE_SCROLLBAR))
- {
- if (m->flags & UI_MATRIX_MENU_AUTO_DISABLE_SCROLLBAR)
- {
- return 1;
- }
- else
- {
- return -1;
- }
- }
- else
- {
- return -1;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * mtk_UI_show_fixed_matrix_menu
- * DESCRIPTION
- * Displays the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void mtk_UI_show_fixed_matrix_menu(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, hilited_x1, hilited_x2, hilited_y1, hilited_y2;
- S32 new_hilited_x1, new_hilited_y1, new_column, new_row;
- S32 xoff, yoff, xoff2, yoff2, width, height;
- S32 first_displayed_item, last_displayed_item;
- U8 show_vbar = 0, show_hbar = 0;
- S32 xPos, xPos2;
- S32 yPos, yPos2;
- S32 vbar_x = 0, vbar_button_x = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- first_displayed_item = m->first_displayed_row * m->n_columns;
- last_displayed_item = first_displayed_item + (m->displayed_rows * m->n_columns);
- width = m->width;
- height = m->height;
- if (m->flags & UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR)
- {
- show_vbar = 1;
- }
- if (m->flags & UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR)
- {
- show_hbar = 1;
- }
- if (show_vbar)
- {
- width -= m->vbar.width - 1;
- }
- if (show_hbar)
- {
- height -= m->hbar.height - 1;
- }
- xoff = (width - (m->item_width * m->displayed_columns)) / (m->displayed_columns + 1);
- yoff = (height - (m->item_height * m->displayed_rows)) / (m->displayed_rows + 1);
- new_row = ((m->last_highlighted_item) / m->n_columns);
- new_column = m->last_highlighted_item - (new_row * m->n_rows);
- x1 = m->x;
- y1 = m->y;
- if (show_vbar && r2lMMIFlag)
- {
- x1 += m->vbar.width;
- }
- new_hilited_x1 = x1 + xoff + (new_column - m->first_displayed_column) * (m->item_width + xoff);
- new_hilited_y1 = y1 + yoff + (new_row - m->first_displayed_row) * (m->item_height + yoff);
- /* if ( m->last_highlighted_item<first_displayed_item || m->last_highlighted_item>last_displayed_item ) */
- if ((m->last_hilited_x != new_hilited_x1 && m->last_hilited_y != new_hilited_y1) ||
- (m->highlighted_item - m->last_highlighted_item) >= (m->displayed_columns * m->displayed_rows))
- {
- m->last_highlighted_item = -1;
- gui_show_fixed_matrix_menu(m);
- return;
- }
- if (m->highlighted_item_width > m->item_width)
- {
- xoff2 = (m->highlighted_item_width - m->item_width);
- }
- else
- {
- xoff2 = 0;
- }
- if (m->highlighted_item_height > m->item_height)
- {
- yoff2 = (m->highlighted_item_height - m->item_height);
- }
- else
- {
- yoff2 = 0;
- }
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- gdi_layer_push_clip();
- //gdi_layer_set_clip(m->last_hilited_x-xoff2, yPos,m->last_hilited_x+xoff2+m->highlighted_item_height, yPos2);
- //gdi_image_cache_bmp_draw(m->last_hilited_x-xoff2, yPos, &m->buffer);
- gdi_layer_set_clip(m->cache_bmp_x1, m->cache_bmp_y1, m->cache_bmp_x2, m->cache_bmp_y2);
- #ifdef __MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__
- MMI_ASSERT((m->cache_bmp_x2 - m->cache_bmp_x1 + 1) * (m->cache_bmp_y2 - m->cache_bmp_y1 +
- 1) * gdi_layer_get_bit_per_pixel() >> 3 <=
- OPTIMIZE_MM_BUF_SIZE);
- #endif /* __MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__ */
- gdi_image_cache_bmp_draw(m->cache_bmp_x1, m->cache_bmp_y1, &m->buffer);
- gdi_layer_pop_clip();
- hilited_x1 = x1 + xoff + (m->highlighted_column - m->first_displayed_column) * (m->item_width + xoff);
- hilited_y1 = y1 + yoff + (m->highlighted_row - m->first_displayed_row) * (m->item_height + yoff);
- hilited_x2 = hilited_x1 + m->highlighted_item_width;
- hilited_y2 = hilited_y1 + m->highlighted_item_height;
- xPos = hilited_x1 - (xoff2 >> 1);
- xPos2 = xPos + m->highlighted_item_width - 1;
- yPos = hilited_y1 - (yoff2 >> 1);
- yPos2 = yPos + m->highlighted_item_height - 1;
- if (xPos < m->x)
- {
- xPos = m->x;
- xPos2 = xPos + m->highlighted_item_width - 1;
- }
- if (xPos2 > m->x + m->width - 1)
- {
- xPos2 = m->x + m->width - 1;
- xPos = xPos2 - m->highlighted_item_width + 1;
- }
- if (yPos < m->y)
- {
- yPos = m->y;
- yPos2 = yPos + m->highlighted_item_height - 1;
- }
- if (yPos2 > m->y + m->height - 1)
- {
- yPos2 = m->y + m->height - 1;
- yPos = yPos2 - m->highlighted_item_height + 1;
- }
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- gdi_layer_push_clip();
- //gdi_layer_set_clip(hilited_x1-xoff2, yPos, hilited_x2+xoff2, yPos2);
- //gdi_image_cache_bmp_get(hilited_x1-xoff2, yPos, hilited_x2+xoff2, yPos2, &m->buffer);
- gdi_layer_set_clip(xPos, yPos, xPos2, yPos2);
- #ifdef __MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__
- MMI_ASSERT((xPos2 - xPos + 1) * (yPos2 - yPos + 1) * gdi_layer_get_bit_per_pixel() >> 3 <= OPTIMIZE_MM_BUF_SIZE);
- #endif
- gdi_image_cache_bmp_get(xPos, yPos, xPos2, yPos2, &m->buffer);
- gdi_layer_pop_clip();
- m->cache_bmp_x1 = xPos;
- m->cache_bmp_x2 = xPos2;
- m->cache_bmp_y1 = yPos;
- m->cache_bmp_y2 = yPos2;
- m->last_hilited_x = hilited_x1;
- m->last_hilited_y = hilited_y1;
- m->item_display_function(m->items[m->highlighted_item], m->common_item_data, hilited_x1, hilited_y1);
- if (show_vbar)
- {
- gui_set_vertical_scrollbar_range(&m->vbar, m->n_rows);
- gui_set_vertical_scrollbar_scale(&m->vbar, m->displayed_rows);
- gui_set_vertical_scrollbar_value(&m->vbar, m->first_displayed_row);
- if (r2lMMIFlag)
- {
- vbar_x = m->vbar.x;
- vbar_button_x = m->vbar.scroll_button.x;
- m->vbar.x = m->vbar.x + m->vbar.width - m->width;
- m->vbar.scroll_button.x = m->vbar.scroll_button.x + m->vbar.scroll_button.width - m->width;
- gui_show_vertical_scrollbar(&m->vbar);
- m->vbar.x = vbar_x;
- m->vbar.scroll_button.x = vbar_button_x;
- }
- else
- {
- gui_show_vertical_scrollbar(&m->vbar);
- }
- }
- if (show_hbar)
- {
- gui_set_horizontal_scrollbar_range(&m->hbar, m->n_columns);
- gui_set_horizontal_scrollbar_scale(&m->hbar, m->displayed_columns);
- gui_set_horizontal_scrollbar_value(&m->hbar, m->first_displayed_column);
- gui_show_horizontal_scrollbar(&m->hbar);
- }
- }
- #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
- /*****************************************************************************
- * FUNCTION
- * gui_setup_fixed_matrix_menu_ind_area
- * DESCRIPTION
- *
- * PARAMETERS
- * ind_area [?]
- * x [IN]
- * y [IN]
- * string [?]
- * img_id [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_setup_fixed_matrix_menu_ind_area(gui_matrix_ind_area_struct *ind_area, S32 x, S32 y, U8 *string, U16 img_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- ind_area->x = x;
- ind_area->y = y;
- ind_area->string = string;
- ind_area->img_id = img_id;
- if (string != NULL && img_id != 0)
- {
- MMI_ASSERT(0);
- }
- #if (0)
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* (0) */
- ind_area->width = 20;
- ind_area->height = 20;
- }
- #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */
- /*****************************************************************************
- * FUNCTION
- * gui_show_fixed_matrix_menu
- * DESCRIPTION
- * Displays the fixed matrix menu
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_show_fixed_matrix_menu(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, x2, y2, xoff, yoff, width, height;
- UI_filled_area *f;
- S32 i, j, k, o;
- S32 cx1, cy1, cx2, cy2;
- S32 tx1, ty1, tx2, ty2;
- S32 ix, iy, iwidth, iheight, ix2, iy2;
- S32 vbar_x = 0, vbar_button_x = 0;
- U8 show_vbar = 0, show_hbar = 0;
- S32 highlite_x = 0, highlite_y = 0; /* Show selected item after all other items displayed //111605 warning Calvin */
- #ifdef __MMI_MATRIX_MAIN_MENU_OPTIMIZE__
- S32 xoff2, yoff2;
- S32 xPos, xPos2, yPos, yPos2;
- #endif /* __MMI_MATRIX_MAIN_MENU_OPTIMIZE__ */
- #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
- MMI_BOOL has_previous_page = MMI_FALSE, has_next_page = MMI_FALSE;
- #endif
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gui_get_clip(&cx1, &cy1, &cx2, &cy2);
- gui_get_text_clip(&tx1, &ty1, &tx2, &ty2);
- if (m->flags & UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR)
- {
- show_vbar = 1;
- }
- if (m->flags & UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR)
- {
- show_hbar = 1;
- }
- if (r2lMMIFlag)
- {
- if (show_vbar)
- {
- x1 = m->x + m->vbar.width;
- }
- else
- {
- x1 = m->x;
- }
- x2 = UI_device_width;
- }
- else
- {
- x1 = m->x;
- x2 = x1 + m->width - 1;
- }
- y1 = m->y;
- #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
- if (m->flags & UI_MATRIX_MENU_SHOW_IND_AREA)
- {
- y2 = y1 + m->height - 1 - MMI_BI_DEGREE_MAIN_MENU_ARROW_BAR_HEIGHT;
- }
- else
- #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */
- y2 = y1 + m->height - 1;
- if (m->flags & UI_LIST_MENU_STATE_FOCUSSED)
- {
- f = m->focussed_filler;
- }
- else
- {
- f = m->normal_filler;
- }
- if (m->flags & UI_MATRIX_MENU_DISABLE_BACKGROUND)
- {
- gdi_layer_push_clip();
- gdi_layer_set_clip(x1, y1, x2, y2);
- gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
- gdi_layer_pop_clip();
- }
- else
- {
- gui_set_clip(x1, y1, x2, y2);
- if (wgui_is_wallpaper_on_bottom() == MMI_TRUE)
- {
- gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT);
- #if defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__)
- /* gui_set_transparent_source_layer(dm_get_scr_bg_layer());//should remove */
- #endif
- }
- else
- {
- UI_filled_area tmp_f = *f;
- /* In current implementation, matrix menu does not support bordered background
- very well because highlighted item is overlapped with border. */
- tmp_f.flags &= ~(UI_FILLED_AREA_SINGLE_BORDER | UI_FILLED_AREA_DOUBLE_BORDER);
- gui_draw_filled_area(x1, y1, x2, y2, &tmp_f);
- }
- }
- #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
- /* Start Draw Indication Arrows. */
- if (MMI_current_menu_type == LIST_MATRIX_MENU)
- {
- if (m->displayed_rows < m->n_rows)
- {
- S32 hor_gap = 0;
- has_previous_page = MMI_FALSE;
- has_next_page = MMI_FALSE;
- gdi_layer_push_clip();
- gdi_layer_reset_clip();
- if (m->first_displayed_row > 0) /* previous page exists */
- {
- has_previous_page = MMI_TRUE;
- }
- if ((m->first_displayed_row + m->displayed_rows - 1) < m->n_rows - 1) /* next page exists */
- {
- has_next_page = MMI_TRUE;
- }
- if (has_previous_page && has_next_page)
- {
- hor_gap = (m->width - MMI_BI_DEGREE_MAIN_MENU_NAVI_BAR_IND_BG_SIZE * 2) / 3;
- gui_setup_fixed_matrix_menu_ind_area(
- &(m->up_ind_area),
- m->x + hor_gap,
- y2 + 1,
- (U8*) get_string(26000),
- 0);
- gui_setup_fixed_matrix_menu_ind_area(
- &(m->down_ind_area),
- m->x + (hor_gap * 2) + MMI_BI_DEGREE_MAIN_MENU_ARROW_IND_SIZE,
- y2 + 1,
- (U8*) get_string(26004),
- 0);
- gdi_draw_solid_rect(
- m->x + hor_gap,
- y2 + 1,
- m->x + hor_gap + MMI_BI_DEGREE_MAIN_MENU_ARROW_IND_SIZE,
- y2 + MMI_BI_DEGREE_MAIN_MENU_ARROW_BAR_HEIGHT,
- GDI_COLOR_GREEN);
- gdi_draw_solid_rect(
- m->x + (hor_gap * 2) + MMI_BI_DEGREE_MAIN_MENU_ARROW_IND_SIZE,
- y2 - MMI_BI_DEGREE_MAIN_MENU_ARROW_BAR_HEIGHT + 1,
- m->x + ((hor_gap + MMI_BI_DEGREE_MAIN_MENU_ARROW_IND_SIZE) * 2),
- y2,
- GDI_COLOR_GREEN);
- }
- else if (has_previous_page)
- {
- hor_gap = (m->width - MMI_BI_DEGREE_MAIN_MENU_NAVI_BAR_IND_BG_SIZE) >> 1;
- gui_setup_fixed_matrix_menu_ind_area(
- &(m->up_ind_area),
- m->x + hor_gap,
- y2 + 1,
- (U8*) get_string(26000),
- 0);
- gui_setup_fixed_matrix_menu_ind_area(&(m->down_ind_area), 0, 0, NULL, 0);
- gdi_draw_solid_rect(
- m->x + hor_gap,
- y2 + 1,
- m->x + hor_gap + MMI_BI_DEGREE_MAIN_MENU_NAVI_BAR_IND_BG_SIZE,
- y2 + MMI_BI_DEGREE_MAIN_MENU_ARROW_BAR_HEIGHT /* MMI_BI_DEGREE_MAIN_MENU_NAVI_BAR_HEIGHT */ ,
- GDI_COLOR_GREEN);
- }
- else if (has_next_page)
- {
- hor_gap = (m->width - MMI_BI_DEGREE_MAIN_MENU_NAVI_BAR_IND_BG_SIZE) >> 1;
- gui_setup_fixed_matrix_menu_ind_area(
- &(m->down_ind_area),
- m->x + hor_gap,
- y2 + 1,
- (U8*) get_string(26000),
- 0);
- gui_setup_fixed_matrix_menu_ind_area(&(m->up_ind_area), 0, 0, NULL, 0);
- gdi_draw_solid_rect(
- m->x + hor_gap,
- y2 + 1,
- m->x + hor_gap + MMI_BI_DEGREE_MAIN_MENU_NAVI_BAR_IND_BG_SIZE,
- y2 + MMI_BI_DEGREE_MAIN_MENU_ARROW_BAR_HEIGHT /* MMI_BI_DEGREE_MAIN_MENU_NAVI_BAR_HEIGHT */ ,
- GDI_COLOR_RED);
- }
- gdi_layer_pop_clip();
- }
- }
- /* End Draw Indication Arrows. */
- #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */
- if (m->flags & UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR)
- {
- show_vbar = 1;
- }
- if (m->flags & UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR)
- {
- show_hbar = 1;
- }
- if (m->n_items == 0)
- {
- return;
- }
- if (r2lMMIFlag)
- {
- if (show_hbar)
- {
- y2 -= m->hbar.height - 1;
- }
- }
- else
- {
- if (show_vbar)
- {
- x2 -= m->vbar.width - 1;
- }
- if (show_hbar)
- {
- y2 -= m->hbar.height - 1;
- }
- }
- width = x2 - x1 + 1;
- #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
- if (m->flags & UI_MATRIX_MENU_SHOW_IND_AREA)
- {
- y2 -= MMI_BI_DEGREE_MAIN_MENU_NAVI_BAR_IND_BG_SIZE;
- }
- #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */
- height = y2 - y1 + 1;
- iwidth = m->item_width;
- iheight = m->item_height;
- gui_set_text_clip(x1, y1, x2, y2);
- gui_set_clip(x1, y1, x2, y2);
- /*
- * xoff=(width>>1)-((iwidth*m->displayed_columns)>>1);
- * yoff=(height>>1)-((iheight*m->displayed_rows)>>1);
- */
- xoff = (width - (iwidth * m->displayed_columns)) / (m->displayed_columns + 1);
- yoff = (height - (iheight * m->displayed_rows)) / (m->displayed_rows + 1);
- iy = y1 + yoff;
- for (j = 0; j < m->displayed_rows; j++)
- {
- ix = x1 + xoff;
- o = (m->first_displayed_row + j) * m->n_columns;
- for (i = 0; i < m->displayed_columns; i++)
- {
- k = o + (m->first_displayed_column + i);
- if (k > (m->n_items - 1))
- {
- break;
- }
- ix2 = ix + iwidth - 1;
- iy2 = iy + iheight - 1;
- if (ix2 > x2)
- {
- ix2 = x2;
- }
- if (iy2 > y2)
- {
- iy2 = y2;
- }
- gdi_layer_push_clip();
- gui_set_clip(ix, iy, ix2, iy2);
- gui_set_text_clip(ix, iy, ix2, iy2);
- /* show selected item after all other items displayed */
- if (k == m->highlighted_item)
- {
- m->item_remove_highlight_function(m->items[k], m->common_item_data);
- m->item_display_function(m->items[k], m->common_item_data, ix, iy);
- m->item_highlight_function(m->items[k], m->common_item_data);
- highlite_x = ix;
- highlite_y = iy;
- }
- else
- {
- m->item_display_function(m->items[k], m->common_item_data, ix, iy);
- }
- gdi_layer_pop_clip();
- ix += iwidth + xoff;
- }
- iy += iheight + yoff;
- }
- /* EMS menu not optimized in current implementation, but it can be optimized */
- if (MMI_current_menu_type != MATRIX_MENU_EMS)
- {
- #ifdef __MMI_MATRIX_MAIN_MENU_OPTIMIZE__
- if (m->highlighted_item_width > m->item_width)
- {
- xoff2 = (m->highlighted_item_width - m->item_width);
- }
- else
- {
- xoff2 = 0;
- }
- if (m->highlighted_item_height > m->item_height)
- {
- yoff2 = (m->highlighted_item_height - m->item_height);
- }
- else
- {
- yoff2 = 0;
- }
- xPos = highlite_x - (xoff2 >> 1);
- xPos2 = xPos + m->highlighted_item_width - 1;
- yPos = highlite_y - (yoff2 >> 1);
- yPos2 = yPos + m->highlighted_item_height - 1;
- if (xPos < m->x)
- {
- xPos = m->x;
- xPos2 = xPos + m->highlighted_item_width - 1;
- }
- if (xPos2 > m->x + m->width - 1)
- {
- xPos2 = m->x + m->width - 1;
- xPos = xPos2 - m->highlighted_item_width + 1;
- }
- if (yPos < m->y)
- {
- yPos = m->y;
- yPos2 = yPos + m->highlighted_item_height - 1;
- }
- if (yPos2 > m->y + m->height - 1)
- {
- yPos2 = m->y + m->height - 1;
- yPos = yPos2 - m->highlighted_item_height + 1;
- }
- #if 0
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- /* under construction !*/
- #endif /* 0 */
- //if ( highlite_y-yoff2 < y1 )
- // gdi_image_cache_bmp_get(highlite_x-xoff2, y1, highlite_x+m->highlighted_item_width+xoff2,highlite_y+m->highlighted_item_height+yoff2,&m->buffer);
- //else if ( highlite_y+m->highlighted_item_height+yoff2 > y2 )
- // gdi_image_cache_bmp_get(highlite_x-xoff2, highlite_y-yoff2, highlite_x+m->highlighted_item_width+xoff2,y2,&m->buffer);
- //else
- // gdi_image_cache_bmp_get(highlite_x-xoff2, highlite_y-yoff2, highlite_x+m->highlighted_item_width+xoff2,highlite_y+m->highlighted_item_height+yoff2,&m->buffer);
- gdi_layer_push_clip();
- gdi_layer_set_clip(xPos, yPos, xPos2, yPos2);
- #ifdef __MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__
- MMI_ASSERT((xPos2 - xPos + 1) * (yPos2 - yPos + 1) * gdi_layer_get_bit_per_pixel() >> 3 <=
- OPTIMIZE_MM_BUF_SIZE);
- #endif /* __MMI_MATRIX_MAIN_MENU_FULL_BACKGROUND__ */
- gdi_image_cache_bmp_get(xPos, yPos, xPos2, yPos2, &m->buffer);
- gdi_layer_pop_clip();
- m->cache_bmp_x1 = xPos;
- m->cache_bmp_x2 = xPos2;
- m->cache_bmp_y1 = yPos;
- m->cache_bmp_y2 = yPos2;
- m->last_hilited_x = highlite_x;
- m->last_hilited_y = highlite_y;
- #endif /* __MMI_MATRIX_MAIN_MENU_OPTIMIZE__ */
- }
- /* gui_set_clip(highlite_x,highlite_y,highlite_x+iwidth,highlite_y+iheight); */
- m->item_display_function(m->items[m->highlighted_item], m->common_item_data, highlite_x, highlite_y);
- gui_set_clip(cx1, cy1, cx2, cy2);
- gui_set_text_clip(tx1, ty1, tx2, ty2);
- if (show_vbar)
- {
- gui_set_vertical_scrollbar_range(&m->vbar, m->n_rows);
- gui_set_vertical_scrollbar_scale(&m->vbar, m->displayed_rows);
- gui_set_vertical_scrollbar_value(&m->vbar, m->first_displayed_row);
- if (r2lMMIFlag)
- {
- vbar_x = m->vbar.x;
- vbar_button_x = m->vbar.scroll_button.x;
- m->vbar.x = m->vbar.x + m->vbar.width - m->width;
- m->vbar.scroll_button.x = m->vbar.scroll_button.x + m->vbar.scroll_button.width - m->width;
- gui_show_vertical_scrollbar(&m->vbar);
- m->vbar.x = vbar_x;
- m->vbar.scroll_button.x = vbar_button_x;
- }
- else
- {
- gui_show_vertical_scrollbar(&m->vbar);
- }
- }
- if (show_hbar)
- {
- gui_set_horizontal_scrollbar_range(&m->hbar, m->n_columns);
- gui_set_horizontal_scrollbar_scale(&m->hbar, m->displayed_columns);
- gui_set_horizontal_scrollbar_value(&m->hbar, m->first_displayed_column);
- gui_show_horizontal_scrollbar(&m->hbar);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_hide_fixed_matrix_menu_highlighted_item
- * DESCRIPTION
- * Hides the highlighted item
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_hide_fixed_matrix_menu_highlighted_item(fixed_matrix_menu *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, x2, y2, xoff, yoff, width, height;
- S32 i, j, k;
- S32 cx1, cy1, cx2, cy2;
- S32 tx1, ty1, tx2, ty2;
- S32 ix, iy, iwidth, iheight, ix2, iy2;
- U8 show_vbar = 0, show_hbar = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gui_get_clip(&cx1, &cy1, &cx2, &cy2);
- gui_get_text_clip(&tx1, &ty1, &tx2, &ty2);
- x1 = m->x;
- y1 = m->y;
- x2 = x1 + m->width - 1;
- y2 = y1 + m->height - 1;
- if (m->flags & UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR)
- {
- show_vbar = 1;
- }
- if (m->flags & UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR)
- {
- show_hbar = 1;
- }
- if (m->n_items == 0)
- {
- return;
- }
- x1 += 3;
- x2 -= 3;
- y1 += 3;
- y2 -= 3;
- if (show_vbar)
- {
- x2 -= m->vbar.width - 1;
- }
- if (show_hbar)
- {
- y2 -= m->hbar.height - 1;
- }
- iwidth = m->item_width;
- iheight = m->item_height;
- width = x2 - x1 + 1;
- height = y2 - y1 + 1;
- gui_set_text_clip(x1, y1, x2, y2);
- gui_set_clip(x1, y1, x2, y2);
- xoff = (width >> 1) - ((iwidth * m->displayed_columns) >> 1);
- yoff = (height >> 1) - ((iheight * m->displayed_rows) >> 1);
- iy = y1 + yoff;
- for (j = 0; j < m->displayed_rows; j++)
- {
- ix = x1 + xoff;
- for (i = 0; i < m->displayed_columns; i++)
- {
- k = ((m->first_displayed_row + j) * m->n_columns) + (m->first_displayed_column + i);
- if (k > (m->n_items - 1))
- {
- break;
- }
- ix2 = ix + iwidth - 1;
- iy2 = iy + iheight - 1;
- if (ix2 > x2)
- {
- ix2 = x2;
- }
- if (iy2 > y2)
- {
- iy2 = y2;
- }
- gui_set_clip(ix, iy, ix2, iy2);
- gui_set_text_clip(ix, iy, ix2, iy2);
- if (k == m->highlighted_item)
- {
- m->item_hide_function(m->items[k], m->common_item_data, ix, iy);
- }
- ix += iwidth;
- }
- iy += iheight;
- }
- gui_set_clip(cx1, cy1, cx2, cy2);
- gui_set_text_clip(tx1, ty1, tx2, ty2);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_matrix_menu_item_functions
- * DESCRIPTION
- * Sets the functions used to display generic menuitems
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * item_display_function [IN] Is the function used to display an item
- * item_measure_function [IN] Is the function used to measure an item
- * item_highlight_function [OUT] Is the function used to highlight an item
- * item_remove_highlight_function [IN] Is the function used to remove highlight of an item
- * item_hide_function [IN] Is the function used to hide the menuitem
- * width(?) [OUT] Height are the dimensions of the menuitem
- * item(?) [IN] Is the specific fixed menuitem
- * x(?) [IN] Position at which the menuitem was displayed
- * y(?) [IN] Position at which the menuitem was displayed
- * common_item_data(?) [IN] Common fixed menuitem
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_matrix_menu_item_functions(
- fixed_matrix_menu *m,
- void (*item_display_function) (void *item, void *common_item_data, S32 x, S32 y),
- void (*item_measure_function) (void *item, void *common_item_data, S32 *width, S32 *height),
- void (*item_highlight_function) (void *item, void *common_item_data),
- void (*item_remove_highlight_function) (void *item, void *common_item_data),
- void (*item_hide_function) (void *item, void *common_item_data, S32 x, S32 y))
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->item_display_function = item_display_function;
- m->item_measure_function = item_measure_function;
- m->item_highlight_function = item_highlight_function;
- m->item_remove_highlight_function = item_remove_highlight_function;
- m->item_hide_function = item_hide_function;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_matrix_menu_common_item_data
- * DESCRIPTION
- * Sets the common item data that the list of items should use
- * PARAMETERS
- * m [IN] Is the fixed matrix menu object
- * c [IN] Is the common item data
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_matrix_menu_common_item_data(fixed_matrix_menu *m, void *c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->common_item_data = c;
- }
- #ifdef __MMI_TOUCH_SCREEN__
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_vertical_scroll_by_pen
- * DESCRIPTION
- * draws the idle screen depending upon the pen event occured
- * PARAMETERS
- * m [IN] Is matrix menu object's description
- * first_displayed_row [IN]
- * menu_event [OUT]
- * first_displayed(?) [IN] Tells the area of the scrollbar at which pen event has happened
- * RETURNS
- * void
- *****************************************************************************/
- static void gui_fixed_matrix_menu_vertical_scroll_by_pen(
- fixed_matrix_menu *m,
- S32 first_displayed_row,
- gui_matrix_pen_enum *menu_event)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_displayed_row;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (first_displayed_row > m->highlighted_row)
- {
- m->flags |= UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_ROW;
- gui_fixed_matrix_menu_goto_row(m, first_displayed_row);
- m->flags &= ~UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_ROW;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- last_displayed_row = first_displayed_row + m->displayed_rows - 1;
- MMI_DBG_ASSERT(last_displayed_row <= m->n_rows - 1);
- if (last_displayed_row < m->highlighted_row)
- {
- m->flags |= UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_ROW;
- gui_fixed_matrix_menu_goto_row(m, last_displayed_row);
- m->flags &= ~UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_ROW;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- /* Scrolling without changing highlight (this case only happens with pen support) */
- m->first_displayed_row = first_displayed_row;
- /* Although highlighted item stays the same, we need to stop and restart the animation */
- m->item_remove_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- *menu_event = GUI_MATRIX_PEN_NEED_REDRAW;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_horizontal_scroll_by_pen
- * DESCRIPTION
- * draws the idle screen depending upon the pen event occured
- * PARAMETERS
- * m [IN] Is matrix menu object's description
- * first_displayed_column [IN]
- * menu_event [OUT]
- * first_displayed(?) [IN] Tells the area of the scrollbar at which pen event has happened
- * RETURNS
- * void
- *****************************************************************************/
- static void gui_fixed_matrix_menu_horizontal_scroll_by_pen(
- fixed_matrix_menu *m,
- S32 first_displayed_column,
- gui_matrix_pen_enum *menu_event)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_displayed_column;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (first_displayed_column > m->highlighted_column)
- {
- m->flags |= UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_COL;
- gui_fixed_matrix_menu_goto_column(m, first_displayed_column);
- m->flags &= ~UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_COL;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- last_displayed_column = first_displayed_column + m->displayed_columns - 1;
- MMI_DBG_ASSERT(last_displayed_column <= m->n_columns - 1);
- if (last_displayed_column < m->highlighted_column)
- {
- m->flags |= UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_COL;
- gui_fixed_matrix_menu_goto_column(m, last_displayed_column);
- m->flags &= ~UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_COL;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- /* Scrolling without changing highlight (this case only happens with pen support) */
- m->first_displayed_column = first_displayed_column;
- /* Although highlighted item stays the same, we need to stop and restart the animation */
- m->item_remove_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- *menu_event = GUI_MATRIX_PEN_NEED_REDRAW;
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_handle_pen_position
- * DESCRIPTION
- * Handle the pen event (down/move/up), go to the menu item, and set the menu event
- * PARAMETERS
- * m [IN] Is matrix menu object's description
- * x [IN] Co-ordinates of the pen down point
- * y [IN] Co-ordinates of the pen down point
- * pen_event [IN] Only MMI_PEN_EVENT_DOWN, MMI_PEN_EVENT_MOVE, MMI_PEN_EVENT_UP is supported
- * menu_event [OUT] Menu event
- * RETURNS
- * void
- *****************************************************************************/
- static void gui_fixed_matrix_menu_handle_pen_position(
- fixed_matrix_menu *m,
- S32 x,
- S32 y,
- mmi_pen_event_type_enum pen_event,
- gui_matrix_pen_enum *menu_event)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*
- * Because the sampling rate of Pen Move events is not very high on hardware,
- * * we might "jump" to a menu item aparted from the last highlighted menu item.
- */
- /* FIXME. we do not handle the case that hilighted menu item has bigger size, but it is usually okay */
- S32 xoff, yoff;
- S32 width, height;
- S32 iwidth, iheight;
- S32 new_row, new_column, item_index;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #define COMPUTE_NEW_ROW() do {
- if (y < yoff)
- new_row = m->first_displayed_row;
- else
- new_row = m->first_displayed_row + ((y - yoff) / (iheight + yoff));
- if (new_row > m->first_displayed_row + m->displayed_rows - 1)
- new_row = m->first_displayed_row + m->displayed_rows - 1;
- } while (0)
- #define COMPUTE_NEW_COLUMN() do {
- if (x < xoff)
- new_column = m->first_displayed_column;
- else
- new_column = m->first_displayed_column + ((x - xoff) / (iwidth + xoff));
- if (new_column > m->first_displayed_column + m->displayed_columns - 1)
- new_column = m->first_displayed_column + m->displayed_columns - 1;
- } while (0)
- y -= m->y;
- x -= m->x;
- iwidth = m->item_width;
- iheight = m->item_height;
- width = m->width;
- height = m->height;
- if (m->flags & UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR)
- {
- width -= m->vbar.width;
- }
- if (m->flags & UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR)
- {
- height -= m->hbar.height;
- }
- xoff = (width - (iwidth * m->displayed_columns)) / (m->displayed_columns + 1);
- yoff = (height - (iheight * m->displayed_rows)) / (m->displayed_rows + 1);
- MMI_DBG_ASSERT(pen_event == MMI_PEN_EVENT_DOWN || pen_event == MMI_PEN_EVENT_MOVE || pen_event == MMI_PEN_EVENT_UP);
- /* These asumptions are mandatory */
- MMI_DBG_ASSERT(m->first_displayed_row >= 0 &&
- m->first_displayed_column >= 0 &&
- m->first_displayed_row <= m->n_rows - m->displayed_rows &&
- m->first_displayed_column <= m->n_columns - m->displayed_columns);
- if (y < 0) /* Scroll up */
- {
- /* drag & scroll only applies to Pen Move event */
- if (pen_event != MMI_PEN_EVENT_MOVE || m->first_displayed_row == 0)
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- }
- else
- {
- new_row = m->first_displayed_row - 1;
- COMPUTE_NEW_COLUMN();
- item_index = new_row * m->n_columns + new_column;
- m->flags |= UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_ROW;
- gui_fixed_matrix_menu_goto_item(m, item_index);
- m->flags &= ~UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_ROW;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- }
- else if (x < 0) /* Scroll left */
- {
- /* drag & scroll only applies to Pen Move event */
- if (pen_event != MMI_PEN_EVENT_MOVE || m->first_displayed_column == 0)
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- }
- else
- {
- new_column = m->first_displayed_column - 1;
- COMPUTE_NEW_ROW();
- item_index = new_row * m->n_columns + new_column;
- m->flags |= UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_COL;
- gui_fixed_matrix_menu_goto_item(m, item_index);
- m->flags &= ~UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_COL;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- }
- else if (y >= height) /* Scroll down */
- {
- /* drag & scroll only applies to Pen Move event */
- if (pen_event != MMI_PEN_EVENT_MOVE || m->first_displayed_row == m->n_rows - m->displayed_rows)
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- }
- else
- {
- new_row = m->first_displayed_row + m->displayed_rows;
- COMPUTE_NEW_COLUMN();
- item_index = new_row * m->n_columns + new_column;
- if (item_index < m->n_items) /* when n_items is not multiple of displayed_columns */
- {
- m->flags |= UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_ROW;
- gui_fixed_matrix_menu_goto_item(m, item_index);
- m->flags &= ~UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_ROW;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- }
- }
- }
- else if (x >= width) /* Scroll right */
- {
- /* drag & scroll only applies to Pen Move event */
- if (pen_event != MMI_PEN_EVENT_MOVE || m->first_displayed_column == m->n_columns - m->displayed_columns)
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- }
- else
- {
- new_column = m->first_displayed_column + m->displayed_columns;
- COMPUTE_NEW_ROW();
- item_index = new_row * m->n_columns + new_column;
- if (item_index < m->n_items) /* when n_items is not multiple of displayed_columns */
- {
- m->flags |= UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_COL;
- gui_fixed_matrix_menu_goto_item(m, item_index);
- m->flags &= ~UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_COL;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- }
- }
- }
- #ifdef __MMI_BI_DEGREE_MAIN_MENU_STYLE__
- else if (pen_event == MMI_PEN_EVENT_DOWN
- && (m->up_ind_area.string != NULL || m->up_ind_area.img_id != 0)
- && ((x + m->x) > m->up_ind_area.x && (x + m->x) < (m->up_ind_area.x + m->up_ind_area.width - 1))
- && ((y + m->y) > m->up_ind_area.y && (y + m->y) < (m->up_ind_area.y + m->up_ind_area.height - 1)))
- {
- new_row = m->first_displayed_row - m->displayed_rows;
- item_index = new_row * m->n_columns + m->first_displayed_column;
- m->flags |= UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_ROW;
- gui_fixed_matrix_menu_goto_item(m, item_index);
- m->flags &= ~UI_MATRIX_MENU_FIRST_SHIFT_HIGHLIGHTED_ROW;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- else if (pen_event == MMI_PEN_EVENT_DOWN
- && (m->down_ind_area.string != NULL || m->down_ind_area.img_id != 0)
- && ((x + m->x) > m->down_ind_area.x && (x + m->x) < (m->down_ind_area.x + m->down_ind_area.width - 1))
- && ((y + m->y) > m->down_ind_area.y && (y + m->y) < (m->down_ind_area.y + m->down_ind_area.height - 1)))
- {
- new_row = m->first_displayed_row + m->displayed_rows;
- item_index = new_row * m->n_columns + m->first_displayed_column;
- if (item_index < m->n_items) /* when n_items is not multiple of displayed_columns */
- {
- m->flags |= UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_ROW;
- gui_fixed_matrix_menu_goto_item(m, item_index);
- m->flags &= ~UI_MATRIX_MENU_LAST_SHIFT_HIGHLIGHTED_ROW;
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- }
- }
- #endif /* __MMI_BI_DEGREE_MAIN_MENU_STYLE__ */
- else
- {
- S32 act_x = 0, act_y = 0;
- act_x = xoff * (m->displayed_columns) + (m->displayed_columns) * m->item_width;
- act_y = yoff * (m->displayed_rows) + (m->displayed_rows) * m->item_height;
- if (x > act_x || y > act_y)
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- return;
- }
- COMPUTE_NEW_ROW();
- COMPUTE_NEW_COLUMN();
- item_index = new_row * m->n_columns + new_column;
- if (item_index < m->n_items && item_index != m->highlighted_item)
- {
- gui_fixed_matrix_menu_goto_item(m, item_index);
- *menu_event = GUI_MATRIX_PEN_HIGHLIGHT_CHANGED;
- }
- else
- {
- if (pen_event == MMI_PEN_EVENT_UP)
- {
- if (m->pen_state.highlight_changed || (item_index >= m->n_items))
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- }
- else
- {
- *menu_event = GUI_MATRIX_PEN_ITEM_SELECTED;
- }
- }
- else
- {
- *menu_event = GUI_MATRIX_PEN_NONE;
- }
- }
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_fixed_matrix_menu_translate_pen_event
- * DESCRIPTION
- * Translate the pen events occured
- *
- * horizontal scrolling inside matrix menu is not supported
- * PARAMETERS
- * m [IN] Is matrix menu object's description
- * pen_event [IN] One of the pen events like pen_down,pen_up etc
- * x [IN] Co-ordinates of the current pen position
- * y [IN] Co-ordinates of the current pen position
- * menu_event [OUT]
- * RETURNS
- * BOOL
- *****************************************************************************/
- BOOL gui_fixed_matrix_menu_translate_pen_event(
- fixed_matrix_menu *m,
- mmi_pen_event_type_enum pen_event,
- S16 x,
- S16 y,
- gui_matrix_pen_enum *menu_event)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL ret;
- gui_matrix_pen_state_struct *pen_state;
- gui_scrollbar_pen_enum scrollbar_event;
- gui_pen_event_param_struct scrollbar_param;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pen_state = &m->pen_state;
- ret = MMI_TRUE;
- *menu_event = GUI_MATRIX_PEN_NONE;
- if (m->flags & UI_MATRIX_MENU_DISABLE_PEN)
- {
- return MMI_FALSE;
- }
- if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->pen_on_vertical_scrollbar)
- {
- gui_vertical_scrollbar_translate_pen_event(&m->vbar, pen_event, x, y, &scrollbar_event, &scrollbar_param);
- if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
- {
- gui_fixed_matrix_menu_vertical_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
- }
- }
- else if (pen_event != MMI_PEN_EVENT_DOWN && pen_state->pen_on_horizontal_scrollbar)
- {
- gui_horizontal_scrollbar_translate_pen_event(&m->hbar, pen_event, x, y, &scrollbar_event, &scrollbar_param);
- if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
- {
- gui_fixed_matrix_menu_horizontal_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
- }
- }
- else
- {
- switch (pen_event)
- {
- case MMI_PEN_EVENT_DOWN:
- if (PEN_CHECK_BOUND(x, y, m->x, m->y, m->width, m->height))
- {
- if ((m->flags & UI_MATRIX_MENU_SHOW_VERTICAL_SCROLLBAR) &&
- gui_vertical_scrollbar_translate_pen_event(
- &m->vbar,
- MMI_PEN_EVENT_DOWN,
- x,
- y,
- &scrollbar_event,
- &scrollbar_param))
- {
- pen_state->pen_on_vertical_scrollbar = 1;
- pen_state->pen_on_horizontal_scrollbar = 0;
- if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
- {
- gui_fixed_matrix_menu_vertical_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
- }
- }
- else if ((m->flags & UI_MATRIX_MENU_SHOW_HORIZONTAL_SCROLLBAR) &&
- gui_horizontal_scrollbar_translate_pen_event(
- &m->hbar,
- MMI_PEN_EVENT_DOWN,
- x,
- y,
- &scrollbar_event,
- &scrollbar_param))
- {
- pen_state->pen_on_vertical_scrollbar = 0;
- pen_state->pen_on_horizontal_scrollbar = 1;
- if (scrollbar_event == GUI_SCROLLBAR_PEN_JUMP_TO_I)
- {
- gui_fixed_matrix_menu_horizontal_scroll_by_pen(m, scrollbar_param._u.i, menu_event);
- }
- }
- else
- {
- pen_state->pen_on_vertical_scrollbar = 0;
- pen_state->pen_on_horizontal_scrollbar = 0;
- gui_fixed_matrix_menu_handle_pen_position(m, x, y, MMI_PEN_EVENT_DOWN, menu_event);
- }
- pen_state->first_highlighed_item = m->highlighted_item;
- pen_state->highlight_changed = 0;
- }
- else
- {
- ret = MMI_FALSE;
- }
- break;
- case MMI_PEN_EVENT_MOVE:
- gui_fixed_matrix_menu_handle_pen_position(m, x, y, MMI_PEN_EVENT_MOVE, menu_event);
- break;
- case MMI_PEN_EVENT_UP:
- gui_fixed_matrix_menu_handle_pen_position(m, x, y, MMI_PEN_EVENT_UP, menu_event);
- break;
- case MMI_PEN_EVENT_LONG_TAP:
- /* Do nothing */
- break;
- case MMI_PEN_EVENT_REPEAT:
- /* Do nothing */
- break;
- case MMI_PEN_EVENT_ABORT:
- /* Do nothing */
- break;
- default:
- MMI_ASSERT(0);
- }
- }
- if (ret)
- {
- if (pen_state->first_highlighed_item != m->highlighted_item)
- {
- pen_state->highlight_changed = 1;
- }
- }
- return ret;
- }
- #endif /* __MMI_TOUCH_SCREEN__ */
- /* GUI: drop down control functions */
- UI_drop_down_control_theme *current_drop_down_control_theme = NULL;
- /*****************************************************************************
- * FUNCTION
- * gui_set_drop_down_control_current_theme
- * DESCRIPTION
- * Sets the current theme of the drop down control
- * PARAMETERS
- * o [?]
- * m(?) [IN] Is the drop down control object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_drop_down_control_current_theme(drop_down_control *o)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- o->normal_filler = current_drop_down_control_theme->normal_filler;
- o->disabled_filler = current_drop_down_control_theme->disabled_filler;
- o->focussed_filler = current_drop_down_control_theme->focussed_filler;
- o->clicked_filler = current_drop_down_control_theme->clicked_filler;
- o->normal_text_color = current_drop_down_control_theme->normal_text_color;
- o->disabled_text_color = current_drop_down_control_theme->disabled_text_color;
- o->focussed_text_color = current_drop_down_control_theme->focussed_text_color;
- o->clicked_text_color = current_drop_down_control_theme->clicked_text_color;
- o->text_font = current_drop_down_control_theme->text_font;
- o->flags |= current_drop_down_control_theme->flags;
- gui_set_icon_button_BG_theme(&o->down_button, current_drop_down_control_theme->down_button_theme);
- gui_icon_button_set_icon(
- &o->down_button,
- current_drop_down_control_theme->down_button_icon,
- UI_DEFAULT_TRANSPARENT_COLOR);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_drop_down_control_theme
- * DESCRIPTION
- * Sets the given theme of the drop down control
- * PARAMETERS
- * o [?]
- * t [IN] Is the drop down control theme
- * m(?) [IN] Is the drop down control object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_drop_down_control_theme(drop_down_control *o, UI_drop_down_control_theme *t)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- o->normal_filler = t->normal_filler;
- o->disabled_filler = t->disabled_filler;
- o->focussed_filler = t->focussed_filler;
- o->clicked_filler = t->clicked_filler;
- o->normal_text_color = t->normal_text_color;
- o->disabled_text_color = t->disabled_text_color;
- o->focussed_text_color = t->focussed_text_color;
- o->clicked_text_color = t->clicked_text_color;
- o->text_font = t->text_font;
- o->flags |= t->flags;
- gui_set_icon_button_BG_theme(&o->down_button, t->down_button_theme);
- gui_icon_button_set_icon(&o->down_button, t->down_button_icon, UI_DEFAULT_TRANSPARENT_COLOR);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_create_drop_down_control
- * DESCRIPTION
- * Creates a drop down control object
- * PARAMETERS
- * o [?]
- * x [IN] Are the co-ordinates
- * y [IN] Are the co-ordinates
- * width [IN] Are the dimensions
- * height [IN] Are the dimensions
- * m(?) [IN] Is the drop down control object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_create_drop_down_control(drop_down_control *o, S32 x, S32 y, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- o->x = x;
- o->y = y;
- o->width = width;
- o->height = height;
- o->flags = 0;
- gui_create_icon_button(&o->down_button, x + width - height + 1, y + 1, height - 2, height - 2, NULL);
- gui_set_drop_down_control_current_theme(o);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_resize_drop_down_control
- * DESCRIPTION
- * Resizes a drop down control object
- * PARAMETERS
- * o [?]
- * width [IN] Are the new dimensions
- * height [IN] Are the new dimensions
- * m(?) [IN] Is the drop down control object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_resize_drop_down_control(drop_down_control *o, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- o->width = width;
- o->height = height;
- gui_resize_icon_button(&o->down_button, height - 2, height - 2);
- gui_move_icon_button(&o->down_button, o->x + width - height + 1, o->y + 1);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_move_drop_down_control
- * DESCRIPTION
- * Moves a drop down control object
- * PARAMETERS
- * o [?]
- * x [IN] Are the new co-ordinates
- * y [IN] Are the new co-ordinates
- * m(?) [IN] Is the drop down control object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_move_drop_down_control(drop_down_control *o, S32 x, S32 y)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- o->x = x;
- o->y = y;
- gui_move_icon_button(&o->down_button, o->x + o->width - o->height + 1, o->y + 1);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_show_drop_down_control
- * DESCRIPTION
- * Displays a drop down control object
- * PARAMETERS
- * o [?]
- * m(?) [IN] Is the drop down control object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_show_drop_down_control(drop_down_control *o)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, x2, y2;
- UI_filled_area *f;
- color text_color;
- S32 tx, ty, text_width, text_height;
- U32 flags = o->flags;
- U8 button_displayed = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (flags & UI_DROP_DOWN_CONTROL_DISABLE_DRAW)
- {
- return;
- }
- x1 = o->x;
- y1 = o->y;
- x2 = x1 + o->width - 1;
- y2 = y1 + o->height - 1;
- gui_push_clip();
- gui_push_text_clip();
- gui_set_clip(x1, y1, x2, y2);
- if (flags & UI_DROP_DOWN_CONTROL_STATE_FOCUSSED)
- {
- f = o->focussed_filler;
- text_color = o->focussed_text_color;
- }
- else if (flags & UI_DROP_DOWN_CONTROL_STATE_CLICKED)
- {
- f = o->clicked_filler;
- text_color = o->clicked_text_color;
- }
- else if (flags & UI_DROP_DOWN_CONTROL_STATE_DISABLED)
- {
- f = o->disabled_filler;
- text_color = o->disabled_text_color;
- }
- else
- {
- f = o->normal_filler;
- text_color = o->normal_text_color;
- }
- if (!(flags & UI_DROP_DOWN_CONTROL_DISABLE_BACKGROUND))
- {
- gui_draw_filled_area(x1, y1, x2, y2, f);
- }
- if (flags & UI_DROP_DOWN_CONTROL_SHOW_BUTTON_ON_FOCUS)
- {
- if ((flags & UI_DROP_DOWN_CONTROL_STATE_FOCUSSED) || (flags & UI_DROP_DOWN_CONTROL_STATE_CLICKED))
- {
- gui_show_icon_button(&o->down_button);
- button_displayed = 1;
- }
- }
- else
- {
- gui_show_icon_button(&o->down_button);
- button_displayed = 1;
- }
- if (o->text != NULL)
- {
- gui_set_font(o->text_font);
- gui_measure_string(o->text, &text_width, &text_height);
- ty = y1 + (o->height >> 1) - (text_height >> 1);
- if (flags & UI_DROP_DOWN_CONTROL_TEXT_RIGHT_JUSTIFY)
- {
- if (button_displayed)
- {
- tx = x2 - 4 - text_width - o->down_button.width;
- }
- else
- {
- tx = x2 - 4 - text_width;
- }
- }
- else if (flags & UI_DROP_DOWN_CONTROL_TEXT_CENTER_JUSTIFY)
- {
- if (button_displayed)
- {
- tx = x1 + ((o->width - o->down_button.width) >> 1) - (text_width >> 1);
- }
- else
- {
- tx = x1 + (o->width >> 1) - (text_width >> 1);
- }
- }
- else
- {
- tx = x1 + 5;
- }
- if (r2lMMIFlag)
- {
- gui_move_text_cursor(tx + text_width, ty);
- }
- else
- {
- gui_move_text_cursor(tx, ty);
- }
- gui_set_text_color(text_color);
- gui_set_line_height(text_height);
- gui_print_text(o->text);
- }
- gui_pop_text_clip();
- gui_pop_clip();
- }
- /* GUI: horizontal select menu functions */
- UI_horizontal_select_theme *current_horizontal_select_theme = NULL;
- /*****************************************************************************
- * FUNCTION
- * gui_set_horizontal_select_current_theme
- * DESCRIPTION
- * Applies the current theme to a horizontal select menu
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_horizontal_select_current_theme(horizontal_select *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->flags |= current_horizontal_select_theme->flags;
- m->background_filler = current_horizontal_select_theme->background_filler;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_horizontal_select_theme
- * DESCRIPTION
- * Applies the given theme to a horizontal select menu
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * t [IN] Is the theme
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_horizontal_select_theme(horizontal_select *m, UI_horizontal_select_theme *t)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->flags |= t->flags;
- m->background_filler = t->background_filler;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_create_horizontal_select
- * DESCRIPTION
- * Creates a horizontal select menu object
- * PARAMETERS
- * m [IN] Is the horizontal select menu object (pre-allocated)
- * x [IN] Is the left-top corner position
- * y [IN] Is the left-top corner position
- * width [IN] Are the dimensions
- * height [IN] Are the dimensions
- * RETURNS
- * void
- *****************************************************************************/
- void gui_create_horizontal_select(horizontal_select *m, S32 x, S32 y, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->x = x;
- m->y = y;
- m->width = width;
- m->height = height;
- m->n_items = 0;
- m->highlighted_item = 0;
- gui_set_horizontal_select_current_theme(m);
- m->clear_background_callback = NULL;
- m->item_highlighted = UI_dummy_function_s32;
- m->item_unhighlighted = UI_dummy_function_s32;
- m->item_display_function = UI_fixed_menuitem_dummy_display_function;
- m->item_hide_function = UI_fixed_menuitem_dummy_display_function;
- m->item_measure_function = UI_fixed_menuitem_dummy_measure_function;
- m->item_highlight_function = UI_fixed_menuitem_dummy_highlight_function;
- m->item_remove_highlight_function = UI_fixed_menuitem_dummy_remove_highlight_function;
- m->items = NULL;
- m->common_item_data = NULL;
- m->left_arrow_pressed = 0;
- m->right_arrow_pressed = 0;
- m->left_arrow_image = NULL;
- m->right_arrow_image = NULL;
- m->lx = 0;
- m->ly = 0;
- m->rx = 0;
- m->ry = 0;
- m->ix1 = 0;
- m->iy1 = 0;
- m->ix2 = m->width - 1;
- m->iy2 = m->height - 1;
- m->flags = UI_HORIZONTAL_SELECT_NO_ITEM_HIGHLIGHTED;
- m->item_displayed_callback = UI_dummy_menuitem_displayed_function;
- #ifdef __MMI_TOUCH_SCREEN__
- memset(&m->pen_state, 0, sizeof(gui_horizontal_select_pen_state_struct));
- #endif
- }
- /*****************************************************************************
- * FUNCTION
- * gui_resize_horizontal_select
- * DESCRIPTION
- * Changes the size of a horizontal select menu
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * width [IN] Is the new width
- * height [IN] Is the new height
- * RETURNS
- * void
- *****************************************************************************/
- void gui_resize_horizontal_select(horizontal_select *m, S32 width, S32 height)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 iwidth, iheight;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->width = width;
- m->height = height;
- m->lx = 0;
- m->ly = 0;
- m->rx = 0;
- m->ry = 0;
- m->ix1 = 0;
- m->iy1 = 0;
- m->ix2 = m->width - 1;
- m->iy2 = m->height - 1;
- if (m->left_arrow_image != NULL)
- {
- gui_measure_image(m->left_arrow_image, &iwidth, &iheight);
- m->lx = 2;
- m->ly = (m->height >> 1) - (iheight >> 1);
- m->ix1 = iwidth + 4;
- }
- if (m->right_arrow_image != NULL)
- {
- gui_measure_image(m->right_arrow_image, &iwidth, &iheight);
- m->rx = m->width - iwidth - 2;
- m->ry = (m->height >> 1) - (iheight >> 1);
- m->ix2 = m->width - iwidth - 4;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_move_horizontal_select
- * DESCRIPTION
- * Moves the horizontal select menu to a different co-ordinate
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * x [IN] Is the new left-top corner position
- * y [IN] Is the new left-top corner position
- * RETURNS
- * void
- *****************************************************************************/
- void gui_move_horizontal_select(horizontal_select *m, S32 x, S32 y)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->x = x;
- m->y = y;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_horizontal_select_goto_item
- * DESCRIPTION
- * Highlights a particular item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * i [IN] Is the index of the item to be highlighted (zero based)
- * RETURNS
- * void
- *****************************************************************************/
- void gui_horizontal_select_goto_item(horizontal_select *m, S32 i)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if ((i < 0) || (i > m->n_items - 1))
- {
- return;
- }
- if (i == m->highlighted_item)
- {
- return;
- }
- last_highlighted_item = m->highlighted_item;
- m->highlighted_item = i;
- if (last_highlighted_item != m->highlighted_item)
- {
- if ((last_highlighted_item >= 0) && (last_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[last_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(last_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_horizontal_select_goto_next_item
- * DESCRIPTION
- * Higlights the next item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_horizontal_select_goto_next_item(horizontal_select *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- U8 loop_flag = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item >= (m->n_items - 1))
- {
- if (m->flags & UI_LIST_MENU_LOOP)
- {
- loop_flag = 1;
- }
- else
- {
- return;
- }
- }
- last_highlighted_item = m->highlighted_item;
- if (loop_flag)
- {
- m->highlighted_item = 0;
- }
- else
- {
- m->highlighted_item++;
- }
- if (last_highlighted_item != m->highlighted_item)
- {
- if ((last_highlighted_item >= 0) && (last_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[last_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(last_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_horizontal_select_goto_previous_item
- * DESCRIPTION
- * Higlights the previous item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_horizontal_select_goto_previous_item(horizontal_select *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- U8 loop_flag = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item <= 0)
- {
- if (m->flags & UI_LIST_MENU_LOOP)
- {
- loop_flag = 1;
- }
- else
- {
- return;
- }
- }
- last_highlighted_item = m->highlighted_item;
- if (loop_flag)
- {
- m->highlighted_item = m->n_items - 1;
- }
- else
- {
- m->highlighted_item--;
- }
- if (last_highlighted_item != m->highlighted_item)
- {
- if ((last_highlighted_item >= 0) && (last_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[last_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(last_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_horizontal_select_goto_first_item
- * DESCRIPTION
- * Higlights the first item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_horizontal_select_goto_first_item(horizontal_select *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item == 0)
- {
- return;
- }
- last_highlighted_item = m->highlighted_item;
- m->highlighted_item = 0;
- if (last_highlighted_item != m->highlighted_item)
- {
- if ((last_highlighted_item >= 0) && (last_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[last_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(last_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_horizontal_select_goto_last_item
- * DESCRIPTION
- * Higlights the last item
- *
- * The fixed list is not redrawn
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_horizontal_select_goto_last_item(horizontal_select *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 last_highlighted_item;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->highlighted_item == (m->n_items - 1))
- {
- return;
- }
- last_highlighted_item = m->highlighted_item;
- m->highlighted_item = (m->n_items - 1);
- if (last_highlighted_item != m->highlighted_item)
- {
- if ((last_highlighted_item >= 0) && (last_highlighted_item < m->n_items))
- {
- m->item_remove_highlight_function(m->items[last_highlighted_item], m->common_item_data);
- }
- if ((m->highlighted_item >= 0) && (m->highlighted_item < m->n_items))
- {
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- m->item_unhighlighted(last_highlighted_item);
- m->item_highlighted(m->highlighted_item);
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_show_horizontal_select
- * DESCRIPTION
- * Displays the horizontal select menu
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_show_horizontal_select(horizontal_select *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, x2, y2;
- UI_filled_area *f = m->background_filler;
- S32 i;
- S32 cx1, cy1, cx2, cy2;
- S32 tx1, ty1, tx2, ty2;
- S32 iwidth, iheight;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __MMI_SUPPORT_DUMP_SCREEN_STRING__
- g_mmi_frm_cntx.dump_screen_info.hightlight_type = MMI_SCREEN_HIGHLIGHT_FOR_HOR_SELECT;
- #endif
- gui_get_clip(&cx1, &cy1, &cx2, &cy2);
- gui_get_text_clip(&tx1, &ty1, &tx2, &ty2);
- x1 = m->x;
- y1 = m->y;
- x2 = x1 + m->width - 1;
- y2 = y1 + m->height - 1;
- gui_set_clip(x1, y1, x2 + 2, y2 + 2);
- if (!(m->flags & UI_LIST_MENU_DISABLE_BACKGROUND))
- {
- /* 20051012 HIMANSHU START INLINE SELECT */
- /* Now the inline item select will be shown with the reduced size of
- highlighted filler, so that only the text is shown as highlighted.
- Hence removing the check, for enabling it for all projects. */
- /* PMT MANISH START 20050722 */
- // #ifdef __MMI_UI_INLINE_EDIT_DEFAULT_TEXT_EFFECT__
- /* pass the modified parameters in case when the Defualt Text Effect is enabled
- so that there will be proper gap between the menu items. */
- /* if(IsInlineItemDefaultTextEnable()) */
- gui_draw_filled_area(x1 + m->ix1, y1, x1 + m->ix2 - 1, y2, f);
- // else
- // #endif /* __MMI_UI_INLINE_EDIT_DEFAULT_TEXT_EFFECT__ */
- // gui_draw_filled_area(x1,y1,x2,y2,f);
- //20051012 HIMANSHU END INLINE SELECT
- #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
- if (line_draw)
- {
- /* To draw the grid overlapped by the heilighter (filler) */
- if (y1 == MMI_fixed_list_menu.y + 1) /* to draw line only for starting position */
- {
- gui_draw_horizontal_line(x1, x2, y1, current_MMI_theme->list_background_filler->border_color);
- }
- gui_draw_horizontal_line(x1, x2, y2, current_MMI_theme->list_background_filler->border_color);
- gui_draw_vertical_line(y1, y2, x2, current_MMI_theme->list_background_filler->border_color);
- }
- #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */
- }
- if (m->clear_background_callback)
- {
- m->clear_background_callback(x1, y1, x2, y2);
- }
- if ((m->n_items == 0) || (m->highlighted_item < 0) || (m->highlighted_item > (m->n_items - 1)))
- {
- gui_set_clip(cx1, cy1, cx2, cy2);
- gui_set_text_clip(tx1, ty1, tx2, ty2);
- return;
- }
- if (m->flags & UI_HORIZONTAL_SELECT_NO_ITEM_HIGHLIGHTED)
- {
- m->flags &= ~UI_HORIZONTAL_SELECT_NO_ITEM_HIGHLIGHTED;
- m->item_highlight_function(m->items[m->highlighted_item], m->common_item_data);
- }
- if (m->left_arrow_image != NULL)
- {
- gui_show_transparent_image(x1 + m->lx, y1 + m->ly + m->left_arrow_pressed, m->left_arrow_image, 0);
- }
- if (m->right_arrow_image != NULL)
- {
- gui_show_transparent_image(x1 + m->rx, y1 + m->ry + m->right_arrow_pressed, m->right_arrow_image, 0);
- }
- x1 = m->x + m->ix1;
- x2 = m->x + m->ix2;
- y1 = m->y + m->iy1;
- y2 = m->y + m->iy2;
- gui_set_text_clip(x1, y1, x2, y2);
- gui_set_clip(x1, y1, x2, y2);
- i = m->highlighted_item;
- {
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- m->item_display_function(m->items[i], m->common_item_data, x1, y1);
- m->item_displayed_callback(i, x1, y1, x1 + iwidth - 1, y1 + iheight - 1);
- }
- #ifdef __MMI_UI_DALMATIAN_FIXEDLIST__
- if (line_draw)
- {
- gui_push_clip();
- gui_set_clip(x1, y1, x2, y2);
- if (y1 == MMI_fixed_list_menu.y + 1) /* To draw after the Text change. As text background again cross the line */
- {
- gui_draw_horizontal_line(x1, x2, y1, current_MMI_theme->list_background_filler->border_color);
- }
- gui_pop_clip();
- }
- #endif /* __MMI_UI_DALMATIAN_FIXEDLIST__ */
- gui_set_clip(cx1, cy1, cx2, cy2);
- gui_set_text_clip(tx1, ty1, tx2, ty2);
- }
- #ifdef __MMI_TOUCH_SCREEN__
- /*****************************************************************************
- * FUNCTION
- * gui_redraw_horizontal_select
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * RETURNS
- * void
- *****************************************************************************/
- static void gui_redraw_horizontal_select(horizontal_select *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- gui_lock_double_buffer();
- gui_show_horizontal_select(m);
- gui_unlock_double_buffer();
- gui_BLT_double_buffer(m->x, m->y, m->x + m->width - 1, m->y + m->height - 1);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_horizontal_select_translate_pen_event
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * pen_event [IN]
- * x [IN]
- * y [IN]
- * select_event [?]
- * RETURNS
- *
- *****************************************************************************/
- BOOL gui_horizontal_select_translate_pen_event(
- horizontal_select *m,
- mmi_pen_event_type_enum pen_event,
- S16 x,
- S16 y,
- gui_horizontal_select_pen_enum *select_event)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- BOOL ret;
- S32 in_left_region = 0, in_right_region = 0;
- gui_horizontal_select_pen_state_struct *pen_state;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- pen_state = &m->pen_state;
- ret = MMI_TRUE;
- *select_event = GUI_HORIZONTAL_SELECT_PEN_NONE;
- if (PEN_CHECK_BOUND(
- x,
- y,
- m->x + pen_state->left_region_x,
- m->y + pen_state->left_region_y,
- pen_state->left_region_width,
- pen_state->left_region_height))
- {
- in_left_region = 1;
- }
- else if (PEN_CHECK_BOUND(
- x,
- y,
- m->x + pen_state->right_region_x,
- m->y + pen_state->right_region_y,
- pen_state->right_region_width,
- pen_state->right_region_height))
- {
- in_right_region = 1;
- }
- switch (pen_event)
- {
- case MMI_PEN_EVENT_DOWN:
- MMI_DBG_ASSERT(!m->left_arrow_pressed && !m->right_arrow_pressed);
- pen_state->pen_down_left_arrow = 0;
- pen_state->pen_down_right_arrow = 0;
- if (in_left_region)
- {
- pen_state->pen_down_left_arrow = 1;
- m->left_arrow_pressed = 1;
- gui_redraw_horizontal_select(m);
- }
- else if (in_right_region)
- {
- pen_state->pen_down_right_arrow = 1;
- m->right_arrow_pressed = 1;
- gui_redraw_horizontal_select(m);
- }
- else if (!PEN_CHECK_BOUND(x, y, m->x, m->y, m->width, m->height))
- {
- ret = MMI_FALSE;
- }
- break;
- case MMI_PEN_EVENT_UP:
- if (pen_state->pen_down_left_arrow)
- {
- if (in_left_region)
- {
- *select_event = GUI_HORIZONTAL_SELECT_PEN_PREV;
- }
- }
- else if (pen_state->pen_down_right_arrow)
- {
- if (in_right_region)
- {
- *select_event = GUI_HORIZONTAL_SELECT_PEN_NEXT;
- }
- }
- if (m->left_arrow_pressed)
- {
- m->left_arrow_pressed = 0;
- gui_redraw_horizontal_select(m);
- }
- else if (m->right_arrow_pressed)
- {
- m->right_arrow_pressed = 0;
- gui_redraw_horizontal_select(m);
- }
- break;
- case MMI_PEN_EVENT_MOVE:
- if (pen_state->pen_down_left_arrow)
- {
- if (in_left_region)
- {
- if (!m->left_arrow_pressed)
- {
- m->left_arrow_pressed = 1;
- gui_redraw_horizontal_select(m);
- }
- }
- else
- {
- if (m->left_arrow_pressed)
- {
- m->left_arrow_pressed = 0;
- gui_redraw_horizontal_select(m);
- }
- }
- }
- else if (pen_state->pen_down_right_arrow)
- {
- if (in_right_region)
- {
- if (!m->right_arrow_pressed)
- {
- m->right_arrow_pressed = 1;
- gui_redraw_horizontal_select(m);
- }
- }
- else
- {
- if (m->right_arrow_pressed)
- {
- m->right_arrow_pressed = 0;
- gui_redraw_horizontal_select(m);
- }
- }
- }
- break;
- case MMI_PEN_EVENT_LONG_TAP:
- /* FALLTHROUGH no break */
- case MMI_PEN_EVENT_REPEAT:
- break;
- case MMI_PEN_EVENT_ABORT:
- if (m->left_arrow_pressed)
- {
- m->left_arrow_pressed = 0;
- gui_redraw_horizontal_select(m);
- }
- else if (m->right_arrow_pressed)
- {
- m->right_arrow_pressed = 0;
- gui_redraw_horizontal_select(m);
- }
- break;
- default:
- MMI_ASSERT(0);
- }
- return ret;
- }
- #endif /* __MMI_TOUCH_SCREEN__ */
- /*****************************************************************************
- * FUNCTION
- * gui_hide_horizontal_select_highlighted_item
- * DESCRIPTION
- * Hides the highlighted item in a horizontal select menu
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * RETURNS
- * void
- *****************************************************************************/
- void gui_hide_horizontal_select_highlighted_item(horizontal_select *m)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 x1, y1, x2, y2;
- S32 i;
- S32 cx1, cy1, cx2, cy2;
- S32 tx1, ty1, tx2, ty2;
- S32 iwidth, iheight;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (m->n_items == 0)
- {
- return;
- }
- if ((m->highlighted_item < 0) || (m->highlighted_item > (m->n_items - 1)))
- {
- return;
- }
- gui_get_clip(&cx1, &cy1, &cx2, &cy2);
- gui_get_text_clip(&tx1, &ty1, &tx2, &ty2);
- x1 = m->x;
- y1 = m->y;
- x2 = x1 + m->width - 1;
- y2 = y1 + m->height - 1;
- gui_set_text_clip(x1, y1, x2, y2);
- gui_set_clip(x1, y1, x2, y2);
- i = m->highlighted_item;
- {
- m->item_measure_function(m->items[i], m->common_item_data, &iwidth, &iheight);
- m->item_hide_function(m->items[i], m->common_item_data, x1, y1);
- }
- gui_set_clip(cx1, cy1, cx2, cy2);
- gui_set_text_clip(tx1, ty1, tx2, ty2);
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_horizontal_select_clear_background_function
- * DESCRIPTION
- * Sets the function used to clear background,
- * The function is typically used when UI_LIST_MENU_DISABLE_BACKGROUND is set.
- *
- * (Set 'clear_bg_function' to NULL to disable the callback)
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * clear_bg_function [IN] Callback to clear background
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_horizontal_select_clear_background_function(
- horizontal_select *m,
- void (*clear_bg_function)(S32 x1, S32 y1, S32 x2, S32 y2))
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->clear_background_callback = clear_bg_function;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_horizontal_select_item_functions
- * DESCRIPTION
- * Sets the functions used to display generic menuitems
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * item_display_function [IN] Is the function used to display an item
- * item_measure_function [IN] Is the function used to measure an item
- * item_highlight_function [OUT] Is the function used to highlight an item
- * item_remove_highlight_function [IN] Is the function used to remove highlight of an item
- * item_hide_function [IN] Is the function used to hide the menuitem
- * width(?) [OUT] Height are the dimensions of the menuitem
- * item(?) [IN] Is the specific fixed menuitem
- * x(?) [IN] Position at which the menuitem was displayed
- * y(?) [IN] Position at which the menuitem was displayed
- * common_item_data(?) [IN] Common fixed menuitem
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_horizontal_select_item_functions(
- horizontal_select *m,
- void (*item_display_function) (void *item, void *common_item_data, S32 x, S32 y),
- void (*item_measure_function) (void *item, void *common_item_data, S32 *width, S32 *height),
- void (*item_highlight_function) (void *item, void *common_item_data),
- void (*item_remove_highlight_function) (void *item, void *common_item_data),
- void (*item_hide_function) (void *item, void *common_item_data, S32 x, S32 y))
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->item_display_function = item_display_function;
- m->item_measure_function = item_measure_function;
- m->item_highlight_function = item_highlight_function;
- m->item_remove_highlight_function = item_remove_highlight_function;
- m->item_hide_function = item_hide_function;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_horizontal_select_common_item_data
- * DESCRIPTION
- * Sets the common item data that the list of items should use
- * PARAMETERS
- * m [IN] Is the horizontal select menu object
- * c [IN] Is the common item data
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_horizontal_select_common_item_data(horizontal_select *m, void *c)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->common_item_data = c;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_horizontal_select_images
- * DESCRIPTION
- *
- * PARAMETERS
- * m [?]
- * left_arrow [IN]
- * right_arrow [IN]
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_horizontal_select_images(horizontal_select *m, PU8 left_arrow, PU8 right_arrow)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S32 width, height;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- m->left_arrow_image = left_arrow;
- m->right_arrow_image = right_arrow;
- if (m->left_arrow_image != NULL)
- {
- gui_measure_image(m->left_arrow_image, &width, &height);
- #ifdef __MMI_UI_INLINE_EDIT_DEFAULT_TEXT_EFFECT__
- m->lx = 0;
- m->ix1 = width + 2;
- #else /* __MMI_UI_INLINE_EDIT_DEFAULT_TEXT_EFFECT__ */
- m->lx = 2;
- m->ly = (m->height >> 1) - (height >> 1);
- m->ix1 = width + 4;
- #endif /* __MMI_UI_INLINE_EDIT_DEFAULT_TEXT_EFFECT__ */
- m->ly = (m->height >> 1) - (height >> 1);
- #ifdef __MMI_TOUCH_SCREEN__
- m->pen_state.left_region_x = m->lx - GUI_HORIZONTAL_SELECT_PEN_VALID_REGION;
- if (m->pen_state.left_region_x < 0)
- {
- m->pen_state.left_region_x = 0;
- }
- m->pen_state.left_region_y = m->ly - GUI_HORIZONTAL_SELECT_PEN_VALID_REGION;
- if (m->pen_state.left_region_y < 0)
- {
- m->pen_state.left_region_y = 0;
- }
- m->pen_state.left_region_width = width + (GUI_HORIZONTAL_SELECT_PEN_VALID_REGION * 2);
- if (m->pen_state.left_region_x + m->pen_state.left_region_width >= (m->width >> 1))
- {
- m->pen_state.left_region_width = (m->width >> 1) - m->pen_state.left_region_x - 1;
- }
- m->pen_state.left_region_height = height + (GUI_HORIZONTAL_SELECT_PEN_VALID_REGION * 2);
- if (m->pen_state.left_region_y + m->pen_state.left_region_height >= m->height)
- {
- m->pen_state.left_region_height = m->height - m->pen_state.left_region_y - 1;
- }
- #endif /* __MMI_TOUCH_SCREEN__ */
- }
- if (m->right_arrow_image != NULL)
- {
- gui_measure_image(m->right_arrow_image, &width, &height);
- #ifdef __MMI_UI_INLINE_EDIT_DEFAULT_TEXT_EFFECT__
- m->rx = m->width - width;
- m->ix2 = m->width - width - 2;
- #else /* __MMI_UI_INLINE_EDIT_DEFAULT_TEXT_EFFECT__ */
- m->rx = m->width - width - 2;
- m->ix2 = m->width - width - 4;
- #endif /* __MMI_UI_INLINE_EDIT_DEFAULT_TEXT_EFFECT__ */
- m->ry = (m->height >> 1) - (height >> 1);
- #ifdef __MMI_TOUCH_SCREEN__
- m->pen_state.right_region_x = m->rx - GUI_HORIZONTAL_SELECT_PEN_VALID_REGION;
- if (m->pen_state.right_region_x < (m->width >> 1))
- {
- m->pen_state.right_region_x = (m->width >> 1);
- }
- m->pen_state.right_region_y = m->ry - GUI_HORIZONTAL_SELECT_PEN_VALID_REGION;
- if (m->pen_state.right_region_y < 0)
- {
- m->pen_state.right_region_y = 0;
- }
- m->pen_state.right_region_width = width + (GUI_HORIZONTAL_SELECT_PEN_VALID_REGION * 2);
- if (m->pen_state.right_region_x + m->pen_state.right_region_width >= m->width)
- {
- m->pen_state.right_region_width = m->width - m->pen_state.right_region_x - 1;
- }
- m->pen_state.right_region_height = height + (GUI_HORIZONTAL_SELECT_PEN_VALID_REGION * 2);
- if (m->pen_state.right_region_y + m->pen_state.right_region_height >= m->height)
- {
- m->pen_state.right_region_height = m->height - m->pen_state.right_region_y - 1;
- }
- #endif /* __MMI_TOUCH_SCREEN__ */
- }
- }
- /*****************************************************************************
- * FUNCTION
- * gui_set_fixed_menu_bg_id
- * DESCRIPTION
- * set a specific image as fixed menu background instead of wallpaper
- * PARAMETERS
- * image_id [IN] Image id
- * RETURNS
- * void
- *****************************************************************************/
- void gui_set_fixed_menu_bg_id(S32 image_id)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_fixed_menu_bg_id = image_id;
- }
- /*****************************************************************************
- * FUNCTION
- * gui_reset_fiexed_menu_bg_id
- * DESCRIPTION
- * reset a fixed menu background to default
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- void gui_reset_fiexed_menu_bg_id(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mmi_fixed_menu_bg_id = -1;
- }