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