PageRenderTime 233ms CodeModel.GetById 110ms app.highlight 5ms RepoModel.GetById 116ms app.codeStats 0ms

/src/demos/demo_keyboard.c

http://ftk.googlecode.com/
C | 56 lines | 46 code | 10 blank | 0 comment | 0 complexity | 74e45b514e069d529120d90e2c851ad3 MD5 | raw file
 1#include "ftk.h"
 2#include "ftk_util.h"
 3#include "ftk_key_board.h"
 4
 5#ifdef FTK_AS_PLUGIN
 6#include "ftk_app_demo.h"
 7FTK_HIDE int FTK_MAIN(int argc, char* argv[]);
 8FtkApp* ftk_app_demo_keyboard_create()
 9{
10	return ftk_app_demo_create(_("keyboard"), ftk_main);
11}
12#else
13#define FTK_HIDE extern
14#endif /*FTK_AS_PLUGIN*/
15
16FTK_HIDE int FTK_MAIN(int argc, char* argv[])
17{
18	size_t w = 0;
19	size_t h = 0;
20	FtkWidget* win = NULL;
21	FtkWidget* entry = NULL;
22	FtkWidget* key_board = NULL;
23	char filename[FTK_MAX_PATH+1] = {0};
24
25	FTK_INIT(argc, argv);
26	win = ftk_app_window_create();
27	ftk_window_set_animation_hint(win, "app_main_window");
28	ftk_widget_set_text(win, "KeyBoard");
29
30	w = ftk_widget_width(win);
31	h = ftk_widget_height(win);
32
33	ftk_input_method_manager_set_current(ftk_default_input_method_manager(), -1);
34	entry = ftk_entry_create(win, 10, 30, w - 20, 30);
35
36	ftk_strs_cat(filename, FTK_MAX_PATH, 
37		ftk_config_get_data_dir(ftk_default_config()), "/theme/", "default", "/keyboard.xml", NULL);
38	key_board = ftk_key_board_create(win, 0, h-180, w, 180);
39	ftk_key_board_load(key_board, filename);
40	ftk_key_board_reset_candidates(key_board);
41	ftk_key_board_add_candidate(key_board, "?");
42	ftk_key_board_add_candidate(key_board, "?");
43	ftk_key_board_add_candidate(key_board, "??");
44	ftk_key_board_add_candidate(key_board, "?");
45	ftk_key_board_add_candidate(key_board, "???");
46	ftk_key_board_add_candidate(key_board, "???");
47	ftk_key_board_set_editor(key_board, entry);
48
49	ftk_widget_show_all(win, 1);
50	FTK_QUIT_WHEN_WIDGET_CLOSE(win);
51
52	FTK_RUN();
53
54	return 0;
55}
56