📄 plxdyncmenu.c
字号:
if (wgui_layer_1 == GDI_LAYER_EMPTY_HANDLE)
{
gdi_layer_create(0, 0, UI_device_width, UI_device_height, &wgui_layer_1);
}
#if defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__)
if(pixtel_UI_get_transparent_source_layer()==GDI_LAYER_EMPTY_HANDLE)
{
pixtel_UI_set_transparent_source_layer(wgui_layer_1);
}
#endif
gdi_layer_set_active(wgui_layer_1);
gdi_layer_lock_frame_buffer();
gdi_layer_push_clip();
gdi_layer_reset_clip();
gdi_layer_set_opacity(TRUE, 150);
gdi_image_draw_animation(0,0, get_image(idle_screen_wallpaper_ID),NULL);
gdi_layer_pop_clip();
gdi_layer_unlock_frame_buffer();
gdi_layer_restore_base_active();
gdi_layer_set_blt_layer(wgui_layer_1, wgui_base_layer, 0, 0);
gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
gdi_layer_set_active(wgui_base_layer);
#endif // __MMI_WALLPAPER_ON_BOTTOM__
pixtel_UI_push_clip();
pixtel_UI_set_clip(0,0,UI_device_width-1,UI_device_height-1);
pixtel_UI_set_font(pFont);
if(0 != nDMTitleID)
MMI_title_string = (UI_string_type) get_string((UI_string_ID_type)nDMTitleID);
else
MMI_title_string = (UI_string_type) get_string((UI_string_ID_type)menuDisp.title);
if(0 != nDMTitleIconID)
MMI_title_icon = (UI_image_type)get_image((UI_image_ID_type)nDMTitleIconID);
else
MMI_title_icon =0;//(UI_image_type)get_image(IMG_GLOBAL_OK);
if(nDMLeftKey == 0)
nDMLeftKey = STR_GLOBAL_OK;
if(nDMLeftKeyIcon == 0)
nDMLeftKeyIcon = IMG_GLOBAL_OK;
if(nDMRightKey == 0)
nDMRightKey = STR_GLOBAL_BACK;
if(nDMRightKeyIcon == 0)
nDMRightKeyIcon = IMG_GLOBAL_BACK;
change_left_softkey( nDMLeftKey, nDMLeftKeyIcon);
change_right_softkey(nDMRightKey, nDMRightKeyIcon);
nDMTitleID = 0;
nDMTitleIconID = 0;
nDMLeftKey = 0;
nDMLeftKeyIcon = 0;
nDMRightKey = 0;
nDMLeftKeyIcon = 0;
// clear_screen();
#ifdef MMI_ON_WIN32
// clear_left_softkey();
// clear_right_softkey();
#else
clear_left_softkey();
clear_right_softkey();
#endif //MMI_ON_WIN32
register_left_softkey_handler();
register_right_softkey_handler();
register_default_hide_softkeys();
show_softkey_background();
show_left_softkey();
show_right_softkey();
show_title_status_icon();
draw_title();
mmi_gui_redraw_menu_shortcut();
menuDisp.txtHeight = pixtel_UI_get_string_height((UI_string_type)"T\x00\x00\x00") + 2;
menuDisp.linesInScreen = MENUS_IN_SCREEN;
menuDisp.itemHeight = (menuDisp.rcTxt.bottom - menuDisp.rcTxt.top)/menuDisp.linesInScreen;
if((menuDisp.rcTxt.bottom - menuDisp.rcTxt.top) - (menuDisp.rcTxt.bottom - menuDisp.rcTxt.top)/menuDisp.linesInScreen * menuDisp.linesInScreen >= 5)
menuDisp.itemHeight ++;
pixtel_UI_create_vertical_scrollbar(&menuDisp.vScroll, menuDisp.rcVScroll.left, menuDisp.rcVScroll.top,
menuDisp.rcVScroll.right - menuDisp.rcVScroll.left, menuDisp.rcVScroll.bottom - menuDisp.rcVScroll.top);
pixtel_UI_set_vertical_scrollbar_current_theme(&menuDisp.vScroll);
pixtel_UI_set_vertical_scrollbar_range(&menuDisp.vScroll, menuDisp.itemCount);
pixtel_UI_set_vertical_scrollbar_value(&menuDisp.vScroll, menuDisp.firstLine);
pixtel_UI_set_vertical_scrollbar_scale(&menuDisp.vScroll, menuDisp.linesInScreen);
pixtel_UI_show_vertical_scrollbar(&menuDisp.vScroll);
//deal with shortcut number
//the shortcut number is remeber in the variable of MMI_menu_shortcut_number,please change it when the focus item changed
//the chararacter number of the shorcut string is set by set_menu_item_count(), call it when the count of items changed.
//please call mmi_gui_redraw_menu_shortcut() to redraw the shortcut when the navigate keys pressed.
//and must call the functions of reset_menu_shortcut_handler() before exit this screen
bIsShortcutDisabled = MMI_disable_title_shortcut_display;
MMI_disable_title_shortcut_display = 0;
register_menu_shortcut_keys();
register_menu_shortcut_selected_only( ShortcutSelectOnlyHandler );
shortcut_width = set_menu_item_count( menuDisp.itemCount) + 7;
resize_menu_shortcut_handler( shortcut_width, (MMI_title_height) );
move_menu_shortcut_handler( UI_device_width - MMI_menu_shortcut_box.width, MMI_title_y );
register_hide_menu_shortcut( mmi_gui_redraw_menu_shortcut );
#ifdef __MMI_TOUCH_SCREEN__
mmi_pen_register_down_handler(OnTouchPenDown);
mmi_pen_register_move_handler(OnTouchPenMove);
mmi_pen_register_up_handler(OnTouchPenUp);
mmi_pen_register_repeat_handler(OnTouchPenRepeat);
#endif //__MMI_TOUCH_SCREEN__
ExitCategoryFunction = ExitDyncMenuScreen;
RedrawCategoryFunction = DrawDyncMenuScreen;
GetCategoryHistory = dummy_get_history;
GetCategoryHistorySize = dummy_get_history_size;
ProcessFocusItem();
ProcessScrollInfo();
DrawMenuList(&menuDisp.rcList);
pixtel_UI_pop_clip();
pixtel_UI_unlock_double_buffer();
pixtel_UI_BLT_double_buffer(0,0,UI_device_width-1,UI_device_height-1);
}
/*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*
<> Function PlxRedrawDMenu
<> Purpose redraw the dync menu screen
<> Params
<> Return
<> Remarks call the function while the dync menu is changed by insert,modify or delete operations
\*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*/
void PlxRedrawDMenu(void)
{
//recaculate the count of items for insert or delete operation can be called
// and the first line and the focust item is recaculate in
//PlxInsertDMenuItem,PlxDeleteDMenuItem,PlxModifyDMenuItem.
menuDisp.itemCount = GetCountToDisplay(menuDisp.pMenu);
ProcessFocusItem();
ProcessScrollInfo();
DrawMenuList(&menuDisp.rcList);
}
/*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*
<> Function ShortcutSelectOnlyHandler
<> Purpose draw the focus menu while one number key is pressed
<> Params
<> Return
<> Remarks
\*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*/
static void ShortcutSelectOnlyHandler(S32 index)
{
int count = 0, oldLine;
if (index >= menuDisp.itemCount || index == menuDisp.focuseItem)
{
return;
}
oldLine = menuDisp.focuseItem;
menuDisp.focuseItem = index;
MMI_menu_shortcut_number = menuDisp.focuseItem +1;
if (index + 1 == menuDisp.itemCount)
{
if (menuDisp.focuseItem > menuDisp.firstLine + menuDisp.linesInScreen - 1)
{
menuDisp.firstLine = menuDisp.itemCount - menuDisp.linesInScreen;
}
else
{
DrawMenuList(&menuDisp.rcList);
return;
}
}
else if (menuDisp.focuseItem == menuDisp.firstLine)
{
if (menuDisp.firstLine > 0)
{
-- menuDisp.firstLine;
}
else
{
ProcessFocusItem();
DrawMenuList(&menuDisp.rcList);
return;
}
}
else
{
if (menuDisp.focuseItem > menuDisp.firstLine + menuDisp.linesInScreen - 2)
{
menuDisp.firstLine = menuDisp.focuseItem + 2 - menuDisp.linesInScreen;
}
else if (menuDisp.focuseItem < menuDisp.firstLine)
{
menuDisp.firstLine = menuDisp.focuseItem + 2 >= menuDisp.linesInScreen ? menuDisp.focuseItem + 2 - menuDisp.linesInScreen : 0;
}
else
{
ProcessFocusItem();
DrawMenuList(&menuDisp.rcList);
return;
}
}
ProcessFocusItem();
ProcessScrollInfo();
DrawMenuList(&menuDisp.rcList);
return;
}
/*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*
<> Function DrawMenuList
<> Purpose
<> Params
<> Return
<> Remarks
\*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*/
static void DrawMenuList(PDM_RC pRcDraw){
S32 lineBegin = 0, lineEnd = 0;
int i;
for (i = 0; i < menuDisp.itemCount; ++ i) {
if (menuDisp.rcTxt.top + (i + 1) * menuDisp.itemHeight >= pRcDraw->top) {
lineBegin = i + menuDisp.firstLine;
break;
}
}
for (i = menuDisp.itemCount - 1; i >= lineBegin; -- i) {
if (menuDisp.rcTxt.top + (i - lineBegin) * menuDisp.itemHeight <= pRcDraw->bottom) {
lineEnd = i + menuDisp.firstLine;
break;
}
}
if (lineEnd < lineBegin) {
return;
}
pixtel_UI_lock_double_buffer();
pixtel_UI_push_clip();
pixtel_UI_set_clip(menuDisp.rcList.left, menuDisp.rcList.top, menuDisp.rcSubIcon.right, menuDisp.rcList.bottom);
pixtel_UI_push_text_clip();
pixtel_UI_set_text_clip(menuDisp.rcList.left, menuDisp.rcList.top, menuDisp.rcSubIcon.right - 1, menuDisp.rcList.bottom);
#ifdef __MMI_WALLPAPER_ON_BOTTOM__
gdi_draw_solid_rect(menuDisp.rcList.left, menuDisp.rcList.top, menuDisp.rcVScroll.left, menuDisp.rcList.bottom,GDI_COLOR_TRANSPARENT);
#else
pixtel_UI_draw_filled_area(menuDisp.rcList.left, menuDisp.rcList.top, menuDisp.rcVScroll.left, menuDisp.rcList.bottom,
current_MMI_theme->list_background_filler);
#endif
DrawLines(lineBegin, lineEnd);
pixtel_UI_pop_text_clip();
pixtel_UI_pop_clip();
pixtel_UI_unlock_double_buffer();
pixtel_UI_BLT_double_buffer(menuDisp.rcList.left, menuDisp.rcList.top, menuDisp.rcSubIcon.right, menuDisp.rcList.bottom);
}
/*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*
<> Function DrawLines
<> Purpose draw menu item lines from line1 to line2
<> Params
<> Return
<> Remarks
\*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*/
static void DrawLines(int line1, int line2){
int trueLine1, trueLine2;
int i, count, j;
PDMENUITEM pItem;
if (line1 < menuDisp.firstLine) {
trueLine1 = menuDisp.firstLine;
}
else{
trueLine1 = line1;
}
if (line1 == line2) {
trueLine2 = line2;
}
else{
if (line2 > menuDisp.firstLine && line2 - menuDisp.firstLine > menuDisp.linesInScreen - 1) {
trueLine2 = menuDisp.firstLine + menuDisp.linesInScreen - 1;
}
else{
trueLine2 = line2;
}
}
if (trueLine1 > trueLine2) {
return;
}
count = 0;
pItem = GetItemFromLine(menuDisp.pMenu, &count, line1);
if (NULL == pItem) {
return;
}
for (j = 0, i = trueLine1; i <= trueLine2; ++ i) {
DrawOneLine(i, pItem);
if ((pItem->wFlags & MF_POPUP) && (pItem->wFlags & ST_EXPAND)) {
i += ((PDMENUOBJ)pItem->hIDorGroup)->wUsedItems;
DrawLines(line1 + j + 1, line2);
}
if (pItem == pItem->pOwner->pItemsMemBlock + pItem->pOwner->wUsedItems - 1) {
if (0 != pItem->pOwner->hParent) {
DrawLines(line1 + j + 1, line2);
}
else{
for(++ i; i <= trueLine2; ++ i){
DrawOneLine(i, NULL);
}
}
break;
}
else{
++ j;
++ pItem;
}
}
}
/*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*
<> Function DrawOneLine
<> Purpose draw one line onto the screen
<> Params
<> Return
<> Remarks
\*<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>*/
extern color UI_current_text_color;
static void DrawOneLine(int line, PDMENUITEM pItem){
DM_RC rcNumIcon, rcTxt, rcSubIcon;
DM_RC rcItemFocus;
int y1, y2;
PDMENUOBJ pObj;
unsigned short imageID;
color colorDisabledText={126, 128, 146, 100};
color SavedColor = UI_current_text_color;
if(line < menuDisp.firstLine || line > menuDisp.firstLine + menuDisp.linesInScreen) {
return;
}
y1 = menuDisp.rcTxt.top + (line - menuDisp.firstLine) * menuDisp.itemHeight;
y2 = y1 + menuDisp.itemHeight;
if (NULL == pItem) {
pixtel_UI_BLT_double_buffer(menuDisp.rcList.left, y1, menuDisp.rcList.right, y2);
return;
}
if(IMG_ID_PLX_PUBLIC_GLOBAL_NUMBERICON == pItem->imageID){
imageID = IMG_GLOBAL_L1+ line; //changed while the sub menu expanded or not
}
else if (pItem->imageID > 0) {
imageID = pItem->imageID;
}
{
UI_image_type img = get_image (imageID);
S32 width, height;
gdi_image_get_dimension (img, &width, &height);
pObj = pItem->pOwner;
rcNumIcon.left = menuDisp.rcOrderIcon.left + pObj->level * INDENT_VALUE;
rcNumIcon.top = y1 + (menuDisp.itemHeight - height)/2;
rcNumIcon.right = menuDisp.rcOrderIcon.right + pObj->level * INDENT_VALUE;
rcNumIcon.bottom = y2 - (menuDisp.itemHeight - height)/2;
}
#if defined(__MMI_MAINLCD_240X320__)
{
int wt, ht;
pixtel_UI_measure_string ((UI_string_type)pItem->pStr, &wt, &ht);
if ( ht != 0 )
menuDisp.txtHeight = ht;
}
#endif
rcTxt.left = menuDisp.rcTxt.left + pObj->level * INDENT_VALUE;
rcTxt.right = menuDisp.rcTxt.right;
#if defined(__MMI_MAINLCD_128X128__)
rcTxt.top = y1 + 2;
rcTxt.bottom = y2 -2;
#else
rcTxt.top = y1 + ((menuDisp.itemHeight - menuDisp.txtHeight)/2 == 0 ? 2 : (menuDisp.itemHeight - menuDisp.txtHeight)/2);
rcTxt.bottom = y2 - ((menuDisp.itemHeight - menuDisp.txtHeight)/2 == 0 ? 2 : (menuDisp.itemHeight - menuDisp.txtHeight)/2);
#endif
if (rcTxt.right <= rcTxt.left) {
return;
}
rcItemFocus.left= menuDisp.rcList.left ;// rcTxt.left -1;
rcItemFocus.right = menuDisp.rcSubIcon.right -1;
#if defined(__MMI_MAINLCD_128X128___)
rcItemFocus.top =rcTxt.top - 2;
rcItemFocus.bottom = rcTxt.bottom + 2 - 1;
#elif defined (__MMI_MAINLCD_240X320__)
rcItemFocus.top = y1;
rcItemFocus.bottom = y2;
#else
rcItemFocus.top =rcTxt.top - ((menuDisp.itemHeight - menuDisp.txtHeight)/3 == 0 ? 2: (menuDisp.itemHeight - menuDisp.txtHeight)/3);
rcItemFocus.bottom = rcTxt.bottom + ((menuDisp.itemHeight - menuDisp.txtHeight)/3 == 0 ? 2: (menuDisp.itemHeight - menuDisp.txtHeight)/3);;
#endif
rcSubIcon.left = menuDisp.rcSubIcon.left;
rcSubIcon.top = y1+ (menuDisp.itemHeight - SUB_ICON_WIDTH)/2;
rcSubIcon.right = menuDisp.rcSubIcon.right;
rcSubIcon.bottom = y2 -(menuDisp.itemHeight - SUB_ICON_WIDTH)/2 ;
if (y2 > menuDisp.rcList.bottom) {
y2 = menuDisp.rcList.bottom;
}
if (pItem->wFlags & MF_DISABLED)
{
if (menuDisp.focuseItem == line)
{
MMI_menu_shortcut_number = menuDisp.focuseItem +1;
{
UI_filled_area bfarea = *(current_MMI_theme->list_selected_item_filler);
#if defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__)
bfarea.flags |= UI_FILLED_AREA_TYPE_TRANSPARENT_COLOR;
bfarea.c.alpha = HIGHLIGHTER_COLOR_OPACITY_VALUE;
#endif
pixtel_UI_draw_filled_area(rcItemFocus.left, rcItemFocus.top ,
rcItemFocus.right , rcItemFocus.bottom, &bfarea);
}
}
if(current_MMI_theme->list_disabled_text_color->r == 255 &&
current_MMI_theme->list_disabled_text_color->g == 255 &&
current_MMI_theme->list_disabled_text_color->b == 255 &&
current_MMI_theme->list_disabled_text_color->alpha == 100)
{
pixtel_UI_set_text_color(colorDisabledText);
}
else
{
pixtel_UI_set_text_color(*current_MMI_theme->list_disabled_text_color);
}
}
else if (menuDisp.focuseItem == line)
{
MMI_menu_shortcut_number = menuDisp.focuseItem +1;
{
UI_filled_area bfarea = *(current_MMI_theme->list_selected_item_filler);
#if defined (__MMI_UI_TRANSPARENT_EFFECT__) || defined (__MMI_UI_LIST_HIGHLIGHT_EFFECTS__)
bfarea.flags |= UI_FILLED_AREA_TYPE_TRANSPARENT_COLOR;
bfarea.c.alpha = HIGHLIGHTER_COLOR_OPACITY_VALUE;
#endif
pixtel_UI_draw_filled_area(rcItemFocus.left, rcItemFocus.top ,
rcItemFocus.right , rcItemFocus.bottom, &bfarea);
}
pixtel_UI_set_text_color(*current_MMI_theme->list_selected_text_color);
}
else
{
pixtel_UI_set_text_color(*current_MMI_theme->list_normal_text_color);
}
if (menuDisp.focuseItem == line && menuDisp.rollStr.bEnable)
{
pixtel_UI_move_text_cursor(menuDisp.rollStr.startX, rcTxt.top);
}
else
{
pixtel_UI_move_text_cursor(rcTxt.left, rcTxt.top);
}
gdi_image_draw_id(rcNumIcon.left, rcNumIcon.top, imageID);
if (pItem->wFlags & MF_POPUP)
{
if (pItem->wFlags & ST_EXPAND)
{
gdi_image_draw_id(rcSubIcon.left , rcSubIcon.top , IMG_ID_PLX_PUBLIC_SUBMENU_EXPAND);
}
else
{
gdi_image_draw_id(rcSubIcon.left , rcSubIcon.top , IMG_ID_PLX_PUBLIC_SUBMENU_CLOSE);
}
}
pixtel_UI_print_text((UI_string_type)pItem->pStr);
if (menuDisp.focuseItem == line && menuDisp.rollStr.bEnable)
{
pixtel_UI_move_text_cursor(menuDisp.rollStr.restartX, rcTxt.top);
pixtel_UI_print_text((UI_string_type)pItem->pStr);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -