Hi,
I was doing some experimentation with the custom skinning callback function for button.
In my code, I write like the following:-
case WM_INIT_DIALOG:
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_B0);
BUTTON_SetSkin(hItem, _CustomSkin);
And inside the custom skinning function, I write:
int _CustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
{
int Id;
switch (pDrawItemInfo->Cmd)
{
case WIDGET_ITEM_DRAW_BACKGROUND:
Id = WM_GetId(pDrawItemInfo->hWin);
switch (Id)
{
case ID_BUTTON_B0:
switch((unsigned int)eToggle)
{
case TOGGLE_YELLOW:
BUTTON_SetSkinFlexProps(&PropsButtonUnpressed1, BUTTON_SKINFLEX_PI_ENABLED);
BUTTON_SetSkinFlexProps(&PropsButtonUnpressed1, BUTTON_SKINFLEX_PI_FOCUSSED);
break;
case TOGGLE_RED:
BUTTON_SetSkinFlexProps(&PropsButtonUnpressed2, BUTTON_SKINFLEX_PI_ENABLED);
BUTTON_SetSkinFlexProps(&PropsButtonUnpressed2, BUTTON_SKINFLEX_PI_FOCUSSED);
break;
}
BUTTON_SetSkinFlexProps(&PropsButtonPressed, BUTTON_SKINFLEX_PI_PRESSED);
BUTTON_DrawSkinFlex(pDrawItemInfo); // Draw button with new properties
break;
}
default:
BUTTON_DrawSkinFlex(pDrawItemInfo);
break;
}
return 0;
}
My problem is:- periodically this toggle parameter is changing in my application side of the code and I want this custom skinning function to be invoked everytime this color toggle happens.
I have met the purpose by directly calling redundantly BUTTON_SetSkin(hItem, _CustomSkin); again wherever I require this.
But I know, it is not the right method. Is it like we need to invalidate or call paint method?
I am not sure. Neither I didn't understand its usecase from any of the emWin samples or emWin user manual as well.
Please share your valuable thoughts on this.
Looking forward to hear from you soon.
Thank you,
Lullaby.
I was doing some experimentation with the custom skinning callback function for button.
In my code, I write like the following:-
case WM_INIT_DIALOG:
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_B0);
BUTTON_SetSkin(hItem, _CustomSkin);
And inside the custom skinning function, I write:
int _CustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
{
int Id;
switch (pDrawItemInfo->Cmd)
{
case WIDGET_ITEM_DRAW_BACKGROUND:
Id = WM_GetId(pDrawItemInfo->hWin);
switch (Id)
{
case ID_BUTTON_B0:
switch((unsigned int)eToggle)
{
case TOGGLE_YELLOW:
BUTTON_SetSkinFlexProps(&PropsButtonUnpressed1, BUTTON_SKINFLEX_PI_ENABLED);
BUTTON_SetSkinFlexProps(&PropsButtonUnpressed1, BUTTON_SKINFLEX_PI_FOCUSSED);
break;
case TOGGLE_RED:
BUTTON_SetSkinFlexProps(&PropsButtonUnpressed2, BUTTON_SKINFLEX_PI_ENABLED);
BUTTON_SetSkinFlexProps(&PropsButtonUnpressed2, BUTTON_SKINFLEX_PI_FOCUSSED);
break;
}
BUTTON_SetSkinFlexProps(&PropsButtonPressed, BUTTON_SKINFLEX_PI_PRESSED);
BUTTON_DrawSkinFlex(pDrawItemInfo); // Draw button with new properties
break;
}
default:
BUTTON_DrawSkinFlex(pDrawItemInfo);
break;
}
return 0;
}
My problem is:- periodically this toggle parameter is changing in my application side of the code and I want this custom skinning function to be invoked everytime this color toggle happens.
I have met the purpose by directly calling redundantly BUTTON_SetSkin(hItem, _CustomSkin); again wherever I require this.
But I know, it is not the right method. Is it like we need to invalidate or call paint method?
I am not sure. Neither I didn't understand its usecase from any of the emWin samples or emWin user manual as well.
Please share your valuable thoughts on this.
Looking forward to hear from you soon.
Thank you,
Lullaby.