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