mirror of
https://github.com/zlgopen/awtk.git
synced 2025-05-08 19:44:45 +08:00
split awtk.a into tkc/base/widgets/extwidgets/awtk
This commit is contained in:
parent
62fb417336
commit
f746ec44e6
@ -196,7 +196,7 @@ CFLAGS=COMMON_CFLAGS
|
||||
LINKFLAGS=OS_LINKFLAGS;
|
||||
LIBPATH=[TK_LIB_DIR] + OS_LIBPATH
|
||||
CCFLAGS=OS_FLAGS + COMMON_CCFLAGS
|
||||
LIBS=['awtk', 'gpinyin', 'tkc', 'linebreak'] + NANOVG_BACKEND_LIBS + ['SDL2', 'glad'] + OS_LIBS
|
||||
LIBS=['awtk', 'exwidgets', 'widgets', 'base', 'gpinyin', 'tkc', 'linebreak'] + NANOVG_BACKEND_LIBS + ['SDL2', 'glad'] + OS_LIBS
|
||||
|
||||
CPPPATH=[TK_ROOT,
|
||||
TK_SRC,
|
||||
|
@ -22,13 +22,13 @@
|
||||
#include "base/timer.h"
|
||||
#include "base/enums.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "widgets/image.h"
|
||||
#include "widgets/label.h"
|
||||
#include "tkc/mem.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "tkc/utf8.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "widgets/slider.h"
|
||||
#include "widgets/group_box.h"
|
||||
#include "widgets/check_button.h"
|
||||
|
@ -22,13 +22,13 @@
|
||||
#include "base/timer.h"
|
||||
#include "base/enums.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "widgets/image.h"
|
||||
#include "widgets/label.h"
|
||||
#include "tkc/mem.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "tkc/utf8.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "widgets/slider.h"
|
||||
#include "widgets/group_box.h"
|
||||
#include "widgets/check_button.h"
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "tkc/mem.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "tkc/utf8.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "base/image_manager.h"
|
||||
#include "widgets/progress_bar.h"
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "widgets/button.h"
|
||||
#include "base/locale_info.h"
|
||||
#include "widgets/check_button.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "widgets/image.h"
|
||||
#include "base/image_manager.h"
|
||||
#include "widgets/label.h"
|
||||
@ -32,7 +32,7 @@
|
||||
#include "widgets/progress_bar.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "tkc/utf8.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "widgets/slider.h"
|
||||
#include "widgets/group_box.h"
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "base/timer.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "base/image_manager.h"
|
||||
#include "canvas_widget/canvas_widget.h"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 最新动态
|
||||
* 2019/08/19
|
||||
* tkc 编译成独立的库。
|
||||
* awtk编译成tkc/base/widgets/extwidgets/awtk几个独立的库,并调整部分文件的位置。
|
||||
|
||||
* 2019/08/18
|
||||
* 去掉widget pool。
|
||||
|
@ -7,17 +7,13 @@ NANOVG_BACKEND=os.environ['NANOVG_BACKEND'];
|
||||
VGCANVAS=os.environ['VGCANVAS'];
|
||||
NATIVE_WINDOW = os.environ['NATIVE_WINDOW'];
|
||||
|
||||
sources=Glob('base/*.c') + \
|
||||
Glob('layouters/*.c') + \
|
||||
Glob('widgets/*.c') + \
|
||||
sources=Glob('layouters/*.c') + \
|
||||
Glob('ui_loader/*.c') + \
|
||||
Glob('xml/*.c') + \
|
||||
Glob('svg/*.c') + \
|
||||
Glob('clip_board/*.c') + \
|
||||
Glob('font_loader/*.c') + \
|
||||
Glob('blend/*.c') + \
|
||||
Glob('ext_widgets/*.c') + \
|
||||
Glob('ext_widgets/*/*.c') + \
|
||||
Glob('image_loader/*.c') + \
|
||||
Glob('designer_support/*.c') + \
|
||||
Glob('widget_animators/*.c') + \
|
||||
@ -92,4 +88,8 @@ if env['PLATFORM'] == 'win32' and os.environ['TOOLS_NAME'] != '':
|
||||
env['SPAWN'] = buf.ourspawn
|
||||
|
||||
env.Library(os.path.join(LIB_DIR, 'tkc'), Glob('tkc/*.c'), LIBS=[])
|
||||
env.Library(os.path.join(LIB_DIR, 'base'), Glob('base/*.c'), LIBS=[])
|
||||
env.Library(os.path.join(LIB_DIR, 'widgets'), Glob('widgets/*.c'), LIBS=[])
|
||||
env.Library(os.path.join(LIB_DIR, 'exwidgets'), Glob('ext_widgets/*.c') + Glob('ext_widgets/*/*.c'), LIBS=[])
|
||||
env.Library(os.path.join(LIB_DIR, 'awtk'), sources, LIBS=[])
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "base/window_animator_factory.h"
|
||||
#include "window_animators/window_animator_builtins.h"
|
||||
|
||||
#include "widgets/widgets.h"
|
||||
#include "base/self_layouter_factory.h"
|
||||
#include "base/children_layouter_factory.h"
|
||||
#include "base/dialog_highlighter_factory.h"
|
||||
@ -177,6 +178,7 @@ ret_t tk_init_internal(void) {
|
||||
dialog_highlighter_register_builtins();
|
||||
#endif/*WITHOUT_DIALOG_HIGHLIGHTER*/
|
||||
|
||||
tk_widgets_init();
|
||||
tk_mem_set_on_out_of_memory(awtk_mem_on_out_of_memory, NULL);
|
||||
|
||||
return RET_OK;
|
||||
|
@ -22,6 +22,9 @@
|
||||
#ifndef AWTK_WIDGETS_H
|
||||
#define AWTK_WIDGETS_H
|
||||
|
||||
#include "base/dialog.h"
|
||||
#include "base/window.h"
|
||||
|
||||
#include "widgets/app_bar.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/button_group.h"
|
||||
@ -31,7 +34,6 @@
|
||||
#include "widgets/column.h"
|
||||
#include "widgets/combo_box.h"
|
||||
#include "widgets/combo_box_item.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "widgets/dialog_client.h"
|
||||
#include "widgets/dialog_title.h"
|
||||
#include "widgets/dragger.h"
|
||||
@ -53,6 +55,5 @@
|
||||
#include "widgets/tab_button_group.h"
|
||||
#include "widgets/tab_control.h"
|
||||
#include "widgets/view.h"
|
||||
#include "widgets/window.h"
|
||||
|
||||
#endif /*AWTK_WIDGETS_H*/
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "base/enums.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "base/layout.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "base/main_loop.h"
|
||||
#include "base/image_manager.h"
|
||||
#include "base/window_manager.h"
|
@ -1,344 +1,344 @@
|
||||
/**
|
||||
* File: dialog.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: dialog
|
||||
*
|
||||
* Copyright (c) 2018 - 2019 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-01-13 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_DIALOG_H
|
||||
#define TK_DIALOG_H
|
||||
|
||||
#include "base/window_base.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class dialog_t
|
||||
* @parent widget_t
|
||||
* @annotation ["scriptable","design","widget","window"]
|
||||
*
|
||||
* 对话框。 对话框是一种特殊的窗口,大小和位置可以自由设置。
|
||||
*
|
||||
* AWTK中的对话框可以是模态的,也可以是非模态的。
|
||||
*
|
||||
* 如果dialog有透明或半透效果则不支持窗口动画。
|
||||
*
|
||||
*> 由于浏览器中无法实现主循环嵌套,因此无法实现模态对话框。
|
||||
* 如果希望自己写的AWTK应用程序可以在浏览器(包括各种小程序)中运行或演示,
|
||||
* 请避免使用模态对话框。
|
||||
*
|
||||
* 对话框通常由对话框标题和对话框客户区两部分组成:
|
||||
*
|
||||
* ```graphviz
|
||||
* [default_style]
|
||||
*
|
||||
* dialog_title_t -> dialog_t[arrowhead = "ediamond"]
|
||||
* dialog_client_t -> dialog_t[arrowhead = "ediamond"]
|
||||
* ```
|
||||
*
|
||||
* dialog\_t是[window\_base\_t](window_base_t.md)的子类控件,window\_base\_t的函数均适用于dialog\_t控件。
|
||||
*
|
||||
* 在xml中使用"dialog"标签创建对话框。如:
|
||||
*
|
||||
* ```xml
|
||||
* <dialog anim_hint="center_scale(duration=300)" x="c" y="m" w="80%" h="160" text="Dialog">
|
||||
* <dialog_title x="0" y="0" w="100%" h="30" text="Hello AWTK" />
|
||||
* <dialog_client x="0" y="bottom" w="100%" h="-30">
|
||||
* <label name="" x="center" y="middle:-20" w="200" h="30" text="Are you ready?"/>
|
||||
* <button name="quit" x="10" y="bottom:10" w="40%" h="30" text="确定"/>
|
||||
* <button name="quit" x="right:10" y="bottom:10" w="40%" h="30" text="取消"/>
|
||||
* </dialog_client>
|
||||
* </dialog>
|
||||
* ```
|
||||
*
|
||||
* 如果你不需要对话框的标题,可以这样写:
|
||||
*
|
||||
* ```xml
|
||||
* <dialog anim_hint="center_scale(duration=300)" x="c" y="m" w="80%" h="160" text="Dialog">
|
||||
* <label name="" x="center" y="middle:-20" w="200" h="30" text="Are you ready?"/>
|
||||
* <button name="quit" x="10" y="bottom:10" w="40%" h="30" text="确定"/>
|
||||
* <button name="quit" x="right:10" y="bottom:10" w="40%" h="30" text="取消"/>
|
||||
* </dialog>
|
||||
* ```
|
||||
*
|
||||
* 打开非模态对话框时,其用法与普通窗口一样。打开非模态对话框时,还需要调用dialog\_modal。
|
||||
*
|
||||
* ```c
|
||||
* widget_t* dlg = dialog_open(name);
|
||||
*
|
||||
* ret = dialog_modal(dlg);
|
||||
* ```
|
||||
*
|
||||
* 关闭模态对话框用dialog\_quit
|
||||
*
|
||||
* ```c
|
||||
* static ret_t on_dialog_btn_click(void* ctx, event_t* evt) {
|
||||
* widget_t* win = widget_get_window(WIDGET(evt->target));
|
||||
* int code = (char*)ctx - (char*)NULL;
|
||||
*
|
||||
* dialog_quit(win, code);
|
||||
*
|
||||
* return RET_OK;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* 关闭非模态对话框用window\_close。
|
||||
*
|
||||
* ```c
|
||||
* static ret_t on_dialog_btn_click(void* ctx, event_t* evt) {
|
||||
* widget_t* win = widget_get_window(WIDGET(evt->target));
|
||||
* int code = (char*)ctx - (char*)NULL;
|
||||
*
|
||||
* window_close(win);
|
||||
*
|
||||
* return RET_OK;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* > 更多用法请参考:
|
||||
* [dialog.xml](https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/ui/)
|
||||
*
|
||||
* > 完整C代码示例请参考:
|
||||
*
|
||||
* * [非模态对话框](https://github.com/zlgopen/awtk-c-demos/blob/master/demos/dialog.c)
|
||||
*
|
||||
* * [模态对话框](https://github.com/zlgopen/awtk-c-demos/blob/master/demos/dialog_modal.c)
|
||||
*
|
||||
*可用通过style来设置控件的显示风格,如字体的大小和颜色等等。如:
|
||||
*
|
||||
* ```xml
|
||||
* <style name="default">
|
||||
* <normal border_color="#606060" />
|
||||
* </style>
|
||||
* ```
|
||||
*
|
||||
* > 更多用法请参考:
|
||||
* [theme default]
|
||||
* (https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/styles/default.xml#L324)
|
||||
*
|
||||
*/
|
||||
typedef struct _dialog_t {
|
||||
window_base_t window;
|
||||
|
||||
/**
|
||||
* @property {const char*} highlight
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* 对话框高亮策略。
|
||||
*/
|
||||
char* highlight;
|
||||
|
||||
/*private*/
|
||||
widget_t* title;
|
||||
widget_t* client;
|
||||
uint32_t quit_code;
|
||||
bool_t quited;
|
||||
bool_t is_model;
|
||||
} dialog_t;
|
||||
|
||||
/**
|
||||
* @method dialog_create
|
||||
* 创建dialog对象。
|
||||
* @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*} dialog对象。
|
||||
*/
|
||||
widget_t* dialog_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
/**
|
||||
* @method dialog_create_simple
|
||||
* 创建dialog对象,同时创建title/client。
|
||||
* @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*} dialog对象。
|
||||
*/
|
||||
widget_t* dialog_create_simple(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
/**
|
||||
* @method dialog_cast
|
||||
* 转换dialog对象(供脚本语言使用)。
|
||||
* @annotation ["cast", "scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {widget_t*} dialog对象。
|
||||
*/
|
||||
widget_t* dialog_cast(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_get_title
|
||||
* 获取title控件。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {widget_t*} title对象。
|
||||
*/
|
||||
widget_t* dialog_get_title(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_get_client
|
||||
* 获取client控件。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {widget_t*} client对象。
|
||||
*/
|
||||
widget_t* dialog_get_client(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_open
|
||||
* @annotation ["constructor", "scriptable"]
|
||||
* 从资源文件中加载并创建Dialog对象。
|
||||
*
|
||||
* 本函数在ui\_loader/ui\_builder_default里实现。
|
||||
* @param {const char*} name dialog的名称。
|
||||
*
|
||||
* @return {widget_t*} 对象。
|
||||
*/
|
||||
widget_t* dialog_open(const char* name);
|
||||
|
||||
/**
|
||||
* @method dialog_set_title
|
||||
* 设置对话框的标题文本。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
* @param {char*} title 标题。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_set_title(widget_t* widget, const char* title);
|
||||
|
||||
/**
|
||||
* @method dialog_modal
|
||||
* 模态显示对话框。
|
||||
* dialog_modal返回后,dialog对象将在下一个idle函数中回收。
|
||||
* 也就是在dialog_modal调用完成后仍然可以访问dialog中控件,直到本次事件结束。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
uint32_t dialog_modal(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_quit
|
||||
* 退出模态显示,关闭对话框。
|
||||
*
|
||||
*> 比如,在对话框中关闭按钮的事件处理函数中,调用本函数关闭对话框。
|
||||
*
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
* @param {uint32_t} code 退出码,作为dialog_modal的返回值。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_quit(widget_t* widget, uint32_t code);
|
||||
|
||||
/**
|
||||
* @method dialog_is_quited
|
||||
* 检查对话框是否已经退出模态。
|
||||
*
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {bool_t} 返回TRUE表示已经退出,否则表示没有。
|
||||
*/
|
||||
bool_t dialog_is_quited(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_is_modal
|
||||
* 检查对话框是否为模态对话框。
|
||||
*
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {bool_t} 返回TRUE表示是模态对话框,否则表示不是。
|
||||
*/
|
||||
bool_t dialog_is_modal(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_toast
|
||||
* 显示『短暂提示信息』对话框。
|
||||
*
|
||||
* 主题由dialog_toast.xml文件决定。
|
||||
*
|
||||
* @annotation ["static", "scriptable"]
|
||||
* @param {const char*} text 文本内容。
|
||||
* @param {uint32_t} duration 显示时间(单位为毫秒)。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_toast(const char* text, uint32_t duration);
|
||||
|
||||
/**
|
||||
* @method dialog_info
|
||||
* 显示『提示信息』对话框。
|
||||
*
|
||||
* 主题由dialog_info.xml文件决定。
|
||||
*
|
||||
* @annotation ["static", "scriptable"]
|
||||
* @param {const char*} title 标题。
|
||||
* @param {const char*} text 文本内容。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_info(const char* title, const char* text);
|
||||
|
||||
/**
|
||||
* @method dialog_warn
|
||||
* 显示『警告』对话框。
|
||||
*
|
||||
* 主题由dialog_warn.xml文件决定。
|
||||
*
|
||||
* @annotation ["static", "scriptable"]
|
||||
* @param {const char*} title 标题。
|
||||
* @param {const char*} text 文本内容。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_warn(const char* title, const char* text);
|
||||
|
||||
/**
|
||||
* @method dialog_confirm
|
||||
* 显示『确认』对话框。
|
||||
*
|
||||
* 主题由dialog_confirm.xml文件决定。
|
||||
*
|
||||
* @annotation ["static", "scriptable"]
|
||||
* @param {const char*} title 标题。
|
||||
* @param {const char*} text 文本内容。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示确认,否则表示取消。
|
||||
*/
|
||||
ret_t dialog_confirm(const char* title, const char* text);
|
||||
|
||||
#define DIALOG(widget) ((dialog_t*)(dialog_cast(WIDGET(widget))))
|
||||
|
||||
/*public for subclass and runtime type check*/
|
||||
TK_EXTERN_VTABLE(dialog);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_DIALOG_H*/
|
||||
/**
|
||||
* File: dialog.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: dialog
|
||||
*
|
||||
* Copyright (c) 2018 - 2019 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-01-13 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_DIALOG_H
|
||||
#define TK_DIALOG_H
|
||||
|
||||
#include "base/window_base.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class dialog_t
|
||||
* @parent widget_t
|
||||
* @annotation ["scriptable","design","widget","window"]
|
||||
*
|
||||
* 对话框。 对话框是一种特殊的窗口,大小和位置可以自由设置。
|
||||
*
|
||||
* AWTK中的对话框可以是模态的,也可以是非模态的。
|
||||
*
|
||||
* 如果dialog有透明或半透效果则不支持窗口动画。
|
||||
*
|
||||
*> 由于浏览器中无法实现主循环嵌套,因此无法实现模态对话框。
|
||||
* 如果希望自己写的AWTK应用程序可以在浏览器(包括各种小程序)中运行或演示,
|
||||
* 请避免使用模态对话框。
|
||||
*
|
||||
* 对话框通常由对话框标题和对话框客户区两部分组成:
|
||||
*
|
||||
* ```graphviz
|
||||
* [default_style]
|
||||
*
|
||||
* dialog_title_t -> dialog_t[arrowhead = "ediamond"]
|
||||
* dialog_client_t -> dialog_t[arrowhead = "ediamond"]
|
||||
* ```
|
||||
*
|
||||
* dialog\_t是[window\_base\_t](window_base_t.md)的子类控件,window\_base\_t的函数均适用于dialog\_t控件。
|
||||
*
|
||||
* 在xml中使用"dialog"标签创建对话框。如:
|
||||
*
|
||||
* ```xml
|
||||
* <dialog anim_hint="center_scale(duration=300)" x="c" y="m" w="80%" h="160" text="Dialog">
|
||||
* <dialog_title x="0" y="0" w="100%" h="30" text="Hello AWTK" />
|
||||
* <dialog_client x="0" y="bottom" w="100%" h="-30">
|
||||
* <label name="" x="center" y="middle:-20" w="200" h="30" text="Are you ready?"/>
|
||||
* <button name="quit" x="10" y="bottom:10" w="40%" h="30" text="确定"/>
|
||||
* <button name="quit" x="right:10" y="bottom:10" w="40%" h="30" text="取消"/>
|
||||
* </dialog_client>
|
||||
* </dialog>
|
||||
* ```
|
||||
*
|
||||
* 如果你不需要对话框的标题,可以这样写:
|
||||
*
|
||||
* ```xml
|
||||
* <dialog anim_hint="center_scale(duration=300)" x="c" y="m" w="80%" h="160" text="Dialog">
|
||||
* <label name="" x="center" y="middle:-20" w="200" h="30" text="Are you ready?"/>
|
||||
* <button name="quit" x="10" y="bottom:10" w="40%" h="30" text="确定"/>
|
||||
* <button name="quit" x="right:10" y="bottom:10" w="40%" h="30" text="取消"/>
|
||||
* </dialog>
|
||||
* ```
|
||||
*
|
||||
* 打开非模态对话框时,其用法与普通窗口一样。打开非模态对话框时,还需要调用dialog\_modal。
|
||||
*
|
||||
* ```c
|
||||
* widget_t* dlg = dialog_open(name);
|
||||
*
|
||||
* ret = dialog_modal(dlg);
|
||||
* ```
|
||||
*
|
||||
* 关闭模态对话框用dialog\_quit
|
||||
*
|
||||
* ```c
|
||||
* static ret_t on_dialog_btn_click(void* ctx, event_t* evt) {
|
||||
* widget_t* win = widget_get_window(WIDGET(evt->target));
|
||||
* int code = (char*)ctx - (char*)NULL;
|
||||
*
|
||||
* dialog_quit(win, code);
|
||||
*
|
||||
* return RET_OK;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* 关闭非模态对话框用window\_close。
|
||||
*
|
||||
* ```c
|
||||
* static ret_t on_dialog_btn_click(void* ctx, event_t* evt) {
|
||||
* widget_t* win = widget_get_window(WIDGET(evt->target));
|
||||
* int code = (char*)ctx - (char*)NULL;
|
||||
*
|
||||
* window_close(win);
|
||||
*
|
||||
* return RET_OK;
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* > 更多用法请参考:
|
||||
* [dialog.xml](https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/ui/)
|
||||
*
|
||||
* > 完整C代码示例请参考:
|
||||
*
|
||||
* * [非模态对话框](https://github.com/zlgopen/awtk-c-demos/blob/master/demos/dialog.c)
|
||||
*
|
||||
* * [模态对话框](https://github.com/zlgopen/awtk-c-demos/blob/master/demos/dialog_modal.c)
|
||||
*
|
||||
*可用通过style来设置控件的显示风格,如字体的大小和颜色等等。如:
|
||||
*
|
||||
* ```xml
|
||||
* <style name="default">
|
||||
* <normal border_color="#606060" />
|
||||
* </style>
|
||||
* ```
|
||||
*
|
||||
* > 更多用法请参考:
|
||||
* [theme default]
|
||||
* (https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/styles/default.xml#L324)
|
||||
*
|
||||
*/
|
||||
typedef struct _dialog_t {
|
||||
window_base_t window;
|
||||
|
||||
/**
|
||||
* @property {const char*} highlight
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* 对话框高亮策略。
|
||||
*/
|
||||
char* highlight;
|
||||
|
||||
/*private*/
|
||||
widget_t* title;
|
||||
widget_t* client;
|
||||
uint32_t quit_code;
|
||||
bool_t quited;
|
||||
bool_t is_model;
|
||||
} dialog_t;
|
||||
|
||||
/**
|
||||
* @method dialog_create
|
||||
* 创建dialog对象。
|
||||
* @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*} dialog对象。
|
||||
*/
|
||||
widget_t* dialog_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
/**
|
||||
* @method dialog_create_simple
|
||||
* 创建dialog对象,同时创建title/client。
|
||||
* @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*} dialog对象。
|
||||
*/
|
||||
widget_t* dialog_create_simple(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
/**
|
||||
* @method dialog_cast
|
||||
* 转换dialog对象(供脚本语言使用)。
|
||||
* @annotation ["cast", "scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {widget_t*} dialog对象。
|
||||
*/
|
||||
widget_t* dialog_cast(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_get_title
|
||||
* 获取title控件。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {widget_t*} title对象。
|
||||
*/
|
||||
widget_t* dialog_get_title(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_get_client
|
||||
* 获取client控件。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {widget_t*} client对象。
|
||||
*/
|
||||
widget_t* dialog_get_client(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_open
|
||||
* @annotation ["constructor", "scriptable"]
|
||||
* 从资源文件中加载并创建Dialog对象。
|
||||
*
|
||||
* 本函数在ui\_loader/ui\_builder_default里实现。
|
||||
* @param {const char*} name dialog的名称。
|
||||
*
|
||||
* @return {widget_t*} 对象。
|
||||
*/
|
||||
widget_t* dialog_open(const char* name);
|
||||
|
||||
/**
|
||||
* @method dialog_set_title
|
||||
* 设置对话框的标题文本。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
* @param {char*} title 标题。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_set_title(widget_t* widget, const char* title);
|
||||
|
||||
/**
|
||||
* @method dialog_modal
|
||||
* 模态显示对话框。
|
||||
* dialog_modal返回后,dialog对象将在下一个idle函数中回收。
|
||||
* 也就是在dialog_modal调用完成后仍然可以访问dialog中控件,直到本次事件结束。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
uint32_t dialog_modal(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_quit
|
||||
* 退出模态显示,关闭对话框。
|
||||
*
|
||||
*> 比如,在对话框中关闭按钮的事件处理函数中,调用本函数关闭对话框。
|
||||
*
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
* @param {uint32_t} code 退出码,作为dialog_modal的返回值。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_quit(widget_t* widget, uint32_t code);
|
||||
|
||||
/**
|
||||
* @method dialog_is_quited
|
||||
* 检查对话框是否已经退出模态。
|
||||
*
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {bool_t} 返回TRUE表示已经退出,否则表示没有。
|
||||
*/
|
||||
bool_t dialog_is_quited(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_is_modal
|
||||
* 检查对话框是否为模态对话框。
|
||||
*
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget dialog对象。
|
||||
*
|
||||
* @return {bool_t} 返回TRUE表示是模态对话框,否则表示不是。
|
||||
*/
|
||||
bool_t dialog_is_modal(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method dialog_toast
|
||||
* 显示『短暂提示信息』对话框。
|
||||
*
|
||||
* 主题由dialog_toast.xml文件决定。
|
||||
*
|
||||
* @annotation ["static", "scriptable"]
|
||||
* @param {const char*} text 文本内容。
|
||||
* @param {uint32_t} duration 显示时间(单位为毫秒)。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_toast(const char* text, uint32_t duration);
|
||||
|
||||
/**
|
||||
* @method dialog_info
|
||||
* 显示『提示信息』对话框。
|
||||
*
|
||||
* 主题由dialog_info.xml文件决定。
|
||||
*
|
||||
* @annotation ["static", "scriptable"]
|
||||
* @param {const char*} title 标题。
|
||||
* @param {const char*} text 文本内容。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_info(const char* title, const char* text);
|
||||
|
||||
/**
|
||||
* @method dialog_warn
|
||||
* 显示『警告』对话框。
|
||||
*
|
||||
* 主题由dialog_warn.xml文件决定。
|
||||
*
|
||||
* @annotation ["static", "scriptable"]
|
||||
* @param {const char*} title 标题。
|
||||
* @param {const char*} text 文本内容。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t dialog_warn(const char* title, const char* text);
|
||||
|
||||
/**
|
||||
* @method dialog_confirm
|
||||
* 显示『确认』对话框。
|
||||
*
|
||||
* 主题由dialog_confirm.xml文件决定。
|
||||
*
|
||||
* @annotation ["static", "scriptable"]
|
||||
* @param {const char*} title 标题。
|
||||
* @param {const char*} text 文本内容。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示确认,否则表示取消。
|
||||
*/
|
||||
ret_t dialog_confirm(const char* title, const char* text);
|
||||
|
||||
#define DIALOG(widget) ((dialog_t*)(dialog_cast(WIDGET(widget))))
|
||||
|
||||
/*public for subclass and runtime type check*/
|
||||
TK_EXTERN_VTABLE(dialog);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_DIALOG_H*/
|
@ -23,46 +23,8 @@
|
||||
|
||||
#include "tkc/value.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "widgets/window.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/widget_factory.h"
|
||||
|
||||
#ifndef AWTK_NOGUI
|
||||
#include "widgets/image.h"
|
||||
#include "widgets/label.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/slider.h"
|
||||
#include "widgets/pages.h"
|
||||
#include "widgets/popup.h"
|
||||
#include "widgets/button_group.h"
|
||||
#include "widgets/group_box.h"
|
||||
#include "widgets/dialog_title.h"
|
||||
#include "widgets/dialog_client.h"
|
||||
#include "widgets/check_button.h"
|
||||
#include "widgets/progress_bar.h"
|
||||
#include "widgets/color_tile.h"
|
||||
|
||||
#ifndef AWTK_LITE
|
||||
#include "widgets/system_bar.h"
|
||||
#include "widgets/calibration_win.h"
|
||||
#include "widgets/dragger.h"
|
||||
#include "widgets/tab_button.h"
|
||||
#include "widgets/tab_control.h"
|
||||
#include "widgets/row.h"
|
||||
#include "widgets/grid.h"
|
||||
#include "widgets/view.h"
|
||||
#include "widgets/overlay.h"
|
||||
#include "widgets/edit.h"
|
||||
#include "widgets/column.h"
|
||||
#include "widgets/app_bar.h"
|
||||
#include "widgets/grid_item.h"
|
||||
#include "widgets/combo_box.h"
|
||||
#include "widgets/combo_box_item.h"
|
||||
#include "widgets/tab_button_group.h"
|
||||
#include "widgets/spin_box.h"
|
||||
#endif/*AWTK_LITE*/
|
||||
#endif /*AWTK_NOGUI*/
|
||||
|
||||
static widget_factory_t* widget_factory_init(widget_factory_t* factory);
|
||||
static ret_t widget_factory_deinit(widget_factory_t* factory);
|
||||
|
||||
@ -76,58 +38,6 @@ static int32_t creator_item_cmp(const creator_item_t* iter, const char* type) {
|
||||
return strcmp(iter->type, type);
|
||||
}
|
||||
|
||||
static const creator_item_t s_builtin_creators[] = {
|
||||
{WIDGET_TYPE_DIALOG, dialog_create},
|
||||
{WIDGET_TYPE_NORMAL_WINDOW, window_create},
|
||||
#ifndef AWTK_NOGUI
|
||||
{WIDGET_TYPE_DIALOG_TITLE, dialog_title_create},
|
||||
{WIDGET_TYPE_DIALOG_CLIENT, dialog_client_create},
|
||||
{WIDGET_TYPE_IMAGE, image_create},
|
||||
{WIDGET_TYPE_BUTTON, button_create},
|
||||
{WIDGET_TYPE_LABEL, label_create},
|
||||
{WIDGET_TYPE_PROGRESS_BAR, progress_bar_create},
|
||||
{WIDGET_TYPE_SLIDER, slider_create},
|
||||
{WIDGET_TYPE_CHECK_BUTTON, check_button_create},
|
||||
{WIDGET_TYPE_RADIO_BUTTON, check_button_create_radio},
|
||||
{WIDGET_TYPE_PAGES, pages_create},
|
||||
{WIDGET_TYPE_BUTTON_GROUP, button_group_create},
|
||||
{WIDGET_TYPE_POPUP, popup_create},
|
||||
{WIDGET_TYPE_COLOR_TILE, color_tile_create},
|
||||
{WIDGET_TYPE_GROUP_BOX, group_box_create},
|
||||
#ifndef AWTK_LITE
|
||||
{WIDGET_TYPE_SYSTEM_BAR, system_bar_create},
|
||||
{WIDGET_TYPE_CALIBRATION_WIN, calibration_win_create},
|
||||
{WIDGET_TYPE_VIEW, view_create},
|
||||
{WIDGET_TYPE_OVERLAY, overlay_create},
|
||||
{WIDGET_TYPE_EDIT, edit_create},
|
||||
{WIDGET_TYPE_TAB_CONTROL, tab_control_create},
|
||||
{WIDGET_TYPE_TAB_BUTTON, tab_button_create},
|
||||
{WIDGET_TYPE_TAB_BUTTON_GROUP, tab_button_group_create},
|
||||
{WIDGET_TYPE_SPIN_BOX, spin_box_create},
|
||||
{WIDGET_TYPE_DRAGGER, dragger_create},
|
||||
{WIDGET_TYPE_COMBO_BOX, combo_box_create},
|
||||
{WIDGET_TYPE_COMBO_BOX_ITEM, combo_box_item_create},
|
||||
{WIDGET_TYPE_GRID, grid_create},
|
||||
{WIDGET_TYPE_GRID_ITEM, grid_item_create},
|
||||
{WIDGET_TYPE_ROW, row_create},
|
||||
{WIDGET_TYPE_COLUMN, column_create},
|
||||
{WIDGET_TYPE_APP_BAR, app_bar_create},
|
||||
#endif/*AWTK_LITE*/
|
||||
#endif /**AWTK_NOGUI*/
|
||||
};
|
||||
|
||||
static const creator_item_t* widget_factory_find_builtin_creator(const char* type) {
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < ARRAY_SIZE(s_builtin_creators); i++) {
|
||||
const creator_item_t* iter = s_builtin_creators + i;
|
||||
if (tk_str_eq(iter->type, type)) {
|
||||
return iter;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
widget_factory_t* widget_factory(void) {
|
||||
return s_widget_factory;
|
||||
}
|
||||
@ -164,22 +74,21 @@ ret_t widget_factory_register(widget_factory_t* factory, const char* type, widge
|
||||
|
||||
widget_t* widget_factory_create_widget(widget_factory_t* factory, const char* type,
|
||||
widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
|
||||
widget_t* widget = NULL;
|
||||
const creator_item_t* iter = NULL;
|
||||
return_value_if_fail(factory != NULL && type != NULL, NULL);
|
||||
|
||||
iter = widget_factory_find_builtin_creator(type);
|
||||
if (iter != NULL) {
|
||||
widget_t* widget = iter->create(parent, x, y, w, h);
|
||||
event_t e = event_init(EVT_WIDGET_CREATED, widget);
|
||||
emitter_dispatch(EMITTER(factory), &e);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
iter = darray_find(&(factory->creators), (void*)type);
|
||||
return_value_if_fail(iter != NULL, NULL);
|
||||
|
||||
return iter->create(parent, x, y, w, h);
|
||||
widget = iter->create(parent, x, y, w, h);
|
||||
if(widget != NULL) {
|
||||
event_t e = event_init(EVT_WIDGET_CREATED, widget);
|
||||
emitter_dispatch(EMITTER(factory), &e);
|
||||
}
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
ret_t widget_factory_set(widget_factory_t* factory) {
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include "tkc/mem.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "base/enums.h"
|
||||
#include "base/window.h"
|
||||
#include "base/window_manager.h"
|
||||
#include "widgets/window.h"
|
||||
|
||||
static const char* s_window_properties[] = {WIDGET_PROP_ANIM_HINT,
|
||||
WIDGET_PROP_OPEN_ANIM_HINT,
|
@ -1,172 +1,172 @@
|
||||
/**
|
||||
* File: window.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: window
|
||||
*
|
||||
* Copyright (c) 2018 - 2019 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-01-13 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_WINDOW_H
|
||||
#define TK_WINDOW_H
|
||||
|
||||
#include "base/window_base.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class window_t
|
||||
* @parent widget_t
|
||||
* @annotation ["scriptable","design","widget","window"]
|
||||
* 窗口。
|
||||
*
|
||||
* 缺省的应用程序窗口,占用除system\_bar\_t之外的整个区域,请不要修改它的位置和大小(除非你清楚后果)。
|
||||
*
|
||||
* window\_t是[window\_base\_t](window_base_t.md)的子类控件,window\_base\_t的函数均适用于window\_t控件。
|
||||
*
|
||||
* 在xml中使用"window"标签创建窗口。无需指定坐标和大小,可以指定主题和动画名称。如:
|
||||
*
|
||||
* ```xml
|
||||
* <window theme="basic" anim_hint="htranslate">
|
||||
* ...
|
||||
* </window>
|
||||
* ```
|
||||
*
|
||||
* >
|
||||
* 更多用法请参考:[window.xml](https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/ui/)
|
||||
*
|
||||
* 在c代码中使用函数window\_create创建窗口。如:
|
||||
*
|
||||
* ```c
|
||||
* widget_t* window = window_create(NULL, 0, 0, 0, 0);
|
||||
* ```
|
||||
*
|
||||
* > 无需指定父控件、坐标和大小,使用0即可。
|
||||
*
|
||||
* > 完整示例请参考:[window
|
||||
* demo](https://github.com/zlgopen/awtk-c-demos/blob/master/demos/)
|
||||
*
|
||||
* 可用通过style来设置窗口的风格,如背景颜色或图片等。如:
|
||||
*
|
||||
* ```xml
|
||||
* <style name="bricks">
|
||||
* <normal bg_image="bricks" bg_image_draw_type="repeat"/>
|
||||
* </style>
|
||||
* ```
|
||||
*
|
||||
* > 更多用法请参考:[theme
|
||||
* default](https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/styles/default.xml#L0)
|
||||
*/
|
||||
typedef struct _window_t {
|
||||
window_base_t window;
|
||||
|
||||
/**
|
||||
* @property {bool_t} fullscreen
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* 是否全屏。
|
||||
*
|
||||
*>这里全屏是指与LCD相同大小,而非让SDL窗口全屏。
|
||||
*/
|
||||
bool_t fullscreen;
|
||||
} window_t;
|
||||
|
||||
/**
|
||||
* @method window_create
|
||||
* 创建window对象
|
||||
* @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* window_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
/**
|
||||
* @method window_set_fullscreen
|
||||
* 设置为全屏窗口。
|
||||
*
|
||||
*>这里全屏是指与LCD相同大小,而非让SDL窗口全屏。
|
||||
*
|
||||
* @annotation ["deconstructor", "scriptable"]
|
||||
* @param {widget_t*} widget window对象。
|
||||
* @param {bool_t} fullscreen 是否全屏。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t window_set_fullscreen(widget_t* widget, bool_t fullscreen);
|
||||
|
||||
/**
|
||||
* @method window_open
|
||||
* @annotation ["constructor", "scriptable"]
|
||||
* 从资源文件中加载并创建window_base对象。本函数在ui_loader/ui_builder_default里实现。
|
||||
*
|
||||
* @param {char*} name window的名称。
|
||||
*
|
||||
* @return {widget_t*} 对象。
|
||||
*/
|
||||
widget_t* window_open(const char* name);
|
||||
|
||||
/**
|
||||
* @method window_open_and_close
|
||||
* @annotation ["constructor", "scriptable"]
|
||||
* 从资源文件中加载并创建window对象。本函数在ui_loader/ui_builder_default里实现。
|
||||
* @param {char*} name window的名称。
|
||||
* @param {widget_t*} to_close 关闭该窗口。
|
||||
*
|
||||
* @return {widget_t*} 对象。
|
||||
*/
|
||||
widget_t* window_open_and_close(const char* name, widget_t* to_close);
|
||||
|
||||
/**
|
||||
* @method window_close
|
||||
* 关闭窗口。
|
||||
* @annotation ["deconstructor", "scriptable"]
|
||||
* @param {widget_t*} widget window对象。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t window_close(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method window_close_force
|
||||
* 立即无条件关闭窗口(无动画)。
|
||||
* @annotation ["deconstructor", "scriptable"]
|
||||
* @param {widget_t*} widget window对象。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t window_close_force(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method window_cast
|
||||
* 转换为window对象(供脚本语言使用)。
|
||||
* @annotation ["cast", "scriptable"]
|
||||
* @param {widget_t*} widget window对象。
|
||||
*
|
||||
* @return {widget_t*} window对象。
|
||||
*/
|
||||
widget_t* window_cast(widget_t* widget);
|
||||
|
||||
#define WINDOW(widget) ((window_t*)(window_cast(WIDGET(widget))))
|
||||
|
||||
/*public for subclass and runtime type check*/
|
||||
TK_EXTERN_VTABLE(window);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_WINDOW_H*/
|
||||
/**
|
||||
* File: window.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: window
|
||||
*
|
||||
* Copyright (c) 2018 - 2019 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-01-13 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_WINDOW_H
|
||||
#define TK_WINDOW_H
|
||||
|
||||
#include "base/window_base.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @class window_t
|
||||
* @parent widget_t
|
||||
* @annotation ["scriptable","design","widget","window"]
|
||||
* 窗口。
|
||||
*
|
||||
* 缺省的应用程序窗口,占用除system\_bar\_t之外的整个区域,请不要修改它的位置和大小(除非你清楚后果)。
|
||||
*
|
||||
* window\_t是[window\_base\_t](window_base_t.md)的子类控件,window\_base\_t的函数均适用于window\_t控件。
|
||||
*
|
||||
* 在xml中使用"window"标签创建窗口。无需指定坐标和大小,可以指定主题和动画名称。如:
|
||||
*
|
||||
* ```xml
|
||||
* <window theme="basic" anim_hint="htranslate">
|
||||
* ...
|
||||
* </window>
|
||||
* ```
|
||||
*
|
||||
* >
|
||||
* 更多用法请参考:[window.xml](https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/ui/)
|
||||
*
|
||||
* 在c代码中使用函数window\_create创建窗口。如:
|
||||
*
|
||||
* ```c
|
||||
* widget_t* window = window_create(NULL, 0, 0, 0, 0);
|
||||
* ```
|
||||
*
|
||||
* > 无需指定父控件、坐标和大小,使用0即可。
|
||||
*
|
||||
* > 完整示例请参考:[window
|
||||
* demo](https://github.com/zlgopen/awtk-c-demos/blob/master/demos/)
|
||||
*
|
||||
* 可用通过style来设置窗口的风格,如背景颜色或图片等。如:
|
||||
*
|
||||
* ```xml
|
||||
* <style name="bricks">
|
||||
* <normal bg_image="bricks" bg_image_draw_type="repeat"/>
|
||||
* </style>
|
||||
* ```
|
||||
*
|
||||
* > 更多用法请参考:[theme
|
||||
* default](https://github.com/zlgopen/awtk/blob/master/demos/assets/raw/styles/default.xml#L0)
|
||||
*/
|
||||
typedef struct _window_t {
|
||||
window_base_t window;
|
||||
|
||||
/**
|
||||
* @property {bool_t} fullscreen
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* 是否全屏。
|
||||
*
|
||||
*>这里全屏是指与LCD相同大小,而非让SDL窗口全屏。
|
||||
*/
|
||||
bool_t fullscreen;
|
||||
} window_t;
|
||||
|
||||
/**
|
||||
* @method window_create
|
||||
* 创建window对象
|
||||
* @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* window_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
/**
|
||||
* @method window_set_fullscreen
|
||||
* 设置为全屏窗口。
|
||||
*
|
||||
*>这里全屏是指与LCD相同大小,而非让SDL窗口全屏。
|
||||
*
|
||||
* @annotation ["deconstructor", "scriptable"]
|
||||
* @param {widget_t*} widget window对象。
|
||||
* @param {bool_t} fullscreen 是否全屏。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t window_set_fullscreen(widget_t* widget, bool_t fullscreen);
|
||||
|
||||
/**
|
||||
* @method window_open
|
||||
* @annotation ["constructor", "scriptable"]
|
||||
* 从资源文件中加载并创建window_base对象。本函数在ui_loader/ui_builder_default里实现。
|
||||
*
|
||||
* @param {char*} name window的名称。
|
||||
*
|
||||
* @return {widget_t*} 对象。
|
||||
*/
|
||||
widget_t* window_open(const char* name);
|
||||
|
||||
/**
|
||||
* @method window_open_and_close
|
||||
* @annotation ["constructor", "scriptable"]
|
||||
* 从资源文件中加载并创建window对象。本函数在ui_loader/ui_builder_default里实现。
|
||||
* @param {char*} name window的名称。
|
||||
* @param {widget_t*} to_close 关闭该窗口。
|
||||
*
|
||||
* @return {widget_t*} 对象。
|
||||
*/
|
||||
widget_t* window_open_and_close(const char* name, widget_t* to_close);
|
||||
|
||||
/**
|
||||
* @method window_close
|
||||
* 关闭窗口。
|
||||
* @annotation ["deconstructor", "scriptable"]
|
||||
* @param {widget_t*} widget window对象。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t window_close(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method window_close_force
|
||||
* 立即无条件关闭窗口(无动画)。
|
||||
* @annotation ["deconstructor", "scriptable"]
|
||||
* @param {widget_t*} widget window对象。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t window_close_force(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method window_cast
|
||||
* 转换为window对象(供脚本语言使用)。
|
||||
* @annotation ["cast", "scriptable"]
|
||||
* @param {widget_t*} widget window对象。
|
||||
*
|
||||
* @return {widget_t*} window对象。
|
||||
*/
|
||||
widget_t* window_cast(widget_t* widget);
|
||||
|
||||
#define WINDOW(widget) ((window_t*)(window_cast(WIDGET(widget))))
|
||||
|
||||
/*public for subclass and runtime type check*/
|
||||
TK_EXTERN_VTABLE(window);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_WINDOW_H*/
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "base/widget.h"
|
||||
#include "base/canvas.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "base/dialog_highlighter.h"
|
||||
#include "base/input_device_status.h"
|
||||
#include "base/window_manager.h"
|
||||
|
@ -63,41 +63,43 @@ static ret_t children_layouter_register_ext_builtins(void) {
|
||||
}
|
||||
|
||||
ret_t tk_ext_widgets_init() {
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_RICH_TEXT, rich_text_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_COLOR_PICKER, color_picker_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_COLOR_COMPONENT, color_component_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SCROLL_VIEW, scroll_view_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_LIST_VIEW, list_view_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_LIST_VIEW_H, list_view_h_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_LIST_ITEM, list_item_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SCROLL_BAR, scroll_bar_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SCROLL_BAR_DESKTOP,
|
||||
widget_factory_t* f = widget_factory();
|
||||
|
||||
widget_factory_register(f, WIDGET_TYPE_RICH_TEXT, rich_text_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_COLOR_PICKER, color_picker_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_COLOR_COMPONENT, color_component_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SCROLL_VIEW, scroll_view_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_LIST_VIEW, list_view_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_LIST_VIEW_H, list_view_h_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_LIST_ITEM, list_item_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SCROLL_BAR, scroll_bar_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SCROLL_BAR_DESKTOP,
|
||||
scroll_bar_create_desktop);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SCROLL_BAR_MOBILE,
|
||||
widget_factory_register(f, WIDGET_TYPE_SCROLL_BAR_MOBILE,
|
||||
scroll_bar_create_mobile);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SLIDE_VIEW, slide_view_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SLIDE_INDICATOR, slide_indicator_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SLIDE_INDICATOR_ARC,
|
||||
widget_factory_register(f, WIDGET_TYPE_SLIDE_VIEW, slide_view_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SLIDE_INDICATOR, slide_indicator_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SLIDE_INDICATOR_ARC,
|
||||
slide_indicator_create_arc);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_KEYBOARD, keyboard_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_CANDIDATES, candidates_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_TIME_CLOCK, time_clock_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_DIGIT_CLOCK, digit_clock_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_GUAGE, guage_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_GUAGE_POINTER, guage_pointer_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_TEXT_SELECTOR, text_selector_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SWITCH, switch_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_IMAGE_ANIMATION, image_animation_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_PROGRESS_CIRCLE, progress_circle_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SVG_IMAGE, svg_image_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_GIF_IMAGE, gif_image_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_CANVAS_WIDGET, canvas_widget_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_IMAGE_VALUE, image_value_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_SLIDE_MENU, slide_menu_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_MUTABLE_IMAGE, mutable_image_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_MLEDIT, mledit_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_LINE_NUMBER, line_number_create);
|
||||
widget_factory_register(widget_factory(), WIDGET_TYPE_HSCROLL_LABEL, hscroll_label_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_KEYBOARD, keyboard_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_CANDIDATES, candidates_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_TIME_CLOCK, time_clock_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_DIGIT_CLOCK, digit_clock_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_GUAGE, guage_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_GUAGE_POINTER, guage_pointer_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_TEXT_SELECTOR, text_selector_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SWITCH, switch_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_IMAGE_ANIMATION, image_animation_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_PROGRESS_CIRCLE, progress_circle_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SVG_IMAGE, svg_image_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_GIF_IMAGE, gif_image_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_CANVAS_WIDGET, canvas_widget_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_IMAGE_VALUE, image_value_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SLIDE_MENU, slide_menu_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_MUTABLE_IMAGE, mutable_image_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_MLEDIT, mledit_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_LINE_NUMBER, line_number_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_HSCROLL_LABEL, hscroll_label_create);
|
||||
|
||||
children_layouter_register_ext_builtins();
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "widgets/button.h"
|
||||
#include "base/layout.h"
|
||||
#include "widgets/popup.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "tkc/tokenizer.h"
|
||||
#include "text_selector/text_selector.h"
|
||||
#include "widget_animators/widget_animator_scroll.h"
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "tkc/mem.h"
|
||||
#include "base/idle.h"
|
||||
#include "base/enums.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "keyboard/keyboard.h"
|
||||
#include "suggest_words.inc"
|
||||
#include "base/input_method.h"
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "tkc/utf8.h"
|
||||
#include "base/enums.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "base/widget_factory.h"
|
||||
#include "ui_loader/ui_builder_default.h"
|
||||
#include "ui_loader/ui_loader_default.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "base/window_manager.h"
|
||||
#include "widgets/calibration_win.h"
|
||||
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "widgets/button.h"
|
||||
#include "base/layout.h"
|
||||
#include "base/window.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/popup.h"
|
||||
#include "widgets/window.h"
|
||||
#include "widgets/combo_box.h"
|
||||
#include "tkc/tokenizer.h"
|
||||
#include "widgets/combo_box_item.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
#include "tkc/utils.h"
|
||||
#include "widgets/label.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/dialog_title.h"
|
||||
#include "widgets/dialog_client.h"
|
||||
|
@ -21,12 +21,12 @@
|
||||
|
||||
#include "tkc/mem.h"
|
||||
#include "base/idle.h"
|
||||
#include "base/window.h"
|
||||
#include "widgets/label.h"
|
||||
#include "base/enums.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "base/layout.h"
|
||||
#include "widgets/popup.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/image_manager.h"
|
||||
#include "base/window_manager.h"
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "base/enums.h"
|
||||
#include "tkc/utils.h"
|
||||
#include "base/layout.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "widgets/system_bar.h"
|
||||
#include "base/window_manager.h"
|
||||
|
||||
|
101
src/widgets/widgets.c
Normal file
101
src/widgets/widgets.c
Normal file
@ -0,0 +1,101 @@
|
||||
/**
|
||||
* File: widgets.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: register widgets
|
||||
*
|
||||
* Copyright (c) 2018 - 2019 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
|
||||
*
|
||||
*/
|
||||
#include "base/widget_factory.h"
|
||||
|
||||
#include "base/window.h"
|
||||
#include "base/dialog.h"
|
||||
#ifndef AWTK_NOGUI
|
||||
#include "widgets/image.h"
|
||||
#include "widgets/label.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/slider.h"
|
||||
#include "widgets/pages.h"
|
||||
#include "widgets/popup.h"
|
||||
#include "widgets/button_group.h"
|
||||
#include "widgets/group_box.h"
|
||||
#include "widgets/dialog_title.h"
|
||||
#include "widgets/dialog_client.h"
|
||||
#include "widgets/check_button.h"
|
||||
#include "widgets/progress_bar.h"
|
||||
#include "widgets/color_tile.h"
|
||||
|
||||
#ifndef AWTK_LITE
|
||||
#include "widgets/system_bar.h"
|
||||
#include "widgets/calibration_win.h"
|
||||
#include "widgets/dragger.h"
|
||||
#include "widgets/tab_button.h"
|
||||
#include "widgets/tab_control.h"
|
||||
#include "widgets/row.h"
|
||||
#include "widgets/grid.h"
|
||||
#include "widgets/view.h"
|
||||
#include "widgets/overlay.h"
|
||||
#include "widgets/edit.h"
|
||||
#include "widgets/column.h"
|
||||
#include "widgets/app_bar.h"
|
||||
#include "widgets/grid_item.h"
|
||||
#include "widgets/combo_box.h"
|
||||
#include "widgets/combo_box_item.h"
|
||||
#include "widgets/tab_button_group.h"
|
||||
#include "widgets/spin_box.h"
|
||||
#endif/*AWTK_LITE*/
|
||||
#endif /*AWTK_NOGUI*/
|
||||
|
||||
ret_t tk_widgets_init(void) {
|
||||
widget_factory_t* f = widget_factory();
|
||||
widget_factory_register(f, WIDGET_TYPE_DIALOG, dialog_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_NORMAL_WINDOW, window_create);
|
||||
#ifndef AWTK_NOGUI
|
||||
widget_factory_register(f, WIDGET_TYPE_DIALOG_TITLE, dialog_title_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_DIALOG_CLIENT, dialog_client_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_IMAGE, image_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_BUTTON, button_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_LABEL, label_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_PROGRESS_BAR, progress_bar_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SLIDER, slider_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_CHECK_BUTTON, check_button_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_RADIO_BUTTON, check_button_create_radio);
|
||||
widget_factory_register(f, WIDGET_TYPE_PAGES, pages_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_BUTTON_GROUP, button_group_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_POPUP, popup_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_COLOR_TILE, color_tile_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_GROUP_BOX, group_box_create);
|
||||
#ifndef AWTK_LITE
|
||||
widget_factory_register(f, WIDGET_TYPE_SYSTEM_BAR, system_bar_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_CALIBRATION_WIN, calibration_win_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_VIEW, view_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_OVERLAY, overlay_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_EDIT, edit_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_TAB_CONTROL, tab_control_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_TAB_BUTTON, tab_button_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_TAB_BUTTON_GROUP, tab_button_group_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_SPIN_BOX, spin_box_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_DRAGGER, dragger_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_COMBO_BOX, combo_box_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_COMBO_BOX_ITEM, combo_box_item_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_GRID, grid_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_GRID_ITEM, grid_item_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_ROW, row_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_COLUMN, column_create);
|
||||
widget_factory_register(f, WIDGET_TYPE_APP_BAR, app_bar_create);
|
||||
#endif/*AWTK_LITE*/
|
||||
#endif /**AWTK_NOGUI*/
|
||||
return RET_OK;
|
||||
}
|
40
src/widgets/widgets.h
Normal file
40
src/widgets/widgets.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* File: widgets.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: ext widgets
|
||||
*
|
||||
* Copyright (c) 2018 - 2019 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-08-07 Li XianJing <xianjimli@hotmail.com> created
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TK_WIDGETS_H
|
||||
#define TK_WIDGETS_H
|
||||
|
||||
#include "tkc/types_def.h"
|
||||
|
||||
BEGIN_C_DECLS
|
||||
|
||||
/**
|
||||
* @method tk_widgets_init
|
||||
* 初始化AWTK控件。
|
||||
* @annotation ["global"]
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t tk_widgets_init(void);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_WIDGETS_H*/
|
@ -26,7 +26,7 @@
|
||||
#include "base/timer.h"
|
||||
#include "base/layout.h"
|
||||
#include "tkc/time_now.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "base/locale_info.h"
|
||||
#include "base/system_info.h"
|
||||
#include "base/image_manager.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "base/timer.h"
|
||||
#include "base/layout.h"
|
||||
#include "tkc/time_now.h"
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "base/locale_info.h"
|
||||
#include "base/system_info.h"
|
||||
#include "base/image_manager.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "font_dummy.h"
|
||||
#include "lcd_log.h"
|
||||
#include "widgets/view.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <string>
|
||||
#include "gtest/gtest.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "layouters/children_layouter_default.h"
|
||||
#include "base/children_layouter_factory.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <string>
|
||||
#include "gtest/gtest.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "layouters/children_layouter_default.h"
|
||||
#include "base/children_layouter_factory.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <string>
|
||||
#include "gtest/gtest.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "base/children_layouter_factory.h"
|
||||
#include "scroll_view/children_layouter_list_view.h"
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "base/canvas.h"
|
||||
#include "base/widget.h"
|
||||
#include "font_dummy.h"
|
||||
#include "lcd_log.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include <stdlib.h>
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
|
||||
TEST(Dialog, basic) {
|
||||
value_t v1;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include <stdlib.h>
|
||||
#include "widgets/edit.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "widgets/group_box.h"
|
||||
#include "common.h"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "gif_image/gif_image.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "guage/guage.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include <stdlib.h>
|
||||
#include "mledit/mledit.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "common.h"
|
||||
|
||||
TEST(MLEdit, int) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "tkc/mem.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "blend/image_g2d.h"
|
||||
#include "mutable_image/mutable_image.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "rich_text/rich_text.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <string>
|
||||
#include "gtest/gtest.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "layouters/self_layouter_default.h"
|
||||
#include "base/self_layouter_factory.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <string>
|
||||
#include "gtest/gtest.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "layouters/self_layouter_default.h"
|
||||
#include "base/self_layouter_factory.h"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "base/style_const.h"
|
||||
#include "widgets/combo_box_item.h"
|
||||
#include <string>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "base/style_mutable.h"
|
||||
|
||||
#include <string>
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "svg_image/svg_image.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "widgets/system_bar.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "ui_loader/ui_builder_default.h"
|
||||
#include "ui_loader/ui_binary_writer.h"
|
||||
#include "ui_loader/ui_loader_default.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "ui_loader/ui_builder_default.h"
|
||||
#include "ui_loader/ui_loader_xml.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/dialog.h"
|
||||
#include "base/dialog.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "ui_loader/ui_xml_writer.h"
|
||||
#include "ui_loader/ui_loader_default.h"
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "widgets/label.h"
|
||||
#include "widgets/group_box.h"
|
||||
#include "widgets/button_group.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "widgets/pages.h"
|
||||
#include "base/style_const.h"
|
||||
#include "font_dummy.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "base/window_base.h"
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
|
||||
widget_t* window_design_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "base/canvas.h"
|
||||
#include "base/widget.h"
|
||||
#include "font_dummy.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "widgets/window.h"
|
||||
#include "base/window.h"
|
||||
#include "base/canvas.h"
|
||||
#include "base/widget.h"
|
||||
#include "font_dummy.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user