PageRenderTime 14ms CodeModel.GetById 2ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/src/demos/demo_combo_box.c

http://ftk.googlecode.com/
C | 89 lines | 76 code | 13 blank | 0 comment | 0 complexity | 76d499cdd94f82726b6eda2febf289cc MD5 | raw file
 1#include "ftk.h"
 2
 3#define IDC_TEST_BUTTON 1000
 4static Ret button_quit_clicked(void* ctx, void* obj)
 5{
 6	ftk_widget_unref(ctx);
 7
 8	return RET_OK;
 9}
10
11#ifdef FTK_AS_PLUGIN
12#include "ftk_app_demo.h"
13FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
14FtkApp* ftk_app_demo_combo_box_create()
15{
16	return ftk_app_demo_create(_("combo_box"), ftk_main);
17}
18#else
19#define FTK_HIDE extern
20#endif /*FTK_AS_PLUGIN*/
21
22FTK_HIDE int FTK_MAIN(int argc, char* argv[])
23{
24	int width = 0;
25	int height = 0;
26	FtkWidget* win = NULL;
27	FtkWidget* button = NULL;
28	FtkWidget* combo_box = NULL;
29
30	FTK_INIT(argc, argv);
31	
32	win = ftk_app_window_create();
33	ftk_window_set_animation_hint(win, "app_main_window");
34	width = ftk_widget_width(win);
35	height = ftk_widget_height(win);
36	
37	width = width/2 - 10;
38	combo_box = ftk_combo_box_create(win, 0, height/4, width, 50);
39	ftk_combo_box_set_text(combo_box, "1 second");
40	ftk_combo_box_append(combo_box, NULL, "1 second");
41	ftk_combo_box_append(combo_box, NULL, "2 seconds");
42	ftk_combo_box_append(combo_box, NULL, "3 seconds");
43	combo_box = ftk_combo_box_create(win, width + 10, height/4, width, 50);
44	ftk_combo_box_set_text(combo_box, "1 second");
45	ftk_combo_box_append(combo_box, NULL, "1 second");
46	ftk_combo_box_append(combo_box, NULL, "2 seconds");
47	ftk_combo_box_append(combo_box, NULL, "3 seconds");
48	ftk_combo_box_append(combo_box, NULL, "4 seconds");
49	ftk_combo_box_append(combo_box, NULL, "5 seconds");
50	ftk_combo_box_append(combo_box, NULL, "6 seconds");
51	ftk_combo_box_append(combo_box, NULL, "7 seconds");
52	ftk_combo_box_append(combo_box, NULL, "8 seconds");
53	ftk_combo_box_append(combo_box, NULL, "9 seconds");
54	ftk_combo_box_append(combo_box, NULL, "0 seconds");
55	ftk_combo_box_append(combo_box, NULL, "0 seconds");
56
57	button = ftk_button_create(win, width/2, height/2, width, 60);
58	ftk_widget_set_text(button, "quit");
59	ftk_button_set_clicked_listener(button, button_quit_clicked, win);
60	ftk_window_set_focus(win, button);
61
62	combo_box = ftk_combo_box_create(win, 0, 3*height/4+5, width, 50);
63	ftk_combo_box_set_text(combo_box, "1 second");
64	ftk_combo_box_append(combo_box, NULL, "1 second");
65	ftk_combo_box_append(combo_box, NULL, "2 seconds");
66	ftk_combo_box_append(combo_box, NULL, "3 seconds");
67	combo_box = ftk_combo_box_create(win, width + 10, 3*height/4+5, width, 50);
68	ftk_combo_box_set_text(combo_box, "1 second");
69	ftk_combo_box_append(combo_box, NULL, "1 second");
70	ftk_combo_box_append(combo_box, NULL, "2 seconds");
71	ftk_combo_box_append(combo_box, NULL, "3 seconds");
72	ftk_combo_box_append(combo_box, NULL, "4 seconds");
73	ftk_combo_box_append(combo_box, NULL, "5 seconds");
74	ftk_combo_box_append(combo_box, NULL, "6 seconds");
75	ftk_combo_box_append(combo_box, NULL, "7 seconds");
76	ftk_combo_box_append(combo_box, NULL, "8 seconds");
77	ftk_combo_box_append(combo_box, NULL, "9 seconds");
78	ftk_combo_box_append(combo_box, NULL, "0 seconds");
79	ftk_combo_box_append(combo_box, NULL, "0 seconds");
80	
81	ftk_widget_set_text(win, "It is ComboBox Demo");
82	ftk_widget_show_all(win, 1);
83	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
84
85	FTK_RUN();
86
87	return 0;
88}
89