0d6cc638db3c2eeccf28184ebf3428ae28317920
[framework/uifw/elementary.git] / src / lib / elm_navigationbar_ex.c
1 #include <Elementary.h>\r
2 #include "elm_priv.h"\r
3 \r
4 /**\r
5  * @defgroup Navigationbar_ex Navigationbar_ex\r
6  * @ingroup Elementary\r
7  *\r
8  * The NavigationBar_ex is an object that allows flipping (with animation) between 1 or\r
9  * more pages of objects, much like a stack of windows within the window as well display\r
10  * the title area for the page consisting of buttons, title, titleobjects etc:-.\r
11  *\r
12  * Objects can be pushed or popped from the stack or deleted as normal.\r
13  * Pushes and pops will animate and a pop will delete the object once the\r
14  * animation is finished if delete_on_pop is set else the content is unset and the \r
15  * content pointer is sent as event information in the hide,finished signal.  \r
16  * Any object in the Navigationbar_ex can be promoted to the top\r
17  * (from its current stacking position) as well. Objects are pushed to the\r
18  * top with elm_navigationbar_ex_item_push() and when the top item is no longer\r
19  * wanted, simply pop it with elm_navigationbar_ex_item_pop() and it will also be\r
20  * deleted/unset depending on delete_on_pop variable. \r
21  * Any object you wish to promote to the top that is already in the\r
22  * navigationbar, simply use elm_navigationbar_ex_item_promote(). If an object is no longer\r
23  * needed and is not the top item, just delete it as normal. You can query\r
24  * which objects are the top and bottom with elm_navigationbar_ex_item_bottom_get()\r
25  * and elm_navigationbar_ex_item_top_get().\r
26  */\r
27 \r
28 typedef struct _Widget_Data Widget_Data;\r
29 typedef struct _function_button fn_button;\r
30 \r
31 \r
32 \r
33 struct _Widget_Data\r
34 {\r
35    Eina_List *stack, *to_delete;\r
36    Elm_Navigationbar_ex_Item *top;\r
37    Evas_Object *rect, *clip;\r
38    Eina_Bool del_on_pop : 1;\r
39 };\r
40 \r
41 struct _Elm_Navigationbar_ex_Item\r
42 {\r
43    Evas_Object *obj, *base, *content;\r
44    Evas_Coord minw, minh;\r
45    const char *title;\r
46    const char *subtitle;\r
47    const char *item_style;\r
48    Eina_List *fnbtn_list;\r
49    Evas_Object *title_obj;\r
50    Evas_Object *icon;\r
51    Eina_Bool popme : 1;\r
52 };\r
53 \r
54 struct _function_button\r
55 {\r
56         Evas_Object *btn;\r
57         int btn_id;\r
58 };\r
59 \r
60 static const char *widtype = NULL;\r
61 static void _del_hook(Evas_Object *obj);\r
62 static void _theme_hook(Evas_Object *obj);\r
63 static void _sizing_eval(Evas_Object *obj);\r
64 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);\r
65 static void _sub_del(void *data, Evas_Object *obj, void *event_info);\r
66 \r
67 \r
68 static void\r
69 _del_hook(Evas_Object *obj)\r
70 {\r
71         Widget_Data *wd = elm_widget_data_get(obj);\r
72         if (!wd) return;\r
73         free(wd);\r
74 }\r
75 \r
76 \r
77 static Evas_Object*\r
78 _content_unset(Elm_Navigationbar_ex_Item* item)\r
79 {\r
80         if(!item) return NULL;\r
81         Evas_Object *content = NULL;\r
82         if(!item->content) return NULL; \r
83         content = item->content;\r
84         elm_widget_sub_object_del(item->obj,item->content);\r
85         edje_object_part_unswallow(item->base,item->content);   \r
86         item->content = NULL;\r
87         evas_object_hide(content);\r
88         return content;\r
89 }\r
90 \r
91 static void\r
92 _theme_hook(Evas_Object *obj)\r
93 {\r
94    Widget_Data *wd = elm_widget_data_get(obj);\r
95    Eina_List *l;\r
96    char buf_fn[1024];\r
97    Elm_Navigationbar_ex_Item *it;\r
98    if (!wd) return;\r
99    EINA_LIST_FOREACH(wd->stack, l, it)\r
100         {\r
101         Eina_List *bl;\r
102         fn_button *btn;\r
103      edje_object_scale_set(it->base, elm_widget_scale_get(obj) * \r
104                            _elm_config->scale);\r
105          EINA_LIST_FOREACH(it->fnbtn_list, bl, btn)\r
106                 {\r
107                         if(btn->btn_id == ELM_NAVIGATIONBAR_EX_BACK_BUTTON)\r
108                                 {\r
109                                         snprintf(buf_fn, sizeof(buf_fn), "navigationbar_backbutton/%s", elm_widget_style_get(obj));\r
110                                         elm_object_style_set(btn->btn, buf_fn);\r
111                                 }\r
112                         else\r
113                                 {\r
114                                         snprintf(buf_fn, sizeof(buf_fn), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));\r
115                                         elm_object_style_set(btn->btn, buf_fn);\r
116                                 }\r
117                 }\r
118         }\r
119    _sizing_eval(obj);\r
120 }\r
121 \r
122 static void\r
123 _sizing_eval(Evas_Object *obj)\r
124 {\r
125    Widget_Data *wd = elm_widget_data_get(obj);\r
126    Evas_Coord minw = -1, minh = -1;\r
127    Eina_List *l;\r
128    Elm_Navigationbar_ex_Item *it;\r
129    if (!wd) return;\r
130    EINA_LIST_FOREACH(wd->stack, l, it)\r
131      {\r
132         if (it->minw > minw) minw = it->minw;\r
133         if (it->minh > minh) minh = it->minh;\r
134      }\r
135    evas_object_size_hint_min_set(obj, minw, minh);\r
136    evas_object_size_hint_max_set(obj, -1, -1);\r
137 }\r
138 \r
139 static void\r
140 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)\r
141 {\r
142    Elm_Navigationbar_ex_Item *it = data;\r
143    Evas_Coord minw = -1, minh = -1;\r
144    evas_object_size_hint_min_get(it->content, &minw, &minh);\r
145    // FIXME: why is this needed? how does edje get this unswallowed or\r
146    // lose its callbacks to edje\r
147    edje_object_part_swallow(it->base, "elm.swallow.content", it->content);\r
148    edje_object_size_min_calc(it->base, &it->minw, &it->minh);\r
149    _sizing_eval(it->obj);\r
150 }\r
151 \r
152 static void\r
153 _eval_top(Evas_Object *obj, Eina_Bool push)\r
154 {\r
155    Widget_Data *wd = elm_widget_data_get(obj);\r
156    Eina_Bool animate=EINA_TRUE;\r
157    Elm_Navigationbar_ex_Item *ittop;\r
158    if (!wd) return;\r
159    if (!wd->stack) return;\r
160    ittop = eina_list_last(wd->stack)->data;\r
161    if (ittop != wd->top)\r
162      {\r
163         Evas_Object *o;\r
164         const char *onshow, *onhide;\r
165 \r
166         if (wd->top)\r
167           {\r
168              o = wd->top->base;\r
169              edje_object_signal_emit(o, "elm,action,hide", "elm");\r
170              onhide = edje_object_data_get(o, "onhide");\r
171              if (onhide)\r
172                {\r
173                   if (!strcmp(onhide, "raise")) evas_object_raise(o);\r
174                   else if (!strcmp(onhide, "lower")) evas_object_lower(o);\r
175                }\r
176           }\r
177         else\r
178           {\r
179              animate = EINA_FALSE;\r
180           }\r
181         wd->top = ittop;\r
182         o = wd->top->base;\r
183         evas_object_show(o);\r
184         if(animate)\r
185                 {\r
186                 if(push)\r
187           edje_object_signal_emit(o, "elm,action,show,push", "elm");\r
188                 else\r
189           edje_object_signal_emit(o, "elm,action,show,pop", "elm");\r
190                 }\r
191         else\r
192           edje_object_signal_emit(o, "elm,action,show,noanimate", "elm");\r
193         onshow = edje_object_data_get(o, "onshow");\r
194         if (onshow)\r
195           {\r
196              if (!strcmp(onshow, "raise")) evas_object_raise(o);\r
197              else if (!strcmp(onshow, "lower")) evas_object_lower(o);            \r
198           }\r
199      }\r
200 }\r
201 \r
202 static void\r
203 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)\r
204 {\r
205    Widget_Data *wd = elm_widget_data_get(data);\r
206    Evas_Coord x, y;\r
207    Eina_List *l;\r
208    Elm_Navigationbar_ex_Item *it;\r
209    if (!wd) return;\r
210    evas_object_geometry_get(obj, &x, &y, NULL, NULL);\r
211    EINA_LIST_FOREACH(wd->stack, l, it)\r
212      evas_object_move(it->base, x, y);\r
213 }\r
214 \r
215 static void\r
216 _sub_del(void *data, Evas_Object *obj __UNUSED__, void *event_info)\r
217 {\r
218    Widget_Data *wd = elm_widget_data_get(data);\r
219    Evas_Object *sub = event_info;\r
220    Eina_List *l,*list;\r
221    fn_button *btn_data;\r
222    Elm_Navigationbar_ex_Item *it;\r
223    if (!wd) return;\r
224    EINA_LIST_FOREACH(wd->stack, l, it)\r
225      {\r
226         if (it->content == sub)\r
227           {\r
228             wd->stack = eina_list_remove_list(wd->stack, l);\r
229             evas_object_event_callback_del_full\r
230                (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);\r
231                 if (it->title) eina_stringshare_del(it->title);\r
232                 if (it->subtitle) eina_stringshare_del(it->subtitle);\r
233                 EINA_LIST_FOREACH(it->fnbtn_list, list, btn_data)\r
234                         {\r
235                                 evas_object_del(btn_data->btn);\r
236                                 free(btn_data);\r
237                                 btn_data = NULL;\r
238                         }\r
239                 if(it->item_style) eina_stringshare_del(it->item_style);\r
240                 if(it->title_obj) evas_object_del(it->title_obj);\r
241              evas_object_del(it->base);\r
242              _eval_top(it->obj, EINA_FALSE);\r
243              free(it);\r
244              return;\r
245           }\r
246      }\r
247 }\r
248 \r
249 static void\r
250 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)\r
251 {   \r
252    Widget_Data *wd = elm_widget_data_get(data);\r
253    Evas_Coord w, h;\r
254    Eina_List *l;\r
255    Elm_Navigationbar_ex_Item *it;\r
256    if (!wd) return;\r
257    evas_object_geometry_get(obj, NULL, NULL, &w, &h);\r
258    EINA_LIST_FOREACH(wd->stack, l, it) evas_object_resize(it->base, w, h);\r
259 }\r
260 \r
261 static void\r
262 _signal_hide_finished(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)\r
263 {\r
264    Elm_Navigationbar_ex_Item *it = data;\r
265    Evas_Object *obj2 = it->obj;\r
266    Widget_Data *wd = elm_widget_data_get(it->obj);\r
267    evas_object_hide(it->base);\r
268    edje_object_signal_emit(it->base, "elm,action,reset", "elm");\r
269    evas_object_smart_callback_call(obj2, "hide,finished", it->content);\r
270    edje_object_message_signal_process(it->base);\r
271    if(it->popme)\r
272         {\r
273                 if(wd->del_on_pop)\r
274                         {\r
275                                 evas_object_del(it->content);\r
276                         }\r
277                 else\r
278                         {\r
279                                 _content_unset(it);\r
280                         }\r
281         }\r
282    _sizing_eval(obj2);\r
283 }\r
284 \r
285 static void _item_promote(Elm_Navigationbar_ex_Item* item)\r
286 {\r
287    if(!item) return;\r
288    Widget_Data *wd = elm_widget_data_get(item->obj);\r
289    Eina_List *l;\r
290    Elm_Navigationbar_ex_Item *it;\r
291    if (!wd) return;\r
292    EINA_LIST_FOREACH(wd->stack, l, it)\r
293      {\r
294         if (it == item)\r
295           {\r
296              wd->stack = eina_list_remove_list(wd->stack, l);\r
297              wd->stack = eina_list_append(wd->stack, it);\r
298              _eval_top(it->obj, EINA_FALSE);\r
299              return;\r
300           }\r
301      }\r
302 }\r
303 \r
304 static void\r
305 _process_deletions(Widget_Data *wd)\r
306 {\r
307         if (!wd) return;        \r
308         Elm_Navigationbar_ex_Item *it;  \r
309         fn_button *btn_data;\r
310         Eina_List *list;\r
311         EINA_LIST_FREE(wd->to_delete, it)\r
312                 {\r
313                         evas_object_event_callback_del_full\r
314                                                   (it->content, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);\r
315                         if (it->title) eina_stringshare_del(it->title);\r
316                         if (it->subtitle) eina_stringshare_del(it->subtitle);\r
317                         if(it->item_style) eina_stringshare_del(it->item_style);\r
318                         EINA_LIST_FOREACH(it->fnbtn_list, list, btn_data)\r
319                                 {\r
320                                         evas_object_del(btn_data->btn);\r
321                                         free(btn_data);\r
322                                         btn_data = NULL;\r
323                                 }\r
324                         if(it->title_obj) evas_object_del(it->title_obj);               \r
325                         if(it->content)  evas_object_del(it->content);\r
326                         evas_object_del(it->base);\r
327                         _eval_top(it->obj, EINA_FALSE);\r
328                         free(it);\r
329                         it = NULL;\r
330                 }       \r
331 }\r
332 \r
333 /**\r
334  * Add a new navigationbar_ex to the parent\r
335  *\r
336  * @param[in] parent The parent object\r
337  * @return The new object or NULL if it cannot be created\r
338  *\r
339  * @ingroup Navigationbar_ex\r
340  */\r
341 EAPI Evas_Object *\r
342 elm_navigationbar_ex_add(Evas_Object *parent)\r
343 {\r
344    Evas_Object *obj;\r
345    Evas *e;\r
346    Widget_Data *wd;\r
347 \r
348    wd = ELM_NEW(Widget_Data);\r
349    e = evas_object_evas_get(parent);\r
350    obj = elm_widget_add(e);\r
351    ELM_SET_WIDTYPE(widtype, "navigationbar_ex");\r
352    elm_widget_type_set(obj, "navigationbar_ex");\r
353    elm_widget_sub_object_add(parent, obj);\r
354    elm_widget_data_set(obj, wd);\r
355    elm_widget_del_hook_set(obj, _del_hook);\r
356    elm_widget_theme_hook_set(obj, _theme_hook);\r
357 \r
358    wd->clip = evas_object_rectangle_add(e);\r
359    elm_widget_resize_object_set(obj, wd->clip);\r
360    elm_widget_sub_object_add(obj, wd->clip);\r
361 \r
362    wd->rect = evas_object_rectangle_add(e);\r
363    elm_widget_sub_object_add(obj, wd->rect);\r
364    evas_object_color_set(wd->rect, 255, 255, 255, 0); \r
365    evas_object_clip_set(wd->rect, wd->clip);\r
366 \r
367    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, obj);\r
368    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);\r
369 \r
370    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);\r
371    wd->del_on_pop = EINA_TRUE;\r
372    _sizing_eval(obj);\r
373    return obj;\r
374 }\r
375 \r
376 /**\r
377  * Push an object along with its style to the top of the Navigationbar_ex stack (and show it)\r
378  *\r
379  * The object pushed becomes a child of the Navigationbar_ex and will be controlled\r
380  * it will be deleted when the Navigationbar_ex is deleted or when content is popped(depending on del_\r
381  * on_pop variable).\r
382  *\r
383  * @param[in] obj The Navigationbar_ex object\r
384  * @param[in] content The object to push\r
385  * @param[in] item_style The style of the page\r
386  * @return The Navigationbar_ex Item or NULL\r
387  * @ingroup Navigationbar_ex\r
388  */\r
389 EAPI Elm_Navigationbar_ex_Item*\r
390 elm_navigationbar_ex_item_push(Evas_Object *obj, Evas_Object *content, const char* item_style)\r
391 {\r
392    ELM_CHECK_WIDTYPE(obj, widtype)NULL;\r
393    Widget_Data *wd = elm_widget_data_get(obj);\r
394    Elm_Navigationbar_ex_Item *it = ELM_NEW(Elm_Navigationbar_ex_Item);\r
395    Evas_Coord x, y, w, h;\r
396    char buf[1024];\r
397    if (!wd) return NULL;\r
398    if (!content) return NULL;\r
399    if (!item_style) return NULL;\r
400    if (!it) return NULL;\r
401    it->obj = obj;\r
402    it->content = content;\r
403    it->base = edje_object_add(evas_object_evas_get(obj));\r
404    evas_object_smart_member_add(it->base, obj);\r
405    evas_object_geometry_get(obj, &x, &y, &w, &h);\r
406    evas_object_move(it->base, x, y);\r
407    evas_object_resize(it->base, w, h);\r
408    evas_object_clip_set(it->base, wd->clip);\r
409    elm_widget_sub_object_add(obj, it->base);\r
410    elm_widget_sub_object_add(obj, it->content);\r
411    strncpy(buf, "item/", sizeof(buf));\r
412    strncat(buf, item_style, sizeof(buf) - strlen(buf));\r
413    if (!eina_stringshare_replace(&it->item_style, item_style)) return NULL;\r
414    \r
415    _elm_theme_object_set(obj, it->base,  "navigationbar_ex", buf, elm_widget_style_get(obj));\r
416    edje_object_signal_callback_add(it->base, "elm,action,hide,finished", "", \r
417                                    _signal_hide_finished, it);\r
418    evas_object_event_callback_add(it->content,\r
419                                   EVAS_CALLBACK_CHANGED_SIZE_HINTS,\r
420                                   _changed_size_hints, it);\r
421    edje_object_part_swallow(it->base, "elm.swallow.content", it->content);\r
422    edje_object_size_min_calc(it->base, &it->minw, &it->minh);\r
423    evas_object_data_set(it->base, "_elm_leaveme", obj);\r
424    evas_object_show(it->content);\r
425    wd->stack = eina_list_append(wd->stack, it);\r
426    _eval_top(obj, EINA_TRUE);\r
427    _sizing_eval(obj);\r
428    return it;\r
429 }\r
430 \r
431 /**\r
432  * Set the title string for the pushed Item.\r
433  * @param[in] item The Navigationbar_ex Item \r
434  * @param[in] title The title string\r
435  *\r
436  * @ingroup Navigationbar_ex\r
437  */\r
438 EAPI void\r
439 elm_navigationbar_ex_item_title_label_set( Elm_Navigationbar_ex_Item* item, \r
440                                                         const char *title)\r
441 {\r
442         if(!item) return;\r
443         if (!eina_stringshare_replace(&item->title, title)) return;\r
444         if (item->base)\r
445      edje_object_part_text_set(item->base, "elm.text", item->title);    \r
446 }\r
447 \r
448 /**\r
449  * Return the title string of the pushed item.\r
450  *\r
451  * @param[in]  item The Navigationbar_ex Item\r
452  * @return The title string or NULL if none\r
453  *\r
454  * @ingroup Navigationbar_ex\r
455  */\r
456 EAPI const char *\r
457 elm_navigationbar_ex_item_title_label_get(Elm_Navigationbar_ex_Item* item)\r
458 {\r
459         if(!item) return NULL;\r
460         return item->title;\r
461 }\r
462 \r
463 /**\r
464  * Set the sub title string for the pushed content\r
465  *\r
466  * @param[in] item The Navigationbar_ex Item \r
467  * @param[in] subtitle The subtitle string\r
468  *\r
469  * @ingroup Navigationbar_ex\r
470  */\r
471 EAPI void \r
472 elm_navigationbar_ex_item_subtitle_label_set( Elm_Navigationbar_ex_Item* item, \r
473                                                         const char *subtitle)\r
474 {\r
475         if(!item) return;\r
476         if (!eina_stringshare_replace(&item->subtitle, subtitle)) return;\r
477         if (item->base)\r
478      edje_object_part_text_set(item->base, "elm.text.sub", item->subtitle);     \r
479 }\r
480 \r
481 /**\r
482  * Return the subtitle string of the pushed content\r
483  *\r
484  * @param[in] item The Navigationbar_ex Item\r
485  * @return The subtitle string or NULL if none\r
486  *\r
487  * @ingroup Navigationbar_ex\r
488  */\r
489 EAPI const char *\r
490 elm_navigationbar_ex_item_subtitle_label_get(Elm_Navigationbar_ex_Item* item)\r
491 {\r
492         if(!item) return NULL;\r
493         return item->subtitle;\r
494 }\r
495 \r
496 \r
497 EAPI void\r
498 elm_navigationbar_ex_item_icon_set(Elm_Navigationbar_ex_Item* item, Evas_Object *icon)\r
499 {\r
500         if(!item) return; \r
501         edje_object_part_swallow(item->base, "elm.swallow.icon", icon);\r
502         elm_widget_sub_object_add(item->obj, icon);\r
503         edje_object_signal_emit(item->base, "elm,state,icon,visible", "elm");\r
504         item->icon = icon;\r
505 }\r
506 \r
507 EAPI Evas_Object *\r
508 elm_navigationbar_ex_item_icon_get(Elm_Navigationbar_ex_Item* item)\r
509 {\r
510         if(!item) return NULL; \r
511         return item->icon;\r
512 }\r
513 \r
514 \r
515 /**\r
516  * Set the button object of the pushed content\r
517  *\r
518  * @param[in] item The Navigationbar_ex Item \r
519  * @param[in] btn_label The button label\r
520  * @param[in] icon The button icon\r
521  * @param[in] button_type Indicates the position[use macros of type Elm_Navi_ex_Button_Type\r
522  * if more function buttons are required you can use values ELM_NAVIGATIONBAR_EX_MAX and more]\r
523  * @param[in] func Callback function called when button is clicked.\r
524  * @param[in] data Callback data that would be sent when button is clicked.\r
525  * @ingroup Navigationbar_ex\r
526  */ \r
527  EAPI void\r
528 elm_navigationbar_ex_item_title_button_set(Elm_Navigationbar_ex_Item* item, char *btn_label, Evas_Object *icon, int button_type, Evas_Smart_Cb func, const void *data)\r
529 {\r
530         if(!item) return;\r
531         Evas_Object *btn;\r
532         char buf[1024],theme[1024];\r
533         fn_button *btn_det;\r
534         btn = elm_button_add(item->obj);\r
535         btn_det = ELM_NEW(btn_det);\r
536         if(button_type == ELM_NAVIGATIONBAR_EX_BACK_BUTTON)\r
537                 {\r
538                         snprintf(theme, sizeof(theme), "navigationbar_backbutton/%s", elm_widget_style_get(item->obj));\r
539                         elm_object_style_set(btn, theme);\r
540                         snprintf(buf, sizeof(buf), "elm.swallow.back");\r
541                 }\r
542         else\r
543                 {\r
544                         snprintf(theme, sizeof(theme), "navigationbar_functionbutton/%s", elm_widget_style_get(item->obj));\r
545                         elm_object_style_set(btn, theme);                                       \r
546                         snprintf(buf, sizeof(buf), "elm.swallow.btn%d", button_type);\r
547                 }\r
548         if(btn_label)\r
549                 elm_button_label_set(btn, btn_label);\r
550         if(icon)\r
551                 elm_button_icon_set(btn, icon);\r
552         elm_object_focus_allow_set(btn, EINA_FALSE); \r
553         evas_object_smart_callback_add(btn, "clicked", func, data);\r
554         edje_object_part_swallow(item->base, buf, btn);\r
555         elm_widget_sub_object_add(item->obj, btn);\r
556         btn_det->btn = btn;\r
557         btn_det->btn_id = button_type;\r
558         item->fnbtn_list = eina_list_append(item->fnbtn_list, btn_det);\r
559 }\r
560 \r
561 /**\r
562  * Return the button object of the pushed content\r
563  *\r
564  * @param[in] item The Navigationbar_ex Item \r
565  * @param[in] button_type Indicates the position\r
566  * @return The button object or NULL if none\r
567  *\r
568  * @ingroup Navigationbar_ex\r
569  */\r
570 EAPI Evas_Object *\r
571 elm_navigationbar_ex_item_title_button_get(Elm_Navigationbar_ex_Item* item, int button_type)\r
572         {\r
573                 fn_button *btn_det;\r
574                 Eina_List *bl;\r
575                 EINA_LIST_FOREACH(item->fnbtn_list, bl, btn_det)\r
576                 {\r
577                         if(btn_det->btn_id == button_type)\r
578                                 return btn_det->btn;\r
579                 }\r
580                 return NULL;\r
581                 \r
582         }\r
583 \r
584 /**\r
585  * Sets a title object for the Item \r
586  * @param[in] item The Navigationbar_ex Item \r
587  * @param[in] title_obj Title object (normally segment_control/searchbar)\r
588  *\r
589  * @ingroup Navigationbar_ex\r
590  */\r
591 EAPI void\r
592 elm_navigationbar_ex_item_title_object_set(Elm_Navigationbar_ex_Item* item,\r
593                                                                         Evas_Object *title_obj)\r
594 {\r
595         if(!item) return;\r
596         if(item->title_obj) evas_object_del(item->title_obj);\r
597         item->title_obj = title_obj;\r
598         if(title_obj)\r
599                 {\r
600                         elm_widget_sub_object_add(item->obj,title_obj);\r
601                         edje_object_part_swallow(item->base, "elm.swallow.title", title_obj);\r
602                 }\r
603         _sizing_eval(item->obj);\r
604 }\r
605 \r
606 /**\r
607  * Hides the title area of the item.\r
608  * @param[in] item The Navigationbar_ex Item \r
609  * @param[in] hidden if EINA_TRUE the title area is hidden else its shown.\r
610  *\r
611  * @ingroup Navigationbar_ex\r
612  */\r
613 \r
614 EAPI void\r
615 elm_navigationbar_ex_item_title_hidden_set(Elm_Navigationbar_ex_Item* item,\r
616                                                                         Eina_Bool hidden)\r
617 {\r
618         if(!item) return;\r
619 \r
620         if (hidden) edje_object_signal_emit(item->base, "elm,state,item,moveup", "elm");\r
621         else edje_object_signal_emit(item->base, "elm,state,item,movedown", "elm");\r
622         _sizing_eval(item->obj);\r
623 }\r
624 \r
625 /**\r
626  * Unsets a title object for the item, the return object has to be deleted\r
627  * by application if not added again in to navigationbar.\r
628  *\r
629  * @param[in] item The Navigationbar_ex Item \r
630  * @return The title object or NULL if none is set\r
631  *\r
632  * @ingroup Navigationbar_ex\r
633  */\r
634 EAPI Evas_Object*\r
635 elm_navigationbar_ex_item_title_object_unset(Elm_Navigationbar_ex_Item* item)\r
636 {\r
637         if(!item) return NULL;\r
638         Evas_Object *title_obj=NULL;\r
639         if(!item->title_obj) return NULL; \r
640         title_obj = item->title_obj;\r
641         elm_widget_sub_object_del(item->obj,item->title_obj);\r
642         edje_object_part_unswallow(item->base,item->title_obj); \r
643         item->title_obj = NULL;\r
644         return title_obj;\r
645 }\r
646 \r
647 /**\r
648  * Returns the title object of the pushed content.\r
649  *\r
650  * @param[in] item The Navigationbar_ex Item \r
651  * @return The title object or NULL if none is set\r
652  *\r
653  * @ingroup Navigationbar_ex\r
654  */\r
655 EAPI Evas_Object*\r
656 elm_navigationbar_ex_item_title_object_get(Elm_Navigationbar_ex_Item* item)\r
657 {\r
658         if(!item) return NULL;\r
659         return item->title_obj;\r
660 }\r
661 \r
662 \r
663 /**\r
664  * Unsets the content of the item, the return object has to be deleted\r
665  * by application if not added again in to navigationbar, when the content \r
666  * is unset the corresponding item would be deleted, when this content is pushed again \r
667  * a new item would be created again.\r
668  *\r
669  * @param[in] item The Navigationbar_ex Item \r
670  * @return The content object or NULL if none is set\r
671  *\r
672  * @ingroup Navigationbar_ex\r
673  */\r
674 EAPI Evas_Object *elm_navigationbar_ex_item_content_unset(Elm_Navigationbar_ex_Item* item)\r
675 {\r
676         Evas_Object *content = _content_unset(item);\r
677         return content;\r
678 }\r
679 \r
680 \r
681 /**\r
682  * Returns the content of the item.\r
683  *\r
684  * @param[in] item The Navigationbar_ex Item \r
685  * @return The content object or NULL if none is set\r
686  *\r
687  * @ingroup Navigationbar_ex\r
688  */\r
689 EAPI Evas_Object *elm_navigationbar_ex_item_content_get(Elm_Navigationbar_ex_Item* item)\r
690 {\r
691         if(!item) return NULL;\r
692         return item->content;\r
693 }\r
694 \r
695 /**\r
696  * Set whether the content pushed has to be deleted on pop.\r
697  * if false the item is not deleted but only removed from the stack\r
698  * the pointer of the content is sent along with hide,finished signal.\r
699  *\r
700  * @param[in] obj The Navigationbar_ex object. \r
701  * @param[in] del_on_pop if set the content is deleted on pop else unset, by default the value is EINA_TRUE.\r
702  *\r
703  * @ingroup Navigationbar_ex\r
704  */\r
705 EAPI void elm_navigationbar_ex_delete_on_pop_set(Evas_Object *obj, Eina_Bool del_on_pop)\r
706 {\r
707         ELM_CHECK_WIDTYPE(obj, widtype);\r
708         Widget_Data *wd = elm_widget_data_get(obj);\r
709         if (!wd) return;\r
710         wd->del_on_pop = del_on_pop;    \r
711 }\r
712 \r
713 /**\r
714  * Sets the style of the navigationbar item. \r
715  * @param[in] item The Navigationbar_ex Item \r
716  * @param[in] item_style Navigationbar Item style, this can be used when the style of the item has to be dynamically set.\r
717  *\r
718  * @ingroup Navigationbar_ex\r
719  */\r
720 EAPI void\r
721 elm_navigationbar_ex_item_style_set(Elm_Navigationbar_ex_Item* item, const char* item_style)\r
722 {\r
723         if(!item) return;\r
724         char buf[1024];\r
725         strncpy(buf, "item/", sizeof(buf));\r
726         strncat(buf, item_style, sizeof(buf) - strlen(buf));\r
727         if (!eina_stringshare_replace(&item->item_style, item_style)) return;\r
728         _elm_theme_object_set(item->obj, item->base,  "navigationbar_ex", buf, elm_widget_style_get(item->obj));\r
729         if(item->title)\r
730                 edje_object_part_text_set(item->base, "elm.text", item->title);\r
731         if(item->subtitle)\r
732                 edje_object_part_text_set(item->base, "elm.text.sub", item->subtitle);\r
733 }\r
734 \r
735 /**\r
736  * Returns the style of the item.\r
737  *\r
738  * @param[in] item The Navigationbar_ex Item \r
739  * @return The item style.\r
740  *\r
741  * @ingroup Navigationbar_ex\r
742  */\r
743 EAPI const char* elm_navigationbar_ex_item_style_get(Elm_Navigationbar_ex_Item* item)\r
744 {\r
745         if(!item) return NULL;\r
746         return item->item_style;\r
747 }\r
748 \r
749 \r
750 /**\r
751  * Promote an object already in the stack to the top of the stack\r
752  *\r
753  * This will take the indicated object and promote it to the top of the stack\r
754  * as if it had been pushed there. The object must already be inside the\r
755  * Navigationbar_ex stack to work.\r
756  *\r
757  * @param[in] item The Navigationbar_ex item to promote.\r
758  * @ingroup Navigationbar_ex\r
759  */\r
760 EAPI void\r
761 elm_navigationbar_ex_item_promote(Elm_Navigationbar_ex_Item* item)\r
762 {\r
763         _item_promote(item);  \r
764 }\r
765 \r
766 /**\r
767  * Pop to the inputted Navigationbar_ex item\r
768  * the rest of the items are deleted.\r
769  *\r
770  * @param[in] item The Navigationbar_ex item\r
771  *\r
772  * @ingroup Navigationbar_ex\r
773  */\r
774 EAPI void elm_navigationbar_ex_to_item_pop(Elm_Navigationbar_ex_Item* item)\r
775 {\r
776    if(!item) return;\r
777    Widget_Data *wd = elm_widget_data_get(item->obj);\r
778    Elm_Navigationbar_ex_Item *it = NULL;\r
779    Eina_List *list;\r
780    if (!wd) return;\r
781    if (!wd->stack) return;\r
782    list = eina_list_last(wd->stack);\r
783    if(list)\r
784         {\r
785                 while(list)\r
786                         {\r
787                                 it = list->data;\r
788                                 if(it != item)\r
789                                         {\r
790                                                 wd->to_delete = eina_list_append(wd->to_delete, it);\r
791                                                 wd->stack = eina_list_remove_list(wd->stack, list);\r
792                                         }\r
793                                 else\r
794                                         break;\r
795                                 \r
796                                 list = list->prev;\r
797                         }\r
798         }  \r
799     _eval_top(it->obj, EINA_FALSE);\r
800         if(wd->to_delete)\r
801                 _process_deletions(wd);\r
802 }\r
803 \r
804 /**\r
805  * Pop the object that is on top of the Navigationbar_ex stack \r
806  * This pops the object that is on top (visible) in the navigationbar, makes it disappear, then deletes/unsets the object\r
807  * based on del_on_pop variable. \r
808  * The object that was underneath it on the stack will become visible.\r
809  *\r
810  * @param[in] obj The Navigationbar_ex object\r
811  *\r
812  * @ingroup Navigationbar_ex\r
813  */\r
814 EAPI void\r
815 elm_navigationbar_ex_item_pop(Evas_Object *obj)\r
816 {\r
817    ELM_CHECK_WIDTYPE(obj, widtype);\r
818    Widget_Data *wd = elm_widget_data_get(obj);\r
819    Eina_List *ll;\r
820    Elm_Navigationbar_ex_Item *it;\r
821    if (!wd) return;\r
822    if (!wd->stack) return;\r
823    it = eina_list_last(wd->stack)->data;\r
824    it->popme = EINA_TRUE;\r
825    ll = eina_list_last(wd->stack);\r
826    if (ll)\r
827      {\r
828         ll = ll->prev;\r
829         if (!ll)\r
830           {\r
831                 \r
832              Evas_Object *o;\r
833              const char *onhide;\r
834 \r
835              wd->top = it;\r
836              o = wd->top->base;\r
837                  \r
838              edje_object_signal_emit(o, "elm,action,hide", "elm");\r
839              onhide = edje_object_data_get(o, "onhide");\r
840              if (onhide)\r
841                {\r
842                   if (!strcmp(onhide, "raise")) evas_object_raise(o);\r
843                   else if (!strcmp(onhide, "lower")) evas_object_lower(o);\r
844                }\r
845              wd->top = NULL;\r
846           }\r
847         else\r
848           {\r
849              it = ll->data;\r
850              _item_promote(it);\r
851           }\r
852      }\r
853 }\r
854 \r
855 \r
856 /**\r
857  * Return the item at the bottom of the Navigationbar_ex stack\r
858  *\r
859  * @param[in] obj The Navigationbar_ex object\r
860  * @return The bottom item or NULL if none\r
861  *\r
862  * @ingroup Navigationbar_ex\r
863  */\r
864 EAPI Elm_Navigationbar_ex_Item*\r
865 elm_navigationbar_ex_item_bottom_get(const Evas_Object *obj)\r
866 {\r
867    ELM_CHECK_WIDTYPE(obj, widtype) NULL;\r
868    Widget_Data *wd = elm_widget_data_get(obj);\r
869    Elm_Navigationbar_ex_Item *it;\r
870    if (!wd) return NULL;\r
871    if (!wd->stack) return NULL;\r
872    it = wd->stack->data;\r
873    return it;\r
874 }\r
875 \r
876 /**\r
877  * Return the item at the top of the Navigationbar_ex stack\r
878  *\r
879  * @param[in] obj The Navigationbar_ex object\r
880  * @return The top object or NULL if none\r
881  *\r
882  * @ingroup Navigationbar_ex\r
883  */\r
884 EAPI Elm_Navigationbar_ex_Item*\r
885 elm_navigationbar_ex_item_top_get(const Evas_Object *obj)\r
886 {\r
887    ELM_CHECK_WIDTYPE(obj, widtype) NULL;\r
888    Widget_Data *wd = elm_widget_data_get(obj);\r
889    Elm_Navigationbar_ex_Item *it;\r
890    if (!wd) return NULL;\r
891    if (!wd->stack) return NULL;\r
892    it = eina_list_last(wd->stack)->data;\r
893    return it;\r
894 }\r
895 \r
896 \r