mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
add window_base and refactoring
This commit is contained in:
parent
4bfd3f9b4f
commit
7096b265a8
@ -3,6 +3,7 @@
|
|||||||
* 2018/10/22
|
* 2018/10/22
|
||||||
* 完善控件动画和demo。
|
* 完善控件动画和demo。
|
||||||
* 支持鼠标指针。
|
* 支持鼠标指针。
|
||||||
|
* 引入window\_base,重构window相关的组件。
|
||||||
* 更新文档。
|
* 更新文档。
|
||||||
|
|
||||||
* 2018/10/21
|
* 2018/10/21
|
||||||
|
@ -32,60 +32,6 @@
|
|||||||
#include "base/image_manager.h"
|
#include "base/image_manager.h"
|
||||||
#include "base/window_manager.h"
|
#include "base/window_manager.h"
|
||||||
|
|
||||||
static ret_t dialog_on_paint_self(widget_t* widget, canvas_t* c) {
|
|
||||||
if (widget->style_data.data != NULL) {
|
|
||||||
return widget_paint_helper(widget, c, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t dialog_get_prop(widget_t* widget, const char* name, value_t* v) {
|
|
||||||
dialog_t* dialog = DIALOG(widget);
|
|
||||||
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
|
||||||
|
|
||||||
if (tk_str_eq(name, WIDGET_PROP_ANIM_HINT)) {
|
|
||||||
value_set_str(v, dialog->anim_hint.str);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
|
||||||
value_set_str(v, dialog->theme.str);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_SCRIPT)) {
|
|
||||||
value_set_str(v, dialog->script.str);
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RET_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t dialog_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
|
||||||
dialog_t* dialog = DIALOG(widget);
|
|
||||||
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
|
||||||
|
|
||||||
if (tk_str_eq(name, WIDGET_PROP_ANIM_HINT)) {
|
|
||||||
str_from_value(&(dialog->anim_hint), v);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
|
||||||
str_from_value(&(dialog->theme), v);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_SCRIPT)) {
|
|
||||||
str_from_value(&(dialog->script), v);
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RET_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t dialog_destroy(widget_t* widget) {
|
|
||||||
dialog_t* dialog = DIALOG(widget);
|
|
||||||
|
|
||||||
str_reset(&(dialog->theme));
|
|
||||||
str_reset(&(dialog->script));
|
|
||||||
str_reset(&(dialog->anim_hint));
|
|
||||||
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t dialog_on_add_child(widget_t* widget, widget_t* child) {
|
static ret_t dialog_on_add_child(widget_t* widget, widget_t* child) {
|
||||||
dialog_t* dialog = DIALOG(widget);
|
dialog_t* dialog = DIALOG(widget);
|
||||||
|
|
||||||
@ -98,38 +44,25 @@ static ret_t dialog_on_add_child(widget_t* widget, widget_t* child) {
|
|||||||
return RET_CONTINUE;
|
return RET_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* s_dialog_properties[] = {WIDGET_PROP_ANIM_HINT, WIDGET_PROP_THEME,
|
static const char* s_dialog_properties[] = {WIDGET_PROP_ANIM_HINT, WIDGET_PROP_OPEN_ANIM_HINT,
|
||||||
WIDGET_PROP_SCRIPT, NULL};
|
WIDGET_PROP_CLOSE_ANIM_HINT, WIDGET_PROP_THEME,
|
||||||
|
WIDGET_PROP_SCRIPT, NULL};
|
||||||
static const widget_vtable_t s_dialog_vtable = {.size = sizeof(dialog_t),
|
static const widget_vtable_t s_dialog_vtable = {.size = sizeof(dialog_t),
|
||||||
.type = WIDGET_TYPE_DIALOG,
|
.type = WIDGET_TYPE_DIALOG,
|
||||||
.clone_properties = s_dialog_properties,
|
.clone_properties = s_dialog_properties,
|
||||||
.persistent_properties = s_dialog_properties,
|
.persistent_properties = s_dialog_properties,
|
||||||
.create = dialog_create,
|
.create = dialog_create,
|
||||||
.get_prop = dialog_get_prop,
|
|
||||||
.set_prop = dialog_set_prop,
|
|
||||||
.on_add_child = dialog_on_add_child,
|
.on_add_child = dialog_on_add_child,
|
||||||
.destroy = dialog_destroy,
|
.on_paint_self = window_base_on_paint_self,
|
||||||
.on_paint_self = dialog_on_paint_self};
|
.set_prop = window_base_set_prop,
|
||||||
|
.get_prop = window_base_get_prop,
|
||||||
|
.destroy = window_base_destroy};
|
||||||
|
|
||||||
widget_t* dialog_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
widget_t* dialog_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||||
dialog_t* dialog = TKMEM_ZALLOC(dialog_t);
|
dialog_t* dialog = TKMEM_ZALLOC(dialog_t);
|
||||||
widget_t* widget = WIDGET(dialog);
|
widget_t* widget = WIDGET(dialog);
|
||||||
return_value_if_fail(dialog != NULL, NULL);
|
|
||||||
|
|
||||||
widget_init(widget, NULL, &s_dialog_vtable, x, y, w, h);
|
return window_base_init(widget, parent, &s_dialog_vtable, x, y, w, h);
|
||||||
|
|
||||||
if (parent == NULL) {
|
|
||||||
parent = window_manager();
|
|
||||||
}
|
|
||||||
|
|
||||||
return_value_if_fail(window_manager_open_window(parent, widget) == RET_OK, NULL);
|
|
||||||
|
|
||||||
widget_update_style(widget);
|
|
||||||
str_init(&(dialog->anim_hint), 0);
|
|
||||||
str_init(&(dialog->theme), 0);
|
|
||||||
str_init(&(dialog->script), 0);
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
widget_t* dialog_create_simple(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
widget_t* dialog_create_simple(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||||
|
@ -22,9 +22,7 @@
|
|||||||
#ifndef TK_DIALOG_H
|
#ifndef TK_DIALOG_H
|
||||||
#define TK_DIALOG_H
|
#define TK_DIALOG_H
|
||||||
|
|
||||||
#include "base/wstr.h"
|
#include "base/window_base.h"
|
||||||
#include "base/widget.h"
|
|
||||||
#include "base/window_animator.h"
|
|
||||||
|
|
||||||
BEGIN_C_DECLS
|
BEGIN_C_DECLS
|
||||||
|
|
||||||
@ -35,13 +33,13 @@ BEGIN_C_DECLS
|
|||||||
* 对话框控件。
|
* 对话框控件。
|
||||||
*/
|
*/
|
||||||
typedef struct _dialog_t {
|
typedef struct _dialog_t {
|
||||||
widget_t widget;
|
window_base_t window;
|
||||||
|
|
||||||
|
/*private*/
|
||||||
widget_t* title;
|
widget_t* title;
|
||||||
widget_t* client;
|
widget_t* client;
|
||||||
uint32_t quit_code;
|
uint32_t quit_code;
|
||||||
str_t anim_hint;
|
|
||||||
str_t theme;
|
|
||||||
str_t script;
|
|
||||||
} dialog_t;
|
} dialog_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,21 +30,11 @@
|
|||||||
#include "base/image_manager.h"
|
#include "base/image_manager.h"
|
||||||
#include "base/window_manager.h"
|
#include "base/window_manager.h"
|
||||||
|
|
||||||
static ret_t popup_on_paint_self(widget_t* widget, canvas_t* c) {
|
|
||||||
return widget_paint_helper(widget, c, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t popup_get_prop(widget_t* widget, const char* name, value_t* v) {
|
static ret_t popup_get_prop(widget_t* widget, const char* name, value_t* v) {
|
||||||
popup_t* popup = POPUP(widget);
|
popup_t* popup = POPUP(widget);
|
||||||
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
||||||
|
|
||||||
if (tk_str_eq(name, WIDGET_PROP_ANIM_HINT)) {
|
if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK)) {
|
||||||
value_set_str(v, popup->anim_hint);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
|
||||||
value_set_str(v, popup->theme);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK)) {
|
|
||||||
value_set_bool(v, popup->close_when_click);
|
value_set_bool(v, popup->close_when_click);
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK_OUTSIDE)) {
|
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK_OUTSIDE)) {
|
||||||
@ -52,22 +42,14 @@ static ret_t popup_get_prop(widget_t* widget, const char* name, value_t* v) {
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RET_NOT_FOUND;
|
return window_base_get_prop(widget, name, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t popup_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
static ret_t popup_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
||||||
popup_t* popup = POPUP(widget);
|
popup_t* popup = POPUP(widget);
|
||||||
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
||||||
|
|
||||||
if (tk_str_eq(name, WIDGET_PROP_ANIM_HINT)) {
|
if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK)) {
|
||||||
TKMEM_FREE(popup->anim_hint);
|
|
||||||
popup->anim_hint = tk_strdup(value_str(v));
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
|
||||||
TKMEM_FREE(popup->theme);
|
|
||||||
popup->theme = tk_strdup(value_str(v));
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK)) {
|
|
||||||
popup->close_when_click = value_bool(v);
|
popup->close_when_click = value_bool(v);
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK_OUTSIDE)) {
|
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_WHEN_CLICK_OUTSIDE)) {
|
||||||
@ -75,16 +57,7 @@ static ret_t popup_set_prop(widget_t* widget, const char* name, const value_t* v
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RET_NOT_FOUND;
|
return window_base_set_prop(widget, name, v);
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t popup_destroy(widget_t* widget) {
|
|
||||||
popup_t* popup = POPUP(widget);
|
|
||||||
|
|
||||||
TKMEM_FREE(popup->theme);
|
|
||||||
TKMEM_FREE(popup->anim_hint);
|
|
||||||
|
|
||||||
return RET_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ret_t popup_on_event(widget_t* widget, event_t* e) {
|
static ret_t popup_on_event(widget_t* widget, event_t* e) {
|
||||||
@ -126,36 +99,28 @@ static ret_t popup_on_event(widget_t* widget, event_t* e) {
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* s_popup_clone_properties[] = {WIDGET_PROP_ANIM_HINT,
|
static const char* s_popup_properties[] = {
|
||||||
WIDGET_PROP_THEME,
|
WIDGET_PROP_ANIM_HINT, WIDGET_PROP_OPEN_ANIM_HINT,
|
||||||
WIDGET_PROP_SCRIPT,
|
WIDGET_PROP_CLOSE_ANIM_HINT, WIDGET_PROP_THEME,
|
||||||
WIDGET_PROP_CLOSE_WHEN_CLICK,
|
WIDGET_PROP_CLOSE_WHEN_CLICK, WIDGET_PROP_CLOSE_WHEN_CLICK_OUTSIDE,
|
||||||
WIDGET_PROP_CLOSE_WHEN_CLICK_OUTSIDE,
|
WIDGET_PROP_SCRIPT, NULL};
|
||||||
NULL};
|
|
||||||
static const widget_vtable_t s_popup_vtable = {.size = sizeof(popup_t),
|
static const widget_vtable_t s_popup_vtable = {.size = sizeof(popup_t),
|
||||||
.type = WIDGET_TYPE_POPUP,
|
.type = WIDGET_TYPE_POPUP,
|
||||||
.clone_properties = s_popup_clone_properties,
|
.clone_properties = s_popup_properties,
|
||||||
|
.persistent_properties = s_popup_properties,
|
||||||
.create = popup_create,
|
.create = popup_create,
|
||||||
.get_prop = popup_get_prop,
|
.get_prop = popup_get_prop,
|
||||||
.set_prop = popup_set_prop,
|
.set_prop = popup_set_prop,
|
||||||
.on_event = popup_on_event,
|
.on_event = popup_on_event,
|
||||||
.destroy = popup_destroy,
|
.on_paint_self = window_base_on_paint_self,
|
||||||
.on_paint_self = popup_on_paint_self};
|
.destroy = window_base_destroy};
|
||||||
|
|
||||||
widget_t* popup_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
widget_t* popup_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||||
popup_t* popup = TKMEM_ZALLOC(popup_t);
|
popup_t* popup = TKMEM_ZALLOC(popup_t);
|
||||||
widget_t* widget = WIDGET(popup);
|
widget_t* widget = WIDGET(popup);
|
||||||
return_value_if_fail(popup != NULL, NULL);
|
|
||||||
|
|
||||||
widget_init(widget, NULL, &s_popup_vtable, x, y, w, h);
|
return window_base_init(widget, parent, &s_popup_vtable, x, y, w, h);
|
||||||
if (parent == NULL) {
|
|
||||||
parent = window_manager();
|
|
||||||
}
|
|
||||||
|
|
||||||
return_value_if_fail(window_manager_open_window(parent, widget) == RET_OK, NULL);
|
|
||||||
widget_update_style(widget);
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
widget_t* popup_cast(widget_t* widget) {
|
widget_t* popup_cast(widget_t* widget) {
|
||||||
|
@ -22,9 +22,7 @@
|
|||||||
#ifndef TK_POPUP_H
|
#ifndef TK_POPUP_H
|
||||||
#define TK_POPUP_H
|
#define TK_POPUP_H
|
||||||
|
|
||||||
#include "base/wstr.h"
|
#include "base/window_base.h"
|
||||||
#include "base/widget.h"
|
|
||||||
#include "base/window_animator.h"
|
|
||||||
|
|
||||||
BEGIN_C_DECLS
|
BEGIN_C_DECLS
|
||||||
|
|
||||||
@ -35,26 +33,15 @@ BEGIN_C_DECLS
|
|||||||
* popup窗口。
|
* popup窗口。
|
||||||
*/
|
*/
|
||||||
typedef struct _popup_t {
|
typedef struct _popup_t {
|
||||||
widget_t widget;
|
window_base_t window;
|
||||||
|
|
||||||
/**
|
|
||||||
* @property {char*} theme
|
|
||||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
|
||||||
* 主题资源的名称。
|
|
||||||
*/
|
|
||||||
char* theme;
|
|
||||||
/**
|
|
||||||
* @property {char*} anim_hint
|
|
||||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
|
||||||
* 窗口动画名称。
|
|
||||||
*/
|
|
||||||
char* anim_hint;
|
|
||||||
/**
|
/**
|
||||||
* @property {bool_t} close_when_click
|
* @property {bool_t} close_when_click
|
||||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||||
* 点击时是否关闭窗口。
|
* 点击时是否关闭窗口。
|
||||||
*/
|
*/
|
||||||
bool_t close_when_click;
|
bool_t close_when_click;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {bool_t} close_when_click_outside
|
* @property {bool_t} close_when_click_outside
|
||||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||||
|
@ -23,83 +23,24 @@
|
|||||||
#include "base/utils.h"
|
#include "base/utils.h"
|
||||||
#include "base/enums.h"
|
#include "base/enums.h"
|
||||||
#include "base/window.h"
|
#include "base/window.h"
|
||||||
#include "base/window_manager.h"
|
|
||||||
|
|
||||||
static ret_t window_on_paint_self(widget_t* widget, canvas_t* c) {
|
static const char* s_window_properties[] = {WIDGET_PROP_ANIM_HINT, WIDGET_PROP_OPEN_ANIM_HINT,
|
||||||
return widget_paint_helper(widget, c, NULL, NULL);
|
WIDGET_PROP_CLOSE_ANIM_HINT, WIDGET_PROP_THEME,
|
||||||
}
|
WIDGET_PROP_SCRIPT, NULL};
|
||||||
|
|
||||||
static ret_t window_get_prop(widget_t* widget, const char* name, value_t* v) {
|
|
||||||
window_t* window = WINDOW(widget);
|
|
||||||
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
|
||||||
|
|
||||||
if (tk_str_eq(name, WIDGET_PROP_ANIM_HINT)) {
|
|
||||||
value_set_str(v, window->anim_hint);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
|
||||||
value_set_str(v, window->theme);
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RET_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t window_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
|
||||||
window_t* window = WINDOW(widget);
|
|
||||||
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
|
||||||
|
|
||||||
if (tk_str_eq(name, WIDGET_PROP_ANIM_HINT)) {
|
|
||||||
TKMEM_FREE(window->anim_hint);
|
|
||||||
window->anim_hint = tk_strdup(value_str(v));
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
|
||||||
TKMEM_FREE(window->theme);
|
|
||||||
window->theme = tk_strdup(value_str(v));
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RET_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t window_destroy(widget_t* widget) {
|
|
||||||
window_t* window = WINDOW(widget);
|
|
||||||
|
|
||||||
TKMEM_FREE(window->theme);
|
|
||||||
TKMEM_FREE(window->anim_hint);
|
|
||||||
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const widget_vtable_t s_window_vtable = {.type = WIDGET_TYPE_NORMAL_WINDOW,
|
static const widget_vtable_t s_window_vtable = {.type = WIDGET_TYPE_NORMAL_WINDOW,
|
||||||
.on_paint_self = window_on_paint_self,
|
.clone_properties = s_window_properties,
|
||||||
.set_prop = window_set_prop,
|
.persistent_properties = s_window_properties,
|
||||||
.get_prop = window_get_prop,
|
.on_paint_self = window_base_on_paint_self,
|
||||||
.destroy = window_destroy};
|
.set_prop = window_base_set_prop,
|
||||||
|
.get_prop = window_base_get_prop,
|
||||||
|
.destroy = window_base_destroy};
|
||||||
|
|
||||||
widget_t* window_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
widget_t* window_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||||
window_t* win = TKMEM_ZALLOC(window_t);
|
window_t* win = TKMEM_ZALLOC(window_t);
|
||||||
widget_t* widget = WIDGET(win);
|
widget_t* widget = WIDGET(win);
|
||||||
return_value_if_fail(win != NULL, NULL);
|
|
||||||
|
|
||||||
widget_init(widget, NULL, &s_window_vtable, x, y, w, h);
|
return window_base_init(widget, parent, &s_window_vtable, x, y, w, h);
|
||||||
if (parent == NULL) {
|
|
||||||
parent = window_manager();
|
|
||||||
}
|
|
||||||
|
|
||||||
return_value_if_fail(window_manager_open_window(parent, widget) == RET_OK, NULL);
|
|
||||||
widget_update_style(widget);
|
|
||||||
|
|
||||||
#ifdef ENABLE_MEM_LEAK_CHECK
|
|
||||||
tk_mem_dump();
|
|
||||||
#endif /*ENABLE_MEM_LEAK_CHECK*/
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret_t window_close(widget_t* widget) {
|
|
||||||
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
|
|
||||||
|
|
||||||
return window_manager_close_window(widget->parent, widget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
widget_t* window_cast(widget_t* widget) {
|
widget_t* window_cast(widget_t* widget) {
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
#ifndef TK_WINDOW_H
|
#ifndef TK_WINDOW_H
|
||||||
#define TK_WINDOW_H
|
#define TK_WINDOW_H
|
||||||
|
|
||||||
#include "base/widget.h"
|
#include "base/window_base.h"
|
||||||
#include "base/window_animator.h"
|
|
||||||
|
|
||||||
BEGIN_C_DECLS
|
BEGIN_C_DECLS
|
||||||
|
|
||||||
@ -34,19 +33,8 @@ BEGIN_C_DECLS
|
|||||||
* 窗口。
|
* 窗口。
|
||||||
*/
|
*/
|
||||||
typedef struct _window_t {
|
typedef struct _window_t {
|
||||||
widget_t widget;
|
window_base_t window;
|
||||||
/**
|
|
||||||
* @property {char*} theme
|
|
||||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
|
||||||
* 主题资源的名称。
|
|
||||||
*/
|
|
||||||
char* theme;
|
|
||||||
/**
|
|
||||||
* @property {char*} anim_hint
|
|
||||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
|
||||||
* 动画的名称。
|
|
||||||
*/
|
|
||||||
char* anim_hint;
|
|
||||||
} window_t;
|
} window_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,37 +61,6 @@ widget_t* window_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
|||||||
*/
|
*/
|
||||||
widget_t* window_cast(widget_t* widget);
|
widget_t* window_cast(widget_t* widget);
|
||||||
|
|
||||||
/**
|
|
||||||
* @method window_open
|
|
||||||
* @annotation ["constructor", "scriptable"]
|
|
||||||
* 从资源文件中加载并创建window对象。本函数在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);
|
|
||||||
|
|
||||||
#define WINDOW(widget) ((window_t*)(widget))
|
#define WINDOW(widget) ((window_t*)(widget))
|
||||||
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
127
src/base/window_base.c
Normal file
127
src/base/window_base.c
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* File: window_base.h
|
||||||
|
* Author: AWTK Develop Team
|
||||||
|
* Brief: window_base
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 - 2018 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "base/mem.h"
|
||||||
|
#include "base/utils.h"
|
||||||
|
#include "base/enums.h"
|
||||||
|
#include "base/window_base.h"
|
||||||
|
#include "base/window_manager.h"
|
||||||
|
|
||||||
|
ret_t window_base_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||||
|
if (widget->style_data.data != NULL) {
|
||||||
|
return widget_paint_helper(widget, c, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_t window_base_get_prop(widget_t* widget, const char* name, value_t* v) {
|
||||||
|
window_base_t* window_base = WINDOW_BASE(widget);
|
||||||
|
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
||||||
|
|
||||||
|
if (tk_str_eq(name, WIDGET_PROP_ANIM_HINT)) {
|
||||||
|
value_set_str(v, window_base->open_anim_hint);
|
||||||
|
return RET_OK;
|
||||||
|
} else if (tk_str_eq(name, WIDGET_PROP_OPEN_ANIM_HINT)) {
|
||||||
|
value_set_str(v, window_base->open_anim_hint);
|
||||||
|
return RET_OK;
|
||||||
|
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_ANIM_HINT)) {
|
||||||
|
value_set_str(v, window_base->close_anim_hint);
|
||||||
|
return RET_OK;
|
||||||
|
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
||||||
|
value_set_str(v, window_base->theme);
|
||||||
|
return RET_OK;
|
||||||
|
} else if (tk_str_eq(name, WIDGET_PROP_SCRIPT)) {
|
||||||
|
value_set_str(v, window_base->script);
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_t window_base_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
||||||
|
window_base_t* window_base = WINDOW_BASE(widget);
|
||||||
|
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
||||||
|
|
||||||
|
if (tk_str_eq(name, WIDGET_PROP_ANIM_HINT)) {
|
||||||
|
TKMEM_FREE(window_base->open_anim_hint);
|
||||||
|
window_base->open_anim_hint = tk_strdup(value_str(v));
|
||||||
|
TKMEM_FREE(window_base->close_anim_hint);
|
||||||
|
window_base->close_anim_hint = tk_strdup(value_str(v));
|
||||||
|
return RET_OK;
|
||||||
|
} else if (tk_str_eq(name, WIDGET_PROP_OPEN_ANIM_HINT)) {
|
||||||
|
TKMEM_FREE(window_base->open_anim_hint);
|
||||||
|
window_base->open_anim_hint = tk_strdup(value_str(v));
|
||||||
|
return RET_OK;
|
||||||
|
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_ANIM_HINT)) {
|
||||||
|
TKMEM_FREE(window_base->close_anim_hint);
|
||||||
|
window_base->close_anim_hint = tk_strdup(value_str(v));
|
||||||
|
return RET_OK;
|
||||||
|
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
||||||
|
TKMEM_FREE(window_base->theme);
|
||||||
|
window_base->theme = tk_strdup(value_str(v));
|
||||||
|
return RET_OK;
|
||||||
|
} else if (tk_str_eq(name, WIDGET_PROP_SCRIPT)) {
|
||||||
|
TKMEM_FREE(window_base->script);
|
||||||
|
window_base->script = tk_strdup(value_str(v));
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_t window_base_destroy(widget_t* widget) {
|
||||||
|
window_base_t* window_base = WINDOW_BASE(widget);
|
||||||
|
|
||||||
|
TKMEM_FREE(window_base->script);
|
||||||
|
TKMEM_FREE(window_base->theme);
|
||||||
|
TKMEM_FREE(window_base->open_anim_hint);
|
||||||
|
TKMEM_FREE(window_base->close_anim_hint);
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
widget_t* window_base_init(widget_t* widget, widget_t* parent, const widget_vtable_t* vt, xy_t x,
|
||||||
|
xy_t y, wh_t w, wh_t h) {
|
||||||
|
window_base_t* win = WINDOW_BASE(widget);
|
||||||
|
|
||||||
|
return_value_if_fail(win != NULL, NULL);
|
||||||
|
|
||||||
|
widget_init(widget, NULL, vt, x, y, w, h);
|
||||||
|
if (parent == NULL) {
|
||||||
|
parent = window_manager();
|
||||||
|
}
|
||||||
|
|
||||||
|
return_value_if_fail(window_manager_open_window(parent, widget) == RET_OK, NULL);
|
||||||
|
widget_update_style(widget);
|
||||||
|
|
||||||
|
#ifdef ENABLE_MEM_LEAK_CHECK
|
||||||
|
tk_mem_dump();
|
||||||
|
#endif /*ENABLE_MEM_LEAK_CHECK*/
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret_t window_close(widget_t* widget) {
|
||||||
|
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
|
||||||
|
|
||||||
|
return window_manager_close_window(widget->parent, widget);
|
||||||
|
}
|
124
src/base/window_base.h
Normal file
124
src/base/window_base.h
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/**
|
||||||
|
* File: window_base.h
|
||||||
|
* Author: AWTK Develop Team
|
||||||
|
* Brief: window_base
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 - 2018 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_BASE_H
|
||||||
|
#define TK_WINDOW_BASE_H
|
||||||
|
|
||||||
|
#include "base/widget.h"
|
||||||
|
|
||||||
|
BEGIN_C_DECLS
|
||||||
|
|
||||||
|
typedef enum _window_stage_t {
|
||||||
|
WINDOW_STAGE_CREATED = 0,
|
||||||
|
WINDOW_STAGE_WILL_OPEN,
|
||||||
|
WINDOW_STAGE_OPEN,
|
||||||
|
WINDOW_STAGE_CLOSED
|
||||||
|
} window_stage_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class window_base_t
|
||||||
|
* @parent widget_t
|
||||||
|
* @annotation ["scriptable"]
|
||||||
|
* 窗口。
|
||||||
|
*/
|
||||||
|
typedef struct _window_base_t {
|
||||||
|
widget_t widget;
|
||||||
|
/**
|
||||||
|
* @property {char*} theme
|
||||||
|
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||||
|
* 主题资源的名称。
|
||||||
|
*/
|
||||||
|
char* theme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {char*} script
|
||||||
|
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
||||||
|
* 脚本文件名称(暂时没用)。
|
||||||
|
*/
|
||||||
|
char* script;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {char*} open_anim_hint
|
||||||
|
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
||||||
|
* 打开时的动画名称。
|
||||||
|
*/
|
||||||
|
char* open_anim_hint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {char*} close_anim_hint
|
||||||
|
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
||||||
|
* 关闭时的动画名称。
|
||||||
|
*/
|
||||||
|
char* close_anim_hint;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property {char*} stage
|
||||||
|
* @annotation ["readable"]
|
||||||
|
* 窗口当前处于的状态。
|
||||||
|
*/
|
||||||
|
window_stage_t stage;
|
||||||
|
|
||||||
|
} window_base_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method window_open
|
||||||
|
* @annotation ["constructor", "scriptable"]
|
||||||
|
* 从资源文件中加载并创建window_base对象。本函数在ui_loader/ui_builder_default里实现。
|
||||||
|
* @param {char*} name window_base的名称。
|
||||||
|
*
|
||||||
|
* @return {widget_t*} 对象。
|
||||||
|
*/
|
||||||
|
widget_t* window_open(const char* name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method window_base_open_and_close
|
||||||
|
* @annotation ["constructor", "scriptable"]
|
||||||
|
* 从资源文件中加载并创建window_base对象。本函数在ui_loader/ui_builder_default里实现。
|
||||||
|
* @param {char*} name window_base的名称。
|
||||||
|
* @param {widget_t*} to_close 关闭该窗口。
|
||||||
|
*
|
||||||
|
* @return {widget_t*} 对象。
|
||||||
|
*/
|
||||||
|
widget_t* window_base_open_and_close(const char* name, widget_t* to_close);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method window_close
|
||||||
|
* 关闭窗口。
|
||||||
|
* @annotation ["deconstructor", "scriptable"]
|
||||||
|
* @param {widget_t*} widget window_base对象。
|
||||||
|
*
|
||||||
|
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||||
|
*/
|
||||||
|
ret_t window_close(widget_t* widget);
|
||||||
|
|
||||||
|
/*for sub class*/
|
||||||
|
ret_t window_base_destroy(widget_t* widget);
|
||||||
|
ret_t window_base_on_paint_self(widget_t* widget, canvas_t* c);
|
||||||
|
ret_t window_base_get_prop(widget_t* widget, const char* name, value_t* v);
|
||||||
|
ret_t window_base_set_prop(widget_t* widget, const char* name, const value_t* v);
|
||||||
|
widget_t* window_base_init(widget_t* widget, widget_t* parent, const widget_vtable_t* vt, xy_t x,
|
||||||
|
xy_t y, wh_t w, wh_t h);
|
||||||
|
|
||||||
|
#define WINDOW_BASE(widget) ((window_base_t*)(widget))
|
||||||
|
|
||||||
|
END_C_DECLS
|
||||||
|
|
||||||
|
#endif /*TK_WINDOW_BASE_H*/
|
@ -32,97 +32,29 @@
|
|||||||
static ret_t keyboard_on_load(void* ctx, event_t* e);
|
static ret_t keyboard_on_load(void* ctx, event_t* e);
|
||||||
static ret_t keyboard_on_action_info(void* ctx, event_t* e);
|
static ret_t keyboard_on_action_info(void* ctx, event_t* e);
|
||||||
|
|
||||||
static ret_t keyboard_on_paint_self(widget_t* widget, canvas_t* c) {
|
static const char* s_keyboard_properties[] = {
|
||||||
return widget_paint_helper(widget, c, NULL, NULL);
|
WIDGET_PROP_ANIM_HINT, WIDGET_PROP_OPEN_ANIM_HINT, WIDGET_PROP_CLOSE_ANIM_HINT,
|
||||||
}
|
WIDGET_PROP_THEME, WIDGET_PROP_SCRIPT, NULL};
|
||||||
|
|
||||||
static ret_t keyboard_get_prop(widget_t* widget, const char* name, value_t* v) {
|
|
||||||
keyboard_t* keyboard = KEYBOARD(widget);
|
|
||||||
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
|
||||||
|
|
||||||
if (tk_str_eq(name, WIDGET_PROP_OPEN_ANIM_HINT)) {
|
|
||||||
value_set_str(v, keyboard->open_anim_hint);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_ANIM_HINT)) {
|
|
||||||
value_set_str(v, keyboard->close_anim_hint);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
|
||||||
value_set_str(v, keyboard->theme);
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RET_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t keyboard_set_prop(widget_t* widget, const char* name, const value_t* v) {
|
|
||||||
keyboard_t* keyboard = KEYBOARD(widget);
|
|
||||||
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
|
|
||||||
|
|
||||||
if (tk_str_eq(name, WIDGET_PROP_ANIM_HINT)) {
|
|
||||||
const char* str = value_str(v);
|
|
||||||
TKMEM_FREE(keyboard->open_anim_hint);
|
|
||||||
TKMEM_FREE(keyboard->close_anim_hint);
|
|
||||||
keyboard->open_anim_hint = tk_strdup(str);
|
|
||||||
keyboard->close_anim_hint = tk_strdup(str);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_OPEN_ANIM_HINT)) {
|
|
||||||
const char* str = value_str(v);
|
|
||||||
TKMEM_FREE(keyboard->open_anim_hint);
|
|
||||||
keyboard->open_anim_hint = tk_strdup(str);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_CLOSE_ANIM_HINT)) {
|
|
||||||
const char* str = value_str(v);
|
|
||||||
TKMEM_FREE(keyboard->close_anim_hint);
|
|
||||||
keyboard->close_anim_hint = tk_strdup(str);
|
|
||||||
return RET_OK;
|
|
||||||
} else if (tk_str_eq(name, WIDGET_PROP_THEME)) {
|
|
||||||
const char* str = value_str(v);
|
|
||||||
TKMEM_FREE(keyboard->theme);
|
|
||||||
keyboard->theme = tk_strdup(str);
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RET_NOT_FOUND;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ret_t keyboard_destroy_default(widget_t* widget) {
|
|
||||||
keyboard_t* keyboard = KEYBOARD(widget);
|
|
||||||
input_method_off(input_method(), keyboard->action_info_id);
|
|
||||||
|
|
||||||
TKMEM_FREE(keyboard->theme);
|
|
||||||
TKMEM_FREE(keyboard->open_anim_hint);
|
|
||||||
TKMEM_FREE(keyboard->close_anim_hint);
|
|
||||||
|
|
||||||
return RET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* s_keyboard_properties[] = {WIDGET_PROP_ANIM_HINT, WIDGET_PROP_OPEN_ANIM_HINT,
|
|
||||||
WIDGET_PROP_CLOSE_ANIM_HINT, WIDGET_PROP_THEME, NULL};
|
|
||||||
static const widget_vtable_t s_keyboard_vtable = {.size = sizeof(keyboard_t),
|
static const widget_vtable_t s_keyboard_vtable = {.size = sizeof(keyboard_t),
|
||||||
.type = WIDGET_TYPE_KEYBOARD,
|
.type = WIDGET_TYPE_KEYBOARD,
|
||||||
.clone_properties = s_keyboard_properties,
|
.clone_properties = s_keyboard_properties,
|
||||||
.persistent_properties = s_keyboard_properties,
|
.persistent_properties = s_keyboard_properties,
|
||||||
.create = keyboard_create,
|
.create = keyboard_create,
|
||||||
.on_paint_self = keyboard_on_paint_self,
|
.on_paint_self = window_base_on_paint_self,
|
||||||
.set_prop = keyboard_set_prop,
|
.set_prop = window_base_set_prop,
|
||||||
.get_prop = keyboard_get_prop,
|
.get_prop = window_base_get_prop,
|
||||||
.destroy = keyboard_destroy_default};
|
.destroy = window_base_destroy};
|
||||||
|
|
||||||
widget_t* keyboard_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
widget_t* keyboard_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||||
keyboard_t* keyboard = TKMEM_ZALLOC(keyboard_t);
|
keyboard_t* keyboard = TKMEM_ZALLOC(keyboard_t);
|
||||||
widget_t* widget = WIDGET(keyboard);
|
widget_t* widget = WIDGET(keyboard);
|
||||||
return_value_if_fail(keyboard != NULL, NULL);
|
return_value_if_fail(keyboard != NULL, NULL);
|
||||||
|
|
||||||
widget_init(widget, NULL, &s_keyboard_vtable, x, y, w, h);
|
window_base_init(widget, parent, &s_keyboard_vtable, x, y, w, h);
|
||||||
|
|
||||||
array_init(&(keyboard->action_buttons), 0);
|
array_init(&(keyboard->action_buttons), 0);
|
||||||
|
|
||||||
if (parent == NULL) {
|
|
||||||
parent = window_manager();
|
|
||||||
}
|
|
||||||
|
|
||||||
return_value_if_fail(window_manager_open_window(parent, widget) == RET_OK, NULL);
|
|
||||||
|
|
||||||
widget_update_style(widget);
|
|
||||||
widget_on(widget, EVT_WINDOW_LOAD, keyboard_on_load, widget);
|
widget_on(widget, EVT_WINDOW_LOAD, keyboard_on_load, widget);
|
||||||
keyboard->action_info_id =
|
keyboard->action_info_id =
|
||||||
input_method_on(input_method(), EVT_IM_ACTION_INFO, keyboard_on_action_info, widget);
|
input_method_on(input_method(), EVT_IM_ACTION_INFO, keyboard_on_action_info, widget);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef TK_KEYBOARD_H
|
#ifndef TK_KEYBOARD_H
|
||||||
#define TK_KEYBOARD_H
|
#define TK_KEYBOARD_H
|
||||||
|
|
||||||
#include "base/widget.h"
|
#include "base/window_base.h"
|
||||||
|
|
||||||
BEGIN_C_DECLS
|
BEGIN_C_DECLS
|
||||||
|
|
||||||
@ -32,27 +32,9 @@ BEGIN_C_DECLS
|
|||||||
* 键盘。
|
* 键盘。
|
||||||
*/
|
*/
|
||||||
typedef struct _keyboard_t {
|
typedef struct _keyboard_t {
|
||||||
widget_t widget;
|
window_base_t window;
|
||||||
|
|
||||||
/**
|
|
||||||
* @property {char*} theme
|
|
||||||
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
|
||||||
* 主题资源的名称。
|
|
||||||
*/
|
|
||||||
char* theme;
|
|
||||||
/**
|
|
||||||
* @property {char*} open_anim_hint
|
|
||||||
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
|
||||||
* 打开时的动画名称。
|
|
||||||
*/
|
|
||||||
char* open_anim_hint;
|
|
||||||
/**
|
|
||||||
* @property {char*} close_anim_hint
|
|
||||||
* @annotation ["set_prop","get_prop","readable","persitent","design"]
|
|
||||||
* 关闭时的动画名称。
|
|
||||||
*/
|
|
||||||
char* close_anim_hint;
|
|
||||||
|
|
||||||
|
/*private*/
|
||||||
array_t action_buttons;
|
array_t action_buttons;
|
||||||
uint32_t action_info_id;
|
uint32_t action_info_id;
|
||||||
} keyboard_t;
|
} keyboard_t;
|
||||||
|
@ -19,7 +19,28 @@ TEST(Window, basic) {
|
|||||||
value_set_str(&v1, "bottom_to_top");
|
value_set_str(&v1, "bottom_to_top");
|
||||||
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_ANIM_HINT, &v1), RET_OK);
|
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_ANIM_HINT, &v1), RET_OK);
|
||||||
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_ANIM_HINT, &v2), RET_OK);
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_ANIM_HINT, &v2), RET_OK);
|
||||||
ASSERT_EQ(strcmp(value_str(&v2), "bottom_to_top"), 0);
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
||||||
|
|
||||||
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_OPEN_ANIM_HINT, &v2), RET_OK);
|
||||||
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
||||||
|
|
||||||
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_CLOSE_ANIM_HINT, &v2), RET_OK);
|
||||||
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
||||||
|
|
||||||
|
value_set_str(&v1, "center_scale");
|
||||||
|
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_OPEN_ANIM_HINT, &v1), RET_OK);
|
||||||
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_OPEN_ANIM_HINT, &v2), RET_OK);
|
||||||
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
||||||
|
|
||||||
|
value_set_str(&v1, "center_scale");
|
||||||
|
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_CLOSE_ANIM_HINT, &v1), RET_OK);
|
||||||
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_CLOSE_ANIM_HINT, &v2), RET_OK);
|
||||||
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
||||||
|
|
||||||
|
value_set_str(&v1, "main");
|
||||||
|
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_THEME, &v1), RET_OK);
|
||||||
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_THEME, &v2), RET_OK);
|
||||||
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
||||||
|
|
||||||
widget_destroy(b);
|
widget_destroy(b);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user