5 typedef struct _Elm_Params_Map
8 const char *map_source;
14 static const char *zoom_choices[] = {"manual", "auto fit", "auto fill", NULL};
16 static const char *source_choices[] =
17 {"Mapnik", "Osmarender", "CycleMap", "Maplint"};
19 static Elm_Map_Zoom_Mode
20 _zoom_mode_get(const char *map_src)
24 assert(sizeof(zoom_choices)/sizeof(zoom_choices[0]) ==
25 ELM_MAP_ZOOM_MODE_LAST + 1);
27 for (i = 0; i < ELM_MAP_ZOOM_MODE_LAST; i++)
28 if (!strcmp(map_src, zoom_choices[i])) return i;
30 return ELM_MAP_ZOOM_MODE_LAST;
34 external_map_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__)
36 const Elm_Params_Map *p;
38 if (to_params) p = to_params;
39 else if (from_params) p = from_params;
44 elm_map_source_set(obj, ELM_MAP_SOURCE_TYPE_TILE, p->map_source);
48 Elm_Map_Zoom_Mode set = _zoom_mode_get(p->zoom_mode);
49 if (set == ELM_MAP_ZOOM_MODE_LAST) return;
50 elm_map_zoom_mode_set(obj, set);
52 if (p->zoom_set) elm_map_zoom_set(obj, p->zoom);
56 external_map_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param)
58 if (!strcmp(param->name, "map source"))
60 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
62 elm_map_source_set(obj, ELM_MAP_SOURCE_TYPE_TILE, param->s);
66 else if (!strcmp(param->name, "zoom mode"))
68 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
70 Elm_Map_Zoom_Mode set = _zoom_mode_get(param->s);
71 if (set == ELM_MAP_ZOOM_MODE_LAST) return EINA_FALSE;
72 elm_map_zoom_mode_set(obj, set);
76 else if (!strcmp(param->name, "zoom level"))
78 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
80 elm_map_zoom_set(obj, param->d);
85 ERR("unknown parameter '%s' of type '%s'",
86 param->name, edje_external_param_type_str(param->type));
92 external_map_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param)
94 if (!strcmp(param->name, "map source"))
96 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
98 const char *set = elm_map_source_get(obj, ELM_MAP_SOURCE_TYPE_TILE);
103 else if (!strcmp(param->name, "zoom mode"))
105 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
107 Elm_Map_Zoom_Mode set = elm_map_zoom_mode_get(obj);
108 if (set == ELM_MAP_ZOOM_MODE_LAST) return EINA_FALSE;
109 param->s = zoom_choices[set];
113 else if (!strcmp(param->name, "zoom level"))
115 if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
117 param->d = elm_map_zoom_get(obj);
122 ERR("unknown parameter '%s' of type '%s'",
123 param->name, edje_external_param_type_str(param->type));
129 external_map_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params)
132 Edje_External_Param *param;
135 mem = calloc(1, sizeof(Elm_Params_Map));
139 EINA_LIST_FOREACH(params, l, param)
141 if (!strcmp(param->name, "map source"))
142 mem->map_source = eina_stringshare_add(param->s);
143 if (!strcmp(param->name, "zoom mode"))
144 mem->zoom_mode = eina_stringshare_add(param->s);
145 else if (!strcmp(param->name, "zoom level"))
147 mem->zoom = param->d;
148 mem->zoom_set = EINA_TRUE;
155 static Evas_Object *external_map_content_get(void *data __UNUSED__,
156 const Evas_Object *obj __UNUSED__, const char *content __UNUSED__)
163 external_map_params_free(void *params)
165 Elm_Params_Map *mem = params;
168 eina_stringshare_del(mem->map_source);
170 eina_stringshare_del(mem->zoom_mode);
174 static Edje_External_Param_Info external_map_params[] =
176 DEFINE_EXTERNAL_COMMON_PARAMS,
177 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("map source", "Mapnik", source_choices),
178 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("zoom mode", "manual", zoom_choices),
179 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("zoom level"),
180 EDJE_EXTERNAL_PARAM_INFO_SENTINEL
183 DEFINE_EXTERNAL_ICON_ADD(map, "map")
184 DEFINE_EXTERNAL_TYPE_SIMPLE(map, "Map")