Files
luban-lite/packages/third-party/awtk-ui/awtk/src/widgets/label.h

224 lines
6.5 KiB
C
Raw Normal View History

2023-11-09 20:19:51 +08:00
/**
* File: label.h
* Author: AWTK Develop Team
* Brief: label
*
* Copyright (c) 2018 - 2023 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-02-06 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef TK_LABEL_H
#define TK_LABEL_H
#include "base/widget.h"
BEGIN_C_DECLS
/**
* @class label_t
* @parent widget_t
* @annotation ["scriptable","design","widget"]
*
*
*
*
*
* 使[rich\_text\_t](rich_text_t.md)
*
* label\_t是[widget\_t](widget_t.md)widget\_t的函数均适用于label\_t控件
*
* xml中使用"label"
*
* ```xml
* <label style="center" text="center"/>
* ```
*
* > [label.xml](
*https://github.com/zlgopen/awtk/blob/master/design/default/ui/label.xml)
*
* c代码中使用函数label\_create创建文本控件
*
* ```c
* widget_t* label = label_create(win, 10, 10, 128, 30);
* widget_set_text(label, L"hello awtk!");
* ```
*
* > widget\_set\_text或widget\_set\_text\_utf8设置文本内容
*
* > [label demo](
*https://github.com/zlgopen/awtk-c-demos/blob/master/demos/label.c)
*
* style来设置控件的显示风格
*
* ```xml
* <style name="left">
* <normal text_color="red" text_align_h="left" border_color="#a0a0a0" margin="4" />
* </style>
* ```
*
* >
* [theme default](
*https://github.com/zlgopen/awtk/blob/master/design/default/styles/default.xml#L144)
*
*/
typedef struct _label_t {
widget_t widget;
/**
* @property {int32_t} length
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* (0)
* [...]
*/
int32_t length;
/**
* @property {bool_t} line_wrap
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* (FALSE)
*/
bool_t line_wrap;
/**
* @property {bool_t} word_wrap
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* (FALSE)
* >
*/
bool_t word_wrap;
/**
* @property {bool_t} ellipses
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* ...
* >
*/
bool_t ellipses;
/**
* @property {int32_t} max_w
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* auto_adjust_size为TRUE时
* >00max_w
*/
int32_t max_w;
} label_t;
/**
* @method label_create
* @annotation ["constructor", "scriptable"]
* label对象
* @param {widget_t*} parent
* @param {xy_t} x x坐标
* @param {xy_t} y y坐标
* @param {wh_t} w
* @param {wh_t} h
*
* @return {widget_t*}
*/
widget_t* label_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method label_set_length
* (0)
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {int32_t} length
*
* @return {ret_t} RET_OK表示成功
*/
ret_t label_set_length(widget_t* widget, int32_t length);
/**
* @method label_set_max_w
* max_w
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {int32_t} max_w
*
* @return {ret_t} RET_OK表示成功
*/
ret_t label_set_max_w(widget_t* widget, int32_t max_w);
/**
* @method label_set_line_wrap
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {bool_t} line_wrap
*
* @return {ret_t} RET_OK表示成功
*/
ret_t label_set_line_wrap(widget_t* widget, bool_t line_wrap);
/**
* @method label_set_word_wrap
* ()
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {bool_t} word_wrap
*
* @return {ret_t} RET_OK表示成功
*/
ret_t label_set_word_wrap(widget_t* widget, bool_t word_wrap);
/**
* @method label_set_ellipses
* ...
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {bool_t} ellipses
*
* @return {ret_t} RET_OK表示成功
*/
ret_t label_set_ellipses(widget_t* widget, bool_t ellipses);
/**
* @method label_resize_to_content
*
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {uint32_t} min_w
* @param {uint32_t} max_w
* @param {uint32_t} min_h
* @param {uint32_t} max_h
*
* @return {ret_t} RET_OK表示成功
*/
ret_t label_resize_to_content(widget_t* widget, uint32_t min_w, uint32_t max_w, uint32_t min_h,
uint32_t max_h);
/**
* @method label_cast
* label对象(使)
* @annotation ["cast", "scriptable"]
* @param {widget_t*} widget label对象
*
* @return {widget_t*} label对象
*/
widget_t* label_cast(widget_t* widget);
#define LABEL(widget) ((label_t*)(label_cast(WIDGET(widget))))
/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(label);
/*public for test*/
END_C_DECLS
#endif /*TK_LABEL_H*/