1 /** 2 * @file lv_calendar.h 3 * 4 */ 5 6 #ifndef LV_CALENDAR_H 7 #define LV_CALENDAR_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "../buttonmatrix/lv_buttonmatrix.h" 17 18 #if LV_USE_CALENDAR 19 20 /********************* 21 * DEFINES 22 *********************/ 23 24 /********************** 25 * TYPEDEFS 26 **********************/ 27 28 /** 29 * Represents a date on the calendar object (platform-agnostic). 30 */ 31 typedef struct { 32 uint16_t year; 33 int8_t month; /**< 1..12 */ 34 int8_t day; /**< 1..31 */ 35 } lv_calendar_date_t; 36 37 LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_calendar_class; 38 39 /********************** 40 * GLOBAL PROTOTYPES 41 **********************/ 42 43 /** 44 * Create a calendar widget 45 * @param parent pointer to an object, it will be the parent of the new calendar 46 * @return pointer the created calendar 47 */ 48 lv_obj_t * lv_calendar_create(lv_obj_t * parent); 49 50 /*====================== 51 * Add/remove functions 52 *=====================*/ 53 54 /*===================== 55 * Setter functions 56 *====================*/ 57 58 /** 59 * Set the today's date 60 * @param obj pointer to a calendar object 61 * @param year today's year 62 * @param month today's month [1..12] 63 * @param day today's day [1..31] 64 */ 65 void lv_calendar_set_today_date(lv_obj_t * obj, uint32_t year, uint32_t month, uint32_t day); 66 67 /** 68 * Set the currently showed 69 * @param obj pointer to a calendar object 70 * @param year today's year 71 * @param month today's month [1..12] 72 */ 73 void lv_calendar_set_month_shown(lv_obj_t * obj, uint32_t year, uint32_t month); 74 75 /** 76 * Set the highlighted dates 77 * @param obj pointer to a calendar object 78 * @param highlighted pointer to an `lv_calendar_date_t` array containing the dates. 79 * Only the pointer will be saved so this variable can't be local which will be destroyed later. 80 * @param date_num number of dates in the array 81 */ 82 void lv_calendar_set_highlighted_dates(lv_obj_t * obj, lv_calendar_date_t highlighted[], size_t date_num); 83 84 /** 85 * Set the name of the days 86 * @param obj pointer to a calendar object 87 * @param day_names pointer to an array with the names. 88 * E.g. `const char * days[7] = {"Sun", "Mon", ...}` 89 * Only the pointer will be saved so this variable can't be local which will be destroyed later. 90 */ 91 void lv_calendar_set_day_names(lv_obj_t * obj, const char ** day_names); 92 93 /*===================== 94 * Getter functions 95 *====================*/ 96 97 /** 98 * Get the button matrix object of the calendar. 99 * It shows the dates and day names. 100 * @param obj pointer to a calendar object 101 * @return pointer to a the button matrix 102 */ 103 lv_obj_t * lv_calendar_get_btnmatrix(const lv_obj_t * obj); 104 105 /** 106 * Get the today's date 107 * @param calendar pointer to a calendar object 108 * @return return pointer to an `lv_calendar_date_t` variable containing the date of today. 109 */ 110 const lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar); 111 112 /** 113 * Get the currently showed 114 * @param calendar pointer to a calendar object 115 * @return pointer to an `lv_calendar_date_t` variable containing the date is being shown. 116 */ 117 const lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar); 118 119 /** 120 * Get the highlighted dates 121 * @param calendar pointer to a calendar object 122 * @return pointer to an `lv_calendar_date_t` array containing the dates. 123 */ 124 lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar); 125 126 /** 127 * Get the number of the highlighted dates 128 * @param calendar pointer to a calendar object 129 * @return number of highlighted days 130 */ 131 size_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar); 132 133 /** 134 * Get the currently pressed day 135 * @param calendar pointer to a calendar object 136 * @param date store the pressed date here 137 * @return LV_RESULT_OK: there is a valid pressed date 138 * LV_RESULT_INVALID: there is no pressed data 139 */ 140 lv_result_t lv_calendar_get_pressed_date(const lv_obj_t * calendar, lv_calendar_date_t * date); 141 142 /*===================== 143 * Other functions 144 *====================*/ 145 146 /********************** 147 * MACROS 148 **********************/ 149 150 #include "lv_calendar_header_arrow.h" 151 #include "lv_calendar_header_dropdown.h" 152 #include "lv_calendar_chinese.h" 153 154 #endif /*LV_USE_CALENDAR*/ 155 156 #ifdef __cplusplus 157 } /*extern "C"*/ 158 #endif 159 160 #endif /*LV_CALENDAR_H*/ 161