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

📄 dialog.c

📁 ct952 source code use for Digital Frame Photo
💻 C
📖 第 1 页 / 共 2 页
字号:
            GDI_FillRoundRect(0|GDI_SHADING_OPERATION, DIALOG_BUTTON_ARC, &Rect);
            break;
        case 2:
            Rect.bShadePtr = _bDIALOGNormalButtonPalette3;
            GDI_FillRect(0|GDI_SHADING_OPERATION, &Rect);
            break;
        case 3:
            Rect.bShadePtr = _bDIALOGNormalButtonPalette4;
            GDI_FillRoundRect(0|GDI_SHADING_OPERATION, DIALOG_BUTTON_ARC, &Rect);
            break;
        case 0:
        default:       
            Rect.bShadePtr = _bDIALOGNormalButtonPalette1;
            GDI_FillRect(0|GDI_SHADING_OPERATION, &Rect);
            break;
        }
    }
    else if (bType == DIALOG_BUTTON_TYPE_HIGHLIGHT)
    {
        switch (_bDIALOGUIStyle[hDialog])
        {
        case 1:
            Rect.bShadePtr = _bDIALOGHighlightButtonPalette2;
            GDI_FillRoundRect(0|GDI_SHADING_OPERATION, DIALOG_BUTTON_ARC, &Rect);
            break;
        case 2:
            Rect.bShadePtr = _bDIALOGHighlightButtonPalette3;
            GDI_FillRect(0|GDI_SHADING_OPERATION, &Rect);
            break;
        case 3:
            Rect.bShadePtr = _bDIALOGHighlightButtonPalette4;
            GDI_FillRoundRect(0|GDI_SHADING_OPERATION, DIALOG_BUTTON_ARC, &Rect);
            break;
        case 0:
        default:       
            Rect.bShadePtr = _bDIALOGHighlightButtonPalette1;
            GDI_FillRect(0|GDI_SHADING_OPERATION, &Rect);
            break;
        }
    }

    //Draw the button string
    ButtonStringAttr.bBackground = 1;
    ButtonStringAttr.bColorKey = 1;
    ButtonStringAttr.bShadow1 = 1;
    ButtonStringAttr.bShadow2 = 1;
    ButtonStringAttr.bTextColor = DIALOG_PALETTE_ENTRY_BUTTON_STRING;
    
    ButtonStringAttr.wX = _DIALOG_GetButtonStartX(hDialog, bButtonIndex)+((_DIALOG_GetButtonWidth(hDialog)-GDI_GetStringWidth_909(_pDIALOGCurrentDialog[hDialog]->pButton[bButtonIndex].pwButtonText))>>1);
    ButtonStringAttr.wY = _DIALOG_GetButtonStartY(hDialog)+((DIALOG_BUTTON_HEIGHT-GDI_GetStringHeight_909(_pDIALOGCurrentDialog[hDialog]->pButton[bButtonIndex].pwButtonText))>>1);
    GDI_DrawString_909(0, &ButtonStringAttr, _pDIALOGCurrentDialog[hDialog]->pButton[bButtonIndex].pwButtonText);
}

BYTE _DIALOG_GetButtonWidth(HDIALOG hDialog)
{
    BYTE bButtonIndex;
    BYTE bMaxButtonWidth = 0;
    BYTE bButtonStringWidth = 0;

    if (_pDIALOGCurrentDialog[hDialog]->bButtonWidth == DIALOG_BUTTON_WIDTH_OPTIMIZED)
    {
        for (bButtonIndex = 0; bButtonIndex < _pDIALOGCurrentDialog[hDialog]->bButtonNum; bButtonIndex++)
        {
            bButtonStringWidth = GDI_GetStringWidth_909(_pDIALOGCurrentDialog[hDialog]->pButton[bButtonIndex].pwButtonText);
            
            if (bMaxButtonWidth < bButtonStringWidth)
            {
                bMaxButtonWidth = bButtonStringWidth;
            }
        }
        
        bMaxButtonWidth += (DIALOG_BUTTON_STRING_OPTIMIZED_DISTANCE_H*2);
    }
    else
    {
        return _pDIALOGCurrentDialog[hDialog]->bButtonWidth;
    }

    return bMaxButtonWidth;
}

WORD _DIALOG_GetButtonStartX(HDIALOG hDialog, BYTE bButtonIndex)
{
    WORD wStartX;

    if (_pDIALOGCurrentDialog[hDialog]->pButton[bButtonIndex].wStartX == DIALOG_BUTTON_START_X_OPTIMIZED)
    {
        wStartX = _pDIALOGCurrentDialog[hDialog]->wStartX+((_pDIALOGCurrentDialog[hDialog]->wWidth - DIALOG_BUTTON_BUTTON_DISTANCE*(_pDIALOGCurrentDialog[hDialog]->bButtonNum-1)-_DIALOG_GetButtonWidth(hDialog)*_pDIALOGCurrentDialog[hDialog]->bButtonNum) >> 1);
        wStartX += (bButtonIndex*_DIALOG_GetButtonWidth(hDialog)+DIALOG_BUTTON_BUTTON_DISTANCE*bButtonIndex);
    }
    else
    {
        return _pDIALOGCurrentDialog[hDialog]->pButton[bButtonIndex].wStartX;
    }

    return wStartX;
}

WORD _DIALOG_GetButtonStartY(HDIALOG hDialog)
{
    if (_pDIALOGCurrentDialog[hDialog]->wButtonStartY == DIALOG_BUTTON_START_Y_OPTIMIZED)
    {
        return (_pDIALOGCurrentDialog[hDialog]->wStartY+_pDIALOGCurrentDialog[hDialog]->wHeight-DIALOG_BUTTON_DISTANCE_V-DIALOG_BUTTON_HEIGHT);
    }
    else
    {
        return _pDIALOGCurrentDialog[hDialog]->wButtonStartY;
    }
}

