BOOL submenu_scroll_down(sub_menu_t* sub_menu) { UINT32 count = sub_menu->item_count; UINT32 depth = sub_menu->list_page; UINT32 top_pos = sub_menu->list_top; UINT32 cur_sel = sub_menu->list_sel; UINT32 cur_pos = cur_sel - top_pos; //UINT32 old_sel = cur_sel; //UINT32 old_top = top_pos; UINT32 i; BOOL ret = TRUE; for (i = 0; i < count; i++) { ret = OSD_ScrollLineDown(count, depth, &top_pos, &cur_pos); if (!ret) return FALSE; cur_sel = top_pos + cur_pos; if (submenu_item_attr(sub_menu, cur_sel) == C_ATTR_ACTIVE) { sub_menu->list_top = top_pos; sub_menu->list_sel = cur_sel; return TRUE; } } return FALSE; }
BOOL submenu_set_items_network() { UINT32 i; sub_menu_item_t* menu_item; CONTAINER* menu_item_obj; POBJECT_HEAD pObj,pObjName,pObjSet; CONTAINER* win_sub_menu = &g_win_submenu; UINT8 action; BOOL ret = TRUE; sub_menu_t* sub_menu=&sub_menu_network; if (sub_menu->item_count <= C_SUBMENU_PAGE) { sub_menu->list_page = sub_menu->item_count; } else { sub_menu->list_page = C_SUBMENU_PAGE; } UINT32 count = sub_menu->item_count; UINT32 depth = sub_menu->list_page; UINT32 max_top = OSD_GetMaxTopPos(count, &depth); if (sub_menu->list_top >= sub_menu->list_sel) sub_menu->list_top = sub_menu->list_sel; else if (sub_menu->list_sel - sub_menu->list_top >= sub_menu->list_page) sub_menu->list_top = sub_menu->list_sel + 1 - sub_menu->list_page; if (sub_menu->list_top > max_top) sub_menu->list_top = max_top; if (submenu_item_attr(sub_menu, sub_menu->list_sel) != C_ATTR_ACTIVE) { ret = submenu_scroll_down(sub_menu); } sub_menu_desc = sub_menu; /*Set menu callback */ if(sub_menu->menu_callback != NULL) OSD_SetCallback(win_sub_menu, sub_menu->menu_callback); else OSD_SetCallback(win_sub_menu, sm_con_callback); submenu_set_one_page(sub_menu); //SCROLL_BAR* sb = &subm_scrollbar; //OSD_SetScrollBarMax(sb, sub_menu->item_count); //OSD_SetScrollBarPos(sb, sub_menu->list_sel); return ret; }
BOOL submenu_active(sub_menu_t* sub_menu) { UINT32 i; UINT8 action; for(i=0;i<sub_menu->item_count;i++) { action = submenu_item_attr(sub_menu, i); if (action == C_ATTR_ACTIVE) return TRUE; } return FALSE; }
BOOL submenu_set_one_page(sub_menu_t* sub_menu) { UINT16 i; sub_menu_item_t* menu_item; CONTAINER* menu_item_obj; POBJECT_HEAD pObj,pObjName,pObjSet; CONTAINER* win_sub_menu = &g_win_submenu; UINT8 action; for(i=0;i<sub_menu->list_page;i++) { #if 0 /* IDX & setting Display */ ComInt2UniStr(display_strs[i], i + 1, 0); ComAscStr2Uni("", display_strs[10 + i]); #endif /* Set attribute to active*/ action = submenu_item_attr(sub_menu, i+sub_menu->list_top); submenu_set_item_attr(i,action); menu_item = &sub_menu->items[i+sub_menu->list_top]; menu_item_obj = submenu_items[i]; /* Link menu items next object and set IDs*/ menu_item_obj->head.pNext = (i< (sub_menu->list_page - 1) ) ? ((POBJECT_HEAD)submenu_items[i + 1]) : NULL; OSD_SetID(menu_item_obj, i + 1, i + 1, i + 1, i==0? sub_menu->list_page : i, (i==sub_menu->list_page - 1)? 1 : i+2); #if 0 /* Link menu item's setting or not*/ pObj = menu_item_obj->pNextInCntn; /* IDX */ pObjName = pObj->pNext; /* Name */ pObjSet = submenu_item_sets[i]; switch(menu_item->item_type) { case ITEM_TYPE_NOMAL: pObjName->pNext = NULL; break; default: pObjName->pNext = pObjSet; break; } #endif /* Set menu item's name display*/ pObjName = OSD_GetContainerNextObj(menu_item_obj); OSD_SetTextFieldContent((PTEXT_FIELD)pObjName, STRING_ID, (UINT32)menu_item->item_name); /*Set menu item's callback */ if(menu_item->item_callback != NULL) OSD_SetCallback(menu_item_obj, menu_item->item_callback); else OSD_SetCallback(menu_item_obj, sm_item_con_callback); } OSD_SetContainerFocus(win_sub_menu, sub_menu->list_sel + 1 - sub_menu->list_top); }
BOOL submenu_set_items(sub_menu_t* sub_menu) { UINT32 i; sub_menu_item_t* menu_item; CONTAINER* menu_item_obj; POBJECT_HEAD pObj,pObjName,pObjSet; CONTAINER* win_sub_menu = &g_win_submenu; UINT8 action; BOOL ret = TRUE; UINT8 focusID; focusID = OSD_GetFocusID((POBJECT_HEAD)&g_win_mainmenu); if (sub_menu->item_count <= C_SUBMENU_PAGE) { #ifdef SATLLITE_SHARE_SUPPORT //guop add 20100903 if(focusID==2) { if(share_flag == FALSE) { sub_menu->item_count =3; } else { sub_menu->item_count =4; } } #endif sub_menu->list_page = sub_menu->item_count; } else { sub_menu->list_page = C_SUBMENU_PAGE; } UINT32 count = sub_menu->item_count; UINT32 depth = sub_menu->list_page; UINT32 max_top = OSD_GetMaxTopPos(count, &depth); if (sub_menu->list_top >= sub_menu->list_sel) sub_menu->list_top = sub_menu->list_sel; else if (sub_menu->list_sel - sub_menu->list_top >= sub_menu->list_page) sub_menu->list_top = sub_menu->list_sel + 1 - sub_menu->list_page; if (sub_menu->list_top > max_top) sub_menu->list_top = max_top; if (submenu_item_attr(sub_menu, sub_menu->list_sel) != C_ATTR_ACTIVE) { ret = submenu_scroll_down(sub_menu); } sub_menu_desc = sub_menu; /*Set menu callback */ if(sub_menu->menu_callback != NULL) OSD_SetCallback(win_sub_menu, sub_menu->menu_callback); else OSD_SetCallback(win_sub_menu, sm_con_callback); submenu_set_one_page(sub_menu); SCROLL_BAR* sb = &subm_scrollbar; OSD_SetScrollBarMax(sb, sub_menu->item_count); OSD_SetScrollBarPos(sb, sub_menu->list_sel); return ret; }
BOOL submenu_unknown_act(sub_menu_t *sub_menu, UINT32 vact) { UINT32 count = sub_menu->item_count; UINT32 depth = sub_menu->list_page; UINT32 top_pos = sub_menu->list_top; UINT32 cur_sel = sub_menu->list_sel; UINT32 cur_pos = cur_sel - top_pos; UINT32 old_sel = cur_sel; UINT32 old_top = top_pos; UINT32 i; BOOL ret = TRUE; TEXT_FIELD* txt1; TEXT_FIELD* txt2; if (vact >= VACT_NUM_1 && vact<= VACT_NUM_9) { OSD_ChangeFocus((POBJECT_HEAD)&g_win_submenu, vact - VACT_NUM_0, C_UPDATE_FOCUS); return TRUE; } if(vact == VACT_FOCUS_P_UP || vact == VACT_FOCUS_P_DOWN) { if (vact == VACT_FOCUS_P_UP) ret = OSD_ScrollLinePgUp(count, depth, &top_pos, &cur_pos); else ret = OSD_ScrollLinePgDown(count, depth, &top_pos, &cur_pos); if (!ret) return FALSE; cur_sel = top_pos + cur_pos; if (cur_sel == old_sel) return FALSE; if (submenu_item_attr(sub_menu, cur_sel) == C_ATTR_ACTIVE) { vact = VACT_PASS; } else { if (vact == VACT_FOCUS_P_UP) vact = VACT_FOCUS_UP; else vact = VACT_FOCUS_DOWN; } } if(vact == VACT_FOCUS_UP || vact == VACT_FOCUS_DOWN) { for (i = 0; i < count; i++) { if (vact == VACT_FOCUS_UP) ret = OSD_ScrollLineUp(count, depth, &top_pos, &cur_pos); else ret = OSD_ScrollLineDown(count, depth, &top_pos, &cur_pos); if (!ret) return FALSE; cur_sel = top_pos + cur_pos; if (cur_sel == old_sel) return FALSE; if (submenu_item_attr(sub_menu, cur_sel) == C_ATTR_ACTIVE) break; } if (i == count) return FALSE; } if (cur_sel != old_sel) { sub_menu->list_top = top_pos; sub_menu->list_sel = cur_sel; OSD_SetScrollBarPos(&subm_scrollbar, cur_sel); if (old_top == top_pos) { OSD_ChangeFocus((POBJECT_HEAD)&g_win_submenu, cur_pos + 1, C_DRAW_SIGN_EVN_FLG |C_UPDATE_FOCUS); /* txt1 = submenu_txt[cur_pos]; txt1->head.bFont = 2; txt2 = submenu_txt[old_sel]; txt2->head.bFont = 0; */ OSD_DrawObject((POBJECT_HEAD)&subm_scrollbar, C_UPDATE_ALL); } else { submenu_set_one_page(sub_menu); OSD_TrackObject((POBJECT_HEAD)&g_win_submenu, C_UPDATE_CONTENT); } } return TRUE; }
BOOL submenu_unknown_act(sub_menu_t *sub_menu, UINT32 vact) { UINT32 count = sub_menu->item_count; UINT32 depth = sub_menu->list_page; UINT32 top_pos = sub_menu->list_top; UINT32 cur_sel = sub_menu->list_sel; UINT32 cur_pos = cur_sel - top_pos; UINT32 old_sel = cur_sel; UINT32 old_top = top_pos; UINT32 i; BOOL ret = TRUE; #ifndef PREVIEW_SUBMENU //-a by wangyang if (vact >= VACT_NUM_1 && vact<= VACT_NUM_9) { OSD_ChangeFocus((POBJECT_HEAD)&g_win_submenu, vact - VACT_NUM_0, C_UPDATE_FOCUS); return TRUE; } if(vact == VACT_FOCUS_P_UP || vact == VACT_FOCUS_P_DOWN) { if (vact == VACT_FOCUS_P_UP) ret = OSD_ScrollLinePgUp(count, depth, &top_pos, &cur_pos); else ret = OSD_ScrollLinePgDown(count, depth, &top_pos, &cur_pos); if (!ret) return FALSE; cur_sel = top_pos + cur_pos; if (cur_sel == old_sel) return FALSE; if (submenu_item_attr(sub_menu, cur_sel) == C_ATTR_ACTIVE) { vact = VACT_PASS; } else { if (vact == VACT_FOCUS_P_UP) vact = VACT_FOCUS_UP; else vact = VACT_FOCUS_DOWN; } } #endif if(vact == VACT_FOCUS_UP || vact == VACT_FOCUS_DOWN) { for (i = 0; i < count; i++) { if (vact == VACT_FOCUS_UP) ret = OSD_ScrollLineUp(count, depth, &top_pos, &cur_pos); else ret = OSD_ScrollLineDown(count, depth, &top_pos, &cur_pos); if (!ret) return FALSE; cur_sel = top_pos + cur_pos; if (cur_sel == old_sel) return FALSE; if (submenu_item_attr(sub_menu, cur_sel) == C_ATTR_ACTIVE) break; } if (i == count) return FALSE; } if (cur_sel != old_sel) { sub_menu->list_top = top_pos; sub_menu->list_sel = cur_sel; //OSD_SetScrollBarPos(&subm_scrollbar, cur_sel); if (old_top == top_pos) { OSD_ChangeFocus((POBJECT_HEAD)&g_win_submenu, cur_pos + 1, C_UPDATE_FOCUS); // OSD_DrawObject((POBJECT_HEAD)&subm_scrollbar, C_UPDATE_ALL); } else { submenu_set_one_page(sub_menu); OSD_TrackObject((POBJECT_HEAD)&g_win_submenu, C_UPDATE_CONTENT); } } #ifdef EXIT_KEY_EXIT_ALL_MENU if(vact == VACT_CLOSE_ALL_MENU) { exit_key_flag =TRUE; OSD_ObjClose((POBJECT_HEAD)&g_win_submenu,C_CLOSE_CLRBACK_FLG); mm_leave_all_menu(); // ap_clear_all_menus(); // ap_exit_key_clear_all_menus(); // ap_send_msg(CTRL_MSG_SUBTYPE_CMD_ENTER_ROOT, (UINT32)&win_diag, TRUE); } #endif return TRUE; }