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_scale_set(wd->noc, elm_widget_scale_get(obj) * _elm_config->scale);
43 _sizing_eval(Evas_Object *obj)
45 Widget_Data *wd = elm_widget_data_get(obj);
46 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
48 edje_object_size_min_calc(wd->noc, &minw, &minh);
49 evas_object_size_hint_min_set(obj, minw, minh);
50 evas_object_size_hint_max_set(obj, maxw, maxh);
51 evas_object_size_hint_align_set(obj, maxw, maxh);
55 * Add a nocontents object to @p parent
57 * @param parent The parent object
59 * @return The nocontents object, or NULL upon failure
64 elm_nocontents_add(Evas_Object *parent)
70 wd = ELM_NEW(Widget_Data);
71 e = evas_object_evas_get(parent);
72 obj = elm_widget_add(e);
73 ELM_SET_WIDTYPE(widtype, "nocontents");
74 elm_widget_type_set(obj, "nocontents");
75 elm_widget_sub_object_add(parent, obj);
76 elm_widget_data_set(obj, wd);
77 elm_widget_del_hook_set(obj, _del_hook);
78 elm_widget_theme_hook_set(obj, _theme_hook);
79 elm_widget_can_focus_set(obj, 0);
84 wd->noc = edje_object_add(e);
85 _elm_theme_object_set(obj, wd->noc, "nocontents", "base", "default");
86 elm_widget_resize_object_set(obj, wd->noc);
92 * Set the label on the nocontents object
94 * @param obj The nocontents object
95 * @param label The label will be used on the nocontents object
100 elm_nocontents_label_set(Evas_Object *obj, const char *label)
102 ELM_CHECK_WIDTYPE(obj, widtype);
103 Widget_Data *wd = elm_widget_data_get(obj);
105 if (!label) label = "";
106 eina_stringshare_replace(&wd->label, label);
107 edje_object_part_text_set(wd->noc, "elm.text", label);
112 * Get the label used on the nocontents object
114 * @param obj The nocontentsl object
115 * @return The string inside the label
116 * @ingroup NoContents
119 elm_nocontents_label_get(const Evas_Object *obj)
121 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
122 Widget_Data *wd = elm_widget_data_get(obj);
123 if (!wd) return NULL;
128 * Set the custom object used on the nocontents object
130 * @param obj The nocontentsl object
131 * @param custom The custom object will be used on the nocontents object
132 * @ingroup NoContents
135 elm_nocontents_custom_set(const Evas_Object *obj, Evas_Object *custom)
137 ELM_CHECK_WIDTYPE(obj, widtype);
138 Widget_Data *wd = elm_widget_data_get(obj);
141 edje_object_part_swallow(wd->noc, "custom", custom);
146 * Get the custom object used on the nocontents object
148 * @param obj The nocontentsl object
149 * @return The custom object inside the nocontents
150 * @ingroup NoContents
153 elm_nocontents_custom_get(const Evas_Object *obj)
155 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
156 Widget_Data *wd = elm_widget_data_get(obj);
157 if (!wd) return NULL;