PageRenderTime 37ms CodeModel.GetById 31ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/demos/demo_image.c

http://ftk.googlecode.com/
C | 74 lines | 59 code | 15 blank | 0 comment | 0 complexity | 957184033908955b47a8398dd178f60b MD5 | raw file
 1#include "ftk.h"
 2
 3#ifdef FTK_AS_PLUGIN
 4#include "ftk_app_demo.h"
 5FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
 6FtkApp* ftk_app_demo_image_create()
 7{
 8	return ftk_app_demo_create(_("image"), ftk_main);
 9}
10#else
11#define FTK_HIDE extern
12#endif /*FTK_AS_PLUGIN*/
13
14FTK_HIDE int FTK_MAIN(int argc, char* argv[])
15{
16	FtkWidget* image = NULL;
17	FtkWidget* button = NULL;
18	FtkWidget* win = NULL;
19	char filename[FTK_MAX_PATH+1] = {0};
20	FTK_INIT(argc, argv);
21	
22	win = ftk_app_window_create();
23	ftk_window_set_animation_hint(win, "app_main_window");
24
25	ftk_snprintf(filename, FTK_MAX_PATH, "%s/earth.png", 
26		ftk_config_get_test_data_dir(ftk_default_config()));
27
28	image = ftk_image_create(win, 0, 0, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
29	ftk_image_set_image(image, 
30		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
31	
32	ftk_snprintf(filename, FTK_MAX_PATH, "%s/png_RGB_tRNS.png", 
33		ftk_config_get_test_data_dir(ftk_default_config()));
34	image = ftk_image_create(win, 0, 0, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
35	ftk_image_set_image(image, 
36		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
37	ftk_widget_set_attr(image, FTK_ATTR_TRANSPARENT);
38
39	ftk_snprintf(filename, FTK_MAX_PATH, "%s/Calculator.png", 
40		ftk_config_get_test_data_dir(ftk_default_config()));
41	image = ftk_image_create(win, ftk_widget_width(win)/2, 0, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
42	ftk_image_set_image(image, 
43		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
44	ftk_widget_set_attr(image, FTK_ATTR_BG_TILE);
45
46	ftk_snprintf(filename, FTK_MAX_PATH, "%s/t8.bmp", 
47		ftk_config_get_test_data_dir(ftk_default_config()));
48	image = ftk_image_create(win, 0, ftk_widget_height(win)/2, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
49	ftk_image_set_image(image, 
50		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
51	ftk_widget_set_attr(image, FTK_ATTR_BG_CENTER);
52	
53	ftk_snprintf(filename, FTK_MAX_PATH,  "%s/jpeg1.jpg", 
54		ftk_config_get_test_data_dir(ftk_default_config()));
55	image = ftk_image_create(win, ftk_widget_width(win)/2, ftk_widget_height(win)/2, ftk_widget_width(win)/2, ftk_widget_height(win)/2);
56	ftk_image_set_image(image, 
57		ftk_bitmap_factory_load(ftk_default_bitmap_factory(), filename));
58	ftk_widget_set_attr(image, FTK_ATTR_BG_TILE);
59
60	button = ftk_button_create(win, 10, 10, 200, 50);
61	ftk_widget_set_text(button, "buton1 on backgruop");
62
63	button = ftk_button_create(win, 10, 70, 200, 50);
64	ftk_widget_set_text(button, "buton2 on backgruop");
65
66	ftk_widget_set_text(win, "image demo");
67	ftk_widget_show_all(win, 1);
68	
69	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
70
71	FTK_RUN();
72
73	return 0;
74}