b89c8f4ffd87e65dc29cff94505c74f9d5c9467f
[profile/ivi/ecore.git] / src / lib / ecore_imf / ecore_imf_context.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <locale.h>
9
10 #include <Ecore.h>
11 #include <ecore_private.h>
12
13 #include "Ecore_IMF.h"
14 #include "ecore_imf_private.h"
15
16 /**
17  * @defgroup Ecore_IMF_Context_Group Ecore Input Method Context Functions
18  *
19  * Functions that operate on Ecore Input Method Context objects.
20  */
21
22 /**
23  * Get the list of the available Input Method Context ids.
24  *
25  * Note that the caller is responsible for freeing the Eina_List
26  * when finished with it. There is no need to finish the list strings.
27  *
28  * @return Return an Eina_List of strings;
29  *         on failure it returns NULL.
30  * @ingroup Ecore_IMF_Context_Group
31  */
32 EAPI Eina_List *
33 ecore_imf_context_available_ids_get(void)
34 {
35    return ecore_imf_module_context_ids_get();
36 }
37
38 EAPI Eina_List *
39 ecore_imf_context_available_ids_by_canvas_type_get(const char *canvas_type)
40 {
41    return ecore_imf_module_context_ids_by_canvas_type_get(canvas_type);
42 }
43
44 /*
45  * Match @locale against @against.
46  *
47  * 'en_US' against 'en_US'       => 4
48  * 'en_US' against 'en'          => 3
49  * 'en', 'en_UK' against 'en_US' => 2
50  *  all locales, against '*'     => 1
51  */
52 static int
53 _ecore_imf_context_match_locale(const char *locale, const char *against, int against_len)
54 {
55   if (strcmp(against, "*") == 0)
56     return 1;
57
58   if (strcasecmp(locale, against) == 0)
59     return 4;
60
61   if (strncasecmp(locale, against, 2) == 0)
62     return (against_len == 2) ? 3 : 2;
63
64   return 0;
65 }
66
67 /**
68  * Get the id of the default Input Method Context.
69  * The id may to used to create a new instance of an Input Method
70  * Context object.
71  *
72  * @return Return a string containing the id of the default Input
73  *         Method Context; on failure it returns NULL.
74  * @ingroup Ecore_IMF_Context_Group
75  */
76 EAPI const char *
77 ecore_imf_context_default_id_get(void)
78 {
79    return ecore_imf_context_default_id_by_canvas_type_get(NULL);
80 }
81
82 EAPI const char *
83 ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type)
84 {
85    const char *id;
86    Eina_List *modules;
87    Ecore_IMF_Module *module;
88    char *locale;
89    char *tmp;
90    int best_goodness = 0;
91
92    id = getenv("ECORE_IMF_MODULE");
93    //printf ("id is %s \n", id);
94    if (id)
95      {
96         if (strcmp(id, "none") == 0) return NULL;
97         if (ecore_imf_module_get(id)) return id;
98      }
99
100    modules = ecore_imf_module_available_get();
101    if (!modules) return NULL;
102
103    locale = setlocale(LC_CTYPE, NULL);
104    if (!locale) return NULL;
105
106    locale = strdup(locale);
107
108    tmp = strchr(locale, '.');
109    if (tmp) *tmp = '\0';
110    tmp = strchr(locale, '@');
111    if (tmp) *tmp = '\0';
112
113    id = NULL;
114
115    EINA_LIST_FREE(modules, module)
116      {
117         if (canvas_type &&
118             strcmp(module->info->canvas_type, canvas_type) == 0)
119           continue;
120
121         const char *p = module->info->default_locales;
122         while (p)
123           {
124              const char *q = strchr(p, ':');
125              int goodness = _ecore_imf_context_match_locale(locale, p, q ? (size_t)(q - p) : strlen (p));
126
127               if (goodness > best_goodness)
128                 {
129                    id = module->info->id;
130                    best_goodness = goodness;
131                 }
132
133               p = q ? q + 1 : NULL;
134           }
135      }
136
137    free(locale);
138    return id;
139 }
140
141 /**
142  * Retrieve the info for the Input Method Context with @p id.
143  *
144  * @param id The Input Method Context id to query for.
145  * @return Return a #Ecore_IMF_Context_Info for the Input Method Context with @p id;
146  *         on failure it returns NULL.
147  * @ingroup Ecore_IMF_Context_Group
148  */
149 EAPI const Ecore_IMF_Context_Info *
150 ecore_imf_context_info_by_id_get(const char *id)
151 {
152    Ecore_IMF_Module *module;
153
154    if (!id) return NULL;
155    module = ecore_imf_module_get(id);
156    if (!module) return NULL;
157    return module->info;
158 }
159
160 /**
161  * Create a new Input Method Context defined by the given id.
162  *
163  * @param id The Input Method Context id.
164  * @return A newly allocated Input Method Context;
165  *         on failure it returns NULL.
166  * @ingroup Ecore_IMF_Context_Group
167  */
168 EAPI Ecore_IMF_Context *
169 ecore_imf_context_add(const char *id)
170 {
171    Ecore_IMF_Context *ctx;
172
173    if (!id) return NULL;
174    ctx = ecore_imf_module_context_create(id);
175    if (!ctx || !ctx->klass) return NULL;
176    if (ctx->klass->add) ctx->klass->add(ctx);
177    /* default use_preedit is EINA_TRUE, so let's make sure it's
178     * set on the immodule */
179    ecore_imf_context_use_preedit_set(ctx, EINA_TRUE);
180    /* default input_mode is ECORE_IMF_INPUT_MODE_FULL, so let's make sure it's
181     * set on the immodule */
182    ecore_imf_context_input_mode_set(ctx, ECORE_IMF_INPUT_MODE_FULL);
183    return ctx;
184 }
185
186 /**
187  * Retrieve the info for the given Input Method Context.
188  *
189  * @param ctx An #Ecore_IMF_Context.
190  * @return Return a #Ecore_IMF_Context_Info for the given Input Method Context;
191  *         on failure it returns NULL.
192  * @ingroup Ecore_IMF_Context_Group
193  */
194 EAPI const Ecore_IMF_Context_Info *
195 ecore_imf_context_info_get(Ecore_IMF_Context *ctx)
196 {
197    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
198      {
199         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
200                          "ecore_imf_context_info_get");
201         return NULL;
202      }
203    return ctx->module->info;
204 }
205
206 /**
207  * Delete the given Input Method Context and free its memory.
208  *
209  * @param ctx An #Ecore_IMF_Context.
210  * @ingroup Ecore_IMF_Context_Group
211  */
212 EAPI void
213 ecore_imf_context_del(Ecore_IMF_Context *ctx)
214 {
215    void *data;
216
217    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
218      {
219         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
220                          "ecore_imf_context_del");
221         return;
222      }
223    if (ctx->klass->del) ctx->klass->del(ctx);
224    ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE);
225         
226    EINA_LIST_FREE(ctx->private_key_list, data)
227       free(data);
228
229    EINA_LIST_FREE(ctx->disabled_key_list, data)
230       free(data);
231
232    ctx->private_key_list = NULL;
233    ctx->disabled_key_list = NULL;
234
235    free(ctx);
236 }
237
238 /**
239  * Set the client window for the Input Method Context; this is the
240  * Ecore_X_Window when using X11, Ecore_Win32_Window when using Win32, etc.
241  * This window is used in order to correctly position status windows, and may
242  * also be used for purposes internal to the Input Method Context.
243  *
244  * @param ctx An #Ecore_IMF_Context.
245  * @param window The client window. This may be NULL to indicate
246  *               that the previous client window no longer exists.
247  * @ingroup Ecore_IMF_Context_Group
248  */
249 EAPI void
250 ecore_imf_context_client_window_set(Ecore_IMF_Context *ctx, void *window)
251 {
252    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
253      {
254         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
255                          "ecore_imf_context_client_window_set");
256         return;
257      }
258    if (ctx->klass->client_window_set) ctx->klass->client_window_set(ctx, window);
259    ctx->window = window;
260 }
261
262 EAPI void*
263 ecore_imf_context_client_window_get(Ecore_IMF_Context *ctx)
264 {
265    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
266      {
267         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
268                          "ecore_imf_context_client_window_get");
269         return NULL;
270      }
271    return ctx->window;
272 }
273
274 /**
275  * Set the client canvas for the Input Method Context; this is the
276  * canvas in which the input appears.
277  * The canvas type can be determined by using the context canvas type.
278  * Actually only canvas with type "evas" (Evas *) is supported.
279  * This canvas may be used in order to correctly position status windows, and may
280  * also be used for purposes internal to the Input Method Context.
281  *
282  * @param ctx An #Ecore_IMF_Context.
283  * @param canvas The client canvas. This may be NULL to indicate
284  *               that the previous client canvas no longer exists.
285  * @ingroup Ecore_IMF_Context_Group
286  */
287 EAPI void
288 ecore_imf_context_client_canvas_set(Ecore_IMF_Context *ctx, void *canvas)
289 {
290    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
291      {
292         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
293                          "ecore_imf_context_client_canvas_set");
294         return;
295      }
296    if (ctx->klass->client_canvas_set) ctx->klass->client_canvas_set(ctx, canvas);
297    ctx->client_canvas = canvas;
298 }
299
300 EAPI void*
301 ecore_imf_context_client_canvas_get(Ecore_IMF_Context *ctx)
302 {
303    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
304      {
305         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
306                          "ecore_imf_context_client_canvas_get");
307         return NULL;
308      }
309    return ctx->client_canvas;
310 }
311
312 /**
313  * Ask the Input Method Context to show itself.
314  *
315  * @param ctx An #Ecore_IMF_Context.
316  * @ingroup Ecore_IMF_Context_Group
317  */
318 EINA_DEPRECATED EAPI void
319 ecore_imf_context_show(Ecore_IMF_Context *ctx)
320 {
321    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
322      {
323         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
324                          "ecore_imf_context_show");
325         return;
326      }
327    if (ctx->klass->show) ctx->klass->show(ctx);
328 }
329
330 /**
331  * Ask the Input Method Context to hide itself.
332  *
333  * @param ctx An #Ecore_IMF_Context.
334  * @ingroup Ecore_IMF_Context_Group
335  */
336 EINA_DEPRECATED EAPI void
337 ecore_imf_context_hide(Ecore_IMF_Context *ctx)
338 {
339    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
340      {
341         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
342                          "ecore_imf_context_hide");
343         return;
344      }
345    if (ctx->klass->hide) ctx->klass->hide(ctx);
346 }
347
348 /**
349  * Retrieve the current preedit string and cursor position
350  * for the Input Method Context.
351  *
352  * @param ctx An #Ecore_IMF_Context.
353  * @param str Location to store the retrieved string. The
354  *            string retrieved must be freed with free().
355  * @param cursor_pos Location to store position of cursor (in characters)
356  *                   within the preedit string.
357  * @ingroup Ecore_IMF_Context_Group
358  */
359 EAPI void
360 ecore_imf_context_preedit_string_get(Ecore_IMF_Context *ctx, char **str, int *cursor_pos)
361 {
362    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
363      {
364         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
365                          "ecore_imf_context_preedit_string_get");
366         return;
367      }
368    if (ctx->klass->preedit_string_get)
369      ctx->klass->preedit_string_get(ctx, str, cursor_pos);
370    else
371      {
372         if (str) *str = strdup("");
373         if (cursor_pos) *cursor_pos = 0;
374      }
375 }
376
377 EAPI void                          
378 ecore_imf_context_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx, char **str, Eina_List **attrs, int *cursor_pos)
379 {
380    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
381      {
382         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
383                          "ecore_imf_context_preedit_string_with_attributes_get");
384         return;
385      }
386    if (ctx->klass->preedit_string_with_attributes_get)
387      ctx->klass->preedit_string_with_attributes_get(ctx, str, attrs, cursor_pos);
388    else
389      {
390         if (str) *str = strdup("");
391                 if (attrs) *attrs = NULL;
392         if (cursor_pos) *cursor_pos = 0;
393      }
394 }
395
396 /**
397  * Notify the Input Method Context that the widget to which its
398  * correspond has gained focus.
399  *
400  * @param ctx An #Ecore_IMF_Context.
401  * @ingroup Ecore_IMF_Context_Group
402  */
403 EAPI void
404 ecore_imf_context_focus_in(Ecore_IMF_Context *ctx)
405 {
406    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
407      {
408         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
409                          "ecore_imf_context_focus_in");
410         return;
411      }
412    if (ctx->klass->focus_in) ctx->klass->focus_in(ctx);
413 }
414
415 /**
416  * Notify the Input Method Context that the widget to which its
417  * correspond has lost focus.
418  *
419  * @param ctx An #Ecore_IMF_Context.
420  * @ingroup Ecore_IMF_Context_Group
421  */
422 EAPI void
423 ecore_imf_context_focus_out(Ecore_IMF_Context *ctx)
424 {
425    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
426      {
427         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
428                          "ecore_imf_context_focus_out");
429         return;
430      }
431    if (ctx->klass->focus_out) ctx->klass->focus_out(ctx);
432 }
433
434 /**
435  * Notify the Input Method Context that a change such as a
436  * change in cursor position has been made. This will typically
437  * cause the Input Method Context to clear the preedit state.
438  *
439  * @param ctx An #Ecore_IMF_Context.
440  * @ingroup Ecore_IMF_Context_Group
441  */
442 EAPI void
443 ecore_imf_context_reset(Ecore_IMF_Context *ctx)
444 {
445    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
446      {
447         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
448                          "ecore_imf_context_reset");
449         return;
450      }
451    if (ctx->klass->reset) ctx->klass->reset(ctx);
452 }
453
454 /**
455  * Notify the Input Method Context that a change in the cursor
456  * position has been made.
457  *
458  * @param ctx An #Ecore_IMF_Context.
459  * @param cursor_pos New cursor position in characters.
460  * @ingroup Ecore_IMF_Context_Group
461  */
462 EAPI void
463 ecore_imf_context_cursor_position_set(Ecore_IMF_Context *ctx, int cursor_pos)
464 {
465    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
466      {
467         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
468                          "ecore_imf_context_cursor_position_set");
469         return;
470      }
471    if (ctx->klass->cursor_position_set) ctx->klass->cursor_position_set(ctx, cursor_pos);
472 }
473
474 /**
475  * Set whether the IM context should use the preedit string
476  * to display feedback. If @use_preedit is EINA_FALSE (default
477  * is EINA_TRUE), then the IM context may use some other method to display
478  * feedback, such as displaying it in a child of the root window.
479  *
480  * @param ctx An #Ecore_IMF_Context.
481  * @param use_preedit Whether the IM context should use the preedit string.
482  * @ingroup Ecore_IMF_Context_Group
483  */
484 EAPI void
485 ecore_imf_context_use_preedit_set(Ecore_IMF_Context *ctx, Eina_Bool use_preedit)
486 {
487    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
488      {
489         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
490                          "ecore_imf_context_use_preedit_set");
491         return;
492      }
493    if (ctx->klass->use_preedit_set) ctx->klass->use_preedit_set(ctx, use_preedit);
494 }
495
496 /**
497  * Set the callback to be used on get_surrounding request.
498  *
499  * This callback will be called when the Input Method Context
500  * module requests the surrounding context.
501  *
502  * @param ctx An #Ecore_IMF_Context.
503  * @param func The callback to be called.
504  * @param data The data pointer to be passed to @p func
505  * @ingroup Ecore_IMF_Context_Group
506  */
507 EAPI void
508 ecore_imf_context_retrieve_surrounding_callback_set(Ecore_IMF_Context *ctx, Eina_Bool (*func)(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos), const void *data)
509 {
510    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
511      {
512         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
513                          "ecore_imf_context_retrieve_surrounding_callback_set");
514         return;
515      }
516
517    ctx->retrieve_surrounding_func = func;
518    ctx->retrieve_surrounding_data = (void *) data;
519 }
520
521 /**
522  * Set the input mode used by the Ecore Input Context.
523  *
524  * The input mode can be one of the input modes defined in
525  * #Ecore_IMF_Input_Mode. The default input mode is
526  * ECORE_IMF_INPUT_MODE_FULL.
527  *
528  * @param ctx An #Ecore_IMF_Context.
529  * @param input_mode The input mode to be used by @p ctx.
530  * @ingroup Ecore_IMF_Context_Group
531  */
532 EINA_DEPRECATED EAPI void
533 ecore_imf_context_input_mode_set(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Mode input_mode)
534 {
535    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
536      {
537         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
538                          "ecore_imf_context_input_mode_set");
539         return;
540      }
541    if (ctx->klass->input_mode_set) ctx->klass->input_mode_set(ctx, input_mode);
542    ctx->input_mode = input_mode;
543 }
544
545 /**
546  * Get the input mode being used by the Ecore Input Context.
547  *
548  * See @ref ecore_imf_context_input_mode_set for more details.
549  *
550  * @param ctx An #Ecore_IMF_Context.
551  * @return The input mode being used by @p ctx.
552  * @ingroup Ecore_IMF_Context_Group
553  */
554 EINA_DEPRECATED EAPI Ecore_IMF_Input_Mode
555 ecore_imf_context_input_mode_get(Ecore_IMF_Context *ctx)
556 {
557    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
558      {
559         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
560                          "ecore_imf_context_input_mode_set");
561         return 0;
562      }
563    return ctx->input_mode;
564 }
565
566 /**
567  * Allow an Ecore Input Context to internally handle an event.
568  * If this function returns EINA_TRUE, then no further processing
569  * should be done for this event.
570  *
571  * Input methods must be able to accept all types of events (simply
572  * returning EINA_FALSE if the event was not handled), but there is no
573  * obligation of any events to be submitted to this function.
574  *
575  * @param ctx An #Ecore_IMF_Context.
576  * @param type The type of event defined by #Ecore_IMF_Event_Type.
577  * @param event The event itself.
578  * @return EINA_TRUE if the event was handled; otherwise EINA_FALSE.
579  * @ingroup Ecore_IMF_Context_Group
580  */
581 EAPI Eina_Bool
582 ecore_imf_context_filter_event(Ecore_IMF_Context *ctx, Ecore_IMF_Event_Type type, Ecore_IMF_Event *event)
583 {
584    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
585      {
586         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
587                          "ecore_imf_context_filter_event");
588         return EINA_FALSE;
589      }
590    if (ctx->klass->filter_event) return ctx->klass->filter_event(ctx, type, event);
591    return EINA_FALSE;
592 }
593
594 /**
595  * @defgroup Ecore_IMF_Context_Module_Group Ecore Input Method Context Module Functions
596  *
597  * Functions that should be used by Ecore Input Method Context modules.
598  */
599
600 /**
601  * Creates a new Input Method Context with klass specified by @p ctxc.
602  *
603  * This method should be used by modules implementing the Input
604  * Method Context interface.
605  *
606  * @param ctxc An #Ecore_IMF_Context_Class.
607  * @return A new #Ecore_IMF_Context; on failure it returns NULL.
608  * @ingroup Ecore_IMF_Context_Module_Group
609  */
610 EAPI Ecore_IMF_Context *
611 ecore_imf_context_new(const Ecore_IMF_Context_Class *ctxc)
612 {
613    Ecore_IMF_Context *ctx;
614
615    if (!ctxc) return NULL;
616    ctx = calloc(1, sizeof(Ecore_IMF_Context));
617    if (!ctx) return NULL;
618    ECORE_MAGIC_SET(ctx, ECORE_MAGIC_CONTEXT);
619    ctx->klass = ctxc;
620    ctx->data = NULL;
621    ctx->retrieve_surrounding_func = NULL;
622    ctx->retrieve_surrounding_data = NULL;
623    ctx->input_panel_x = 0;
624    ctx->input_panel_y = 0;
625    ctx->input_panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
626    ctx->input_panel_orient = ECORE_IMF_INPUT_PANEL_ORIENT_NONE;
627    ctx->use_effect = EINA_TRUE;
628    ctx->callbacks = NULL;
629    
630    return ctx;
631 }
632
633 /**
634  * Set the Input Method Context specific data.
635  *
636  * Note that this method should be used by modules to set
637  * the Input Method Context specific data and it's not meant to
638  * be used by applications to store application specific data.
639  *
640  * @param ctx An #Ecore_IMF_Context.
641  * @param data The Input Method Context specific data.
642  * @return A new #Ecore_IMF_Context; on failure it returns NULL.
643  * @ingroup Ecore_IMF_Context_Module_Group
644  */
645 EAPI void
646 ecore_imf_context_data_set(Ecore_IMF_Context *ctx, void *data)
647 {
648    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
649      {
650         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
651                          "ecore_imf_context_data_set");
652         return;
653      }
654    ctx->data = data;
655 }
656
657 /**
658  * Get the Input Method Context specific data.
659  *
660  * See @ref ecore_imf_context_data_set for more details.
661  *
662  * @param ctx An #Ecore_IMF_Context.
663  * @return The Input Method Context specific data.
664  * @ingroup Ecore_IMF_Context_Module_Group
665  */
666 EAPI void *ecore_imf_context_data_get(Ecore_IMF_Context *ctx)
667 {
668    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
669      {
670         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
671                          "ecore_imf_context_data_get");
672         return NULL;
673      }
674    return ctx->data;
675 }
676
677 /**
678  * Retrieve context around insertion point.
679  *
680  * This function is implemented by calling the
681  * Ecore_IMF_Context::retrieve_surrounding_func (
682  * set using #ecore_imf_context_retrieve_surrounding_callback_set).
683  *
684  * There is no obligation for a widget to respond to the
685  * ::retrieve_surrounding_func, so input methods must be prepared
686  * to function without context.
687  *
688  * @param ctx An #Ecore_IMF_Context.
689  * @param text Location to store a UTF-8 encoded string of text
690  *             holding context around the insertion point.
691  *             If the function returns EINA_TRUE, then you must free
692  *             the result stored in this location with free().
693  * @param cursor_pos Location to store the position in characters of
694  *                   the insertion cursor within @text.
695  * @return EINA_TRUE if surrounding text was provided; otherwise EINA_FALSE.
696  * @ingroup Ecore_IMF_Context_Module_Group
697  */
698 EAPI Eina_Bool
699 ecore_imf_context_surrounding_get(Ecore_IMF_Context *ctx, char **text, int *cursor_pos)
700 {
701    int result = EINA_FALSE;
702
703    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
704      {
705         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
706                          "ecore_imf_context_surrounding_get");
707         return EINA_FALSE;
708      }
709
710    if (ctx->retrieve_surrounding_func)
711      {
712         result = ctx->retrieve_surrounding_func(ctx->retrieve_surrounding_data, ctx, text, cursor_pos);
713         if (!result)
714           {
715              if (text) *text = NULL;
716              if (cursor_pos) *cursor_pos = 0;
717           }
718      }
719    return result;
720 }
721
722 static void
723 _ecore_imf_event_free_preedit(void *data __UNUSED__, void *event)
724 {
725    free(event);
726 }
727
728 /**
729  * Adds ECORE_IMF_EVENT_PREEDIT_START to the event queue.
730  * ECORE_IMF_EVENT_PREEDIT_START should be added when a new preedit sequence starts.
731  *
732  * @param ctx An #Ecore_IMF_Context.
733  * @ingroup Ecore_IMF_Context_Module_Group
734  */
735 EAPI void
736 ecore_imf_context_preedit_start_event_add(Ecore_IMF_Context *ctx)
737 {
738    Ecore_IMF_Event_Commit *ev;
739
740    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
741      {
742         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
743                          "ecore_imf_context_preedit_start_event_add");
744         return;
745      }
746
747    ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Start));
748    ev->ctx = ctx;
749    ecore_event_add(ECORE_IMF_EVENT_PREEDIT_START,
750                    ev, _ecore_imf_event_free_preedit, NULL);
751 }
752
753 /**
754  * Adds ECORE_IMF_EVENT_PREEDIT_END to the event queue.
755  * ECORE_IMF_EVENT_PREEDIT_END should be added when a new preedit sequence has been completed or canceled.
756  *
757  * @param ctx An #Ecore_IMF_Context.
758  * @ingroup Ecore_IMF_Context_Module_Group
759  */
760 EAPI void
761 ecore_imf_context_preedit_end_event_add(Ecore_IMF_Context *ctx)
762 {
763    Ecore_IMF_Event_Commit *ev;
764
765    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
766      {
767         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
768                          "ecore_imf_context_preedit_end_event_add");
769         return;
770      }
771
772    ev = malloc(sizeof(Ecore_IMF_Event_Preedit_End));
773    ev->ctx = ctx;
774    ecore_event_add(ECORE_IMF_EVENT_PREEDIT_END,
775                    ev, _ecore_imf_event_free_preedit, NULL);
776 }
777
778 /**
779  * Adds ECORE_IMF_EVENT_PREEDIT_CHANGED to the event queue.
780  *
781  * @param ctx An #Ecore_IMF_Context.
782  * @ingroup Ecore_IMF_Context_Module_Group
783  */
784 EAPI void
785 ecore_imf_context_preedit_changed_event_add(Ecore_IMF_Context *ctx)
786 {
787    Ecore_IMF_Event_Commit *ev;
788
789    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
790      {
791         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
792                          "ecore_imf_context_preedit_changed_event_add");
793         return;
794      }
795
796    ev = malloc(sizeof(Ecore_IMF_Event_Preedit_Changed));
797    ev->ctx = ctx;
798    ecore_event_add(ECORE_IMF_EVENT_PREEDIT_CHANGED,
799                    ev, _ecore_imf_event_free_preedit, NULL);
800 }
801
802 static void
803 _ecore_imf_event_free_commit(void *data __UNUSED__, void *event)
804 {
805    Ecore_IMF_Event_Commit *ev;
806
807    ev = event;
808    if (ev->str) free(ev->str);
809    free(ev);
810 }
811
812 /**
813  * Adds ECORE_IMF_EVENT_COMMIT to the event queue.
814  *
815  * @param ctx An #Ecore_IMF_Context.
816  * @param str The committed string.
817  * @ingroup Ecore_IMF_Context_Module_Group
818  */
819 EAPI void
820 ecore_imf_context_commit_event_add(Ecore_IMF_Context *ctx, const char *str)
821 {
822    Ecore_IMF_Event_Commit *ev;
823
824    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
825      {
826         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
827                          "ecore_imf_context_commit_event_add");
828         return;
829      }
830
831    ev = malloc(sizeof(Ecore_IMF_Event_Commit));
832    ev->ctx = ctx;
833    ev->str = str ? strdup(str) : NULL;
834    ecore_event_add(ECORE_IMF_EVENT_COMMIT,
835                    ev, _ecore_imf_event_free_commit, NULL);
836
837 }
838
839 static void
840 _ecore_imf_event_free_delete_surrounding(void *data __UNUSED__, void *event)
841 {
842    free(event);
843 }
844
845 /**
846  * Asks the widget that the input context is attached to to delete characters around the cursor position 
847  * by adding the ECORE_IMF_EVENT_DELETE_SURROUNDING to the event queue. 
848  * Note that offset and n_chars are in characters not in bytes.
849  *
850  * @param ctx An #Ecore_IMF_Context.
851  * @param offset The start offset of surrounding to be deleted.
852  * @param n_chars The number of characters to be deleted.
853  * @ingroup Ecore_IMF_Context_Module_Group
854  */
855 EAPI void
856 ecore_imf_context_delete_surrounding_event_add(Ecore_IMF_Context *ctx, int offset, int n_chars)
857 {
858    Ecore_IMF_Event_Delete_Surrounding *ev;
859
860    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
861      {
862         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
863                          "ecore_imf_context_delete_surrounding_event_add");
864         return;
865      }
866
867    ev = malloc(sizeof(Ecore_IMF_Event_Delete_Surrounding));
868    ev->ctx = ctx;
869    ev->offset = offset;
870    ev->n_chars = n_chars;
871    ecore_event_add(ECORE_IMF_EVENT_DELETE_SURROUNDING,
872                    ev, _ecore_imf_event_free_delete_surrounding, NULL);
873 }
874
875 /*** ImControl Related APIs */
876 EAPI void  
877 ecore_imf_context_input_panel_show(Ecore_IMF_Context *ctx)
878 {
879    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
880      {
881         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_show");
882         return;
883      }
884
885    if (ctx->klass->show) ctx->klass->show(ctx);
886 }
887
888 EAPI void  
889 ecore_imf_context_input_panel_hide(Ecore_IMF_Context *ctx)
890 {
891    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
892      {
893         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_hide");
894         return;
895      }
896
897    if (ctx->klass->hide) ctx->klass->hide(ctx);
898 }
899
900 EAPI void  
901 ecore_imf_context_control_panel_show (Ecore_IMF_Context *ctx)
902 {
903    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
904      {
905         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_control_panel_show");
906         return;
907      }
908
909    if (ctx->klass->control_panel_show) ctx->klass->control_panel_show(ctx);
910 }
911
912 EAPI void  
913 ecore_imf_context_control_panel_hide (Ecore_IMF_Context *ctx)
914 {
915    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
916      {
917         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_control_panel_hide");
918         return;
919      }
920
921    if (ctx->klass->control_panel_hide) ctx->klass->control_panel_hide(ctx);
922 }
923
924 EAPI void  
925 ecore_imf_context_input_panel_language_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Lang lang)
926 {
927    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
928      {
929         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_language_set");
930         return;
931      }
932    if (ctx->klass->input_panel_language_set) ctx->klass->input_panel_language_set(ctx, lang);
933    ctx->input_panel_lang = lang;   
934 }
935
936 EAPI Ecore_IMF_Input_Panel_Lang  
937 ecore_imf_context_input_panel_language_get (Ecore_IMF_Context *ctx)
938 {
939    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
940      {
941         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_language_get");
942         return ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC;
943      }
944
945    return ctx->input_panel_lang;
946 }
947
948 EAPI int  
949 ecore_imf_context_ise_get_ise_language (Ecore_IMF_Context *ctx, const char* ise_name, char ***langlist)
950 {
951    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
952      {
953         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_ise_language");
954         return -1;
955      }
956
957    if (!ise_name)
958      {
959         printf ("input parameters error!!! \n");
960         return -1;
961      }
962
963    if (ctx->klass->ise_get_ise_language) 
964      {
965         return ctx->klass->ise_get_ise_language(ctx, ise_name, langlist);
966      }
967    else 
968       return -1;
969 }
970
971 EAPI void ecore_imf_context_keyboard_language_set (Ecore_IMF_Context *ctx, Ecore_IMF_Keyboard_Lang lang)
972 {
973    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
974      {
975         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_keyboard_language_set");
976         return;
977      }
978 //   if (ctx->klass->ise_set_language) ctx->klass->ise_set_language(ctx, lang);
979 }
980
981 EAPI Ecore_IMF_Keyboard_Lang ecore_imf_context_keyboard_language_get (Ecore_IMF_Context *ctx)
982 {
983    Ecore_IMF_Keyboard_Lang lang = ECORE_IMF_KEYBOARD_LANG_NATIVE;
984    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
985      {
986         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_keyboard_language_get");
987         return lang;
988      }
989 /*
990    if (ctx->klass->input_panel_language_get) 
991      lang = ctx->klass->input_panel_language_get(ctx);
992 */
993    return lang;
994 }
995
996 EAPI void  
997 ecore_imf_context_ise_set_isf_language (Ecore_IMF_Context *ctx, const char* lang)
998 {
999    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1000      {
1001         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_isf_language");
1002         return;
1003      }
1004
1005    if (!lang)
1006      {
1007         printf ("input parameters error!!! \n");
1008         return;
1009      }
1010
1011    if (ctx->klass->ise_set_isf_language) ctx->klass->ise_set_isf_language(ctx, lang);
1012 }
1013
1014 EAPI void  
1015 ecore_imf_context_input_panel_imdata_set (Ecore_IMF_Context *ctx, const char * data, int len)
1016 {
1017    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1018      {
1019         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_imdata_set");
1020         return;
1021      }
1022
1023    if (!data || len <=0)
1024      {
1025         printf ("input parameters error!!! \n");
1026         return;
1027      }
1028
1029    if (ctx->klass->input_panel_imdata_set) ctx->klass->input_panel_imdata_set(ctx, data, len);
1030 }
1031
1032 EAPI void  
1033 ecore_imf_context_input_panel_imdata_get (Ecore_IMF_Context *ctx, char * data, int *len)
1034 {
1035    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1036      {
1037         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_get_imdata");
1038         return;
1039      }
1040
1041    if (!data)
1042      {
1043         printf ("input parameters error!!! \n");
1044         return;
1045      }
1046
1047    if (ctx->klass->input_panel_imdata_get) ctx->klass->input_panel_imdata_get(ctx, data, len);
1048 }
1049
1050 EAPI void  
1051 ecore_imf_context_input_panel_use_effect_set (Ecore_IMF_Context *ctx, Eina_Bool use_effect)
1052 {
1053    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1054      {
1055         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_use_effect_set");
1056         return;
1057      }
1058
1059    if (ctx->klass->input_panel_use_effect_set) ctx->klass->input_panel_use_effect_set(ctx, use_effect);
1060    ctx->use_effect = use_effect;
1061 }
1062
1063 EAPI Eina_Bool  
1064 ecore_imf_context_input_panel_use_effect_get (Ecore_IMF_Context *ctx)
1065 {
1066    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1067      {
1068         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_use_effect_get");
1069         return EINA_TRUE;
1070      }
1071
1072    return ctx->use_effect;
1073 }
1074
1075 EAPI void  
1076 ecore_imf_context_input_panel_geometry_get (Ecore_IMF_Context *ctx, int *x, int *y, int *w, int *h)
1077 {
1078    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1079      {
1080         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_geometry_get");
1081         return;
1082      }
1083
1084    if (ctx->klass->input_panel_geometry_get) ctx->klass->input_panel_geometry_get(ctx, x, y, w, h);
1085 }
1086
1087 EAPI void  
1088 ecore_imf_context_input_panel_private_key_set (Ecore_IMF_Context *ctx, int layout_index, int key_index, const char *img_path, const char* label, int key_value, const char* key_string)
1089 {
1090    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1091      {
1092         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_private_key_set");
1093         return;
1094      }
1095
1096    if (label == NULL && img_path == NULL)
1097      {
1098         printf ("input parameters error!!! \n");
1099         return;
1100      }
1101
1102    Private_Key_Item *key_item;
1103    Eina_List *l;
1104    Eina_Bool exist = EINA_FALSE;
1105
1106    EINA_LIST_FOREACH(ctx->private_key_list, l, key_item)
1107      {
1108         if (key_item && key_item->layout_idx == layout_index && key_item->key_idx == key_index)
1109           {
1110              // if exist in the list
1111              exist = EINA_TRUE;   
1112              if (label)
1113                {
1114                   key_item->type = 0;
1115                   strcpy(key_item->data, label);
1116                }                        
1117              else
1118                {
1119                   key_item->type = 1;
1120                   strcpy(key_item->data, img_path);
1121                }
1122              key_item->key_value = key_value;
1123              strcpy(key_item->key_string, key_string);
1124           }
1125      }
1126
1127    if (!exist)
1128      {
1129         key_item = calloc(1, sizeof(Private_Key_Item));
1130         if (!key_item) return;
1131
1132         key_item->layout_idx = layout_index;
1133         key_item->key_idx = key_index;;
1134         if (label)
1135           {
1136              key_item->type = 0;
1137              strcpy(key_item->data, label);
1138           }                     
1139         else
1140           {
1141              key_item->type = 1;
1142              strcpy(key_item->data, img_path);
1143           }
1144         key_item->key_value = key_value;
1145
1146         if (key_string)
1147           {
1148              strcpy(key_item->key_string, key_string);
1149           }
1150
1151         ctx->private_key_list = eina_list_append(ctx->private_key_list, key_item);
1152      }
1153
1154 //   if (ctx->klass->input_panel_private_key_set) ctx->klass->input_panel_private_key_set(ctx, layout_index, key_index, img_path, label, value);
1155 }
1156
1157 EAPI Eina_List *
1158 ecore_imf_context_input_panel_private_key_list_get  (Ecore_IMF_Context *ctx)
1159 {
1160    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1161      {
1162         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_private_key_list_get");
1163         return NULL;
1164      }
1165
1166    return ctx->private_key_list;
1167 }
1168
1169 EAPI void  
1170 ecore_imf_context_input_panel_key_disabled_set (Ecore_IMF_Context *ctx, int layout_index, int key_index, Eina_Bool disabled)
1171 {
1172    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1173      {
1174         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_key_disabled_set");
1175         return;
1176      }
1177
1178    Disable_Key_Item *key_item;
1179    Eina_List *l;
1180    Eina_Bool exist = EINA_FALSE;
1181
1182    EINA_LIST_FOREACH(ctx->disabled_key_list, l, key_item)
1183      {
1184         if (key_item && key_item->layout_idx == layout_index && key_item->key_idx == key_index)
1185           {
1186              key_item->disabled = disabled;
1187              exist = EINA_TRUE;
1188           }
1189      }
1190
1191    if (!exist)
1192      {
1193         key_item = calloc(1, sizeof(Disable_Key_Item));
1194         if (!key_item) return;
1195
1196         key_item->layout_idx = layout_index;
1197         key_item->key_idx = key_index;;
1198         key_item->disabled = disabled;
1199
1200         ctx->disabled_key_list = eina_list_append(ctx->disabled_key_list, key_item);
1201      }
1202
1203 //   if (ctx->klass->input_panel_key_disabled_set) ctx->klass->input_panel_key_disabled_set(ctx, layout_index, key_index, disabled);
1204 }
1205
1206 EAPI Eina_List *
1207 ecore_imf_context_input_panel_key_disabled_list_get  (Ecore_IMF_Context *ctx)
1208 {
1209         return ctx->disabled_key_list;
1210 }
1211
1212 EAPI void  
1213 ecore_imf_context_input_panel_layout_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Layout layout)
1214 {
1215    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1216      {
1217         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_layout_set");
1218         return;
1219      }
1220
1221    if (ctx->klass->input_panel_layout_set) ctx->klass->input_panel_layout_set(ctx, layout);
1222    ctx->input_panel_layout = layout;
1223 }
1224
1225 EAPI Ecore_IMF_Input_Panel_Layout
1226 ecore_imf_context_input_panel_layout_get  (Ecore_IMF_Context *ctx)
1227 {
1228    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1229      {
1230         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_layout_get");
1231         return ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID;
1232      }
1233
1234    if (ctx->klass->input_panel_layout_get ) 
1235      {
1236         //      ctx->klass->input_panel_layout_get (ctx, &layout);
1237         return ctx->input_panel_layout;
1238      }
1239    else
1240      return ECORE_IMF_INPUT_PANEL_LAYOUT_INVALID;
1241 }
1242
1243 EAPI void      
1244 ecore_imf_context_input_panel_reset (Ecore_IMF_Context *ctx)
1245 {
1246    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1247      {
1248         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_reset");
1249         return;
1250      }
1251
1252    if (ctx->klass->input_panel_reset) ctx->klass->input_panel_reset(ctx);
1253 }
1254
1255 EAPI void      
1256 ecore_imf_context_input_panel_orient_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Orient orientation)
1257 {
1258    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1259      {
1260         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_orient_set");
1261         return;
1262      }
1263
1264    if (ctx->klass->input_panel_orient_set) ctx->klass->input_panel_orient_set(ctx, orientation*90);
1265    ctx->input_panel_orient = orientation;
1266 }
1267
1268 EAPI Ecore_IMF_Input_Panel_Orient 
1269 ecore_imf_context_input_panel_orient_get (Ecore_IMF_Context *ctx)
1270 {
1271    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1272      {
1273         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_orient_get");
1274         return ECORE_IMF_INPUT_PANEL_ORIENT_NONE;
1275      }
1276
1277    return ctx->input_panel_orient;
1278 }
1279
1280 EAPI void      
1281 ecore_imf_context_ise_get_active_isename (Ecore_IMF_Context *ctx, char* name)
1282 {
1283    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1284      {
1285         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_active_isename");
1286         return;
1287      }
1288
1289    if (!name)
1290      {
1291         printf ("input parameters error!!! \n");
1292         return;
1293      }
1294
1295    if (ctx->klass->ise_get_active_isename) ctx->klass->ise_get_active_isename(ctx, name);
1296 }
1297     
1298 EAPI void      
1299 ecore_imf_context_ise_set_active_ise_by_name (Ecore_IMF_Context *ctx, const char* name)
1300 {
1301    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1302      {
1303         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_active_ise_by_name");
1304         return;
1305      }
1306    if (!name)
1307      {
1308         printf ("input parameters error!!! \n");
1309         return;
1310      }
1311
1312    if (ctx->klass->ise_set_active_ise_by_name) ctx->klass->ise_set_active_ise_by_name(ctx, name);
1313 }
1314     
1315 EAPI void      
1316 ecore_imf_context_ise_set_active_ise_by_uuid (Ecore_IMF_Context *ctx, const char* uuid)
1317 {
1318    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1319      {
1320         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_set_active_ise_by_uuid");
1321         return;
1322      }
1323    if (!uuid)
1324      {
1325         printf ("input parameters error!!! \n");
1326         return;
1327      }
1328
1329    if (ctx->klass->ise_set_active_ise_by_uuid) ctx->klass->ise_set_active_ise_by_uuid(ctx, uuid);
1330 }
1331
1332 EAPI int      
1333 ecore_imf_context_ise_get_iselist (Ecore_IMF_Context *ctx,  char*** iselist)
1334 {
1335    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1336      {
1337         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_ise_get_iselist");
1338         return -1;
1339      }  
1340
1341    if (ctx->klass->ise_get_iselist) 
1342      {
1343         return ctx->klass->ise_get_iselist(ctx, iselist);
1344      }
1345    else 
1346      return -1;
1347 }
1348
1349 EAPI Ecore_IMF_Input_Panel_State      
1350 ecore_imf_context_input_panel_state_get (Ecore_IMF_Context *ctx)
1351 {
1352    Ecore_IMF_Input_Panel_State state = ECORE_IMF_INPUT_PANEL_STATE_INVALID;
1353    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1354      {
1355         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_state_get");
1356         return ECORE_IMF_INPUT_PANEL_STATE_INVALID;
1357      }
1358
1359    if (ctx->klass->input_panel_state_get) 
1360      {
1361         state = ctx->klass->input_panel_state_get(ctx);
1362      }
1363    
1364    return state;   
1365 }
1366
1367 EAPI void      
1368 ecore_imf_context_input_panel_event_callback_add (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*pEventCallBackFunc) (void *data, Ecore_IMF_Context *ctx, int value), const void *data)
1369 {
1370    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1371      {
1372         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_add");
1373         return;
1374      }
1375
1376    if (ctx->klass->input_panel_event_callback_add) 
1377      {
1378         ctx->klass->input_panel_event_callback_add(ctx, type, pEventCallBackFunc, data);
1379      }
1380 }
1381
1382 EAPI void
1383 ecore_imf_context_input_panel_event_callback_del (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*pEventCallBackFunc) (void *data, Ecore_IMF_Context *ctx, int value))
1384 {
1385    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1386      {
1387         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_del");
1388         return;
1389      }
1390
1391    if (ctx->klass->input_panel_event_callback_del) 
1392      {
1393         ctx->klass->input_panel_event_callback_del(ctx, type, pEventCallBackFunc);
1394      }
1395 }
1396
1397 EAPI void      
1398 ecore_imf_context_input_panel_move (Ecore_IMF_Context *ctx, int x, int y)
1399 {
1400    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1401      {
1402         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_move");
1403         return;
1404      }
1405
1406    if (ctx->klass->input_panel_move) ctx->klass->input_panel_move(ctx, x, y);
1407    ctx->input_panel_x = x;
1408    ctx->input_panel_y = y;
1409 }
1410
1411 EAPI void      
1412 ecore_imf_context_input_panel_caps_mode_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Caps_Mode mode)
1413 {
1414    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1415      {
1416         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_caps_mode_set");
1417         return;
1418      }
1419
1420    if (ctx->klass->input_panel_caps_mode_set) ctx->klass->input_panel_caps_mode_set(ctx, mode);
1421 }