硬汉嵌入式论坛

 找回密码
 立即注册
查看: 4090|回复: 10
收起左侧

[emWin] 设置按键皮肤

[复制链接]

36

主题

142

回帖

250

积分

高级会员

积分
250
发表于 2019-8-14 08:38:39 | 显示全部楼层 |阅读模式
通过 _DrawSkin_BUTTON函数设置皮肤,通过BUTTON_IsPressed函数可以设置 是否按键皮肤,那怎么设置聚焦皮肤和使能失能皮肤啊,还有怎么知道当前按键聚焦啊
回复

使用道具 举报

36

主题

142

回帖

250

积分

高级会员

积分
250
 楼主| 发表于 2019-8-14 09:27:31 | 显示全部楼层
还有我想通过 此方法 设置dropdown的大小  ,这个怎么办
回复

使用道具 举报

36

主题

142

回帖

250

积分

高级会员

积分
250
 楼主| 发表于 2019-8-14 09:27:43 | 显示全部楼层
dropdown箭头的大小
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115778
QQ
发表于 2019-8-14 12:04:57 | 显示全部楼层
QQ截图20190814120450.jpg
回复

使用道具 举报

36

主题

142

回帖

250

积分

高级会员

积分
250
 楼主| 发表于 2019-8-15 19:14:15 | 显示全部楼层
_DrawSkin_Delete_BUTTON(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
{
    switch (pDrawItemInfo->Cmd)
    {
    case WIDGET_ITEM_DRAW_BACKGROUND:

        if (BUTTON_IsPressed(pDrawItemInfo->hWin))
        {
            GUI_SetColor(NUMPAD_BUTTON_DELETE_PRESSED);
            GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, 2);
            GUI_SetColor(NUMPAD_BUTTON_DELETE_UNPRESSED);
            GUI_DrawRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0  , pDrawItemInfo->x1, pDrawItemInfo->y1 , 2);
            GUI_DrawRoundedRect(pDrawItemInfo->x0 +1, pDrawItemInfo->y0 +1, pDrawItemInfo->x1 - 1, pDrawItemInfo->y1 - 1, 1);
        } else
        {
            GUI_SetColor(NUMPAD_BUTTON_DELETE_UNPRESSED);
            GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, 2);
        }
    break;
    default:
        return BUTTON_DrawSkinFlex(pDrawItemInfo);
    break;
    }
    return 0;
回复

使用道具 举报

36

主题

142

回帖

250

积分

高级会员

积分
250
 楼主| 发表于 2019-8-15 19:14:29 | 显示全部楼层
回复

使用道具 举报

36

主题

142

回帖

250

积分

高级会员

积分
250
 楼主| 发表于 2019-8-15 19:14:37 | 显示全部楼层
_DrawSkin_Delete_BUTTON(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
{
    switch (pDrawItemInfo->Cmd)
    {
    case WIDGET_ITEM_DRAW_BACKGROUND:

        if (BUTTON_IsPressed(pDrawItemInfo->hWin))
        {
            GUI_SetColor(NUMPAD_BUTTON_DELETE_PRESSED);
            GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, 2);
            GUI_SetColor(NUMPAD_BUTTON_DELETE_UNPRESSED);
            GUI_DrawRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0  , pDrawItemInfo->x1, pDrawItemInfo->y1 , 2);
            GUI_DrawRoundedRect(pDrawItemInfo->x0 +1, pDrawItemInfo->y0 +1, pDrawItemInfo->x1 - 1, pDrawItemInfo->y1 - 1, 1);
        } else
        {
            GUI_SetColor(NUMPAD_BUTTON_DELETE_UNPRESSED);
            GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, 2);
        }
    break;
    default:
        return BUTTON_DrawSkinFlex(pDrawItemInfo);
    break;
    }
    return 0;
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115778
QQ
发表于 2019-8-16 01:05:20 | 显示全部楼层

可以的,这种是属于设置皮肤色回调函数,还有一种是设置皮肤属性。

这种的话,在回调函数里面调用WM_GetFocusedWindow获取此按钮是否被聚焦,然后设置按钮聚焦,看看此函数是否返回正常。
回复

