提交 e97fa002 编写于 作者: qiuyiuestc's avatar qiuyiuestc

delete ftk_label demo

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1229 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 b050da1c
Import('env')
Import('projects')
Import('RTT_ROOT')
Import('rtconfig')
Import('TARGET')
RTMLINKER = RTT_ROOT + '/tools/rtmlinker.exe '
# group definitions
group = {}
group['CCFLAGS'] = ''
group['CPPPATH'] = [RTT_ROOT + '/include',
RTT_ROOT + '/examples/module',
RTT_ROOT + '/components/external/ftk/ftk/src']
group['CPPDEFINES'] = ''
target = 'label.so'
POST_ACTION = RTMLINKER + ' -l ' + TARGET + ' -o label.mo ' + '$TARGET'
# add group to project list
projects.append(group)
src_local = Split("""
demo_label.c
""")
env.Append(CCFLAGS = group['CCFLAGS'])
env.Append(CPPPATH = group['CPPPATH'])
env.Append(CPPDEFINES = group['CPPDEFINES'])
module_env = env.Clone(CCFLAGS = ' -mcpu=arm920t -O0 -fPIC')
module_env.Replace(LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e main -nostdlib -s')
module_env.Program(target, src_local)
module_env.AddPostAction(target, POST_ACTION)
#include "ftk.h"
typedef struct _TimerInfo
{
int times;
FtkWidget* label;
}TimerInfo;
static Ret timeout(void* ctx)
{
TimerInfo* info = ctx;
char buffer[32] = {0};
if(info->times > 0)
{
snprintf(buffer, sizeof(buffer), "Quit after %d seconds", info->times);
ftk_widget_set_text(info->label, buffer);
info->times--;
return RET_OK;
}
else
{
ftk_widget_unref(ftk_widget_toplevel(info->label));
ftk_logd("%s: timeout and quit.\n", __func__);
FTK_FREE(info);
FTK_QUIT();
return RET_REMOVE;
}
}
#ifdef FTK_AS_PLUGIN
#include "ftk_app_demo.h"
FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
FtkApp* ftk_app_demo_label_create()
{
return ftk_app_demo_create(_("label"), ftk_main);
}
#else
#define FTK_HIDE extern
#endif /*FTK_AS_PLUGIN*/
FTK_HIDE int FTK_MAIN(int argc, char* argv[])
{
int width = 0;
int height = 0;
FtkGc gc = {.mask = FTK_GC_BG};
TimerInfo* info = NULL;
FTK_INIT(argc, argv);
info = (TimerInfo*)FTK_ZALLOC(sizeof(TimerInfo));
info->times = 5;
FtkSource* timer = ftk_source_timer_create(1000, timeout, info);
FtkWidget* win = ftk_app_window_create();
width = ftk_widget_width(win);
height = ftk_widget_height(win);
FtkWidget* label = ftk_label_create(win, 10, 10, width - 20, 20);
ftk_widget_set_text(label, "中文文本");
label = ftk_label_create(win, 10, 40, width - 20, 20);
ftk_widget_set_text(label, "English Text(center)");
ftk_label_set_alignment(label, FTK_ALIGN_CENTER);
assert(strcmp(ftk_widget_get_text(label), "English Text(center)") == 0);
label = ftk_label_create(win, 10, 70, width - 20, 20);
ftk_widget_set_text(label, "English Text(right)");
ftk_label_set_alignment(label, FTK_ALIGN_RIGHT);
gc.bg.a = 0xff;
gc.bg.r = 0xF0;
gc.bg.g = 0xF0;
gc.bg.b = 0x80;
label = ftk_label_create(win, 10, height/2, width - 20, 120);
ftk_widget_set_gc(label, FTK_WIDGET_INSENSITIVE, &gc);
ftk_widget_unset_attr(label, FTK_ATTR_TRANSPARENT);
ftk_widget_set_text(label, "中英文混合多行文本显示:the linux mobile development.带有背景颜色。");
label = ftk_label_create(win, 50, height/2-30, width, 20);
info->label = label;
ftk_widget_set_text(win, "label demo");
ftk_widget_show_all(win, 1);
ftk_widget_set_attr(win, FTK_ATTR_IGNORE_CLOSE);
ftk_main_loop_add_source(ftk_default_main_loop(), timer);
FTK_RUN();
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册