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