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