CHECKBOX custom checked state

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

  • CHECKBOX custom checked state

    Hi,

    I'm using the emWin simulator and want to have a checkbox with a custom checked state. I've tried CHECKBOX_SetImage and CHECKBOX_SetDefaultImage but I keep getting the standard checked image. Does the simulator show custom checkbox images and, if so, any idea why my check image is not overriding the standard image ?

    Thanks
    Dave
  • Hi Dave,

    When using a precompiled library the default look of the widgets is set to use the FLEX_SKIN. Unfortunately this makes some functions obsolete ,and CHECKBOX_SetImage() is one of those.

    But you can set a custom skinning routine which handles the drawing of the widgets.

    Attached is a quick sample which shows how to draw a custom bitmap in the checkbox. You can find more information about skinning in the emWin user manual (UM03001_emWin5.pdf) in chapter 22 'Skinning'.

    Regards,
    Sven
    Files
    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.
  • If you are wanting to skin the whole checkbox button not just the checkmark using two different bitmaps. You will need to draw the unchecked bitmap in the WIDGET_ITEM_DRAW_BUTTON case.

    C Source Code

    1. int CHECKBOX_DrawCustomSkin(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
    2. {
    3. switch (pDrawItemInfo->Cmd)
    4. {
    5. case WIDGET_ITEM_DRAW_BUTTON:
    6. GUI_DrawBitmap(&bmcheckboxUnchecked,0,0);
    7. break;
    8. case WIDGET_ITEM_DRAW_BITMAP:
    9. GUI_DrawBitmap(&bmcheckboxChecked,0,0);
    10. break;
    11. default:
    12. return CHECKBOX_DrawSkinFlex(pDrawItemInfo);
    13. }
    14. return 0;
    15. }
    Display All