⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu_121.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 5 页
字号:
    }        if (_SubMenuDisplay[hMenu].bDownMark == TRUE)    {        pMENURect->rect.wBottom += MENU_SEPARATE_FRAME_THICKNESS;        pMENURect->rect.wBottom += MENU_UP_DOWN_ITEM_HEIGHT;    } }void _MENU_DrawFrame(BYTE bMenuMode, HMENU hMenu){    PARM_RECT MENURect;    PARM_FRAME MENUFrame;    if (bMenuMode == MENU_MAIN_MENU)    {        _MENU_GetMainMenuDisplayRect(hMenu, &MENURect);    }    else if (bMenuMode == MENU_SUB_MENU)    {        _MENU_GetSubMenuDisplayRect(hMenu, &MENURect);    }    MENUFrame.rect.wTop = MENURect.rect.wTop - MENU_FRAME_THICKNESS;    MENUFrame.rect.wBottom = MENURect.rect.wBottom + MENU_FRAME_THICKNESS;    MENUFrame.rect.wLeft = MENURect.rect.wLeft - MENU_FRAME_THICKNESS;    MENUFrame.rect.wRight = MENURect.rect.wRight + MENU_FRAME_THICKNESS;    MENUFrame.bColorBright = MENU_PALETTE_ENTRY_NORMAL_FRAME_BRIGHT;    MENUFrame.bColorDark = MENU_PALETTE_ENTRY_NORMAL_FRAME_DARK;        MENUFrame.bColorCenter = MENU_PALETTE_ENTRY_NORMAL_FRAME_CENTER;    MENUFrame.bStyle = FRAME_POP_SOLID; //FRAME_DOUBLE;    MENUFrame.bThickness = MENU_FRAME_THICKNESS;        GDI_DrawFrame_909(0, &MENUFrame);}void _MENU_ShowMainMenu(HMENU hMenu){    BYTE bMenuIndex;    PARM_RECT MENURect;    PARM_DRAW_STRING MENUStringAttr;    BYTE bDisplayItemNum;
    BYTE bCount;

    if (_pMENUCurrentMenu[hMenu]->pMenuItem[_Cursor[hMenu].bMainMenuIndex].bAttribute == MENU_ITEM_STATE_DISABLE)
    {
         bCount = _MENU_GetCountForDownItem(_pMENUCurrentMenu[hMenu], _Cursor[hMenu].bMainMenuIndex);

         if (bCount == 0)
         {
             bCount = _MENU_GetCountForUpItem(_pMENUCurrentMenu[hMenu], _Cursor[hMenu].bMainMenuIndex);
             if (bCount > 0)
             {
                 _Cursor[hMenu].bMainMenuIndex -= bCount;
             }
         }
         else
         {
            _Cursor[hMenu].bMainMenuIndex += bCount;
         }

         _pMENUCurrentMenu[hMenu]->bDefaultCursorPos = _Cursor[hMenu].bMainMenuIndex;
         _MENU_SetMainMenuInitialDisplay(hMenu);
    }
    //Fill rectangle    MENURect.bColor = MENU_PALETTE_ENTRY_GENERAL_BACKGROUND;    _MENU_GetMainMenuDisplayRect(hMenu, &MENURect);         GDI_FillRect(0, &MENURect);        //Fill frame    _MENU_DrawFrame(MENU_MAIN_MENU, hMenu);    //Draw separate frame    if (_MainMenuDisplay[hMenu].bUpMark == TRUE)     {        _MENU_DrawSeparateFrame(MENU_MAIN_MENU, hMenu, MENU_UP_SEPARATE_FRAME);        _MENU_UpdateUpDownArraow(MENU_MAIN_MENU, hMenu, MENU_ARROW_TYPE_UP);    }    if (_MainMenuDisplay[hMenu].bDownMark == TRUE)    {        _MENU_DrawSeparateFrame(MENU_MAIN_MENU, hMenu, MENU_DOWN_SEPARATE_FRAME);        _MENU_UpdateUpDownArraow(MENU_MAIN_MENU, hMenu, MENU_ARROW_TYPE_DOWN);    }                //Draw String    MENUStringAttr.bBackground = MENU_PALETTE_ENTRY_GENERAL_BACKGROUND; //PAL_ENTRY_COLOR_TRANSPARENT; //Set the color of background is the same as color key.    MENUStringAttr.bColorKey = 0;    MENUStringAttr.bShadow1 = PAL_ENTRY_COLOR_TRANSPARENT; //Use OSDDSPLY_LD_PALETTE_ENTRY_GENERAL_BACKGROUND to prevent the "Open Folder" icon is wrong.    MENUStringAttr.bShadow2 = PAL_ENTRY_COLOR_TRANSPARENT; //Use OSDDSPLY_LD_PALETTE_ENTRY_GENERAL_BACKGROUND to prevent the "Open Folder" icon is wrong.        if (_pMENUCurrentMenu[hMenu]->bTotalItem <= _MainMenuDisplay[hMenu].bMaxVisibleItem)    {        bDisplayItemNum = _pMENUCurrentMenu[hMenu]->bTotalItem;    }    else    {        bDisplayItemNum = _MainMenuDisplay[hMenu].bMaxVisibleItem;    }    for (bMenuIndex = 0; bMenuIndex < bDisplayItemNum; bMenuIndex++)    {            if (_pMENUCurrentMenu[hMenu]->pMenuItem[bMenuIndex+(_MainMenuDisplay[hMenu].bStartDrawItem)].bAttribute == MENU_ITEM_STATE_DISABLE)        {            MENUStringAttr.bTextColor = MENU_PALETTE_ENTRY_ITEM_GRAYED;        }        else        {            MENUStringAttr.bTextColor = MENU_PALETTE_ENTRY_ITEM_TEXT;                    }                MENUStringAttr.wX = _MENU_GetStringStartH(MENU_MAIN_MENU, hMenu, _pMENUCurrentMenu[hMenu]->pMenuItem[bMenuIndex+(_MainMenuDisplay[hMenu].bStartDrawItem)].pwItemText);        MENUStringAttr.wY = _pMENUCurrentMenu[hMenu]->wStartY + MENU_STRING_DISTANCE_V + bMenuIndex*MENU_ITEM_HEIGHT+((MENU_ITEM_HEIGHT-GDI_GetStringHeight(_pMENUCurrentMenu[hMenu]->pMenuItem[bMenuIndex+(_MainMenuDisplay[hMenu].bStartDrawItem)].pwItemText)) >> 1);        GDI_DrawString_909(0, &MENUStringAttr, _pMENUCurrentMenu[hMenu]->pMenuItem[bMenuIndex+(_MainMenuDisplay[hMenu].bStartDrawItem)].pwItemText);        if (_pMENUCurrentMenu[hMenu]->pMenuItem[bMenuIndex+(_MainMenuDisplay[hMenu].bStartDrawItem)].pSubMenu != NULL)        {            MENUStringAttr.wX = MENURect.rect.wRight-MENU_STRING_DISTANCE_H-GDI_GetStringWidth_909(aMENUSubMenuSymbol);            MENUStringAttr.wY = _pMENUCurrentMenu[hMenu]->wStartY+MENU_STRING_DISTANCE_V+bMenuIndex*MENU_ITEM_HEIGHT+((MENU_ITEM_HEIGHT-GDI_GetStringHeight(aMENUSubMenuSymbol)) >> 1);           GDI_DrawString_909(0, &MENUStringAttr, aMENUSubMenuSymbol);        }    }}void _MENU_DrawSeparateFrame(BYTE bMenuMode, HMENU hMenu, BYTE bFrameType){    PARM_RECT MENURect;    if (bMenuMode == MENU_MAIN_MENU)    {        _MENU_GetMainMenuDisplayRect(hMenu, &MENURect);    }    else if (bMenuMode == MENU_SUB_MENU)    {        _MENU_GetSubMenuDisplayRect(hMenu, &MENURect);    }    if (bFrameType == MENU_UP_SEPARATE_FRAME)    {        MENURect.rect.wTop = MENURect.rect.wTop+MENU_UP_DOWN_ITEM_HEIGHT;    }    else if (bFrameType == MENU_DOWN_SEPARATE_FRAME)    {        MENURect.rect.wTop = MENURect.rect.wBottom-MENU_UP_DOWN_ITEM_HEIGHT-MENU_SEPARATE_FRAME_THICKNESS+1;    }    MENURect.rect.wBottom = MENURect.rect.wTop+(MENU_SEPARATE_FRAME_THICKNESS >> 1) -1;    MENURect.bColor = MENU_PALETTE_ENTRY_NORMAL_FRAME_DARK;       GDI_FillRect_909(0, &MENURect);              MENURect.rect.wTop = MENURect.rect.wBottom + 1;    MENURect.rect.wBottom = MENURect.rect.wTop+(MENU_SEPARATE_FRAME_THICKNESS >> 1) -1;        MENURect.bColor = MENU_PALETTE_ENTRY_NORMAL_FRAME_BRIGHT;       GDI_FillRect_909(0, &MENURect);          }void _MENU_UpdateUpDownArraow(BYTE bMenuMode, HMENU hMenu, BYTE bArrowType){    PARM_DRAW_STRING MENUStringAttr;    PARM_RECT MENURect;    WORD wMenuWidth = 0;    _MENU_SetCommonItemStringAttribute(&MENUStringAttr);    if (bMenuMode == MENU_MAIN_MENU)    {        _MENU_GetMainMenuDisplayRect(hMenu, &MENURect);        wMenuWidth = _MENU_GetMenuWidth(_pMENUCurrentMenu[hMenu]);    }    else if (bMenuMode == MENU_SUB_MENU)    {        _MENU_GetSubMenuDisplayRect(hMenu, &MENURect);        wMenuWidth = _MENU_GetMenuWidth(_pMENUSubMenu[hMenu]);    }    if (bArrowType == MENU_ARROW_TYPE_UP)    {        MENUStringAttr.wX = MENURect.rect.wLeft+((wMenuWidth-GDI_GetStringWidth_909(aMENUUpArrowSymbol)) >> 1);        MENUStringAttr.wY = MENURect.rect.wTop+((MENU_UP_DOWN_ITEM_HEIGHT-GDI_GetStringHeight_909(aMENUUpArrowSymbol)) >> 1);        //Output the "up arraow"        GDI_DrawString_909(0, &MENUStringAttr, aMENUUpArrowSymbol);    }    else if (bArrowType == MENU_ARROW_TYPE_DOWN)    {        MENUStringAttr.wX = MENURect.rect.wLeft+((wMenuWidth-GDI_GetStringWidth_909(aMENUDownArrowSymbol)) >> 1);        MENUStringAttr.wY = MENURect.rect.wBottom-MENU_UP_DOWN_ITEM_HEIGHT+1+((MENU_UP_DOWN_ITEM_HEIGHT-GDI_GetStringHeight_909(aMENUDownArrowSymbol)) >> 1);        //Output the "down arraow"        GDI_DrawString_909(0, &MENUStringAttr, aMENUDownArrowSymbol);    }}void _MENU_SetCommonItemStringAttribute(PARM_DRAW_STRING *pMENUStringAttr){    pMENUStringAttr->bBackground = MENU_PALETTE_ENTRY_GENERAL_BACKGROUND;     pMENUStringAttr->bColorKey = 0;    pMENUStringAttr->bShadow1 = PAL_ENTRY_COLOR_TRANSPARENT;    pMENUStringAttr->bShadow2 = PAL_ENTRY_COLOR_TRANSPARENT;    pMENUStringAttr->bTextColor = MENU_PALETTE_ENTRY_ITEM_TEXT; }void _MENU_ClearUpDownArrowBackground(BYTE bMenuMode, HMENU hMenu, BYTE bArrowType){    PARM_RECT MENURect;    if (bMenuMode == MENU_MAIN_MENU)    {        _MENU_GetMainMenuDisplayRect(hMenu, &MENURect);    }    else if (bMenuMode == MENU_SUB_MENU)    {        _MENU_GetSubMenuDisplayRect(hMenu, &MENURect);    }    MENURect.rect.wLeft -= MENU_FRAME_THICKNESS;    MENURect.rect.wRight += MENU_FRAME_THICKNESS;        if (bArrowType == MENU_ARROW_TYPE_UP)    {        MENURect.rect.wBottom = MENURect.rect.wTop+MENU_UP_DOWN_ITEM_HEIGHT+MENU_SEPARATE_FRAME_THICKNESS-1;        MENURect.rect.wTop = MENURect.rect.wTop-MENU_FRAME_THICKNESS;    }    else if (bArrowType == MENU_ARROW_TYPE_DOWN)    {        MENURect.rect.wTop = MENURect.rect.wBottom-MENU_UP_DOWN_ITEM_HEIGHT-MENU_SEPARATE_FRAME_THICKNESS+1;        MENURect.rect.wBottom = MENURect.rect.wBottom+MENU_FRAME_THICKNESS;    }    MENURect.bColor = _bMENUBackgroundColor[hMenu];       GDI_FillRect_909(0, &MENURect);          }void _MENU_SetSubMenuInitialDisplay(HMENU hMenu){     //Sub-menu has "Up" mark?    if (_pMENUSubMenu[hMenu]->bDefaultCursorPos > (_SubMenuDisplay[hMenu].bMaxVisibleItem-1))    {        _SubMenuDisplay[hMenu].bUpMark = TRUE;        _SubMenuDisplay[hMenu].bStartDrawItem = _pMENUSubMenu[hMenu]->bDefaultCursorPos-_SubMenuDisplay[hMenu].bMaxVisibleItem+1;    }    else    {        _SubMenuDisplay[hMenu].bUpMark = FALSE;        _SubMenuDisplay[hMenu].bStartDrawItem = 0;    }    //Sub-menu has "Down" mark?    if ((_SubMenuDisplay[hMenu].bStartDrawItem + _SubMenuDisplay[hMenu].bMaxVisibleItem) < _pMENUSubMenu[hMenu]->bTotalItem)    {        _SubMenuDisplay[hMenu].bDownMark = TRUE;    }    else    {        _SubMenuDisplay[hMenu].bDownMark = FALSE;    }            }void _MENU_SetMainMenuInitialDisplay(HMENU hMenu){    if (_pMENUCurrentMenu[hMenu]->bDefaultCursorPos > (_MainMenuDisplay[hMenu].bMaxVisibleItem-1))
    {        _MainMenuDisplay[hMenu].bUpMark = TRUE;        _MainMenuDisplay[hMenu].bStartDrawItem = _pMENUCurrentMenu[hMenu]->bDefaultCursorPos-_MainMenuDisplay[hMenu].bMaxVisibleItem+1;    }    else    {        _MainMenuDisplay[hMenu].bUpMark = FALSE;        _MainMenuDisplay[hMenu].bStartDrawItem = 0;    }        //Main menu has "Down" mark?    if ((_MainMenuDisplay[hMenu].bStartDrawItem + _MainMenuDisplay[hMenu].bMaxVisibleItem) < _pMENUCurrentMenu[hMenu]->bTotalItem)    {        _MainMenuDisplay[hMenu].bDownMark = TRUE;    }    else    {        _MainMenuDisplay[hMenu].bDownMark = FALSE;    }}BYTE _MENU_GetCountForUpItem(MENU *pMenu, BYTE bCursorIndex){    BYTE bCount = 0;    if (bCursorIndex == 0)        return 0;    while (bCursorIndex != 0)    {        bCursorIndex--;        bCount++;        if (pMenu->pMenuItem[bCursorIndex].bAttribute == MENU_ITEM_STATE_ENABLE)            break;      }        if (bCursorIndex == 0)    {        if (pMenu->pMenuItem[bCursorIndex].bAttribute == MENU_ITEM_STATE_DISABLE)        {            return 0;        }    }                        return bCount;}BYTE _MENU_GetCountForDownItem(MENU *pMenu, BYTE bCursorIndex){    BYTE bCount = 0;    if (bCursorIndex == (pMenu->bTotalItem-1))        return 0;    while (bCursorIndex != (pMenu->bTotalItem-1))    {        bCursorIndex++;        bCount++;                if (pMenu->pMenuItem[bCursorIndex].bAttribute == MENU_ITEM_STATE_ENABLE)            break;      }    if (bCursorIndex == (pMenu->bTotalItem-1))    {        if (pMenu->pMenuItem[bCursorIndex].bAttribute == MENU_ITEM_STATE_DISABLE)        {            return 0;        }    }                        return bCount;}void MENU_ClearMenuBackground(BYTE bMenuMode, HMENU hMenu){    PARM_RECT MENURect;    if (bMenuMode == MENU_MAIN_MENU)    {        _MENU_GetMainMenuDisplayRect(hMenu, &MENURect);    }    else if (bMenuMode == MENU_SUB_MENU)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -