PageRenderTime 344ms CodeModel.GetById 201ms app.highlight 6ms RepoModel.GetById 135ms app.codeStats 0ms

/src/demos/demo_wait_box.c

http://ftk.googlecode.com/
C | 72 lines | 55 code | 17 blank | 0 comment | 0 complexity | 813b2be339af37155e50b6378737f44c MD5 | raw file
 1#include "ftk.h"
 2
 3static Ret button_quit_clicked(void* ctx, void* obj)
 4{
 5	ftk_widget_unref(ctx);
 6	return RET_OK;
 7}
 8
 9static Ret button_start_clicked(void* ctx, void* obj)
10{
11	ftk_widget_show(ctx, 1);
12	ftk_wait_box_start_waiting(ctx);
13
14	return RET_OK;
15}
16
17static Ret button_stop_clicked(void* ctx, void* obj)
18{
19	ftk_wait_box_stop_waiting(ctx);
20
21	return RET_OK;
22}
23
24#ifdef FTK_AS_PLUGIN
25#include "ftk_app_demo.h"
26FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
27FtkApp* ftk_app_demo_wait_box_create()
28{
29	return ftk_app_demo_create(_("wait_box"), ftk_main);
30}
31#else
32#define FTK_HIDE extern
33#endif /*FTK_AS_PLUGIN*/
34
35FTK_HIDE int FTK_MAIN(int argc, char* argv[])
36{
37	int width = 0;
38	int height = 0;
39	FtkWidget* win = NULL;
40	FtkWidget* button = NULL;
41	FtkWidget* wait_box = NULL;
42
43	FTK_INIT(argc, argv);
44	
45	win = ftk_app_window_create();
46	width = ftk_widget_width(win);
47	height = ftk_widget_height(win);
48	
49	wait_box = ftk_wait_box_create(win, width/2 - 16, height/4, 0, 0);
50	
51	button = ftk_button_create(win, 0, height/2, width/3, 50);
52	ftk_widget_set_text(button, "start");
53	ftk_button_set_clicked_listener(button, button_start_clicked, wait_box);
54	
55	button = ftk_button_create(win, 2*width/3, height/2, width/3, 50);
56	ftk_widget_set_text(button, "stop");
57	ftk_button_set_clicked_listener(button, button_stop_clicked, wait_box);
58
59	button = ftk_button_create(win, width/4, 3*height/4, width/2, 60);
60	ftk_widget_set_text(button, "quit");
61	ftk_button_set_clicked_listener(button, button_quit_clicked, win);
62	ftk_window_set_focus(win, button);
63
64	ftk_widget_set_text(win, "wait_box demo");
65	ftk_widget_show_all(win, 1);
66	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
67
68	FTK_RUN();
69
70	return 0;
71}
72