使用道具 举报

36

主题

142

回帖

250

积分

高级会员

积分
250
 楼主| 发表于 2019-8-16 13:44:49 | 显示全部楼层
int _DrawSkin_Backspace_BUTTON(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
{
    switch (pDrawItemInfo->Cmd)
    {
    case WIDGET_ITEM_DRAW_BACKGROUND:

        if(WM_GetFocussedWindow() == 1)
        {
            GUI_SetColor(NUMPAD_BUTTON_BACKSPACE_UNPRESSED);
            GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, 2);
            GUI_SetColor(GUI_WHITE);
            GUI_DrawRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0  , pDrawItemInfo->x1, pDrawItemInfo->y1 , 2);
            GUI_DrawRoundedRect(pDrawItemInfo->x0 +1, pDrawItemInfo->y0 +1, pDrawItemInfo->x1 - 1, pDrawItemInfo->y1 - 1, 1);
        }else if (BUTTON_IsPressed(pDrawItemInfo->hWin))
        {
            GUI_SetColor(NUMPAD_BUTTON_BACKSPACE_PRESSED);
            GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, 2);
            GUI_SetColor(NUMPAD_BUTTON_BACKSPACE_UNPRESSED);
            GUI_DrawRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0  , pDrawItemInfo->x1, pDrawItemInfo->y1 , 2);
            GUI_DrawRoundedRect(pDrawItemInfo->x0 +1, pDrawItemInfo->y0 +1, pDrawItemInfo->x1 - 1, pDrawItemInfo->y1 - 1, 1);
        } else
        {
            GUI_SetColor(NUMPAD_BUTTON_BACKSPACE_UNPRESSED);
            GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, 2);
        }
    break; 我这不没有实现啊,
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115778
QQ
发表于 2019-8-17 01:22:01 | 显示全部楼层
老虎的菜 发表于 2019-8-16 13:44
int _DrawSkin_Backspace_BUTTON(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
{
    switch (pDrawIte ...

统一的问题,他测试已经无问题

http://www.armbbs.cn/forum.php?m ... &extra=page%3D1
回复

使用道具 举报

36

主题

142

回帖

250

积分

高级会员

积分
250
 楼主| 发表于 2019-8-17 09:25:59 | 显示全部楼层
eric2013 发表于 2019-8-17 01:22
统一的问题,他测试已经无问题

http://www.armbbs.cn/forum.php?mod=viewthread&tid=94749&extra=page ...

case WIDGET_ITEM_DRAW_FOCUS:
        if(WM_GetFocussedWindow() == 1)
        {
           GUI_SetColor(NUMPAD_BUTTON_BACKSPACE_UNPRESSED);
           GUI_FillRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0, pDrawItemInfo->x1, pDrawItemInfo->y1, 2);
           GUI_SetColor(GUI_WHITE);
           GUI_DrawRoundedRect(pDrawItemInfo->x0, pDrawItemInfo->y0  , pDrawItemInfo->x1, pDrawItemInfo->y1 , 2);
           GUI_DrawRoundedRect(pDrawItemInfo->x0 +1, pDrawItemInfo->y0 +1, pDrawItemInfo->x1 - 1, pDrawItemInfo->y1 - 1, 1);
           GUI_SetFont(&GUI_Font_app20);
           GUI_DispStringHCenterAt("退格",(pDrawItemInfo->x0 + pDrawItemInfo->x1)/2,(pDrawItemInfo->y0 + pDrawItemInfo->y1)/2);
           //BUTTON_SetFont(pDrawItemInfo->hWin, &GUI_Font_app20);

            //  BUTTON_SetTextColor(pDrawItemInfo->hWin, 0, GUI_WHITE);
           //BUTTON_SetText(pDrawItemInfo->hWin, "退格" );
        }
    break;
谢谢 问题解决了 我昨天都这样试了当时也不行,是我把WM_GetFocussedWindow() 返回值看错了,改成if(WM_GetFocussedWindow() == pDrawItemInfo->hWin)就好了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-5-18 07:32 , Processed in 0.398650 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表