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

210 lines
5.6 KiB
C
Raw Normal View History

2023-11-09 20:19:51 +08:00
/**
* File: check_button.h
* Author: AWTK Develop Team
* Brief: check_button
*
* 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_CHECK_BUTTON_H
#define TK_CHECK_BUTTON_H
#include "base/widget.h"
BEGIN_C_DECLS
/**
* @class check_button_t
* @parent widget_t
* @annotation ["scriptable","design","widget"]
* (/)
*
* check\_button\_t是[widget\_t](widget_t.md)widget\_t的函数均适用于check\_button\_t控件
*
* xml中使用"check_button"
*
* ```xml
* <check_button name="c1" text="Book"/>
* ```
*
* xml中使用"radio_button"
*
* ```xml
* <radio_button name="r1" text="Book"/>
* ```
*
* >
* [button.xml](https://github.com/zlgopen/awtk/blob/master/design/default/ui/basic.xml)
*
* c代码中使用函数check\_button\_create创建多选按钮控件
*
* ```c
* widget_t* button = check_button_create(win, x, y, w, h);
* widget_set_text(button, L"OK");
* widget_on(button, EVT_VALUE_CHANGED, on_changed, NULL);
* ```
*
* c代码中使用函数check\_button\_create\_radio创建单选按钮控件
*
* ```c
* widget_t* button = check_button_create_radio(win, x, y, w, h);
* widget_set_text(button, L"OK");
* widget_on(button, EVT_VALUE_CHANGED, on_changed, NULL);
* ```
*
* >
* [button demo](https://github.com/zlgopen/awtk-c-demos/blob/master/demos/check_button.c)
*
* style来设置控件的显示风格
*
* ```xml
* <style name="default" icon_at="left">
* <normal icon="unchecked" />
* <pressed icon="unchecked" />
* <over icon="unchecked" text_color="green"/>
* <normal_of_checked icon="checked" text_color="blue"/>
* <pressed_of_checked icon="checked" text_color="blue"/>
* <over_of_checked icon="checked" text_color="green"/>
* </style>
* ```
*
* >
* [theme
* default](https://github.com/zlgopen/awtk/blob/master/design/default/styles/default.xml#L227)
*
*/
typedef struct _check_button_t {
widget_t widget;
/**
* @property {bool_t} value
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* (TRUEFALSE)
*/
bool_t value;
/**
* @property {bool_t} radio
* @annotation ["set_prop","get_prop"]
*
*/
bool_t radio;
/*private*/
bool_t pressed;
bool_t point_down_aborted;
const char* type;
} check_button_t;
/**
* @event {value_change_event_t} EVT_VALUE_WILL_CHANGE
* ()
*/
/**
* @event {value_change_event_t} EVT_VALUE_CHANGED
* ()
*/
/**
* @event {pointer_event_t} EVT_CLICK
*
*/
/**
* @method check_button_create
*
* @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对象
*/
widget_t* check_button_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method check_button_create_radio
*
* @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对象
*/
widget_t* check_button_create_radio(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method check_button_set_value
*
* @annotation ["scriptable"]
* @param {widget_t*} widget check_button对象
* @param {bool_t} value (TRUEFALSE)
*
* @return {ret_t} RET_OK表示成功
*/
ret_t check_button_set_value(widget_t* widget, bool_t value);
/**
* @method check_button_get_checked_button
* radio button获取同组中勾选的radio button
*
* @param {widget_t*} widget radio_button对象
*
* @return {widget_t*} radio button对象
*/
widget_t* check_button_get_checked_button(widget_t* widget);
/**
* @method check_button_cast
* check_button对象(使)
* @annotation ["cast", "scriptable"]
* @param {widget_t*} widget check_button对象
*
* @return {widget_t*} check_button对象
*/
widget_t* check_button_cast(widget_t* widget);
#define CHECK_BUTTON(widget) ((check_button_t*)(check_button_cast(WIDGET(widget))))
/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(check_button);
/**
* @method check_button_create_ex
* check button对象
* @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
* @param {const char*} type
* @param {bool_t} radio
*
* @return {widget_t*} widget对象
*/
widget_t* check_button_create_ex(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h, const char* type,
bool_t radio);
END_C_DECLS
#endif /*TK_CHECK_BUTTON_H*/