PageRenderTime 63ms CodeModel.GetById 58ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/src/demos/demo_ime.c

http://ftk.googlecode.com/
C | 60 lines | 47 code | 13 blank | 0 comment | 0 complexity | bf037dde0bd47b8c9c610af34c96e4c9 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
 9#ifdef FTK_AS_PLUGIN
10#include "ftk_app_demo.h"
11FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
12FtkApp* ftk_app_demo_ime_create()
13{
14	return ftk_app_demo_create(_("ime"), ftk_main);
15}
16#else
17#define FTK_HIDE extern
18#endif /*FTK_AS_PLUGIN*/
19
20FTK_HIDE int FTK_MAIN(int argc, char* argv[])
21{
22	int width = 0;
23	int height = 0;
24	FtkWidget* win = NULL;
25	FtkWidget* button = NULL;
26	FtkWidget* entry  = NULL;
27
28	FTK_INIT(argc, argv);
29
30	win = ftk_app_window_create();
31	ftk_window_set_animation_hint(win, "app_main_window");
32	width = ftk_widget_width(win);
33	height = ftk_widget_height(win);
34	entry = ftk_entry_create(win, 10, 30, ftk_widget_width(win) - 20, 30);
35	ftk_entry_set_text(entry, "Single line editor");
36	ftk_input_method_manager_set_current(ftk_default_input_method_manager(), 0);
37
38	entry = ftk_entry_create(win, 10, 80, ftk_widget_width(win) - 20, 30);
39	ftk_entry_set_text(entry, "Single line editor, that means you can input a one line only.");
40	
41	entry = ftk_entry_create(win, 10, 130, ftk_widget_width(win) - 20, 30);
42	ftk_entry_set_text(entry, "Single line editor, ?????????????.");
43	
44	button = ftk_button_create(win, width/4, height/2, width/2, 60);
45	ftk_widget_set_text(button, "quit");
46	ftk_button_set_clicked_listener(button, button_quit_clicked, win);
47	ftk_window_set_focus(win, button);
48	
49	entry = ftk_entry_create(win, 10, height-60, ftk_widget_width(win) - 20, 30);
50	ftk_entry_set_text(entry, "Single line editor");
51
52	ftk_widget_set_text(win, "entry demo");
53	ftk_widget_show_all(win, 1);
54	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
55
56	FTK_RUN();
57
58	return 0;
59}
60