//***************************************************************************
//  Function    :   DIALOG_Processkey
//  Abstract    :   
//  Arguments   :   none.
//  Return      :   
//  Side Effect :   none.
//  Notes       :   
//***************************************************************************
WORD DIALOG_Processkey(HDIALOG hDialog, BYTE bKey)
{
    if (_pDIALOGCurrentDialog[hDialog] == NULL)
    {
        return DIALOG_ACTION_NONE;
    }

    switch (bKey)
    {
    case KEY_LEFT:
        if (_bDIALOGCursor[hDialog] == 0)
        {
            break;
        }
        else
        {
            _DIALOG_DrawButton(hDialog, _bDIALOGCursor[hDialog], DIALOG_BUTTON_TYPE_NORMAL);
            _bDIALOGCursor[hDialog]--;
            _DIALOG_DrawButton(hDialog, _bDIALOGCursor[hDialog], DIALOG_BUTTON_TYPE_HIGHLIGHT);
        }
        break;
    case KEY_RIGHT:
        if (_bDIALOGCursor[hDialog] == (_pDIALOGCurrentDialog[hDialog]->bButtonNum-1))
        {
            break;
        }
        else
        {
            _DIALOG_DrawButton(hDialog, _bDIALOGCursor[hDialog], DIALOG_BUTTON_TYPE_NORMAL);
            _bDIALOGCursor[hDialog]++;
            _DIALOG_DrawButton(hDialog, _bDIALOGCursor[hDialog], DIALOG_BUTTON_TYPE_HIGHLIGHT);
        }
        break;
    case KEY_PLAY:
   case KEY_PLAY_PAUSE:
    case KEY_ENTER:
        return (DIALOG_ACTION_BUTTON_PRESSED|_pDIALOGCurrentDialog[hDialog]->pButton[(_bDIALOGCursor[hDialog])].bID);
    default:
        return DIALOG_ACTION_NONE;
    }

    return DIALOG_ACTION_DONE;
}

//***************************************************************************
//  Function    :   DIALOG_DeleteDialog
//  Abstract    :   
//  Arguments   :   none.
//  Return      :   
//  Side Effect :   none.
//  Notes       :   
//***************************************************************************
void DIALOG_DeleteDialog(HDIALOG hDialog, BYTE bClearBackground)
{
    PARM_RECT Rect;

    if (bClearBackground)
    {
        //clear the dialog region
        Rect.bColor = _bDIALOGBackgroundColor[hDialog];
        Rect.rect.wLeft = _pDIALOGCurrentDialog[hDialog]->wStartX;
        Rect.rect.wTop = _pDIALOGCurrentDialog[hDialog]->wStartY;
        Rect.rect.wRight = Rect.rect.wLeft+_pDIALOGCurrentDialog[hDialog]->wWidth-1;
        Rect.rect.wBottom = Rect.rect.wTop+_pDIALOGCurrentDialog[hDialog]->wHeight-1;
        
        switch (_bDIALOGUIStyle[hDialog])
        {
        case 1:
        case 2:
        case 3:
            GDI_FillRoundRect(0, DIALOG_CONTENT_REGION_ARC, &Rect);
            break;
        case 0:
        default:
            GDI_FillRect(0, &Rect);
            break;
        }
    }

    _pDIALOGCurrentDialog[hDialog] = NULL;
    _hDIALOGStack[hDialog] = DIALOG_HANDLE_FREE;
}


HDIALOG _DIALOG_GetDialogHandle(void)
{
    BYTE i;
    for (i = 0; i < MAX_SUPPORT_DIALOG_HANDLE_NUM; i++)
    {
        if (_hDIALOGStack[i] == DIALOG_HANDLE_FREE)
        {
            _hDIALOGStack[i] = i;
            return _hDIALOGStack[i];
        }
    }

    return DIALOG_HANDLE_INVALID;
}

void DIALOG_SetCursor(HDIALOG hDialog, BYTE bButtonID)
{
    BYTE bButtonIndex;

    for (bButtonIndex = 0; bButtonIndex <  _pDIALOGCurrentDialog[hDialog]->bButtonNum; bButtonIndex++)
    {
        if (_pDIALOGCurrentDialog[hDialog]->pButton[bButtonIndex].bID == bButtonID)
        {
            _bDIALOGCursor[hDialog] = bButtonIndex;            
            break;
        }
    }

    _DIALOG_DrawButton(hDialog, bButtonIndex, DIALOG_BUTTON_TYPE_HIGHLIGHT);
}

void DIALOG_ClearCursor(HDIALOG hDialog)
{
    _DIALOG_DrawButton(hDialog, _bDIALOGCursor[hDialog], DIALOG_BUTTON_TYPE_NORMAL);
}

void DIALOG_ShowMessage(HDIALOG hDialog, WORD wStartX, WORD wStartY, WORD *pwString)
{
    PARM_DRAW_STRING StringAttr;
    
    MAINMENU_UseColorKey(&StringAttr);
    StringAttr.bTextColor = DIALOG_PALETTE_ENTRY_CONTENT_TEXT;
    
    StringAttr.wX = wStartX+_pDIALOGCurrentDialog[hDialog]->wStartX;
    StringAttr.wY = wStartY+_pDIALOGCurrentDialog[hDialog]->wStartY+DIALOG_TITLE_HEIGHT;        
    GDI_DrawString_909(0, &StringAttr, pwString);    
}

⌨️ 快捷键说明

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