CALENDAR_SetDefaultBkColor no effect

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

  • CALENDAR_SetDefaultBkColor no effect

    Hi, i have an issue with calendar widget.

    Source Code

    1. CALENDAR_SetDefaultBkColor(CALENDAR_CI_WEEKEND,GUI_BLACK); CALENDAR_SetDefaultBkColor(CALENDAR_CI_WEEKDAY,GUI_GREEN); CALENDAR_SetDefaultBkColor(CALENDAR_CI_SEL,GUI_BLACK); CALENDAR_SetDefaultBkColor(CALENDAR_CI_HEADER,GUI_BLACK); CALENDAR_SetDefaultColor(CALENDAR_CI_WEEKEND,GUI_CYAN); CALENDAR_SetDefaultColor(CALENDAR_CI_WEEKDAY,GUI_BLUE); CALENDAR_SetDefaultColor(CALENDAR_CI_SEL,GUI_YELLOW); CALENDAR_SetDefaultColor(CALENDAR_CI_MONTH,GUI_ORANGE); CALENDAR_SetDefaultColor(CALENDAR_CI_LABEL,GUI_LIGHTMAGENTA); CALENDAR_SetDefaultColor(CALENDAR_CI_FRAME,GUI_GREEN); calendar = CALENDAR_Create(hWin, xSize/2, 0,2014, 10,7, 2,GUI_ID_CALENDAR0, WM_CF_SHOW);



    CALENDAR_SetDefaultColor do correctly changes but
    CALENDAR_SetDefaultBkColor don't have any effect..any suggest?




    thank you
  • Hi,
    i found a bug on calendar widget about setting colors, if anyone is interested i attach a patch.
    The fix for FirstDayOfWeek work only for week starting from Saturday or from Monday.

    C Source Code

    1. diff --git a/GUI/Widget/CALENDAR.c b/GUI/Widget/CALENDAR.c
    2. index d40d59e..b04a5de 100644
    3. --- a/GUI/Widget/CALENDAR.c
    4. +++ b/GUI/Widget/CALENDAR.c
    5. @@ -593,7 +593,10 @@ static void _OnPaint(WM_HWIN hWin) {
    6. }
    7. Color = Context.Props.aColor[CALENDAR_CI_SEL];
    8. } else {
    9. - Color = Context.Props.aColor[(Index < 2) ? CALENDAR_CI_WEEKEND : CALENDAR_CI_WEEKDAY];
    10. + if(!Context.FirstDayOfWeek)
    11. + Color = Context.Props.aColor[(Index < 2) ? CALENDAR_CI_WEEKEND : CALENDAR_CI_WEEKDAY];
    12. + else
    13. + Color = Context.Props.aColor[(Index > 4) ? CALENDAR_CI_WEEKEND : CALENDAR_CI_WEEKDAY];
    14. }
    15. if ((Context.Date.Year == Context.DateCur.Year) && (Context.Date.Month == Context.DateCur.Month) && ((i + 1) == Context.Date.Day)) {
    16. GUI_SetColor(Context.Props.ColorFrame);
    17. @@ -1023,7 +1026,7 @@ void CALENDAR_ShowDate(WM_HWIN hWin, CALENDAR_DATE * pDate) {
    18. */
    19. void CALENDAR_SetDefaultBkColor(unsigned Index, GUI_COLOR Color) {
    20. if (Index < GUI_COUNTOF(_DefaultProps.aBkColor)) {
    21. - _DefaultProps.aColor[Index] = Color;
    22. + _DefaultProps.aBkColor[Index] = Color;
    23. } else {
    24. switch (Index) {
    25. case CALENDAR_CI_HEADER:
    Display All



    Regards.
  • Hello Andrea,

    Indeed there was a problem in the CALENDAR widget. In certain cases the function CALENDAR_SetDefaultBkColor() mistakenly sets the foreground color which in turn causes the font to be displayed in the according color. This will be fixed in the next emWin version.

    Best regards,
    Adrian
  • Hello Adrian,

    The first patch is related to text color of weekend days.
    In the attached image i have:

    CALENDAR_SetDefaultColor(CALENDAR_CI_WEEKEND, GUI_RED);
    CALENDAR_SetDefaultColor(CALENDAR_CI_WEEKDAY, GUI_GREEN);

    CALENDAR_Create(hDlg, x, y, Year, Month, Day, 2, GUI_ID_CALENDAR0, 0);

    Note that firstDayOfWeek is = 2, we are using this on Italian calendar.

    If the week start from Monday the colors are wrong, must be green form Mo to Fr, red Sa to Su



    The second patch is related to background colors as you stated on previous message.

    Regards,
    Toni.