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 #ifdef LV_CONF_INCLUDE_SIMPLE 17 #include "lv_conf.h" 18 #else 19 #include "../../lv_conf.h" 20 #endif 21 22 #if LV_USE_CALENDAR != 0 23 24 #include "../lv_core/lv_obj.h" 25 26 /********************* 27 * DEFINES 28 *********************/ 29 30 /********************** 31 * TYPEDEFS 32 **********************/ 33 34 /** 35 * Represents a date on the calendar object (platform-agnostic). 36 */ 37 typedef struct 38 { 39 uint16_t year; 40 int8_t month; 41 int8_t day; 42 } lv_calendar_date_t; 43 44 /*Data of calendar*/ 45 typedef struct 46 { 47 /*None*/ /*Ext. of ancestor*/ 48 /*New data for this type */ 49 lv_calendar_date_t today; /*Date of today*/ 50 lv_calendar_date_t showed_date; /*Currently visible month (day is ignored)*/ 51 lv_calendar_date_t * highlighted_dates; /*Apply different style on these days (pointer to an 52 array defined by the user)*/ 53 uint8_t highlighted_dates_num; /*Number of elements in `highlighted_days`*/ 54 int8_t btn_pressing; /*-1: prev month pressing, +1 next month pressing on the header*/ 55 lv_calendar_date_t pressed_date; 56 const char ** day_names; /*Pointer to an array with the name of the days (NULL: use default names)*/ 57 const char ** month_names; /*Pointer to an array with the name of the month (NULL. use default names)*/ 58 59 /*Styles*/ 60 const lv_style_t * style_header; 61 const lv_style_t * style_header_pr; 62 const lv_style_t * style_day_names; 63 const lv_style_t * style_highlighted_days; 64 const lv_style_t * style_inactive_days; 65 const lv_style_t * style_week_box; 66 const lv_style_t * style_today_box; 67 } lv_calendar_ext_t; 68 69 /** Calendar styles*/ 70 enum { 71 LV_CALENDAR_STYLE_BG, /**< Background and "normal" date numbers style */ 72 LV_CALENDAR_STYLE_HEADER, /** Calendar header style */ 73 LV_CALENDAR_STYLE_HEADER_PR, /** Calendar header style (when pressed) */ 74 LV_CALENDAR_STYLE_DAY_NAMES, /** Day name style */ 75 LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, /** Highlighted day style */ 76 LV_CALENDAR_STYLE_INACTIVE_DAYS, /** Inactive day style */ 77 LV_CALENDAR_STYLE_WEEK_BOX, /** Week highlight style */ 78 LV_CALENDAR_STYLE_TODAY_BOX, /** Today highlight style */ 79 }; 80 typedef uint8_t lv_calendar_style_t; 81 82 /********************** 83 * GLOBAL PROTOTYPES 84 **********************/ 85 86 /** 87 * Create a calendar objects 88 * @param par pointer to an object, it will be the parent of the new calendar 89 * @param copy pointer to a calendar object, if not NULL then the new object will be copied from it 90 * @return pointer to the created calendar 91 */ 92 lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy); 93 94 /*====================== 95 * Add/remove functions 96 *=====================*/ 97 98 /*===================== 99 * Setter functions 100 *====================*/ 101 102 /** 103 * Set the today's date 104 * @param calendar pointer to a calendar object 105 * @param today pointer to an `lv_calendar_date_t` variable containing the date of today. The value 106 * will be saved it can be local variable too. 107 */ 108 void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today); 109 110 /** 111 * Set the currently showed 112 * @param calendar pointer to a calendar object 113 * @param showed pointer to an `lv_calendar_date_t` variable containing the date to show. The value 114 * will be saved it can be local variable too. 115 */ 116 void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showed); 117 118 /** 119 * Set the the highlighted dates 120 * @param calendar pointer to a calendar object 121 * @param highlighted pointer to an `lv_calendar_date_t` array containing the dates. ONLY A POINTER 122 * WILL BE SAVED! CAN'T BE LOCAL ARRAY. 123 * @param date_num number of dates in the array 124 */ 125 void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, uint16_t date_num); 126 127 /** 128 * Set the name of the days 129 * @param calendar pointer to a calendar object 130 * @param day_names pointer to an array with the names. E.g. `const char * days[7] = {"Sun", "Mon", 131 * ...}` Only the pointer will be saved so this variable can't be local which will be destroyed 132 * later. 133 */ 134 void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names); 135 136 /** 137 * Set the name of the month 138 * @param calendar pointer to a calendar object 139 * @param day_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb", 140 * ...}` Only the pointer will be saved so this variable can't be local which will be destroyed 141 * later. 142 */ 143 void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** day_names); 144 145 /** 146 * Set a style of a calendar. 147 * @param calendar pointer to calendar object 148 * @param type which style should be set 149 * @param style pointer to a style 150 * */ 151 void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, const lv_style_t * style); 152 153 /*===================== 154 * Getter functions 155 *====================*/ 156 157 /** 158 * Get the today's date 159 * @param calendar pointer to a calendar object 160 * @return return pointer to an `lv_calendar_date_t` variable containing the date of today. 161 */ 162 lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar); 163 164 /** 165 * Get the currently showed 166 * @param calendar pointer to a calendar object 167 * @return pointer to an `lv_calendar_date_t` variable containing the date is being shown. 168 */ 169 lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar); 170 171 /** 172 * Get the the pressed date. 173 * @param calendar pointer to a calendar object 174 * @return pointer to an `lv_calendar_date_t` variable containing the pressed date. 175 * `NULL` if not date pressed (e.g. the header) 176 */ 177 lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar); 178 179 /** 180 * Get the the highlighted dates 181 * @param calendar pointer to a calendar object 182 * @return pointer to an `lv_calendar_date_t` array containing the dates. 183 */ 184 lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar); 185 186 /** 187 * Get the number of the highlighted dates 188 * @param calendar pointer to a calendar object 189 * @return number of highlighted days 190 */ 191 uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar); 192 193 /** 194 * Get the name of the days 195 * @param calendar pointer to a calendar object 196 * @return pointer to the array of day names 197 */ 198 const char ** lv_calendar_get_day_names(const lv_obj_t * calendar); 199 200 /** 201 * Get the name of the month 202 * @param calendar pointer to a calendar object 203 * @return pointer to the array of month names 204 */ 205 const char ** lv_calendar_get_month_names(const lv_obj_t * calendar); 206 207 /** 208 * Get style of a calendar. 209 * @param calendar pointer to calendar object 210 * @param type which style should be get 211 * @return style pointer to the style 212 * */ 213 const lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_t type); 214 215 /*===================== 216 * Other functions 217 *====================*/ 218 219 /********************** 220 * MACROS 221 **********************/ 222 223 #endif /*LV_USE_CALENDAR*/ 224 225 #ifdef __cplusplus 226 } /* extern "C" */ 227 #endif 228 229 #endif /*LV_CALENDAR_H*/ 230