1 #include <Elementary.h>
5 * @defgroup NoContents NoContents
10 typedef struct _Widget_Data Widget_Data;
19 static const char *widtype = NULL;
20 static void _del_hook(Evas_Object *obj);
21 static void _theme_hook(Evas_Object *obj);
22 static void _sizing_eval(Evas_Object *obj);
25 _del_hook(Evas_Object *obj)
27 Widget_Data *wd = elm_widget_data_get(obj);
33 _theme_hook(Evas_Object *obj)
35 Widget_Data *wd = elm_widget_data_get(obj);
37 _elm_theme_object_set(obj, wd->noc, "nocontents", "base", elm_widget_style_get(obj));
38 edje_object_part_text_set(wd->noc, "elm.text", wd->label);
39 edje_object_message_signal_process(wd->noc);
40 edje_object_scale_set(wd->noc, elm_widget_scale_get(obj) * _elm_config->scale);
45 _sizing_eval(Evas_Object *obj)
47 Widget_Data *wd = elm_widget_data_get(obj);
48 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
50 edje_object_size_min_calc(wd->noc, &minw, &minh);
51 evas_object_size_hint_min_set(obj, minw, minh);
52 evas_object_size_hint_max_set(obj, maxw, maxh);
53 evas_object_size_hint_align_set(obj, maxw, maxh);
57 * Add a nocontents object to @p parent
59 * @param parent The parent object
61 * @return The nocontents object, or NULL upon failure
66 elm_nocontents_add(Evas_Object *parent)
72 wd = ELM_NEW(Widget_Data);
73 e = evas_object_evas_get(parent);
74 obj = elm_widget_add(e);
75 ELM_SET_WIDTYPE(widtype, "nocontents");
76 elm_widget_type_set(obj, "nocontents");
77 elm_widget_sub_object_add(parent, obj);
78 elm_widget_data_set(obj, wd);
79 elm_widget_del_hook_set(obj, _del_hook);
80 elm_widget_theme_hook_set(obj, _theme_hook);
81 elm_widget_can_focus_set(obj, 0);
86 wd->noc = edje_object_add(e);
87 _elm_theme_object_set(obj, wd->noc, "nocontents", "base", "default");
88 elm_widget_resize_object_set(obj, wd->noc);
94 * Set the label on the nocontents object
96 * @param obj The nocontents object
97 * @param label The label will be used on the nocontents object
102 elm_nocontents_label_set(Evas_Object *obj, const char *label)
104 ELM_CHECK_WIDTYPE(obj, widtype);
105 Widget_Data *wd = elm_widget_data_get(obj);
107 if (!label) label = "";
108 eina_stringshare_replace(&wd->label, label);
109 edje_object_part_text_set(wd->noc, "elm.text", label);
114 * Get the label used on the nocontents object
116 * @param obj The nocontentsl object
117 * @return The string inside the label
118 * @ingroup NoContents
121 elm_nocontents_label_get(const Evas_Object *obj)
123 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
124 Widget_Data *wd = elm_widget_data_get(obj);
125 if (!wd) return NULL;
130 * Set the custom object used on the nocontents object
132 * @param obj The nocontentsl object
133 * @param custom The custom object will be used on the nocontents object
134 * @ingroup NoContents
137 elm_nocontents_custom_set(const Evas_Object *obj, Evas_Object *custom)
139 ELM_CHECK_WIDTYPE(obj, widtype);
140 Widget_Data *wd = elm_widget_data_get(obj);
144 elm_widget_sub_object_add((Evas_Object *)obj, custom);
145 edje_object_part_swallow(wd->noc, "custom", custom);
150 * Get the custom object used on the nocontents object
152 * @param obj The nocontentsl object
153 * @return The custom object inside the nocontents
154 * @ingroup NoContents
157 elm_nocontents_custom_get(const Evas_Object *obj)
159 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
160 Widget_Data *wd = elm_widget_data_get(obj);
161 if (!wd) return NULL;