【声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】
前面说到了脚本,那么就看看ftk中demo与script搭配的效果是什么样的?
上面的效果图就类似于一个通讯录的输入功能,大家可以和之前的脚本对照起来看,检查一下是不是这样的。如题所示,今天所示的是waitbox。它出现的场合,一般是交互时间比较长的情况。比如说信用卡付款,游戏登陆等等。闲话不多,直接上demo代码。
#include "ftk.h" static Ret button_quit_clicked(void* ctx, void* obj) { ftk_quit(); return RET_OK; } static Ret button_start_clicked(void* ctx, void* obj) { ftk_wait_box_start_waiting(ctx); return RET_OK; } static Ret button_stop_clicked(void* ctx, void* obj) { ftk_wait_box_stop_waiting(ctx); return RET_OK; } int main(int argc, char* argv[]) { int width = 0; int height = 0; FtkWidget* win = NULL; FtkWidget* button = NULL; FtkWidget* wait_box = NULL; ftk_init(argc, argv); win = ftk_app_window_create(); width = ftk_widget_width(win); height = ftk_widget_height(win); wait_box = ftk_wait_box_create(win, width/2 - 16, height/4); button = ftk_button_create(win, 0, height/2, width/3, 50); ftk_widget_set_text(button, "start"); ftk_button_set_clicked_listener(button, button_start_clicked, wait_box); button = ftk_button_create(win, 2*width/3, height/2, width/3, 50); ftk_widget_set_text(button, "stop"); ftk_button_set_clicked_listener(button, button_stop_clicked, wait_box); button = ftk_button_create(win, width/4, 3*height/4, width/2, 60); ftk_widget_set_text(button, "quit"); ftk_button_set_clicked_listener(button, button_quit_clicked, win); ftk_window_set_focus(win, button); ftk_widget_set_text(win, "wait_box demo"); ftk_widget_show_all(win, 1); ftk_widget_set_attr(win, FTK_ATTR_QUIT_WHEN_CLOSE); ftk_run(); return 0; }
想看效果,只能等下次见了。