upload tizen1.0 source
[profile/ivi/isf.git] / ism / demos / isf_return_key_disable_efl.cpp
1 /*
2  * ISF(Input Service Framework)
3  *
4  * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
5  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6  *
7  * Contact: Shuo Liu <shuo0805.liu@samsung.com>, Jihoon Kim <jihoon48.kim@samsung.com>
8  *
9  * This library is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Lesser General Public License as published by the
11  * Free Software Foundation; either version 2.1 of the License, or (at your option)
12  * any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
15  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this library; if not, write to the Free Software Foundation, Inc., 51
21  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24
25 #include "isf_demo_efl.h"
26 #include "isf_return_key_disable_efl.h"
27
28 static void
29 _cursor_changed_cb(void *data, Evas_Object *obj, void *event_info)
30 {
31     Evas_Object *en = obj;
32
33     int pos = elm_entry_cursor_pos_get (en);
34
35     if (pos == 0) {
36         elm_entry_input_panel_return_key_disabled_set (en, EINA_TRUE);
37     }
38     else {
39         elm_entry_input_panel_return_key_disabled_set (en, EINA_FALSE);
40     }
41 }
42
43 static Evas_Object *_create_ef_layout (Evas_Object *parent, const char *label, const char *guide_text)
44 {
45     Evas_Object *ef = NULL;
46     ef = _create_ef(parent,label,guide_text);
47     Evas_Object *en = elm_object_part_content_get(ef,"elm.swallow.content");
48     evas_object_smart_callback_add (en, "cursor,changed", _cursor_changed_cb, NULL);
49
50     return ef;
51 }
52
53 static void add_layout_to_conformant (void *data, Evas_Object *lay_in, const char *title)
54 {
55    Evas_Object *scroller = NULL;
56    Evas_Object *win = NULL;
57    Evas_Object *conform = NULL;
58    struct appdata *ad = NULL;
59
60    ad = (struct appdata *) data;
61
62    win = ad->win_main;
63    // Enabling illume notification property for window
64    elm_win_conformant_set (win, EINA_TRUE);
65
66    // Creating conformant widget
67    conform = elm_conformant_add (win);
68    evas_object_size_hint_weight_set (conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
69    evas_object_show (conform);
70
71    scroller = elm_scroller_add (ad->naviframe);
72
73    elm_scroller_bounce_set (scroller, EINA_FALSE, EINA_TRUE);
74    evas_object_show (scroller);
75
76    elm_object_content_set (scroller, lay_in);
77    elm_object_content_set (conform, scroller);
78    elm_naviframe_item_push (ad->naviframe, title, NULL, NULL, conform, NULL);
79 }
80
81 static Evas_Object * create_inner_layout (void *data)
82 {
83     struct appdata *ad = (struct appdata *)data;
84     Evas_Object *bx = NULL ;
85     Evas_Object *ef = NULL ;
86
87     Evas_Object *parent = ad->naviframe;
88
89     bx = elm_box_add (parent);
90     evas_object_size_hint_weight_set (bx, EVAS_HINT_EXPAND, 0.0);
91     evas_object_size_hint_align_set (bx, EVAS_HINT_FILL, 0.0);
92     evas_object_show (bx);
93
94     /* Prediction allow : TRUE */
95     ef = _create_ef_layout (parent, _("Return Key Disable"), _("Return Key will be activated when any key is pressed"));
96     elm_box_pack_end (bx, ef);
97
98     return bx;
99 }
100
101 void ise_return_key_disable_bt (void *data, Evas_Object *obj, void *event_info)
102 {
103     Evas_Object *lay_inner = create_inner_layout (data);
104     add_layout_to_conformant (data, lay_inner, _("Return Key Disable"));
105 }
106
107 /*
108 vi:ts=4:ai:nowrap:expandtab
109 */