init Files
This commit is contained in:
12
libraries/lvgl/examples/widgets/calendar/index.rst
Normal file
12
libraries/lvgl/examples/widgets/calendar/index.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
Calendar with header
|
||||
--------------------
|
||||
|
||||
.. lv_example:: widgets/calendar/lv_example_calendar_1
|
||||
:language: c
|
||||
|
||||
Chinese calendar
|
||||
-------------------------------------
|
||||
|
||||
.. lv_example:: widgets/calendar/lv_example_calendar_2
|
||||
:language: c
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CALENDAR && LV_BUILD_EXAMPLES
|
||||
|
||||
static void event_handler(lv_event_t * e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t * obj = lv_event_get_current_target(e);
|
||||
|
||||
if(code == LV_EVENT_VALUE_CHANGED) {
|
||||
lv_calendar_date_t date;
|
||||
if(lv_calendar_get_pressed_date(obj, &date)) {
|
||||
LV_LOG_USER("Clicked date: %02d.%02d.%d", date.day, date.month, date.year);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lv_example_calendar_1(void)
|
||||
{
|
||||
lv_obj_t * calendar = lv_calendar_create(lv_screen_active());
|
||||
lv_obj_set_size(calendar, 185, 230);
|
||||
lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 27);
|
||||
lv_obj_add_event_cb(calendar, event_handler, LV_EVENT_ALL, NULL);
|
||||
|
||||
lv_calendar_set_today_date(calendar, 2021, 02, 23);
|
||||
lv_calendar_set_showed_date(calendar, 2021, 02);
|
||||
|
||||
/*Highlight a few days*/
|
||||
static lv_calendar_date_t highlighted_days[3]; /*Only its pointer will be saved so should be static*/
|
||||
highlighted_days[0].year = 2021;
|
||||
highlighted_days[0].month = 02;
|
||||
highlighted_days[0].day = 6;
|
||||
|
||||
highlighted_days[1].year = 2021;
|
||||
highlighted_days[1].month = 02;
|
||||
highlighted_days[1].day = 11;
|
||||
|
||||
highlighted_days[2].year = 2022;
|
||||
highlighted_days[2].month = 02;
|
||||
highlighted_days[2].day = 22;
|
||||
|
||||
lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3);
|
||||
|
||||
#if LV_USE_CALENDAR_HEADER_DROPDOWN
|
||||
lv_calendar_header_dropdown_create(calendar);
|
||||
#elif LV_USE_CALENDAR_HEADER_ARROW
|
||||
lv_calendar_header_arrow_create(calendar);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CALENDAR && LV_USE_CALENDAR_CHINESE && LV_BUILD_EXAMPLES
|
||||
|
||||
void lv_example_calendar_2(void)
|
||||
{
|
||||
lv_obj_t * calendar = lv_calendar_create(lv_screen_active());
|
||||
lv_obj_set_size(calendar, 300, 300);
|
||||
lv_obj_align(calendar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
lv_calendar_set_today_date(calendar, 2024, 03, 22);
|
||||
lv_calendar_set_showed_date(calendar, 2024, 03);
|
||||
|
||||
#if LV_USE_CALENDAR_HEADER_DROPDOWN
|
||||
lv_calendar_header_dropdown_create(calendar);
|
||||
#elif LV_USE_CALENDAR_HEADER_ARROW
|
||||
lv_calendar_header_arrow_create(calendar);
|
||||
#endif
|
||||
|
||||
lv_calendar_set_chinese_mode(calendar, true);
|
||||
lv_obj_set_style_text_font(calendar, &lv_font_simsun_14_cjk, LV_PART_MAIN);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void lv_example_calendar_2(void)
|
||||
{
|
||||
lv_obj_t * label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(label, "chinese calendar is not enabled");
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user