diff --git a/lv_objx/lv_img.c b/lv_objx/lv_img.c index f4246b1ee4..cd03cb2975 100644 --- a/lv_objx/lv_img.c +++ b/lv_objx/lv_img.c @@ -78,6 +78,9 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy) ext->w = lv_obj_get_width(new_img); ext->h = lv_obj_get_height(new_img); ext->auto_size = 1; +#if USE_LV_MULTI_LANG + ext->lang_txt_id = LV_LANG_TXT_ID_NONE; +#endif /*Init the new object*/ lv_obj_set_signal_func(new_img, lv_img_signal); @@ -265,6 +268,21 @@ const char * lv_img_get_file_name(const lv_obj_t * img) else return ""; } +/** + * Get the source ID of the image. (Used by the multi-language feature) + * @param img pointer to an image + * @return ID of the source + */ +uint16_t lv_img_get_text_lang(lv_obj_t * img) +{ +#if USE_LV_MULTI_LANG + lv_img_ext_t * ext = lv_obj_get_ext_attr(img); + return ext->lang_txt_id; +#else + LV_LOG_WARN("lv_img_get_text_lang: multiple languages are not enabled. See lv_conf.h USE_LV_MULTI_LANG ") + return NULL; +#endif +} /** * Get the auto size enable attribute diff --git a/lv_objx/lv_img.h b/lv_objx/lv_img.h index b1dd08d095..36222f975f 100644 --- a/lv_objx/lv_img.h +++ b/lv_objx/lv_img.h @@ -94,6 +94,13 @@ static inline void lv_img_set_file(lv_obj_t * img, const char * fn) (void) fn; } +/** + * Set an ID which means a the same source but on different languages + * @param img pointer to an image object + * @param src_id ID of the source + */ +void lv_img_set_src_multi(lv_obj_t * img, uint32_t txt_id); + /** * Enable the auto size feature. * If enabled the object size will be same as the picture size. @@ -141,6 +148,13 @@ const void * lv_img_get_src(lv_obj_t * img); */ const char * lv_img_get_file_name(const lv_obj_t * img); +/** + * Get the source ID of the image. (Used by the multi-language feature) + * @param img pointer to an image + * @return ID of the source + */ +uint16_t lv_img_get_text_lang(lv_obj_t * img); + /** * Get the auto size enable attribute * @param img pointer to an image