diff --git a/examples/module/SConstruct b/examples/module/SConstruct deleted file mode 100644 index 2d1814c197..0000000000 --- a/examples/module/SConstruct +++ /dev/null @@ -1,38 +0,0 @@ -import os -import sys -import rtconfig - -RTT_ROOT = os.path.normpath(os.getcwd() + '/../..') -sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] -import building - -target = RTT_ROOT + '/bsp/mini2440/rtthread-mini2440' -projects = [] - -AddOption('--target', - dest='target', - type='string', - help='set target project: mdk') - -if GetOption('target'): - SetOption('no_exec', 1) - -TARGET = target + '.' + rtconfig.TARGET_EXT - -env = Environment(tools = ['mingw'], - AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, - CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS, - AR = rtconfig.AR, ARFLAGS = '-rc', - LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) -env.PrependENVPath('PATH', rtconfig.EXEC_PATH) - -Export('env') -Export('RTT_ROOT') -Export('rtconfig') -Export('projects') -Export('TARGET') - -SConscript(RTT_ROOT + '/examples/module/tetris/SConscript', duplicate=0) -SConscript(RTT_ROOT + '/examples/module/basicapp/SConscript', duplicate=0) -SConscript(RTT_ROOT + '/examples/module/extension/SConscript', duplicate=0) -SConscript(RTT_ROOT + '/examples/module/extapp/SConscript', duplicate=0) \ No newline at end of file diff --git a/examples/module/basicapp/SConscript b/examples/module/basicapp/SConscript deleted file mode 100644 index 4b739c079e..0000000000 --- a/examples/module/basicapp/SConscript +++ /dev/null @@ -1,32 +0,0 @@ -Import('env') -Import('projects') -Import('RTT_ROOT') -Import('rtconfig') -Import('TARGET') - -RTMLINKER = RTT_ROOT + '/tools/rtmlinker.exe ' - -# group definitions -group = {} -group['name'] = 'examples' -group['src'] = Glob('*.c') -group['CCFLAGS'] = '' -group['CPPPATH'] = [RTT_ROOT + '/include', RTT_ROOT + '/examples/module'] -group['CPPDEFINES'] = '' - -target = 'basicapp.so' -POST_ACTION = RTMLINKER + '-l ' + TARGET + ' -o basicapp.mo ' + '$TARGET' - -# add group to project list -projects.append(group) - -src_local = Glob('basicapp.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 rt_application_init -nostdlib -s') -module_env.Program(target, src_local) -module_env.AddPostAction(target, POST_ACTION) - diff --git a/examples/module/basicapp/SConstruct b/examples/module/basicapp/SConstruct new file mode 100644 index 0000000000..35df31d886 --- /dev/null +++ b/examples/module/basicapp/SConstruct @@ -0,0 +1,27 @@ +import os +import sys + +EXEC_PATH = '/home/shaolin/CodeSourcery/Sourcery_G++_Lite/bin' +RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..') +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +PREFIX = 'arm-none-eabi-' +env = Environment(tools = ['mingw'], + AS = PREFIX + 'gcc', + ASFLAGS = '', + CC = PREFIX + 'gcc', + CCFLAGS = '-mcpu=arm920t -O0 -fPIC' , + AR = PREFIX + 'ar', + ARFLAGS = '-rc', + LINK = PREFIX + 'ld', + LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e rt_application_init -nostdlib -s', + CPPPATH = [ + RTT_ROOT + '/include', + RTT_ROOT + '/bsp/mini2440' + ]) +env.PrependENVPath('PATH', EXEC_PATH) + +target = 'basicapp.so' +src = Glob('*.c') + +env.Program(target, src) + diff --git a/examples/module/extapp/SConscript b/examples/module/extapp/SConscript deleted file mode 100644 index 9209a640f2..0000000000 --- a/examples/module/extapp/SConscript +++ /dev/null @@ -1,33 +0,0 @@ -Import('env') -Import('projects') -Import('RTT_ROOT') -Import('rtconfig') -Import('TARGET') - -RTMLINKER = RTT_ROOT + '/tools/rtmlinker.exe ' - -# group definitions -group = {} -group['name'] = 'examples' -group['src'] = Glob('*.c') -group['CCFLAGS'] = '' -group['CPPPATH'] = [RTT_ROOT + '/include', RTT_ROOT + '/examples/module', RTT_ROOT + '/components/libdl'] -group['CPPDEFINES'] = '' - -target = 'extapp.so' -POST_ACTION = RTMLINKER + '-l ' + TARGET + ' -o extapp.mo ' + '$TARGET' - -# add group to project list -projects.append(group) - -src_local = Glob('extapp.c') - -env.Append(CCFLAGS = group['CCFLAGS']) -env.Append(CPPPATH = group['CPPPATH']) -env.Append(CPPDEFINES = group['CPPDEFINES']) -module_env = env.Clone(CPPDEFINE = 'RT_MODULE') -module_env = env.Clone(CCFLAGS = ' -mcpu=arm920t -O0 -fPIC') -module_env.Replace(LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e rt_application_init -nostdlib -s') -module_env.Program(target, src_local) -module_env.AddPostAction(target, POST_ACTION) - diff --git a/examples/module/extapp/SConstruct b/examples/module/extapp/SConstruct new file mode 100644 index 0000000000..d02d847ab8 --- /dev/null +++ b/examples/module/extapp/SConstruct @@ -0,0 +1,24 @@ +import os +import sys + +EXEC_PATH = '/home/shaolin/CodeSourcery/Sourcery_G++_Lite/bin' +RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..') +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +PREFIX = 'arm-none-eabi-' +env = Environment(tools = ['mingw'], + AS = PREFIX + 'gcc', + ASFLAGS = '', + CC = PREFIX + 'gcc', + CCFLAGS = '-mcpu=arm920t -O0 -fPIC' , + AR = PREFIX + 'ar', + ARFLAGS = '-rc', + LINK = PREFIX + 'ld', + LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e rt_application_init -nostdlib -s', + CPPPATH = [RTT_ROOT + '/include', RTT_ROOT + '/examples/module', RTT_ROOT + '/bsp/mini2440', RTT_ROOT + '/components/libdl']) +env.PrependENVPath('PATH', EXEC_PATH) + +target = 'extapp.so' +src = Glob('extapp.c') + +env.Program(target, src) + diff --git a/examples/module/extension/SConstruct b/examples/module/extension/SConstruct new file mode 100644 index 0000000000..2603e456d7 --- /dev/null +++ b/examples/module/extension/SConstruct @@ -0,0 +1,27 @@ +import os +import sys + +EXEC_PATH = '/home/shaolin/CodeSourcery/Sourcery_G++_Lite/bin' +RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..') +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +PREFIX = 'arm-none-eabi-' +env = Environment(tools = ['mingw'], + AS = PREFIX + 'gcc', + ASFLAGS = '', + CC = PREFIX + 'gcc', + CCFLAGS = '-mcpu=arm920t -O0 -fPIC' , + AR = PREFIX + 'ar', + ARFLAGS = '-rc', + LINK = PREFIX + 'ld', + LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e 0 -nostdlib -s', + CPPPATH = [ + RTT_ROOT + '/include', + RTT_ROOT + '/bsp/mini2440' + ]) +env.PrependENVPath('PATH', EXEC_PATH) + +target = 'extension.so' +src = Glob('*.c') + +env.Program(target, src) + diff --git a/examples/module/ftk_calculator/SConscript b/examples/module/ftk_calculator/SConscript deleted file mode 100644 index bbfd5ca8a9..0000000000 --- a/examples/module/ftk_calculator/SConscript +++ /dev/null @@ -1,39 +0,0 @@ -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/apps/common', - RTT_ROOT + '/components/external/ftk/ftk/src/os/rt-thread', - RTT_ROOT + '/components/external/ftk/ftk/src', - RTT_ROOT + '/components/dfs', - RTT_ROOT + '/components/dfs/include', - RTT_ROOT + '/components/libc/newlib'] -group['CPPDEFINES'] = '' - -target = 'calculator.so' -POST_ACTION = RTMLINKER + ' -l ' + TARGET + ' -o calculator.mo ' + '$TARGET' - -# add group to project list -projects.append(group) - -src_local = Split(""" -ftk_app_calc.c -""") - -env.Append(CCFLAGS = group['CCFLAGS']) -env.Append(CPPPATH = group['CPPPATH']) -env.Append(CPPDEFINES = group['CPPDEFINES']) -module_env = env.Clone(CCFLAGS = ' -DRT_THREAD -mcpu=arm920t -O0 -fPIC') -module_env.Replace(LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e 0 -nostdlib -s') -module_env.Program(target, src_local) -module_env.AddPostAction(target, POST_ACTION) - diff --git a/examples/module/ftk_calculator/SConstruct b/examples/module/ftk_calculator/SConstruct new file mode 100644 index 0000000000..e7177f5e39 --- /dev/null +++ b/examples/module/ftk_calculator/SConstruct @@ -0,0 +1,34 @@ +import os +import sys + +EXEC_PATH = '/home/shaolin/CodeSourcery/Sourcery_G++_Lite/bin' +RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..') +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +PREFIX = 'arm-none-eabi-' +env = Environment(tools = ['mingw'], + AS = PREFIX + 'gcc', + ASFLAGS = '', + CC = PREFIX + 'gcc', + CCFLAGS = '-DRT_THREAD -DFTK_AS_PLUGIN -mcpu=arm920t -O0 -fPIC' , + AR = PREFIX + 'ar', + ARFLAGS = '-rc', + LINK = PREFIX + 'ld', + LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e 0 -nostdlib -s', + CPPPATH = [ + RTT_ROOT + '/include', + RTT_ROOT + '/bsp/mini2440', + RTT_ROOT + '/components/external/ftk/ftk/src/os/rt-thread', + RTT_ROOT + '/components/external/ftk/ftk/src/demos', + RTT_ROOT + '/components/external/ftk/ftk/apps/common', + RTT_ROOT + '/components/external/ftk/ftk/src', + RTT_ROOT + '/components/dfs', + RTT_ROOT + '/components/dfs/include', + RTT_ROOT + '/components/libc/newlib' + ]) +env.PrependENVPath('PATH', EXEC_PATH) + +target = 'calculator.so' +src = Glob('*.c') + +env.Program(target, src) + diff --git a/examples/module/ftk_calculator/ftk_app_calc.c b/examples/module/ftk_calculator/ftk_app_calc.c index 118ce8dba7..e2952572bc 100644 --- a/examples/module/ftk_calculator/ftk_app_calc.c +++ b/examples/module/ftk_calculator/ftk_app_calc.c @@ -1,7 +1,6 @@ #include "ftk_xul.h" #include "ftk_expr.h" #include "ftk_app_calc.h" -#include "ftk_animator_expand.h" typedef struct _PrivInfo { @@ -73,6 +72,7 @@ static FtkWidget* ftk_calc_create_window(void) FtkBitmap* bitmap_focus = NULL; char path[FTK_MAX_PATH+1] = {0}; FtkWidget* win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); entry = ftk_entry_create(win, 0, 0, width, 30); diff --git a/examples/module/ftk_demo/SConscript b/examples/module/ftk_demo/SConscript deleted file mode 100644 index 820f180e40..0000000000 --- a/examples/module/ftk_demo/SConscript +++ /dev/null @@ -1,37 +0,0 @@ -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/os/rt-thread', - RTT_ROOT + '/components/external/ftk/ftk/src/demos', - RTT_ROOT + '/components/external/ftk/ftk/apps/common', - RTT_ROOT + '/components/external/ftk/ftk/src', - RTT_ROOT + '/components/dfs', - RTT_ROOT + '/components/dfs/include', - RTT_ROOT + '/components/libc/newlib'] -group['CPPDEFINES'] = '' - -target = 'libftk_demos.so' -POST_ACTION = RTMLINKER + ' -l ' + TARGET + ' -o libftk_demos.mo ' + '$TARGET' - -# add group to project list -projects.append(group) - -src_local = Glob('*.c') - -env.Append(CCFLAGS = group['CCFLAGS']) -env.Append(CPPPATH = group['CPPPATH']) -env.Append(CPPDEFINES = group['CPPDEFINES']) -module_env = env.Clone(CCFLAGS = ' -DRT_THREAD -DFTK_AS_PLUGIN -mcpu=arm920t -O0 -fPIC') -module_env.Replace(LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e 0 -nostdlib -s') -module_env.Program(target, src_local) -module_env.AddPostAction(target, POST_ACTION) diff --git a/examples/module/ftk_demo/SConstruct b/examples/module/ftk_demo/SConstruct new file mode 100644 index 0000000000..00caaf54ed --- /dev/null +++ b/examples/module/ftk_demo/SConstruct @@ -0,0 +1,34 @@ +import os +import sys + +EXEC_PATH = '/home/shaolin/CodeSourcery/Sourcery_G++_Lite/bin' +RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..') +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +PREFIX = 'arm-none-eabi-' +env = Environment(tools = ['mingw'], + AS = PREFIX + 'gcc', + ASFLAGS = '', + CC = PREFIX + 'gcc', + CCFLAGS = '-DRT_THREAD -DFTK_AS_PLUGIN -mcpu=arm920t -O0 -fPIC' , + AR = PREFIX + 'ar', + ARFLAGS = '-rc', + LINK = PREFIX + 'ld', + LINKFLAGS = '-z max-page-size=0x4 -shared -fPIC -e 0 -nostdlib -s', + CPPPATH = [ + RTT_ROOT + '/include', + RTT_ROOT + '/bsp/mini2440', + RTT_ROOT + '/components/external/ftk/ftk/src/os/rt-thread', + RTT_ROOT + '/components/external/ftk/ftk/src/demos', + RTT_ROOT + '/components/external/ftk/ftk/apps/common', + RTT_ROOT + '/components/external/ftk/ftk/src', + RTT_ROOT + '/components/dfs', + RTT_ROOT + '/components/dfs/include', + RTT_ROOT + '/components/libc/newlib' + ]) +env.PrependENVPath('PATH', EXEC_PATH) + +target = 'libftk_demos.so' +src = Glob('*.c') + +env.Program(target, src) + diff --git a/examples/module/ftk_demo/demo_alpha.c b/examples/module/ftk_demo/demo_alpha.c deleted file mode 100644 index c5e27241a9..0000000000 --- a/examples/module/ftk_demo/demo_alpha.c +++ /dev/null @@ -1,104 +0,0 @@ -#include "ftk.h" -#include "ftk_animator_alpha.h" - -static void create_ani_window(int type, int sync); - -static Ret button_fast_clicked(void* ctx, void* obj) -{ - create_ani_window(1, 0); - - return RET_OK; -} - -static Ret button_slow_clicked(void* ctx, void* obj) -{ - create_ani_window(0, 0); - - return RET_OK; -} - -static Ret button_quit_clicked(void* ctx, void* obj) -{ - FtkWidget* win = ctx; - ftk_widget_unref(win); - ftk_logd("%s: close window %s\n", __func__, ftk_widget_get_text(win)); - - return RET_OK; -} - -static void create_ani_window(int type, int sync) -{ - FtkGc gc = {0}; - char filename[FTK_MAX_PATH+1] = {0}; - FtkWidget* win = ftk_app_window_create(); - FtkAnimator* ani = ftk_animator_alpha_create(1); - - gc.mask = FTK_GC_BITMAP; - - ftk_snprintf(filename, FTK_MAX_PATH, "%s/jpeg1.jpg", - ftk_config_get_test_data_dir(ftk_default_config())); - gc.bitmap = ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename); - ftk_widget_set_gc(win, FTK_WIDGET_NORMAL, &gc); - ftk_gc_reset(&gc); - - ftk_animator_set_param(ani, 0, 0, 0xff, type ? 0x60 : 0x20, type ? 200 : 1000); - ftk_animator_start(ani, win, 0); - - return; -} - -static void create_app_window(void) -{ - char title[32] = {0}; - int width = 0; - int height = 0; - FtkWidget* win = ftk_app_window_create(); - FtkWidget* button = NULL; - - width = ftk_widget_width(win); - height = ftk_widget_height(win); - - button = ftk_button_create(win, 5, height/6, width/2-5, 50); - ftk_widget_set_text(button, "Fast"); - ftk_button_set_clicked_listener(button, button_fast_clicked, win); - - button = ftk_button_create(win, width/2, height/6, width/2-5, 50); - ftk_widget_set_text(button, "Slow"); - ftk_button_set_clicked_listener(button, button_slow_clicked, win); - - - button = ftk_button_create(win, width/4-2, height/6 + 180, width/2-5, 50); - ftk_widget_set_text(button, "Quit"); - ftk_button_set_clicked_listener(button, button_quit_clicked, win); - - ftk_snprintf(title, sizeof(title), "Alpha Demo"); - ftk_widget_set_text(win, title); - FTK_QUIT_WHEN_WIDGET_CLOSE(win); - - ftk_widget_show_all(win, 1); - - return; -} - -#ifdef FTK_AS_PLUGIN -#include "ftk_app_demo.h" -FTK_HIDE int FTK_MAIN(int argc, char* argv[]); -FtkApp* ftk_app_demo_alpha_create() -{ - return ftk_app_demo_create(_("alpha"), ftk_main); -} -#else -#define FTK_HIDE extern -#endif /*FTK_AS_PLUGIN*/ - -FTK_HIDE int FTK_MAIN(int argc, char* argv[]) -{ - FTK_INIT(argc, argv); - - create_app_window(); - - FTK_RUN(); - - return 0; -} - diff --git a/examples/module/ftk_demo/demo_button.c b/examples/module/ftk_demo/demo_button.c index 52b6407f53..c9eca6b3c4 100644 --- a/examples/module/ftk_demo/demo_button.c +++ b/examples/module/ftk_demo/demo_button.c @@ -50,6 +50,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); diff --git a/examples/module/ftk_demo/demo_check_button.c b/examples/module/ftk_demo/demo_check_button.c index aa60974981..b0b5803fda 100644 --- a/examples/module/ftk_demo/demo_check_button.c +++ b/examples/module/ftk_demo/demo_check_button.c @@ -33,6 +33,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); diff --git a/examples/module/ftk_demo/demo_combo_box.c b/examples/module/ftk_demo/demo_combo_box.c index 910fdda280..941e652a34 100644 --- a/examples/module/ftk_demo/demo_combo_box.c +++ b/examples/module/ftk_demo/demo_combo_box.c @@ -30,6 +30,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); diff --git a/examples/module/ftk_demo/demo_dialog.c b/examples/module/ftk_demo/demo_dialog.c index 8cbafbd8e8..a8ae518900 100644 --- a/examples/module/ftk_demo/demo_dialog.c +++ b/examples/module/ftk_demo/demo_dialog.c @@ -92,6 +92,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); diff --git a/examples/module/ftk_demo/demo_entry.c b/examples/module/ftk_demo/demo_entry.c index ac90b8aa86..e49f951047 100644 --- a/examples/module/ftk_demo/demo_entry.c +++ b/examples/module/ftk_demo/demo_entry.c @@ -62,6 +62,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); entry = ftk_entry_create(win, 10, 30, ftk_widget_width(win) - 20, 30); diff --git a/examples/module/ftk_demo/demo_expand.c b/examples/module/ftk_demo/demo_expand.c deleted file mode 100644 index bfb2e94ed2..0000000000 --- a/examples/module/ftk_demo/demo_expand.c +++ /dev/null @@ -1,189 +0,0 @@ -#include "ftk.h" -#include "ftk_animator_expand.h" - -static void create_ani_window(int type, int sync); - -static Ret button_to_east_south_clicked(void* ctx, void* obj) -{ - create_ani_window(FTK_ANI_TO_EAST_SOUTH, 1); - - return RET_OK; -} - -static Ret button_to_east_north_clicked(void* ctx, void* obj) -{ - create_ani_window(FTK_ANI_TO_EAST_NORTH, 1); - - return RET_OK; -} - -static Ret button_to_right_clicked(void* ctx, void* obj) -{ - create_ani_window(FTK_ANI_TO_RIGHT, 0); - - return RET_OK; -} - -static Ret button_to_down_clicked(void* ctx, void* obj) -{ - create_ani_window(FTK_ANI_TO_DOWN, 0); - - return RET_OK; -} - -static Ret button_to_up_clicked(void* ctx, void* obj) -{ - create_ani_window(FTK_ANI_TO_UP, 0); - - return RET_OK; -} - -static Ret button_to_brink_clicked(void* ctx, void* obj) -{ - create_ani_window(FTK_ANI_TO_BRINK, 0); - - return RET_OK; -} - -static Ret button_close_clicked(void* ctx, void* obj) -{ - FtkWidget* win = ctx; - ftk_logd("%s: close window %s\n", __func__, ftk_widget_get_text(win)); - ftk_widget_unref(win); - - return RET_OK; -} - -static Ret button_quit_clicked(void* ctx, void* obj) -{ - FtkWidget* win = ctx; - ftk_widget_unref(win); - ftk_logd("%s: close window %s\n", __func__, ftk_widget_get_text(win)); - - return RET_OK; -} - -static void create_ani_window(int type, int sync) -{ - int delta = 0; - int width = 0; - int height = 0; - FtkWidget* button = NULL; - FtkGc gc = {0}; - char filename[FTK_MAX_PATH+1] = {0}; - FtkWidget* win = ftk_app_window_create(); - FtkAnimator* ani = ftk_animator_expand_create(1); - - gc.mask = FTK_GC_BITMAP; - width = ftk_widget_width(win); - height = ftk_widget_height(win); - delta = height/6; - - button = ftk_button_create(win, width/3, height/3, width/3, 50); - ftk_widget_set_text(button, "关闭"); - ftk_widget_show(button, 1); - ftk_button_set_clicked_listener(button, button_close_clicked, win); - - ftk_snprintf(filename, FTK_MAX_PATH, "%s/jpeg1.jpg", - ftk_config_get_test_data_dir(ftk_default_config())); - gc.bitmap = ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename); - ftk_widget_set_gc(win, FTK_WIDGET_NORMAL, &gc); - ftk_gc_reset(&gc); - - switch(type) - { - case FTK_ANI_TO_RIGHT: - case FTK_ANI_TO_EAST_SOUTH: - case FTK_ANI_TO_EAST_NORTH: - { - ftk_animator_set_param(ani, type, 100, width, delta, 200); - break; - } - case FTK_ANI_TO_BRINK: - case FTK_ANI_TO_DOWN: - { - ftk_animator_set_param(ani, type, 100, height, delta, 200); - break; - } - case FTK_ANI_TO_UP: - { - ftk_animator_set_param(ani, type, height - 100, ftk_widget_top(win), delta, 200); - break; - } - default:break; - } - ftk_animator_start(ani, win, 0); - - return; -} - -static void create_app_window(void) -{ - char title[32] = {0}; - int width = 0; - int height = 0; - FtkWidget* win = ftk_app_window_create(); - FtkWidget* button = NULL; - - width = ftk_widget_width(win); - height = ftk_widget_height(win); - - button = ftk_button_create(win, 5, height/6, width/2-5, 50); - ftk_widget_set_text(button, "向右伸展"); - ftk_button_set_clicked_listener(button, button_to_right_clicked, win); - - button = ftk_button_create(win, width/2, height/6, width/2-5, 50); - ftk_widget_set_text(button, "Down"); - ftk_button_set_clicked_listener(button, button_to_down_clicked, win); - - button = ftk_button_create(win, 5, height/6 + 60, width/2-5, 50); - ftk_widget_set_text(button, "RightDown"); - ftk_button_set_clicked_listener(button, button_to_east_south_clicked, win); - - button = ftk_button_create(win, width/2, height/6 + 60, width/2-5, 50); - ftk_widget_set_text(button, "RightUp"); - ftk_button_set_clicked_listener(button, button_to_east_north_clicked, win); - - button = ftk_button_create(win, 5, height/6 + 120, width/2-5, 50); - ftk_widget_set_text(button, "Up"); - ftk_button_set_clicked_listener(button, button_to_up_clicked, win); - - button = ftk_button_create(win, width/2, height/6 + 120, width/2-5, 50); - ftk_widget_set_text(button, "Brink"); - ftk_button_set_clicked_listener(button, button_to_brink_clicked, win); - - button = ftk_button_create(win, width/4-2, height/6 + 180, width/2-5, 50); - ftk_widget_set_text(button, "Quit"); - ftk_button_set_clicked_listener(button, button_quit_clicked, win); - - ftk_snprintf(title, sizeof(title), "Expand Demo"); - ftk_widget_set_text(win, title); - FTK_QUIT_WHEN_WIDGET_CLOSE(win); - - ftk_widget_show_all(win, 1); - - return; -} - -#ifdef FTK_AS_PLUGIN -#include "ftk_app_demo.h" -FTK_HIDE int FTK_MAIN(int argc, char* argv[]); -FtkApp* ftk_app_demo_expand_create() -{ - return ftk_app_demo_create(_("expand"), ftk_main); -} -#else -#define FTK_HIDE extern -#endif /*FTK_AS_PLUGIN*/ - -FTK_HIDE int FTK_MAIN(int argc, char* argv[]) -{ - FTK_INIT(argc, argv); - - create_app_window(); - - FTK_RUN(); - - return 0; -} - diff --git a/examples/module/ftk_demo/demo_file_browser.c b/examples/module/ftk_demo/demo_file_browser.c index 451473f9d7..a7a9fc0752 100644 --- a/examples/module/ftk_demo/demo_file_browser.c +++ b/examples/module/ftk_demo/demo_file_browser.c @@ -67,6 +67,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); diff --git a/examples/module/ftk_demo/demo_fullscreen.c b/examples/module/ftk_demo/demo_fullscreen.c index c58bdbb22f..a2cf78d12e 100644 --- a/examples/module/ftk_demo/demo_fullscreen.c +++ b/examples/module/ftk_demo/demo_fullscreen.c @@ -1,5 +1,19 @@ #include "ftk.h" +static Ret on_prepare_options_menu(void* ctx, FtkWidget* menu_panel) +{ + int i = 0; + for(i = 0; i < 3; i++) + { + char text[32] = {0}; + FtkWidget* item = ftk_menu_item_create(menu_panel); + ftk_snprintf(text, sizeof(text), "Menu%02d", i); + ftk_widget_set_text(item, text); + ftk_widget_show(item, 1); + } + + return i > 0 ? RET_OK : RET_FAIL; +} #define IDC_TEST_BUTTON 1000 static Ret button_quit_clicked(void* ctx, void* obj) { @@ -8,16 +22,31 @@ static Ret button_quit_clicked(void* ctx, void* obj) return RET_OK; } +static const char* buttons[] = {"OK", NULL}; static Ret button_unfullscreen_clicked(void* ctx, void* obj) { - ftk_window_set_fullscreen(ctx, 0); + if(!ftk_window_is_fullscreen(ctx)) + { + ftk_infomation("Infomation", "Windows is not fullscreen.", buttons); + } + else + { + ftk_window_set_fullscreen(ctx, 0); + } return RET_OK; } static Ret button_fullscreen_clicked(void* ctx, void* obj) { - ftk_window_set_fullscreen(ctx, 1); + if(ftk_window_is_fullscreen(ctx)) + { + ftk_infomation("Infomation", "Windows is fullscreen.", buttons); + } + else + { + ftk_window_set_fullscreen(ctx, 1); + } return RET_OK; } @@ -42,6 +71,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); @@ -62,6 +92,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) ftk_widget_set_text(win, "fullscreen"); ftk_widget_show_all(win, 1); FTK_QUIT_WHEN_WIDGET_CLOSE(win); + ftk_app_window_set_on_prepare_options_menu(win, on_prepare_options_menu, win); FTK_RUN(); diff --git a/examples/module/ftk_demo/demo_hello.c b/examples/module/ftk_demo/demo_hello.c index 9e8b7ff2ac..af2dbeee09 100644 --- a/examples/module/ftk_demo/demo_hello.c +++ b/examples/module/ftk_demo/demo_hello.c @@ -17,6 +17,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); ftk_widget_set_text(win, "Hello FTK!"); ftk_widget_show(win, 1); FTK_QUIT_WHEN_WIDGET_CLOSE(win); diff --git a/examples/module/ftk_demo/demo_icon_view.c b/examples/module/ftk_demo/demo_icon_view.c index 2167bea981..534bbae8b0 100644 --- a/examples/module/ftk_demo/demo_icon_view.c +++ b/examples/module/ftk_demo/demo_icon_view.c @@ -62,6 +62,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); diff --git a/examples/module/ftk_demo/demo_image.c b/examples/module/ftk_demo/demo_image.c index 4bc95d577b..cca9712812 100644 --- a/examples/module/ftk_demo/demo_image.c +++ b/examples/module/ftk_demo/demo_image.c @@ -19,6 +19,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); ftk_snprintf(filename, FTK_MAX_PATH, "%s/earth.png", ftk_config_get_test_data_dir(ftk_default_config())); diff --git a/examples/module/ftk_demo/demo_image_button.c b/examples/module/ftk_demo/demo_image_button.c index f76a884ce4..026289c816 100644 --- a/examples/module/ftk_demo/demo_image_button.c +++ b/examples/module/ftk_demo/demo_image_button.c @@ -77,6 +77,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) gc.mask = FTK_GC_BITMAP; win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); for(i = 0; i < height/80; i++) diff --git a/examples/module/ftk_demo/demo_ime.c b/examples/module/ftk_demo/demo_ime.c index c5539cca83..459a71c3f5 100644 --- a/examples/module/ftk_demo/demo_ime.c +++ b/examples/module/ftk_demo/demo_ime.c @@ -28,6 +28,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) FTK_INIT(argc, argv); win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); entry = ftk_entry_create(win, 10, 30, ftk_widget_width(win) - 20, 30); diff --git a/examples/module/ftk_demo/demo_label.c b/examples/module/ftk_demo/demo_label.c index bc293e26eb..4f8d2b03af 100644 --- a/examples/module/ftk_demo/demo_label.c +++ b/examples/module/ftk_demo/demo_label.c @@ -12,7 +12,7 @@ static Ret timeout(void* ctx) char buffer[32] = {0}; if(info->times > 0) { - snprintf(buffer, sizeof(buffer), "Quit after %d seconds", info->times); + ftk_snprintf(buffer, sizeof(buffer), "Quit after %d seconds", info->times); ftk_widget_set_text(info->label, buffer); info->times--; @@ -43,22 +43,30 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) { int width = 0; int height = 0; - FtkGc gc = {.mask = FTK_GC_BG}; + FtkGc gc = {0}; TimerInfo* info = NULL; + FtkSource* timer = NULL; + FtkWidget* win = NULL; + FtkWidget* label = NULL; + + gc.mask = FTK_GC_BG; 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(); + timer = ftk_source_timer_create(1000, timeout, info); + win = ftk_app_window_create(); + ftk_window_set_animation_hint(win, "app_main_window"); width = ftk_widget_width(win); height = ftk_widget_height(win); - FtkWidget* label = ftk_label_create(win, 10, 10, width - 20, 20); +#ifdef WIN32 + label = ftk_label_create(win, 10, 10, width - 20, 20); ftk_widget_set_text(label, "中文文本"); - +#else +#endif 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); @@ -75,8 +83,11 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) 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); +#ifdef WIN32 + ftk_widget_set_text(label, "The linux mobile development(with background color)"); +#else ftk_widget_set_text(label, "中英文混合多行文本显示:the linux mobile development.带有背景颜色。"); - +#endif label = ftk_label_create(win, 50, height/2-30, width, 20); info->label = label; diff --git a/examples/module/ftk_demo/demo_listview.c b/examples/module/ftk_demo/demo_listview.c index 43d1ed0628..058f652c82 100644 --- a/examples/module/ftk_demo/demo_listview.c +++ b/examples/module/ftk_demo/demo_listview.c @@ -37,7 +37,7 @@ static Ret button_more_clicked(void* ctx, void* obj) return RET_OK; } -static Ret on_item_clicked(void* ctx, void* list) +Ret on_item_clicked(void* ctx, void* list) { FtkListItemInfo* info = NULL; FtkListModel* model = ftk_list_view_get_model(list); @@ -111,6 +111,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) button = ftk_button_create(win, width/4, 3 * height/4 + 5, width/4, 60); ftk_widget_set_text(button, "more"); + ftk_widget_set_font_size(button, 20); ftk_button_set_clicked_listener(button, button_more_clicked, model); button = ftk_button_create(win, width/2, 3 * height/4 + 5, width/4, 60); diff --git a/examples/module/ftk_demo/demo_menu.c b/examples/module/ftk_demo/demo_menu.c index 31ad58f82c..7736276346 100644 --- a/examples/module/ftk_demo/demo_menu.c +++ b/examples/module/ftk_demo/demo_menu.c @@ -51,7 +51,7 @@ static void create_app_window(void) { int width = 0; int height = 0; - char title[32] = {0}; + char title[128] = {0}; FtkWidget* win = ftk_app_window_create(); FtkWidget* label = NULL; FtkWidget* button = NULL; @@ -68,7 +68,10 @@ static void create_app_window(void) ftk_button_set_clicked_listener(button, button_close_clicked, win); label = ftk_label_create(win, 10, height/2, width-20, 60); - ftk_widget_set_text(label, "Press F2 to open menu, Presss F3 close window."); + + ftk_snprintf(title, sizeof(title), + "Press F2 to open menu, Presss F3 close window%02d", g_index++); + ftk_widget_set_text(label, title); ftk_snprintf(title, sizeof(title), "window%02d", g_index++); ftk_widget_set_text(win, title); diff --git a/examples/module/ftk_demo/demo_multi_win.c b/examples/module/ftk_demo/demo_multi_win.c index 85b5442b77..151341553d 100644 --- a/examples/module/ftk_demo/demo_multi_win.c +++ b/examples/module/ftk_demo/demo_multi_win.c @@ -52,7 +52,7 @@ static void create_app_window(void) ftk_widget_set_text(button, "关闭窗口"); ftk_button_set_clicked_listener(button, button_close_clicked, win); - snprintf(title, sizeof(title), "window%02d", g_index++); + ftk_snprintf(title, sizeof(title), "window%02d", g_index++); label = ftk_label_create(win, width/4, height/2, width/2, 30); ftk_widget_set_text(label, title); diff --git a/examples/module/ftk_demo/demo_progress_bar.c b/examples/module/ftk_demo/demo_progress_bar.c index fa1e1625f2..7694cf407a 100644 --- a/examples/module/ftk_demo/demo_progress_bar.c +++ b/examples/module/ftk_demo/demo_progress_bar.c @@ -57,7 +57,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) height = ftk_widget_height(win); width = width - 20; - progress_bar = ftk_progress_bar_create(win, 10, height/6, width, 20); + progress_bar = ftk_progress_bar_create(win, 10, height/6, width, 32); ftk_progress_bar_set_percent(progress_bar, 20); timer = ftk_source_timer_create(1000, update_progress, progress_bar); ftk_main_loop_add_source(ftk_default_main_loop(), timer); @@ -70,7 +70,7 @@ FTK_HIDE int FTK_MAIN(int argc, char* argv[]) ftk_widget_set_user_data(progress_bar, on_window_destroy, timer); ftk_progress_bar_set_interactive(progress_bar, 1); - progress_bar = ftk_progress_bar_create(win, 10, height/2, width, 20); + progress_bar = ftk_progress_bar_create(win, 10, height/2, width, 32); ftk_progress_bar_set_percent(progress_bar, 20); timer = ftk_source_timer_create(1000, update_progress, progress_bar); ftk_main_loop_add_source(ftk_default_main_loop(), timer); diff --git a/examples/module/ftk_demo/demo_sprite.c b/examples/module/ftk_demo/demo_sprite.c index 2888e33a15..1c1ee551c5 100644 --- a/examples/module/ftk_demo/demo_sprite.c +++ b/examples/module/ftk_demo/demo_sprite.c @@ -6,14 +6,14 @@ static Ret button_quit_clicked(void* ctx, void* obj) return RET_OK; } -static Ret on_move(void* ctx, void* obj) +Ret on_move(void* ctx, void* obj) { ftk_logd("%s: %d %d\n", __func__, ftk_sprite_get_x(obj), ftk_sprite_get_y(obj)); return RET_OK; } -static Ret move_cursor(void* ctx, void* obj) +Ret move_cursor(void* ctx, void* obj) { FtkEvent* event = obj; diff --git a/examples/module/ftk_demo/demo_statusbar.c b/examples/module/ftk_demo/demo_statusbar.c index 31f76593cf..a7e5003d29 100644 --- a/examples/module/ftk_demo/demo_statusbar.c +++ b/examples/module/ftk_demo/demo_statusbar.c @@ -13,7 +13,7 @@ static Ret update_time(void* ctx) struct tm* t = localtime(&now); panel = ftk_default_status_panel(); - snprintf(text, sizeof(text)-1, "%2d:%2d", t->tm_hour, t->tm_min); + ftk_snprintf(text, sizeof(text)-1, "%2d:%2d", t->tm_hour, t->tm_min); item = ftk_widget_lookup(panel, IDC_TIME_ITEM); diff --git a/examples/module/ftk_demo/demo_zoom.c b/examples/module/ftk_demo/demo_zoom.c deleted file mode 100644 index 282a36c466..0000000000 --- a/examples/module/ftk_demo/demo_zoom.c +++ /dev/null @@ -1,137 +0,0 @@ -#include "ftk.h" -#include "ftk_animator_zoom.h" - -static void create_ani_window(int type, int sync); - -static Ret button_to_zoom_in_clicked(void* ctx, void* obj) -{ - create_ani_window(FTK_ANI_ZOOM_IN, 1); - - return RET_OK; -} - -static Ret button_to_zoom_out_clicked(void* ctx, void* obj) -{ - create_ani_window(FTK_ANI_ZOOM_OUT, 1); - - return RET_OK; -} - -static Ret button_close_clicked(void* ctx, void* obj) -{ - FtkWidget* win = ctx; - ftk_logd("%s: close window %s\n", __func__, ftk_widget_get_text(win)); - ftk_widget_unref(win); - - return RET_OK; -} - -static Ret button_quit_clicked(void* ctx, void* obj) -{ - FtkWidget* win = ctx; - ftk_widget_unref(win); - ftk_logd("%s: close window %s\n", __func__, ftk_widget_get_text(win)); - - return RET_OK; -} - -static void create_ani_window(int type, int sync) -{ - int delta = 0; - int width = 0; - int height = 0; - FtkWidget* button = NULL; - FtkGc gc = {0}; - char filename[FTK_MAX_PATH+1] = {0}; - FtkWidget* win = ftk_app_window_create(); - FtkAnimator* ani = ftk_animator_zoom_create(1); - - gc.mask = FTK_GC_BITMAP; - width = ftk_widget_width(win); - height = ftk_widget_height(win); - delta = height/6; - - button = ftk_button_create(win, width/3, height/3, width/3, 50); - ftk_widget_set_text(button, "关闭"); - ftk_widget_show(button, 1); - ftk_button_set_clicked_listener(button, button_close_clicked, win); - - ftk_snprintf(filename, FTK_MAX_PATH, "%s/jpeg1.jpg", - ftk_config_get_test_data_dir(ftk_default_config())); - gc.bitmap = ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename); - ftk_widget_set_gc(win, FTK_WIDGET_NORMAL, &gc); - ftk_gc_reset(&gc); - - switch(type) - { - case FTK_ANI_ZOOM_IN: - { - ftk_animator_set_param(ani, type, 10, 100, delta, 200); - break; - } - case FTK_ANI_ZOOM_OUT: - { - ftk_animator_set_param(ani, type, 10, 100, delta, 200); - break; - } - default:break; - } - ftk_animator_start(ani, win, 0); - - return; -} - -static void create_app_window(void) -{ - char title[32] = {0}; - int width = 0; - int height = 0; - FtkWidget* win = ftk_app_window_create(); - FtkWidget* button = NULL; - - width = ftk_widget_width(win); - height = ftk_widget_height(win); - - button = ftk_button_create(win, 5, height/6 + 60, width/2-5, 50); - ftk_widget_set_text(button, "ZoomIn"); - ftk_button_set_clicked_listener(button, button_to_zoom_in_clicked, win); - - button = ftk_button_create(win, width/2, height/6 + 60, width/2-5, 50); - ftk_widget_set_text(button, "ZoomOut"); - ftk_button_set_clicked_listener(button, button_to_zoom_out_clicked, win); - - button = ftk_button_create(win, width/4-2, height/6 + 180, width/2-5, 50); - ftk_widget_set_text(button, "Quit"); - ftk_button_set_clicked_listener(button, button_quit_clicked, win); - - ftk_snprintf(title, sizeof(title), "Zoom Demo"); - ftk_widget_set_text(win, title); - FTK_QUIT_WHEN_WIDGET_CLOSE(win); - - ftk_widget_show_all(win, 1); - - return; -} - -#ifdef FTK_AS_PLUGIN -#include "ftk_app_demo.h" -FTK_HIDE int FTK_MAIN(int argc, char* argv[]); -FtkApp* ftk_app_demo_zoom_create() -{ - return ftk_app_demo_create(_("zoom"), ftk_main); -} -#else -#define FTK_HIDE extern -#endif /*FTK_AS_PLUGIN*/ - -FTK_HIDE int FTK_MAIN(int argc, char* argv[]) -{ - FTK_INIT(argc, argv); - - create_app_window(); - - FTK_RUN(); - - return 0; -} - diff --git a/examples/module/ftk_demo/demos.desktop b/examples/module/ftk_demo/demos.desktop index 19b7776041..330df5a88a 100644 --- a/examples/module/ftk_demo/demos.desktop +++ b/examples/module/ftk_demo/demos.desktop @@ -1,30 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/module/ftk_demo/t1.xul b/examples/module/ftk_demo/t1.xul index bebc879c83..0f607d292f 100644 --- a/examples/module/ftk_demo/t1.xul +++ b/examples/module/ftk_demo/t1.xul @@ -1,5 +1,5 @@ - +