Files
luban-lite-t3e-pro/packages/third-party/awtk-ui/awtk/src/widgets/image.h

161 lines
4.3 KiB
C
Raw Normal View History

2023-11-09 20:19:51 +08:00
/**
* File: image.h
* Author: AWTK Develop Team
* Brief: image
*
* 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-03 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef TK_IMAGE_H
#define TK_IMAGE_H
#include "base/widget.h"
#include "base/image_base.h"
BEGIN_C_DECLS
/**
* @class image_t
* @parent image_base_t
* @annotation ["scriptable","design","widget"]
*
*
* bmp/png/jpg等格式
*
* gif文件[gif\_image](gif_image_t.md)
*
* svg文件[svg\_image](svg_image_t.md)
*
* **selectable**
*
* **clickable**
*
* image\_t是[image\_base\_t](image_base_t.md)image\_base\_t的函数均适用于image\_t控件
*
* xml中使用"image"
*
* ```xml
* <image style="border" image="earth" draw_type="icon" />
* ```
*
* >
* [image.xml](https://github.com/zlgopen/awtk/blob/master/design/default/ui/images.xml)
*
* c代码中使用函数image\_create创建图片控件
*
* ```c
* widget_t* image = image_create(win, 10, 10, 128, 30);
* image_set_image(image, "earth");
* ```
*
* > :
* >
* > widget\_set\_image设置图片名称
* >
* > image\_set\_draw\_type设置图片的绘制方式
*
* > [image\_draw\_type\_t](image_draw_type_t.md)
*
* > :
* [image\_draw\_type\_name\_value](https://github.com/zlgopen/awtk/blob/master/src/base/enums.c#L98)
*
* >
* [image demo](https://github.com/zlgopen/awtk-c-demos/blob/master/demos/image.c)
*
* style来设置控件的显示风格
*
* ```xml
* <image>
* <style name="border">
* <normal border_color="#000000" bg_color="#e0e0e0" text_color="black"/>
* </style>
* </image>
* ```
*
* >
* [theme
* default](https://github.com/zlgopen/awtk/blob/master/design/default/styles/default.xml#L313)
*
*/
typedef struct _image_t {
image_base_t image_base;
/**
* @property {image_draw_type_t} draw_type
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* ()
*/
image_draw_type_t draw_type;
} image_t;
/**
* @method image_create
* image对象
* @annotation ["constructor", "scriptable"]
* @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* image_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method icon_create
* icon对象
* @annotation ["constructor", "scriptable"]
* @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* icon_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method image_set_draw_type
*
* @annotation ["scriptable"]
* @param {widget_t*} widget image对象
* @param {image_draw_type_t} draw_type ()
*
* @return {ret_t} RET_OK表示成功
*/
ret_t image_set_draw_type(widget_t* widget, image_draw_type_t draw_type);
/**
* @method image_cast
* image对象(使)
* @annotation ["cast", "scriptable"]
* @param {widget_t*} widget image对象
*
* @return {widget_t*} image对象
*/
widget_t* image_cast(widget_t* widget);
#define IMAGE(widget) ((image_t*)(image_cast(WIDGET(widget))))
/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(image);
END_C_DECLS
#endif /*TK_IMAGE_H*/