PageRenderTime 284ms CodeModel.GetById 150ms app.highlight 8ms RepoModel.GetById 123ms app.codeStats 0ms

/src/demos/demo_check_button.c

http://ftk.googlecode.com/
C | 88 lines | 71 code | 17 blank | 0 comment | 0 complexity | 99bfbf5e603162cc3aacc3faceada8e0 MD5 | raw file
 1#include "ftk.h"
 2
 3static Ret button_clicked(void* ctx, void* obj)
 4{
 5	return RET_OK;
 6}
 7
 8#ifdef FTK_AS_PLUGIN
 9#include "ftk_app_demo.h"
10FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
11FtkApp* ftk_app_demo_check_button_create()
12{
13	return ftk_app_demo_create(_("check_button"), ftk_main);
14}
15#else
16#define FTK_HIDE extern
17#endif /*FTK_AS_PLUGIN*/
18
19FTK_HIDE int FTK_MAIN(int argc, char* argv[])
20{
21	int win_width = 0;
22	int win_height = 0;
23	int group_height = 0;
24	int button_width = 0;
25	int button_height = 0;
26	FtkWidget* win = NULL;
27	FtkWidget* button = NULL;
28	FtkWidget* group = NULL;
29	FTK_INIT(argc, argv);
30	
31	win = ftk_app_window_create();
32	ftk_window_set_animation_hint(win, "app_main_window");
33	win_width = ftk_widget_width(win);
34	win_height = ftk_widget_height(win);
35	
36	button_width = win_width/2 - 20;
37	button_height = 50;
38	group_height = (win_height - 6)/3;
39
40	group = ftk_group_box_create(win, 0, 0, win_width, group_height);
41	ftk_widget_set_text(group, "Favorites");
42	button = ftk_check_button_create(group, 20, 
43		(group_height - button_height) / 2, button_width, button_height);
44	ftk_widget_set_text(button, "Sports");
45	ftk_check_button_set_clicked_listener(button, button_clicked, win);
46
47	button = ftk_check_button_create(group, button_width + 20, 
48		(group_height - button_height) / 2, button_width, button_height);
49	ftk_widget_set_text(button, "Reading");
50	ftk_check_button_set_clicked_listener(button, button_clicked, win);
51
52	group = ftk_group_box_create(win, 0, group_height + 2, win_width, group_height);
53	ftk_widget_set_text(group, "Gender");
54	
55	button = ftk_check_button_create_radio(group, 20,
56		(group_height - button_height) / 2, button_width, button_height);
57	ftk_widget_set_text(button, "Male");
58	ftk_check_button_set_clicked_listener(button, button_clicked, win);
59
60	button = ftk_check_button_create_radio(group, button_width + 20, 
61		(group_height - button_height) / 2, button_width, button_height);
62	ftk_widget_set_text(button, "Female");
63	ftk_check_button_set_clicked_listener(button, button_clicked, win);
64	
65	group = ftk_group_box_create(win, 0, 2 * group_height + 2, win_width, group_height);
66	ftk_widget_set_text(group, "Gender(Right Icon)");
67	
68	button = ftk_check_button_create_radio(group, 20,
69		(group_height - button_height) / 2, button_width, button_height);
70	ftk_widget_set_text(button, "Male");
71	ftk_check_button_set_icon_position(button, 1);
72	ftk_check_button_set_clicked_listener(button, button_clicked, win);
73
74	button = ftk_check_button_create_radio(group, button_width + 20, 
75		(group_height - button_height) / 2, button_width, button_height);
76	ftk_widget_set_text(button, "Female");
77	ftk_check_button_set_icon_position(button, 1);
78	ftk_check_button_set_clicked_listener(button, button_clicked, win);
79	
80	ftk_widget_set_text(win, "check button demo");
81	ftk_widget_show_all(win, 1);
82	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
83
84	FTK_RUN();
85
86	return 0;
87}
88