{
struct
{
- int min, max, step;
+ int def, min, max, step;
} i;
struct
{
- double min, max, step;
+ double def, min, max, step;
} d;
struct
{
+ const char *def;
const char *accept_fmt;
const char *deny_fmt;
} s;
};
typedef struct _Edje_External_Param_Info Edje_External_Param_Info;
-#define EDJE_EXTERNAL_PARAM_INFO_INT_FULL(name, min, max, step) \
- {name, EDJE_EXTERNAL_PARAM_TYPE_INT, {.i = {min, max, step}}}
-#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL(name, min, max, step) \
- {name, EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, {.d = {min, max, step}}}
-#define EDJE_EXTERNAL_PARAM_INFO_STRING_FULL(name, accept, deny) \
- {name, EDJE_EXTERNAL_PARAM_TYPE_STRING, {.s = {accept, deny}}}
+#define EDJE_EXTERNAL_PARAM_INFO_INT_FULL(name, def, min, max, step) \
+ {name, EDJE_EXTERNAL_PARAM_TYPE_INT, {.i = {def, min, max, step}}}
+#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL(name, def, min, max, step) \
+ {name, EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, {.d = {def, min, max, step}}}
+#define EDJE_EXTERNAL_PARAM_INFO_STRING_FULL(name, def, accept, deny) \
+ {name, EDJE_EXTERNAL_PARAM_TYPE_STRING, {.s = {def, accept, deny}}}
+
+#define EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT(name, def) \
+ EDJE_EXTERNAL_PARAM_INFO_INT_FULL(name, def, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET)
+#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT(name, def) \
+ EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL(name, def, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET)
+#define EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT(name, def) \
+ EDJE_EXTERNAL_PARAM_INFO_STRING_FULL(name, def, NULL, NULL)
#define EDJE_EXTERNAL_PARAM_INFO_INT(name) \
- EDJE_EXTERNAL_PARAM_INFO_INT_FULL(name, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET)
+ EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT(name, 0)
#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE(name) \
- EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL(name, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET)
+ EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT(name, 0.0)
#define EDJE_EXTERNAL_PARAM_INFO_STRING(name) \
- EDJE_EXTERNAL_PARAM_INFO_STRING_FULL(name, NULL, NULL)
+ EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT(name, NULL)
-#define EDJE_EXTERNAL_PARAM_INFO_SENTINEL {NULL, 0, {.s = {NULL, NULL}}}
+#define EDJE_EXTERNAL_PARAM_INFO_SENTINEL {NULL, 0, {.s = {NULL, NULL, NULL}}}
struct _Edje_External_Type
{
Edje_Part_Type type ///< The type of the part to create (One of: EDJE_PART_TYPE_NONE, EDJE_PART_TYPE_RECTANGLE, EDJE_PART_TYPE_TEXT,EDJE_PART_TYPE_IMAGE, EDJE_PART_TYPE_SWALLOW, EDJE_PART_TYPE_TEXTBLOCK,EDJE_PART_TYPE_GRADIENT or EDJE_PART_TYPE_GROUP)
);
+/**Create a new part of type EXTERNAL in the given edje
+ * If another part with the same name just exists nothing is created and FALSE is returned.
+ * Note that this function also create a default description for the part.
+ */
+EAPI Eina_Bool ///@return TRUE on success, FALSE if the part can't be created
+edje_edit_part_external_add(
+ Evas_Object *obj, ///< The edje object
+ const char *name, ///< The name for the new part
+ const char *source ///< External type of the part
+);
+
/**Delete the given part from the edje
* All the reference to this part will be zeroed.
* A group must have at least one part, so it's not possible to
return 1;
}
-EAPI Eina_Bool
-edje_edit_part_add(Evas_Object *obj, const char* name, Edje_Part_Type type)
+Eina_Bool
+_edje_edit_real_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type, const char *source)
{
Edje_Part_Collection *pc;
Edje_Part *ep;
ep->clip_to_id = -1;
ep->dragable.confine_id = -1;
ep->dragable.events_id = -1;
+ if (source)
+ ep->source = eina_stringshare_add(source);
ep->default_desc = NULL;
ep->other_desc = NULL;
evas_object_text_font_source_set(rp->object, ed->path);
}
else if (ep->type == EDJE_PART_TYPE_SWALLOW ||
- ep->type == EDJE_PART_TYPE_GROUP)
+ ep->type == EDJE_PART_TYPE_GROUP ||
+ ep->type == EDJE_PART_TYPE_EXTERNAL)
{
rp->object = evas_object_rectangle_add(ed->evas);
evas_object_color_set(rp->object, 0, 0, 0, 0);
evas_object_pass_events_set(rp->object, 1);
evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
+ if (ep->type == EDJE_PART_TYPE_EXTERNAL)
+ {
+ Evas_Object *child;
+ child = _edje_external_type_add(source, evas_object_evas_get(obj), obj, NULL);
+ if (child)
+ _edje_real_part_swallow(rp, child);
+ }
}
else if (ep->type == EDJE_PART_TYPE_TEXTBLOCK)
rp->object = evas_object_textblock_add(ed->evas);
}
EAPI Eina_Bool
+edje_edit_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type)
+{
+ if (type == EDJE_PART_TYPE_EXTERNAL)
+ return EINA_FALSE;
+ return _edje_edit_real_part_add(obj, name, type, NULL);
+}
+
+EAPI Eina_Bool
+edje_edit_part_external_add(Evas_Object *obj, const char *name, const char *source)
+{
+ if (!source)
+ return EINA_FALSE;
+ return _edje_edit_real_part_add(obj, name, EDJE_PART_TYPE_EXTERNAL, source);
+}
+
+EAPI Eina_Bool
edje_edit_part_del(Evas_Object *obj, const char* part)
{
Edje_Part *ep;
//printf("Set source for part: %s [source: %s]\n", part, source);
+ if (rp->part->type == EDJE_PART_TYPE_EXTERNAL)
+ return 0;
+
_edje_if_string_free(ed, rp->part->source);
if (source)
pd->gradient.rel2.offset_x = -1;
pd->gradient.rel2.offset_y = -1;
pd->gradient.use_rel = 1;
+
+ if (rp->part->type == EDJE_PART_TYPE_EXTERNAL && rp->part->source)
+ {
+ Edje_External_Param_Info *pi;
+ pi = edje_external_param_info_get(rp->part->source);
+ while (pi && pi->name)
+ {
+ Edje_External_Param *p;
+ p = _alloc(sizeof(Edje_External_Param));
+ /* error checking.. meh */
+ p->name = eina_stringshare_add(pi->name);
+ p->type = pi->type;
+ switch(p->type)
+ {
+ case EDJE_EXTERNAL_PARAM_TYPE_INT:
+ p->i = pi->info.i.def;
+ break;
+ case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
+ p->d = pi->info.d.def;
+ break;
+ case EDJE_EXTERNAL_PARAM_TYPE_STRING:
+ if (pi->info.s.def)
+ p->s = eina_stringshare_add(pi->info.s.def);
+ break;
+ }
+ pd->external_params = eina_list_append(pd->external_params, p);
+ pi++;
+ }
+ if (pd->external_params)
+ rp->param1.external_params = _edje_external_params_parse(rp->swallowed_object, pd->external_params);
+ }
}
EAPI Eina_Bool