2018-05-08 10:33:02 +02:00
|
|
|
/**
|
|
|
|
* @file lv_calendar.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_CALENDAR_H
|
|
|
|
#define LV_CALENDAR_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2018-07-08 01:12:20 +02:00
|
|
|
#ifdef LV_CONF_INCLUDE_SIMPLE
|
|
|
|
#include "lv_conf.h"
|
|
|
|
#else
|
2019-03-17 08:33:03 +01:00
|
|
|
#include "../../../lv_conf.h"
|
2018-07-08 01:12:20 +02:00
|
|
|
#endif
|
|
|
|
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_CALENDAR != 0
|
2018-05-08 10:33:02 +02:00
|
|
|
|
|
|
|
#include "../lv_core/lv_obj.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
2019-06-27 18:07:26 -04:00
|
|
|
/**
|
|
|
|
* Represents a date on the calendar object (platform-agnostic).
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2018-05-08 10:33:02 +02:00
|
|
|
uint16_t year;
|
2018-05-16 22:34:39 +02:00
|
|
|
int8_t month;
|
|
|
|
int8_t day;
|
2018-06-19 09:49:58 +02:00
|
|
|
} lv_calendar_date_t;
|
2018-05-08 10:33:02 +02:00
|
|
|
|
|
|
|
/*Data of calendar*/
|
2019-04-04 07:15:40 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2018-05-08 10:33:02 +02:00
|
|
|
/*None*/ /*Ext. of ancestor*/
|
|
|
|
/*New data for this type */
|
2019-04-04 07:15:40 +02:00
|
|
|
lv_calendar_date_t today; /*Date of today*/
|
|
|
|
lv_calendar_date_t showed_date; /*Currently visible month (day is ignored)*/
|
|
|
|
lv_calendar_date_t * highlighted_dates; /*Apply different style on these days (pointer to an
|
|
|
|
array defined by the user)*/
|
2019-06-06 06:05:40 +02:00
|
|
|
int8_t btn_pressing; /*-1: prev month pressing, +1 next month pressing on the header*/
|
2019-12-02 12:20:01 +01:00
|
|
|
uint16_t highlighted_dates_num; /*Number of elements in `highlighted_days`*/
|
2018-10-14 14:08:43 +03:30
|
|
|
lv_calendar_date_t pressed_date;
|
2019-06-06 06:05:40 +02:00
|
|
|
const char ** day_names; /*Pointer to an array with the name of the days (NULL: use default names)*/
|
|
|
|
const char ** month_names; /*Pointer to an array with the name of the month (NULL. use default names)*/
|
2018-05-08 10:33:02 +02:00
|
|
|
|
|
|
|
/*Styles*/
|
2019-04-11 19:59:55 +08:00
|
|
|
const lv_style_t * style_header;
|
|
|
|
const lv_style_t * style_header_pr;
|
|
|
|
const lv_style_t * style_day_names;
|
|
|
|
const lv_style_t * style_highlighted_days;
|
|
|
|
const lv_style_t * style_inactive_days;
|
|
|
|
const lv_style_t * style_week_box;
|
|
|
|
const lv_style_t * style_today_box;
|
2018-06-19 09:49:58 +02:00
|
|
|
} lv_calendar_ext_t;
|
2018-05-08 10:33:02 +02:00
|
|
|
|
2019-06-27 18:07:26 -04:00
|
|
|
/** Calendar styles*/
|
2018-09-18 13:59:40 +02:00
|
|
|
enum {
|
2019-06-27 18:07:26 -04:00
|
|
|
LV_CALENDAR_STYLE_BG, /**< Background and "normal" date numbers style */
|
|
|
|
LV_CALENDAR_STYLE_HEADER, /** Calendar header style */
|
|
|
|
LV_CALENDAR_STYLE_HEADER_PR, /** Calendar header style (when pressed) */
|
|
|
|
LV_CALENDAR_STYLE_DAY_NAMES, /** Day name style */
|
|
|
|
LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, /** Highlighted day style */
|
|
|
|
LV_CALENDAR_STYLE_INACTIVE_DAYS, /** Inactive day style */
|
|
|
|
LV_CALENDAR_STYLE_WEEK_BOX, /** Week highlight style */
|
|
|
|
LV_CALENDAR_STYLE_TODAY_BOX, /** Today highlight style */
|
2018-09-18 13:59:40 +02:00
|
|
|
};
|
|
|
|
typedef uint8_t lv_calendar_style_t;
|
|
|
|
|
2018-05-08 10:33:02 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a calendar objects
|
|
|
|
* @param par pointer to an object, it will be the parent of the new calendar
|
|
|
|
* @param copy pointer to a calendar object, if not NULL then the new object will be copied from it
|
|
|
|
* @return pointer to the created calendar
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy);
|
2018-05-08 10:33:02 +02:00
|
|
|
|
|
|
|
/*======================
|
|
|
|
* Add/remove functions
|
|
|
|
*=====================*/
|
|
|
|
|
|
|
|
/*=====================
|
|
|
|
* Setter functions
|
|
|
|
*====================*/
|
2018-10-16 14:15:54 +02:00
|
|
|
|
2018-05-16 22:34:39 +02:00
|
|
|
/**
|
|
|
|
* Set the today's date
|
|
|
|
* @param calendar pointer to a calendar object
|
2019-04-04 07:15:40 +02:00
|
|
|
* @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.
|
2018-05-16 22:34:39 +02:00
|
|
|
*/
|
|
|
|
void lv_calendar_set_today_date(lv_obj_t * calendar, lv_calendar_date_t * today);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the currently showed
|
|
|
|
* @param calendar pointer to a calendar object
|
2019-04-04 07:15:40 +02:00
|
|
|
* @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.
|
2018-05-16 22:34:39 +02:00
|
|
|
*/
|
|
|
|
void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showed);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the the highlighted dates
|
|
|
|
* @param calendar pointer to a calendar object
|
2019-04-04 07:15:40 +02:00
|
|
|
* @param highlighted pointer to an `lv_calendar_date_t` array containing the dates. ONLY A POINTER
|
|
|
|
* WILL BE SAVED! CAN'T BE LOCAL ARRAY.
|
2018-05-26 09:48:46 +02:00
|
|
|
* @param date_num number of dates in the array
|
2018-05-16 22:34:39 +02:00
|
|
|
*/
|
2019-11-21 06:08:01 +01:00
|
|
|
void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t highlighted[], uint16_t date_num);
|
2018-10-16 18:04:43 +03:30
|
|
|
|
2018-05-26 09:48:46 +02:00
|
|
|
/**
|
|
|
|
* Set the name of the days
|
|
|
|
* @param calendar pointer to a calendar object
|
2019-04-04 07:15:40 +02:00
|
|
|
* @param day_names pointer to an array with the names. E.g. `const char * days[7] = {"Sun", "Mon",
|
|
|
|
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
|
|
|
* later.
|
2018-05-26 09:48:46 +02:00
|
|
|
*/
|
|
|
|
void lv_calendar_set_day_names(lv_obj_t * calendar, const char ** day_names);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the name of the month
|
|
|
|
* @param calendar pointer to a calendar object
|
2019-09-26 12:54:40 +02:00
|
|
|
* @param month_names pointer to an array with the names. E.g. `const char * days[12] = {"Jan", "Feb",
|
2019-04-04 07:15:40 +02:00
|
|
|
* ...}` Only the pointer will be saved so this variable can't be local which will be destroyed
|
|
|
|
* later.
|
2018-05-26 09:48:46 +02:00
|
|
|
*/
|
2019-09-26 12:54:40 +02:00
|
|
|
void lv_calendar_set_month_names(lv_obj_t * calendar, const char ** month_names);
|
2018-05-16 22:34:39 +02:00
|
|
|
|
2018-05-08 10:33:02 +02:00
|
|
|
/**
|
|
|
|
* Set a style of a calendar.
|
|
|
|
* @param calendar pointer to calendar object
|
|
|
|
* @param type which style should be set
|
|
|
|
* @param style pointer to a style
|
|
|
|
* */
|
2019-04-11 19:59:55 +08:00
|
|
|
void lv_calendar_set_style(lv_obj_t * calendar, lv_calendar_style_t type, const lv_style_t * style);
|
2018-05-08 10:33:02 +02:00
|
|
|
|
|
|
|
/*=====================
|
|
|
|
* Getter functions
|
|
|
|
*====================*/
|
2018-10-16 14:15:54 +02:00
|
|
|
|
2018-05-16 22:34:39 +02:00
|
|
|
/**
|
|
|
|
* Get the today's date
|
|
|
|
* @param calendar pointer to a calendar object
|
|
|
|
* @return return pointer to an `lv_calendar_date_t` variable containing the date of today.
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * calendar);
|
2018-05-16 22:34:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the currently showed
|
|
|
|
* @param calendar pointer to a calendar object
|
|
|
|
* @return pointer to an `lv_calendar_date_t` variable containing the date is being shown.
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * calendar);
|
2018-05-16 22:34:39 +02:00
|
|
|
|
2018-10-16 18:04:43 +03:30
|
|
|
/**
|
|
|
|
* Get the the pressed date.
|
|
|
|
* @param calendar pointer to a calendar object
|
|
|
|
* @return pointer to an `lv_calendar_date_t` variable containing the pressed date.
|
2019-07-26 13:23:19 +02:00
|
|
|
* `NULL` if not date pressed (e.g. the header)
|
2018-10-16 18:04:43 +03:30
|
|
|
*/
|
|
|
|
lv_calendar_date_t * lv_calendar_get_pressed_date(const lv_obj_t * calendar);
|
|
|
|
|
2018-05-16 22:34:39 +02:00
|
|
|
/**
|
|
|
|
* Get the the highlighted dates
|
|
|
|
* @param calendar pointer to a calendar object
|
|
|
|
* @return pointer to an `lv_calendar_date_t` array containing the dates.
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * calendar);
|
2018-05-16 22:34:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the number of the highlighted dates
|
|
|
|
* @param calendar pointer to a calendar object
|
|
|
|
* @return number of highlighted days
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * calendar);
|
2018-05-26 09:48:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of the days
|
|
|
|
* @param calendar pointer to a calendar object
|
|
|
|
* @return pointer to the array of day names
|
|
|
|
*/
|
2018-09-25 23:33:17 +02:00
|
|
|
const char ** lv_calendar_get_day_names(const lv_obj_t * calendar);
|
2018-05-26 09:48:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of the month
|
|
|
|
* @param calendar pointer to a calendar object
|
|
|
|
* @return pointer to the array of month names
|
|
|
|
*/
|
2018-09-25 23:33:17 +02:00
|
|
|
const char ** lv_calendar_get_month_names(const lv_obj_t * calendar);
|
2018-05-16 22:34:39 +02:00
|
|
|
|
2018-05-08 10:33:02 +02:00
|
|
|
/**
|
|
|
|
* Get style of a calendar.
|
|
|
|
* @param calendar pointer to calendar object
|
|
|
|
* @param type which style should be get
|
|
|
|
* @return style pointer to the style
|
|
|
|
* */
|
2019-04-11 19:59:55 +08:00
|
|
|
const lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_t type);
|
2018-05-08 10:33:02 +02:00
|
|
|
|
|
|
|
/*=====================
|
|
|
|
* Other functions
|
|
|
|
*====================*/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2019-04-04 07:15:40 +02:00
|
|
|
#endif /*LV_USE_CALENDAR*/
|
2018-05-08 10:33:02 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
2019-04-04 07:15:40 +02:00
|
|
|
#endif /*LV_CALENDAR_H*/
|