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

163 lines
4.2 KiB
C
Raw Normal View History

2024-11-29 08:23:11 +00:00
/**
* File: pages.h
* Author: AWTK Develop Team
* Brief: pages
*
* 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-06-16 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef TK_PAGES_H
#define TK_PAGES_H
#include "base/widget.h"
#include "tkc/str.h"
BEGIN_C_DECLS
/**
* @class pages_t
* @parent widget_t
* @annotation ["scriptable","design","widget"]
*
*
* Page处于active状态active状态的Page才能显示并接收事件
*
*
* pages\_t是[widget\_t](widget_t.md)
* widget\_t的函数均适用于pages\_t控件
*
* xml中使用"pages"
*
* ```xml
* <tab_control x="0" y="0" w="100%" h="100%" >
* <pages x="c" y="20" w="90%" h="-60" value="1">
* ...
* </pages>
* <tab_button_group>
* ...
* </tab_button_group>
* </tab_control>
* ```
*
* >
* [tab control](https://github.com/zlgopen/awtk/blob/master/design/default/ui/)
*
*/
typedef struct _pages_t {
widget_t widget;
/**
* @property {uint32_t} active
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* page( MVVM value )
*/
uint32_t active;
/**
* @property {bool_t} auto_focused
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* TRUE
*/
bool_t auto_focused;
/**
* @property {uint32_t} value
* @annotation ["set_prop","get_prop","readable","persitent","design","fake"]
* page
*/
/* private */
str_t str_target;
uint32_t init_idle_id;
uint32_t focused_idle_id;
bool_t has_active;
} pages_t;
/**
* @event {value_change_event_t} EVT_VALUE_WILL_CHANGE
* ()
*/
/**
* @event {value_change_event_t} EVT_VALUE_CHANGED
* ()
*/
/**
* @method pages_create
* pages对象
* @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* pages_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method pages_cast
* pages对象(使)
* @annotation ["cast", "scriptable"]
* @param {widget_t*} widget pages对象
*
* @return {widget_t*} pages对象
*/
widget_t* pages_cast(widget_t* widget);
/**
* @method pages_set_active
* Page
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {uint32_t} index Page的序号
*
* @return {ret_t} RET_OK表示成功
*/
ret_t pages_set_active(widget_t* widget, uint32_t index);
/**
* @method pages_set_auto_focused
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {bool_t} auto_focused
*
* @return {ret_t} RET_OK表示成功
*/
ret_t pages_set_auto_focused(widget_t* widget, bool_t auto_focused);
/**
* @method pages_set_active_by_name
* Page
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {const char*} name Page的名字
*
* @return {ret_t} RET_OK表示成功
*/
ret_t pages_set_active_by_name(widget_t* widget, const char* name);
#define PAGES(widget) ((pages_t*)(pages_cast(WIDGET(widget))))
#define WIDGET_PROP_AUTO_FOCUSED "auto_focused"
/*public for subclass and runtime type check*/
TK_EXTERN_VTABLE(pages);
END_C_DECLS
#endif /*TK_PAGES_H*/