2021-04-08 13:07:48 +02:00
|
|
|
#include "../../lv_examples.h"
|
2021-02-14 14:56:34 +01:00
|
|
|
#if LV_USE_LIST && LV_BUILD_EXAMPLES
|
2021-02-28 13:29:13 +01:00
|
|
|
static lv_obj_t * list1;
|
2021-02-08 09:53:03 +01:00
|
|
|
|
2021-04-14 15:31:54 +02:00
|
|
|
static void event_handler(lv_event_t * e)
|
2021-02-08 09:53:03 +01:00
|
|
|
{
|
2021-04-14 15:31:54 +02:00
|
|
|
lv_event_code_t code = lv_event_get_code(e);
|
|
|
|
lv_obj_t * obj = lv_event_get_target(e);
|
|
|
|
if(code == LV_EVENT_CLICKED) {
|
2021-02-28 15:02:00 +01:00
|
|
|
LV_LOG_USER("Clicked: %s", lv_list_get_btn_text(list1, obj));
|
2021-02-08 09:53:03 +01:00
|
|
|
}
|
|
|
|
}
|
2021-02-19 18:19:32 +01:00
|
|
|
void lv_example_list_1(void)
|
2021-02-08 09:53:03 +01:00
|
|
|
{
|
|
|
|
/*Create a list*/
|
2021-02-28 13:29:13 +01:00
|
|
|
list1 = lv_list_create(lv_scr_act());
|
2021-03-23 20:51:39 +01:00
|
|
|
lv_obj_set_size(list1, 180, 220);
|
2021-03-25 16:14:17 +01:00
|
|
|
lv_obj_center(list1);
|
2021-02-08 09:53:03 +01:00
|
|
|
|
|
|
|
/*Add buttons to the list*/
|
2021-05-13 00:42:52 +02:00
|
|
|
lv_obj_t * btn;
|
|
|
|
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_list_add_text(list1, "File");
|
2021-05-13 00:42:52 +02:00
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "New");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_DIRECTORY, "Open");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_SAVE, "Save");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Delete");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_EDIT, "Edit");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_list_add_text(list1, "Connectivity");
|
2021-05-13 00:42:52 +02:00
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_BLUETOOTH, "Bluetooth");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_GPS, "Navigation");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_USB, "USB");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_BATTERY_FULL, "Battery");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
|
2021-02-08 09:53:03 +01:00
|
|
|
lv_list_add_text(list1, "Exit");
|
2021-05-13 00:42:52 +02:00
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_OK, "Apply");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
|
|
|
btn = lv_list_add_btn(list1, LV_SYMBOL_CLOSE, "Close");
|
|
|
|
lv_obj_add_event_cb(btn, event_handler, LV_EVENT_CLICKED, NULL);
|
2021-02-08 09:53:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|