📄 menu_121.c
字号:
_pMENUSubMenu[hMenu] = (PMENU)(_pMENUCurrentMenu[hMenu]->pMenuItem[_Cursor[hMenu].bMainMenuIndex].pSubMenu); _MENU_SetSubMenuInitialDisplay(hMenu); _Cursor[hMenu].bSubMenuIndex = _pMENUSubMenu[hMenu]->bDefaultCursorPos; _MENU_ShowSubMenu(hMenu); }
return MENU_ACTION_UP_MAIN_MENU; } } else if (_Cursor[hMenu].bPos == MENU_SUB_MENU) { if (_Cursor[hMenu].bSubMenuIndex == 0) {
#ifndef SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS
return MENU_ACTION_EXCEED_UP_SUB_MENU;
#else
_MENU_GoToSubMenuItem(hMenu, MENU_LAST_ITEM);
return MENU_ACTION_UP_SUB_MENU;
#endif //SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS } else {
bCount = _MENU_GetCountForUpItem(_pMENUSubMenu[hMenu], _Cursor[hMenu].bSubMenuIndex);
if (bCount == 0)
{
#ifndef SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS
return MENU_ACTION_EXCEED_UP_SUB_MENU;
#else
_MENU_GoToSubMenuItem(hMenu, MENU_LAST_ITEM);
return MENU_ACTION_UP_SUB_MENU;
#endif //SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS
}
if ((_Cursor[hMenu].bSubMenuIndex-bCount) < _SubMenuDisplay[hMenu].bStartDrawItem) { //scroll up _Cursor[hMenu].bSubMenuIndex -= bCount;
if (_SubMenuDisplay[hMenu].bStartDrawItem >= bCount)
{ _SubMenuDisplay[hMenu].bStartDrawItem -= bCount;
}
else
{
_SubMenuDisplay[hMenu].bStartDrawItem = 0;
}
//Note: Must clear the "up" region before re-draw the sub menu. if (_SubMenuDisplay[hMenu].bStartDrawItem == 0) { //Clear "Up" mark _MENU_ClearUpDownArrowBackground(MENU_SUB_MENU, hMenu, MENU_ARROW_TYPE_UP); _SubMenuDisplay[hMenu].bUpMark = FALSE; } if ((_SubMenuDisplay[hMenu].bStartDrawItem+_SubMenuDisplay[hMenu].bMaxVisibleItem) < _pMENUSubMenu[hMenu]->bTotalItem) { _SubMenuDisplay[hMenu].bDownMark = TRUE; } _MENU_ShowSubMenu(hMenu); } else { //Update the cursor MENU_UpdateCursor(hMenu, CURSOR_STYLE_CLEAR); _Cursor[hMenu].bSubMenuIndex -= bCount; } MENU_UpdateCursor(hMenu, CURSOR_STYLE_NORMAL);
return MENU_ACTION_UP_SUB_MENU; } } break; case KEY_DOWN: if (_Cursor[hMenu].bPos == MENU_MAIN_MENU) { if (_Cursor[hMenu].bMainMenuIndex == (_pMENUCurrentMenu[hMenu]->bTotalItem-1)) {
#ifndef SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS return MENU_ACTION_EXCEED_DOWN_MAIN_MENU;
#else
_MENU_GoToMainMenuItem(hMenu, MENU_FIRST_ITEM);
return MENU_ACTION_UP_MAIN_MENU;
#endif //SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS } else { //Check if there is any enabled items for "Down" action. bCount = _MENU_GetCountForDownItem(_pMENUCurrentMenu[hMenu], _Cursor[hMenu].bMainMenuIndex); if (bCount == 0) {
#ifndef SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS return MENU_ACTION_EXCEED_DOWN_MAIN_MENU;
#else
_MENU_GoToMainMenuItem(hMenu, MENU_FIRST_ITEM);
return MENU_ACTION_UP_MAIN_MENU;
#endif //SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS
} //Clear current sub-menu. MENU_ClearMenuBackground(MENU_SUB_MENU, hMenu); //if ((_Cursor[hMenu].bMainMenuIndex-_MainMenuDisplay[hMenu].bStartDrawItem+1) >= _MainMenuDisplay[hMenu].bMaxVisibleItem) if ((_Cursor[hMenu].bMainMenuIndex-_MainMenuDisplay[hMenu].bStartDrawItem+bCount) >= _MainMenuDisplay[hMenu].bMaxVisibleItem) { //scroll down _Cursor[hMenu].bMainMenuIndex += bCount; //_MainMenuDisplay[hMenu].bStartDrawItem += bCount; _MainMenuDisplay[hMenu].bStartDrawItem = _Cursor[hMenu].bMainMenuIndex-_MainMenuDisplay[hMenu].bMaxVisibleItem+1; _MainMenuDisplay[hMenu].bDownMark = TRUE; //Note: Must clear the "Down" region before re-draw the sub menu. if ((_MainMenuDisplay[hMenu].bStartDrawItem+_MainMenuDisplay[hMenu].bMaxVisibleItem) == _pMENUCurrentMenu[hMenu]->bTotalItem) { //Clear "Down" mark _MENU_ClearUpDownArrowBackground(MENU_MAIN_MENU, hMenu, MENU_ARROW_TYPE_DOWN); _MainMenuDisplay[hMenu].bDownMark = FALSE; } if (_MainMenuDisplay[hMenu].bStartDrawItem != 0) { _MainMenuDisplay[hMenu].bUpMark = TRUE; } _MENU_ShowMainMenu(hMenu); } else { //Update the cursor MENU_UpdateCursor(hMenu, CURSOR_STYLE_CLEAR); _Cursor[hMenu].bMainMenuIndex += bCount; } MENU_UpdateCursor(hMenu, CURSOR_STYLE_NORMAL); _pMENUSubMenu[hMenu] = _pMENUCurrentMenu[hMenu]->pMenuItem[_Cursor[hMenu].bMainMenuIndex].pSubMenu; //Show sub-menu if ((_pMENUSubMenu[hMenu] != NULL) && (_pMENUSubMenu[hMenu]->bTotalItem != 0)) { _pMENUSubMenu[hMenu] = (PMENU)(_pMENUCurrentMenu[hMenu]->pMenuItem[_Cursor[hMenu].bMainMenuIndex].pSubMenu); _MENU_SetSubMenuInitialDisplay(hMenu); _Cursor[hMenu].bSubMenuIndex = _pMENUSubMenu[hMenu]->bDefaultCursorPos; _MENU_ShowSubMenu(hMenu); }
return MENU_ACTION_DOWN_MAIN_MENU; } } else if (_Cursor[hMenu].bPos == MENU_SUB_MENU) { if (_Cursor[hMenu].bSubMenuIndex == (_pMENUSubMenu[hMenu]->bTotalItem-1)) {
#ifndef SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS return MENU_ACTION_EXCEED_DOWN_SUB_MENU;
#else
_MENU_GoToSubMenuItem(hMenu, MENU_FIRST_ITEM);
return MENU_ACTION_DOWN_SUB_MENU;
#endif //SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS } else {
bCount = _MENU_GetCountForDownItem(_pMENUSubMenu[hMenu], _Cursor[hMenu].bSubMenuIndex);
if (bCount == 0)
{
#ifndef SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS
return MENU_ACTION_EXCEED_DOWN_SUB_MENU;
#else
_MENU_GoToSubMenuItem(hMenu, MENU_FIRST_ITEM);
return MENU_ACTION_DOWN_SUB_MENU;
#endif //SETUP_KEY_UP_DOWN_TOGGLE_OPTIONS
}
if ((_Cursor[hMenu].bSubMenuIndex-_SubMenuDisplay[hMenu].bStartDrawItem+bCount) >= _SubMenuDisplay[hMenu].bMaxVisibleItem)
{
//scroll down _Cursor[hMenu].bSubMenuIndex += bCount; _SubMenuDisplay[hMenu].bStartDrawItem++; _SubMenuDisplay[hMenu].bDownMark = TRUE; //Note: Must clear the "Down" region before re-draw the sub menu. if ((_SubMenuDisplay[hMenu].bStartDrawItem+_SubMenuDisplay[hMenu].bMaxVisibleItem) == _pMENUSubMenu[hMenu]->bTotalItem) { //Clear "Down" mark _MENU_ClearUpDownArrowBackground(MENU_SUB_MENU, hMenu, MENU_ARROW_TYPE_DOWN); _SubMenuDisplay[hMenu].bDownMark = FALSE; } if (_SubMenuDisplay[hMenu].bStartDrawItem != 0) { _SubMenuDisplay[hMenu].bUpMark = TRUE; } _MENU_ShowSubMenu(hMenu); } else { //Update the cursor MENU_UpdateCursor(hMenu, CURSOR_STYLE_CLEAR); _Cursor[hMenu].bSubMenuIndex += bCount; } MENU_UpdateCursor(hMenu, CURSOR_STYLE_NORMAL);
return MENU_ACTION_DOWN_SUB_MENU; } } break; case KEY_PLAY:
case KEY_ENTER: if (_Cursor[hMenu].bPos == MENU_MAIN_MENU) { if (_pMENUSubMenu[hMenu] != NULL) {
if (_pMENUSubMenu[hMenu]->bTotalItem != 0) //to prevent go to a "no item" sub-menu.
{ MENU_UpdateCursor(hMenu, CURSOR_STYLE_GRAYED); //update the cursor to the sub-menu _Cursor[hMenu].bPos = MENU_SUB_MENU; MENU_UpdateCursor(hMenu, CURSOR_STYLE_NORMAL);
} } else { //return the ID to do exact action. return ((((DWORD)MENU_ACTION_PROCESS_MENU_ITEM) << 16) | _pMENUCurrentMenu[hMenu]->pMenuItem[_Cursor[hMenu].bMainMenuIndex].bID); } } else if (_Cursor[hMenu].bPos == MENU_SUB_MENU) {
if (_pMENUSubMenu[hMenu]->bCheckMenuItemPos != MENU_ITEM_NO_CHECKED_ITEM) //CoCo2.38
{ _pMENUSubMenu[hMenu]->bCheckMenuItemPos = _Cursor[hMenu].bSubMenuIndex; _pMENUSubMenu[hMenu]->bDefaultCursorPos = _pMENUSubMenu[hMenu]->bCheckMenuItemPos;
} //Recover the cursor to normal state in the sub-menu and re-draw the check item. _MENU_ShowSubMenu(hMenu); //Return to main menu _Cursor[hMenu].bPos = MENU_MAIN_MENU; MENU_UpdateCursor(hMenu, CURSOR_STYLE_NORMAL); if (_pMENUSubMenu[hMenu]->bMenuType == MENU_TYPE_NUM) { return (MENU_ACTION_PROCESS_NUN_ITEM) | (((DWORD)(_pMENUCurrentMenu[hMenu]->pMenuItem[_Cursor[hMenu].bMainMenuIndex].bID)) << 16) | _Cursor[hMenu].bSubMenuIndex; } else { return (((DWORD)MENU_ACTION_PROCESS_MENU_ITEM << 16) | _pMENUSubMenu[hMenu]->pMenuItem[(_Cursor[hMenu].bSubMenuIndex)].bID); } } break; default: break; } return MENU_ACTION_NONE;}//***************************************************************************// Function : MENU_DeleteMenu// Abstract : // Arguments : none.// Return : // Side Effect : none.// Notes : //***************************************************************************void MENU_DeleteMenu(HMENU hMenu, BYTE bClearBackground){ //clear menu if (_pMENUCurrentMenu[hMenu] != NULL) {
if (bClearBackground)
{ MENU_ClearMenuBackground(MENU_MAIN_MENU, hMenu);
} } if (_pMENUSubMenu[hMenu] != NULL) {
if (bClearBackground)
{ MENU_ClearMenuBackground(MENU_SUB_MENU, hMenu);
} } _pMENUCurrentMenu[hMenu] = NULL; _pMENUSubMenu[hMenu] = NULL; _hMenuStack[hMenu] = MENU_HANDLE_FREE;}HMENU _MENU_GetMenuHandle(void){ BYTE i; for (i = 0; i < MAX_SUPPORT_MENU_HANDLE_NUM; i++) { if (_hMenuStack[i] == MENU_HANDLE_FREE) { _hMenuStack[i] = i; return _hMenuStack[i]; } } return MENU_HANDLE_INVALID;}WORD _MENU_GetMenuWidth(MENU *pMenu){ BYTE bItemIndex; WORD wMaxWidth = 0; WORD wStringWidth; if (pMenu == NULL) return 0; if (pMenu->wWidth != MENU_WIDTH_OPTIMIZED) return pMenu->wWidth; for (bItemIndex = 0; bItemIndex < pMenu->bTotalItem; bItemIndex++) { if (pMenu->bMenuType == MENU_TYPE_NUM) { OSDUTL_PrepareOutputString(); OSDUTL_OutputNumFromIndex(pMenu->wStartNum+bItemIndex); wStringWidth = GDI_GetStringWidth_909(__pOSDUTLOutputString); if (wMaxWidth < wStringWidth) wMaxWidth = wStringWidth; } else { wStringWidth = GDI_GetStringWidth_909(pMenu->pMenuItem[bItemIndex].pwItemText); if (wMaxWidth < wStringWidth) wMaxWidth = wStringWidth; } } wMaxWidth += MENU_STRING_DISTANCE_H*2;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -