In Switch widget Disabled state thumb bitmap not getting drawn

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • In Switch widget Disabled state thumb bitmap not getting drawn

      Hi,

      This is regarding the switch widget.
      I have used sample code SWITCH_Usage.c and use API WM_DisableWindow() for disabling the switch widget.
      After disabled, the switch widget provided a disabled bitmap as a thumb image not getting drawn(shown black circle as per enabled state bitmap) but background bitmap is get drawn which provided for disabled state.
      Please help me out with this switch widget Disabled case.
      I am attaching the sample code.

      Thanks and regards,
      Amol
      Files
      • SWITCH_Usage.txt

        (128.91 kB, downloaded 274 times, last: )
    • Hi,

      Thanks for pointing this out, I have fixed the issue. The fix will be released with the next emWin version V6.24.

      For now, you can fix this by setting a custom skinning routine to the SWITCH widget:

      C Source Code

      1. /*********************************************************************
      2. *
      3. * _SwitchSkin
      4. */
      5. static int _SwitchSkin(const WIDGET_ITEM_DRAW_INFO * pInfo) {
      6. switch (pInfo->Cmd) {
      7. case WIDGET_ITEM_DRAW_BITMAP:
      8. //
      9. // Draw bitmap manually for disabled thumb
      10. //
      11. if ((WM_IsEnabled(pInfo->hWin) == 0) && ((pInfo->ItemIndex == SWITCH_BI_THUMB_LEFT) || (pInfo->ItemIndex == SWITCH_BI_THUMB_RIGHT))) {
      12. GUI_DrawBitmap(&bmThumbDisabled_30x30, pInfo->x0, pInfo->y0);
      13. return 0;
      14. }
      15. //
      16. // Let default skinning routine handle the rest
      17. //
      18. else {
      19. return SWITCH_DrawSkin(pInfo);
      20. }
      21. break;
      22. default:
      23. return SWITCH_DrawSkin(pInfo);
      24. }
      25. }
      26. SWITCH_SetSkin(hSwitch, _SwitchSkin);
      Display All

      Best regards,
      Florian
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.
    • Hi,

      Do you mean that the text is still being displayed in the disabled state? This is normal behavior of the widget as there are only two text indices: SWITCH_TI_LEFT and SWITCH_TI_RIGHT.

      If you want to hide the text when the widget is disabled, you can react on the WIDGET_ITEM_DRAW_TEXT in the custom skinning routine and simply do nothing if the widget is disabled.

      Best regards,
      Florian
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.