2 * ISF(Input Service Framework)
4 * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
5 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
7 * Contact: Shuo Liu <shuo0805.liu@samsung.com>, Jihoon Kim <jihoon48.kim@samsung.com>
9 * This library is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU Lesser General Public License as published by the
11 * Free Software Foundation; either version 2.1 of the License, or (at your option)
14 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 * License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software Foundation, Inc., 51
21 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <Elementary.h>
28 #include <ui-gadget.h>
30 #include "isf_demo_efl.h"
31 #include "isf_imcontrol_efl.h"
32 #include "isf_layout_efl.h"
33 #include "isf_event_efl.h"
34 #include "isf_autocapital_efl.h"
35 #include "isf_prediction_efl.h"
37 #define BASE_THEME_WIDTH 720.0f
39 static void _quit_cb (void *data, Evas_Object *obj, void *event_info)
44 static void _list_click (void *data, Evas_Object *obj, void *event_info)
46 struct appdata *ad = (struct appdata *)data;
47 if (ad == NULL) return;
49 Evas_Object *li = ad->li;
50 if (li == NULL) return;
52 Elm_List_Item *it = (Elm_List_Item *)elm_list_selected_item_get (li);
55 elm_list_item_selected_set (it, EINA_FALSE);
58 static void layout_cb (struct ui_gadget *ug, enum ug_mode mode, void *priv)
60 struct appdata *ad = NULL;
61 Evas_Object *base = NULL;
63 if ( ug == NULL || priv == NULL)
68 base = (Evas_Object *)ug_get_layout (ug);
73 case UG_MODE_FULLVIEW:
74 evas_object_size_hint_weight_set (base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 elm_win_resize_object_add (ad->win_main, base);
76 evas_object_show (base);
78 case UG_MODE_FRAMEVIEW:
79 printf("please set ug mode to UG_MODE_FULLVIEW!\n");
86 static void result_cb (struct ui_gadget *ug, bundle *result, void *priv)
90 const char *name = bundle_get_val(result, "name");
91 printf("get key [ %s ]\n",name);
93 if (strcmp(name, "keyboard-setting-wizard-efl") == 0) {
94 const char *desp = bundle_get_val(result,"description");
95 printf("====================\nresult:%s\n====================\n",desp);
99 static void destroy_cb (struct ui_gadget *ug, void *priv)
107 static void isfsetting_bt (void *data, Evas_Object *obj, void *event_info)
109 struct appdata *ad = (struct appdata *)data;
110 struct ug_cbs cbs = {0, };
112 UG_INIT_EFL (ad->win_main, UG_OPT_INDICATOR_ENABLE);
114 cbs.layout_cb = layout_cb;
115 cbs.result_cb = result_cb;
116 cbs.destroy_cb = destroy_cb;
118 ad->ug = ug_create (NULL, "isfsetting-efl",
121 bundle_free (ad->data);
125 static void keyboard_setting_wizard_bt (void *data, Evas_Object *obj, void *event_info)
127 struct appdata *ad = (struct appdata *)data;
128 struct ug_cbs cbs = {0, };
130 UG_INIT_EFL (ad->win_main, UG_OPT_INDICATOR_ENABLE);
132 cbs.layout_cb = layout_cb;
133 cbs.result_cb = result_cb;
134 cbs.destroy_cb = destroy_cb;
136 ad->data = bundle_create();
137 bundle_add(ad->data, "navi_btn_left", _("Previous"));
138 //bundle_add(ad->data, "navi_btn_left", NULL);
139 bundle_add(ad->data, "navi_btn_right", _("Next"));
140 ad->ug = ug_create (NULL, "keyboard-setting-wizard-efl",
143 bundle_free (ad->data);
147 static int create_demo_view (struct appdata *ad)
149 Evas_Object *li = NULL;
151 Evas_Object *l_button = elm_button_add (ad->naviframe);
152 elm_object_style_set (l_button, "naviframe/end_btn/default");
153 evas_object_smart_callback_add (l_button, "clicked", _quit_cb, NULL);
156 ad->li = li = elm_list_add (ad->naviframe);
157 elm_list_mode_set (li, ELM_LIST_COMPRESS);
158 evas_object_smart_callback_add (ad->li, "selected", _list_click, ad);
160 // Test ISF imcontrol API
161 elm_list_item_append (li, "ISF imcontrol API", NULL, NULL, imcontrolapi_bt, ad);
164 elm_list_item_append (li, "ISF Layout", NULL, NULL, ise_layout_bt, ad);
166 // Test autocapital type
167 elm_list_item_append (li, "ISF Autocapital", NULL, NULL, ise_autocapital_bt, ad);
169 // Test prediction allow
170 elm_list_item_append (li, "ISF Prediction allow", NULL, NULL, ise_prediction_bt, ad);
172 elm_list_item_append (li, "ISF Event Demo", NULL, NULL, isf_event_demo_bt, ad);
175 ISF language selection
178 elm_list_item_append (li, "ISF Setting", NULL, NULL, isfsetting_bt, ad);
179 elm_list_item_append (li, "keyboard Setting wizard", NULL, NULL, keyboard_setting_wizard_bt, ad);
180 // ISF preedit string and commit string on Label and Entry
184 elm_naviframe_item_push (ad->naviframe, _("isf demo"), l_button, NULL, li, NULL);
189 static int lang_changed (void *data)
191 struct appdata *ad = (appdata *)data;
193 if (ad->layout_main == NULL)
196 ug_send_event (UG_EVENT_LANG_CHANGE);
200 static int _rotate_cb (enum appcore_rm m, void *data)
202 struct appdata *ad = (struct appdata *)data;
203 if (ad == NULL || ad->win_main == NULL)
208 case APPCORE_RM_PORTRAIT_NORMAL:
209 ug_send_event (UG_EVENT_ROTATE_PORTRAIT);
212 case APPCORE_RM_PORTRAIT_REVERSE:
213 ug_send_event (UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN);
216 case APPCORE_RM_LANDSCAPE_NORMAL:
217 ug_send_event (UG_EVENT_ROTATE_LANDSCAPE);
220 case APPCORE_RM_LANDSCAPE_REVERSE:
221 ug_send_event (UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN);
230 elm_win_rotation_with_resize_set (ad->win_main, r);
235 static void win_del (void *data, Evas_Object *obj, void *event)
240 static Evas_Object* create_win (const char *name)
242 Evas_Object *eo = NULL;
245 eo = elm_win_add (NULL, name, ELM_WIN_BASIC);
247 elm_win_title_set (eo, name);
248 elm_win_borderless_set (eo, EINA_TRUE);
249 evas_object_smart_callback_add (eo, "delete,request",
251 ecore_x_window_size_get (ecore_x_window_root_first_get (), &w, &h);
252 evas_object_resize (eo, w, h);
258 static Evas_Object* create_layout_main (Evas_Object* parent)
260 Evas_Object *layout = elm_layout_add (parent);
261 elm_layout_theme_set (layout, "layout", "application", "default");
262 evas_object_size_hint_weight_set (layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
263 elm_win_resize_object_add (parent, layout);
265 evas_object_show (layout);
270 static Evas_Object* _create_naviframe_layout (Evas_Object* parent)
272 Evas_Object *naviframe = elm_naviframe_add (parent);
273 elm_layout_content_set (parent, "elm.swallow.content", naviframe);
275 evas_object_show (naviframe);
280 static Evas_Object* create_bg(Evas_Object *win)
282 Evas_Object *bg = elm_bg_add(win);
283 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
284 elm_win_resize_object_add(win, bg);
285 evas_object_show(bg);
290 static Eina_Bool _keydown_event(void *data, int type, void *event)
292 Ecore_Event_Key *ev = (Ecore_Event_Key *)event;
293 struct appdata *ad = (struct appdata *)data;
294 Elm_Object_Item *top_it, *bottom_it;
295 if (ad == NULL || ev == NULL) return ECORE_CALLBACK_RENEW;
297 if (strcmp(ev->keyname, "XF86Stop") == 0) {
298 if (ug_send_key_event(UG_KEY_EVENT_END) == -1) {
299 top_it = elm_naviframe_top_item_get(ad->naviframe);
300 bottom_it = elm_naviframe_top_item_get(ad->naviframe);
301 if (top_it && bottom_it && (elm_object_item_content_get(top_it) == elm_object_item_content_get(bottom_it))) {
305 elm_naviframe_item_pop(ad->naviframe);
309 return ECORE_CALLBACK_RENEW;
312 static int app_create (void *data)
314 struct appdata *ad = (struct appdata *)data;
316 appcore_measure_start ();
318 ad->win_main = create_win ("isf-demo-efl");
319 evas_object_show (ad->win_main);
321 ad->evas = evas_object_evas_get (ad->win_main);
322 /* get width and height of main window */
323 evas_object_geometry_get (ad->win_main, NULL, NULL, &ad->root_w, &ad->root_h);
325 if (ad->root_w >= 0) {
326 elm_scale_set(ad->root_w / BASE_THEME_WIDTH );
329 ad->bg = create_bg(ad->win_main);
331 ad->layout_main = create_layout_main (ad->win_main);
334 elm_win_indicator_state_set (ad->win_main, EINA_TRUE);
337 ad->naviframe = _create_naviframe_layout (ad->layout_main);
339 //init the content in layout_main.
340 create_demo_view (ad);
344 evas_object_show (ad->win_main);
346 /* add system event callback */
347 appcore_set_event_callback (APPCORE_EVENT_LANG_CHANGE,
350 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _keydown_event, ad);
352 appcore_set_rotation_cb (_rotate_cb, ad);
354 appcore_measure_time ();
359 static int app_exit (void *data)
361 struct appdata *ad = (struct appdata *)data;
363 evas_object_del (ad->li);
365 if (ad->ev_li != NULL)
366 evas_object_del (ad->ev_li);
368 if (ad->layout_main != NULL)
369 evas_object_del (ad->layout_main);
371 if (ad->win_main != NULL)
372 evas_object_del (ad->win_main);
377 static int app_pause(void *data)
382 static int app_resume (void *data)
387 static int app_reset (bundle *b, void *data)
389 struct appdata *ad = (struct appdata *)data;
391 if ( (ad != NULL) && (ad->win_main != NULL))
392 elm_win_activate (ad->win_main);
397 int main (int argc, char *argv[])
400 struct appcore_ops ops;
402 ops.create = app_create;
403 ops.terminate = app_exit;
404 ops.pause = app_pause;
405 ops.resume = app_resume;
406 ops.reset = app_reset;
408 memset (&ad, 0x0, sizeof (struct appdata));
410 return appcore_efl_main ("isf-demo-efl", &argc, &argv, &ops);
414 vi:ts=4:ai:nowrap:expandtab