elementary/map - map supports language,changed
[framework/uifw/elementary.git] / src / lib / elm_inwin.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3 #include "elm_widget_inwin.h"
4
5 EAPI const char ELM_INWIN_SMART_NAME[] = "elm_inwin";
6
7 EVAS_SMART_SUBCLASS_NEW
8   (ELM_INWIN_SMART_NAME, _elm_inwin, Elm_Inwin_Smart_Class,
9   Elm_Layout_Smart_Class, elm_layout_smart_class_get, NULL);
10
11 static const Elm_Layout_Part_Alias_Description _content_aliases[] =
12 {
13    {"default", "elm.swallow.content"},
14    {NULL, NULL}
15 };
16
17 static void
18 _elm_inwin_smart_sizing_eval(Evas_Object *obj)
19 {
20    Evas_Object *content;
21    Evas_Coord minw = -1, minh = -1;
22
23    ELM_INWIN_DATA_GET(obj, sd);
24
25    content = elm_layout_content_get(obj, NULL);
26
27    if (!content) return;
28
29    evas_object_size_hint_min_get(content, &minw, &minh);
30    edje_object_size_min_calc(ELM_WIDGET_DATA(sd)->resize_obj, &minw, &minh);
31
32    evas_object_size_hint_min_set(obj, minw, minh);
33    evas_object_size_hint_max_set(obj, -1, -1);
34 }
35
36 static Eina_Bool
37 _elm_inwin_smart_focus_next(const Evas_Object *obj,
38                             Elm_Focus_Direction dir,
39                             Evas_Object **next)
40 {
41    Evas_Object *content;
42
43    content = elm_layout_content_get(obj, NULL);
44
45    /* attempt to follow focus cycle into sub-object */
46    if (content)
47      {
48         elm_widget_focus_next_get(content, dir, next);
49         if (*next)
50           return EINA_TRUE;
51      }
52
53    *next = (Evas_Object *)obj;
54    return EINA_FALSE;
55 }
56
57 static void
58 _elm_inwin_smart_add(Evas_Object *obj)
59 {
60    EVAS_SMART_DATA_ALLOC(obj, Elm_Inwin_Smart_Data);
61
62    ELM_WIDGET_CLASS(_elm_inwin_parent_sc)->base.add(obj);
63
64    elm_widget_can_focus_set(obj, EINA_FALSE);
65    elm_widget_highlight_ignore_set(obj, EINA_TRUE);
66
67    evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
68    evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
69    elm_layout_theme_set(obj, "win", "inwin", elm_object_style_get(obj));
70 }
71
72 static void
73 _elm_inwin_smart_parent_set(Evas_Object *obj,
74                             Evas_Object *parent)
75 {
76    elm_win_resize_object_add(parent, obj);
77
78    elm_layout_sizing_eval(obj);
79 }
80
81 static void
82 _elm_inwin_smart_set_user(Elm_Inwin_Smart_Class *sc)
83 {
84    ELM_WIDGET_CLASS(sc)->base.add = _elm_inwin_smart_add;
85
86    ELM_WIDGET_CLASS(sc)->focus_next = _elm_inwin_smart_focus_next;
87    ELM_WIDGET_CLASS(sc)->parent_set = _elm_inwin_smart_parent_set;
88
89    ELM_LAYOUT_CLASS(sc)->sizing_eval = _elm_inwin_smart_sizing_eval;
90
91    ELM_LAYOUT_CLASS(sc)->content_aliases = _content_aliases;
92 }
93
94 EAPI const Elm_Inwin_Smart_Class *
95 elm_inwin_smart_class_get(void)
96 {
97    static Elm_Inwin_Smart_Class _sc =
98      ELM_INWIN_SMART_CLASS_INIT_NAME_VERSION(ELM_INWIN_SMART_NAME);
99    static const Elm_Inwin_Smart_Class *class = NULL;
100
101    if (class)
102      return class;
103
104    _elm_inwin_smart_set(&_sc);
105    class = &_sc;
106
107    return class;
108 }
109
110 EAPI Evas_Object *
111 elm_win_inwin_add(Evas_Object *parent)
112 {
113    Evas_Object *obj;
114
115    if (!parent || !elm_widget_type_check((parent), "elm_win", __func__))
116      return NULL;  /* *has* to have a parent window */
117
118    obj = elm_widget_add(_elm_inwin_smart_class_new(), parent);
119    if (!obj) return NULL;
120
121    if (!elm_widget_sub_object_add(parent, obj))
122      ERR("could not add %p as sub object of %p", obj, parent);
123
124    return obj;
125 }
126
127 EAPI void
128 elm_win_inwin_activate(Evas_Object *obj)
129 {
130    ELM_INWIN_CHECK(obj);
131    ELM_INWIN_DATA_GET_OR_RETURN(obj, sd);
132
133    evas_object_raise(obj);
134    evas_object_show(obj);
135    edje_object_signal_emit
136      (ELM_WIDGET_DATA(sd)->resize_obj, "elm,action,show", "elm");
137    elm_object_focus_set(obj, EINA_TRUE);
138 }
139
140 EAPI void
141 elm_win_inwin_content_set(Evas_Object *obj,
142                           Evas_Object *content)
143 {
144    ELM_INWIN_CHECK(obj);
145    ELM_INWIN_DATA_GET_OR_RETURN(obj, sd);
146
147    ELM_CONTAINER_CLASS(_elm_inwin_parent_sc)->content_set(obj, NULL, content);
148 }
149
150 EAPI Evas_Object *
151 elm_win_inwin_content_get(const Evas_Object *obj)
152 {
153    ELM_INWIN_CHECK(obj) NULL;
154    ELM_INWIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
155
156    return ELM_CONTAINER_CLASS(_elm_inwin_parent_sc)->content_get(obj, NULL);
157 }
158
159 EAPI Evas_Object *
160 elm_win_inwin_content_unset(Evas_Object *obj)
161 {
162    ELM_INWIN_CHECK(obj) NULL;
163    ELM_INWIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
164
165    return ELM_CONTAINER_CLASS(_elm_inwin_parent_sc)->content_unset(obj, NULL);
166 }