linuxOS_D21X/source/artinchip/awtk-ui/awtk/src/widgets/progress_bar.h

234 lines
6.5 KiB
C
Raw Normal View History

2024-11-29 08:23:11 +00:00
/**
* File: progress_bar.h
* Author: AWTK Develop Team
* Brief: progress_bar
*
* 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-09 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef TK_PROGRESS_BAR_H
#define TK_PROGRESS_BAR_H
#include "base/widget.h"
BEGIN_C_DECLS
/**
* @class progress_bar_t
* @parent widget_t
* @annotation ["scriptable","design","widget"]
*
*
* vertical属性决定
*
* progress\_bar\_t是[widget\_t](widget_t.md)widget\_t的函数均适用于progress\_bar\_t控件
*
* xml中使用"progress\_bar"
*
* ```xml
* <progress_bar name="bar1" x="10" y="128" w="240" h="30" value="40"/>
* <progress_bar name="bar2" x="280" y="128" w="30" h="118" value="20" vertical="true"/>
* ```
*
* >
* [basic demo](https://github.com/zlgopen/awtk/blob/master/design/default/ui/basic.xml)
*
* c代码中使用函数progress\_bar\_create创建进度条控件
*
* ```c
* widget_t* progress_bar = progress_bar_create(win, 10, 10, 128, 30);
* ```
*
* >
* [progress_bar demo](https://github.com/zlgopen/awtk-c-demos/blob/master/demos/progress_bar.c)
*
* style来设置控件的显示风格
*
* ```xml
* <style>
* <normal bg_color="#f0f0f0" text_color="gold" fg_color="#c0c0c0" border_color="#a0a0a0" />
* </style>
* ```
*
* >
* [theme
* default](https://github.com/zlgopen/awtk/blob/master/design/default/styles/default.xml#L183)
*
*/
typedef struct _progress_bar_t {
widget_t widget;
/**
* @property {double} value
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* [0-max]
*/
double value;
/**
* @property {double} max
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* (100)
*/
double max;
/**
* @property {char*} format
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* "%d"
*/
char* format;
/**
* @property {bool_t} vertical
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
*
*/
bool_t vertical;
/**
* @property {bool_t} show_text
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
*
*/
bool_t show_text;
/**
* @property {bool_t} reverse
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* TRUE
*/
bool_t reverse;
} progress_bar_t;
/**
* @event {value_change_event_t} EVT_VALUE_WILL_CHANGE
*
*/
/**
* @event {value_change_event_t} EVT_VALUE_CHANGED
*
*/
/**
* @method progress_bar_create
* @annotation ["constructor", "scriptable"]
* progress_bar对象
* @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* progress_bar_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method progress_bar_cast
* progress_bar对象(使)
* @annotation ["cast", "scriptable"]
* @param {widget_t*} widget progress_bar对象
*
* @return {widget_t*} progress_bar对象
*/
widget_t* progress_bar_cast(widget_t* widget);
/**
* @method progress_bar_set_value
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {double} value
*
* @return {ret_t} RET_OK表示成功
*/
ret_t progress_bar_set_value(widget_t* widget, double value);
/**
* @method progress_bar_set_max
*
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {double} max
*
* @return {ret_t} RET_OK表示成功
*/
ret_t progress_bar_set_max(widget_t* widget, double max);
/**
* @method progress_bar_set_format
*
* @annotation ["scriptable"]
* @param {widget_t*} widget progress_bar对象
* @param {const char*} format
*
* @return {ret_t} RET_OK表示成功
*/
ret_t progress_bar_set_format(widget_t* widget, const char* format);
/**
* @method progress_bar_set_vertical
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {bool_t} vertical
*
* @return {ret_t} RET_OK表示成功
*/
ret_t progress_bar_set_vertical(widget_t* widget, bool_t vertical);
/**
* @method progress_bar_set_show_text
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {bool_t} show_text
*
* @return {ret_t} RET_OK表示成功
*/
ret_t progress_bar_set_show_text(widget_t* widget, bool_t show_text);
/**
* @method progress_bar_set_reverse
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {bool_t} reverse
*
* @return {ret_t} RET_OK表示成功
*/
ret_t progress_bar_set_reverse(widget_t* widget, bool_t reverse);
/**
* @method progress_bar_get_percent
*
*
* > max为100时percent和value取整后一致
* @annotation ["scriptable"]
* @param {widget_t*} widget
*
* @return {uint32_t}
*/
uint32_t progress_bar_get_percent(widget_t* widget);
#define PROGRESS_BAR(widget) ((progress_bar_t*)(progress_bar_cast(WIDGET(widget))))
/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(progress_bar);
END_C_DECLS
#endif /*TK_PROGRESS_BAR_H*/