/**1* @file lv_calendar.h2*3*/45#ifndef LV_CALENDAR_H6#define LV_CALENDAR_H78#ifdef __cplusplus9extern "C" {10#endif1112/*********************13* INCLUDES14*********************/15#ifdef LV_CONF_INCLUDE_SIMPLE16#include "lv_conf.h"17#else18#include "../../lv_conf.h"19#endif2021#if USE_LV_CALENDAR != 02223#include "../lv_core/lv_obj.h"2425/*********************26* DEFINES27*********************/2829/**********************30* TYPEDEFS31**********************/3233typedef struct {34uint16_t year;35int8_t month;36int8_t day;37} lv_calendar_date_t;3839enum40{41LV_CALENDAR_ACTION_CLICK,42LV_CALENDAR_ACTION_PR,43LV_CALENDAR_ACTION_LONG_PR,44LV_CALENDAR_ACTION_LONG_PR_REPEAT,45LV_CALENDAR_ACTION_NUM,46};47typedef uint8_t lv_calendar_action_t;4849/*Data of calendar*/50typedef struct {51/*None*/ /*Ext. of ancestor*/52/*New data for this type */53lv_calendar_date_t today; /*Date of today*/54lv_calendar_date_t showed_date; /*Currently visible month (day is ignored)*/55lv_calendar_date_t * highlighted_dates; /*Apply different style on these days (pointer to an array defined by the user)*/56uint8_t highlighted_dates_num; /*Number of elements in `highlighted_days`*/57int8_t btn_pressing; /*-1: prev month pressing, +1 next month pressing on the header*/58lv_calendar_date_t pressed_date;59const char ** day_names; /*Pointer to an array with the name of the days (NULL: use default names)*/60const char ** month_names; /*Pointer to an array with the name of the month (NULL. use default names)*/61lv_action_t actions[LV_CALENDAR_ACTION_NUM];6263/*Styles*/64lv_style_t * style_header;65lv_style_t * style_header_pr;66lv_style_t * style_day_names;67lv_style_t * style_highlighted_days;68lv_style_t * style_inactive_days;69lv_style_t * style_week_box;70lv_style_t * style_today_box;71} lv_calendar_ext_t;7273/*Styles*/74enum {75LV_CALENDAR_STYLE_BG, /*Also the style of the "normal" date numbers*/76LV_CALENDAR_STYLE_HEADER,77LV_CALENDAR_STYLE_HEADER_PR,78LV_CALENDAR_STYLE_DAY_NAMES,79LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS,80LV_CALENDAR_STYLE_INACTIVE_DAYS,81LV_CALENDAR_STYLE_WEEK_BOX,82LV_CALENDAR_STYLE_TODAY_BOX,83};84typedef uint8_t lv_calendar_style_t;8586878889/**********************90* GLOBAL PROTOTYPES91**********************/9293/**94* Create a calendar objects95* @param par pointer to an object, it will be the parent of the new calendar96* @param copy pointer to a calendar object, if not NULL then the new object will be copied from it97* @return pointer to the created calendar98*/99lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy);100101/*======================102* Add/remove functions103*=====================*/104105106/*=====================107* Setter functions108*====================*/109/**110* Set a function to call when a calendar event happens111* @param calendar pointer to a calendar object112* @param action type of event form 'lv_action_t' (press, release, long press, long press repeat)113*/114void lv_calendar_set_action(lv_obj_t * calendar, lv_calendar_action_t type, lv_action_t action);115116/**117* Set the today's date118* @param calendar pointer to a calendar object119* @param today pointer to an `lv_calendar_date_t` variable containing the date of today. The value will be saved it can be local variable too.120*/121void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today);122123/**124* Set the currently showed125* @param calendar pointer to a calendar object126* @param showed pointer to an `lv_calendar_date_t` variable containing the date to show. The value will be saved it can be local variable too.127*/128void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showed);129130/**131* Set the the highlighted dates132* @param calendar pointer to a calendar object133* @param highlighted pointer to an `lv_calendar_date_t` array containing the dates. ONLY A POINTER WILL BE SAVED! CAN'T BE LOCAL ARRAY.134* @param date_num number of dates in the array135*/136void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, uint16_t date_num);137138139/**140* Set the name of the days141* @param calendar pointer to a calendar object142* @param day_names pointer to an array with the names. E.g. `const char * days[7] = {"Sun", "Mon", ...}`143* Only the pointer will be saved so this variable can't be local which will be destroyed later.144*/145void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names);146147/**148* Set the name of the month149* @param calendar pointer to a calendar object150* @param day_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb", ...}`151* Only the pointer will be saved so this variable can't be local which will be destroyed later.152*/153void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** day_names);154155/**156* Set a style of a calendar.157* @param calendar pointer to calendar object158* @param type which style should be set159* @param style pointer to a style160* */161void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, lv_style_t *style);162163/*=====================164* Getter functions165*====================*/166/**167* Get the action of a calendar168* @param calendar pointer to a calendar object169* @return pointer to the action function170*/171lv_action_t lv_calendar_get_action(const lv_obj_t * calendar, lv_calendar_action_t type);172173/**174* Get the today's date175* @param calendar pointer to a calendar object176* @return return pointer to an `lv_calendar_date_t` variable containing the date of today.177*/178lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar);179180/**181* Get the currently showed182* @param calendar pointer to a calendar object183* @return pointer to an `lv_calendar_date_t` variable containing the date is being shown.184*/185lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar);186187/**188* Get the the pressed date.189* @param calendar pointer to a calendar object190* @return pointer to an `lv_calendar_date_t` variable containing the pressed date.191*/192lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar);193194/**195* Get the the highlighted dates196* @param calendar pointer to a calendar object197* @return pointer to an `lv_calendar_date_t` array containing the dates.198*/199lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar);200201/**202* Get the number of the highlighted dates203* @param calendar pointer to a calendar object204* @return number of highlighted days205*/206uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar);207208209/**210* Get the name of the days211* @param calendar pointer to a calendar object212* @return pointer to the array of day names213*/214const char ** lv_calendar_get_day_names(const lv_obj_t * calendar);215216/**217* Get the name of the month218* @param calendar pointer to a calendar object219* @return pointer to the array of month names220*/221const char ** lv_calendar_get_month_names(const lv_obj_t * calendar);222223/**224* Get style of a calendar.225* @param calendar pointer to calendar object226* @param type which style should be get227* @return style pointer to the style228* */229lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_t type);230231/*=====================232* Other functions233*====================*/234235/**********************236* MACROS237**********************/238239#endif /*USE_LV_CALENDAR*/240241#ifdef __cplusplus242} /* extern "C" */243#endif244245#endif /*LV_CALENDAR_H*/246247248