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

157 lines
4.2 KiB
C
Raw Normal View History

2024-11-29 08:23:11 +00:00
/**
* File: grid.h
* Author: AWTK Develop Team
* Brief:
*
* Copyright (c) 2022 - 2022 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:
* ================================================================
* 2022-06-18 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef TK_GRID_H
#define TK_GRID_H
#include "base/widget.h"
BEGIN_C_DECLS
/**
* @class grid_t
* @parent widget_t
* @annotation ["scriptable","design","widget"]
*
* xml中使用"grid"
*
* ```xml
* <!-- ui -->
* <grid x="c" y="50" w="100" h="100"/>
* ```
*
* style来设置控件的显示风格
*
* ```xml
* <!-- style -->
* <grid>
* <style name="default" grid_color="gray" border_color="black" odd_bg_color="#f5f5f5" even_bg_color="#eeeeee">
* <normal />
* </style>
* </grid>
* ```
*/
typedef struct _grid_t {
widget_t widget;
/**
* @property {uint32_t} rows
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
*
*/
uint32_t rows;
/**
* @property {char*} columns_definition
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
*
* (;)
*
* col(w=?,left_margin=?,right_margin=?,top_maorgin=?,bottom_margin=?)
*
* * w ()(0-1]grid控件宽度的比例
* ()
* * left_margin(l)
* * right_margin(r)
* * top_margin(t)
* * bottom_margin(b)
* * margin(m) 4
* * fill_available(f) ()
*
*/
char* columns_definition;
/**
* @property {bool_t} show_grid
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
*
*/
bool_t show_grid;
/*private*/
darray_t cols_definition;
} grid_t;
/**
* @method grid_create
* @annotation ["constructor", "scriptable"]
* grid对象
* @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*} grid对象
*/
widget_t* grid_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method grid_cast
* grid对象(使)
* @annotation ["cast", "scriptable"]
* @param {widget_t*} widget grid对象
*
* @return {widget_t*} grid对象
*/
widget_t* grid_cast(widget_t* widget);
/**
* @method grid_set_rows
*
* @annotation ["scriptable"]
* @param {widget_t*} widget widget对象
* @param {uint32_t} rows
*
* @return {ret_t} RET_OK表示成功
*/
ret_t grid_set_rows(widget_t* widget, uint32_t rows);
/**
* @method grid_set_columns_definition
*
* @annotation ["scriptable"]
* @param {widget_t*} widget widget对象
* @param {const char*} columns_definition
*
* @return {ret_t} RET_OK表示成功
*/
ret_t grid_set_columns_definition(widget_t* widget, const char* columns_definition);
/**
* @method grid_set_show_grid
*
* @annotation ["scriptable"]
* @param {widget_t*} widget widget对象
* @param {bool_t} show_grid
*
* @return {ret_t} RET_OK表示成功
*/
ret_t grid_set_show_grid(widget_t* widget, bool_t show_grid);
#define GRID(widget) ((grid_t*)(grid_cast(WIDGET(widget))))
/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(grid);
END_C_DECLS
#endif /*TK_GRID_H*/