map_example_02.c
#include <Elementary.h>
typedef struct _Overlay_Data
{
const char *name;
const char *file;
} Overlay_Data;
Overlay_Data data_argentina = {"Argentina", NULL};
Overlay_Data data_chile = {"Chile", NULL};
Overlay_Data data_sampa = {"São Paulo", NULL};
Overlay_Data data_rio = {"Rio de Janeiro", NULL};
Overlay_Data data_brasilia = {"Brasília", NULL};
static Elm_Map_Overlay *bubble;
const char *data_dir;
static Evas_Object *
_icon_get(Evas_Object *obj, const char *file)
{
Evas_Object *icon = elm_icon_add(obj);
elm_image_file_set(icon, file, NULL);
return icon;
}
static Evas_Object *
_city_icon_get(Evas_Object *obj)
{
char buf[256];
snprintf(buf, sizeof(buf), "%s/images/icon_07.png", data_dir);
return _icon_get(obj, buf);
}
static Evas_Object *
_clas_city_icon_get(Evas_Object *obj)
{
char buf[256];
snprintf(buf, sizeof(buf), "%s/images/icon_05.png", data_dir);
return _icon_get(obj, buf);
}
static Evas_Object *
_country_icon_get(Evas_Object *obj)
{
char buf[256];
snprintf(buf, sizeof(buf), "%s/images/icon_06.png", data_dir);
return _icon_get(obj, buf);
}
static Evas_Object *
_clas_country_icon_get(Evas_Object *obj)
{
char buf[256];
snprintf(buf, sizeof(buf), "%s/images/icon_04.png", data_dir);
return _icon_get(obj, buf);
}
static Evas_Object *
_box_get(Evas_Object *obj, Overlay_Data *data)
{
Evas_Object *bx, *img, *label;
bx = elm_box_add(obj);
img = evas_object_image_add(evas_object_evas_get(obj));
evas_object_image_file_set(img, data->file, NULL);
evas_object_image_filled_set(img, EINA_TRUE);
evas_object_size_hint_min_set(img, 64, 64);
elm_box_pack_end(bx, img);
label = elm_label_add(obj);
elm_object_text_set(label, data->name);
elm_box_pack_end(bx, label);
return bx;
}
static void
_overlay_cb(void *data EINA_UNUSED, Evas_Object *map, void *ev)
{
printf("Overlay clicked\n");
Elm_Map_Overlay *overlay = ev;
// prevent duplication
if (!bubble) bubble = elm_map_overlay_bubble_add(map);
bx = _box_get(map, elm_map_overlay_data_get(overlay));
}
static void
_bt_zoom_in(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
{
Evas_Object *map = data;
int zoom;
zoom = elm_map_zoom_get(map);
elm_map_zoom_set(map, zoom + 1);
}
static void
_bt_zoom_out(void *data, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
{
Evas_Object *map = data;
int zoom;
zoom = elm_map_zoom_get(map);
elm_map_zoom_set(map, zoom - 1);
}
static void
_bt_zoom_fit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *map = data;
}
static void
_bt_zoom_fill(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *map = data;
}
/* FIXME: it shouldn't be required. For unknown reason map won't call
* pan_calculate until shot delay time, but then it will take a screenshot
* when the map isn't loaded yet (actually it won't be downloaded, because
* after the SS it will kill the example). */
static Eina_Bool
_nasty_hack(void *data)
{
Evas_Object *o = data;
Evas *e = evas_object_evas_get(o);
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *win, *map, *box, *bt;
Eina_List *ovls = NULL;
Elm_Map_Overlay *ovl, *city_clas, *country_clas;
char buf[255];
elm_app_info_set(elm_main, "elementary", "images");
data_dir = elm_app_data_dir_get();
snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", "sdf");
data_argentina.file = strdup(buf);
snprintf(buf, sizeof(buf), "%s/images/rock_02.jpg", "sdf");
data_chile.file = strdup(buf);
snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", "sdf");
data_sampa.file = strdup(buf);
snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", "sdf");
data_rio.file = strdup(buf);
snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", "sdf");
data_brasilia.file = strdup(buf);
win = elm_win_util_standard_add("map", "Map Overlay Example");
map = elm_map_add(win);
evas_object_size_hint_weight_set(map, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
box = elm_box_add(win);
bt = elm_button_add(win);
elm_object_text_set(bt, "+");
elm_box_pack_end(box, bt);
evas_object_smart_callback_add(bt, "clicked", _bt_zoom_in, map);
bt = elm_button_add(win);
elm_object_text_set(bt, "-");
elm_box_pack_end(box, bt);
evas_object_smart_callback_add(bt, "clicked", _bt_zoom_out, map);
bt = elm_button_add(win);
elm_object_text_set(bt, "X");
elm_box_pack_end(box, bt);
evas_object_smart_callback_add(bt, "clicked", _bt_zoom_fit, map);
bt = elm_button_add(win);
elm_object_text_set(bt, "#");
elm_box_pack_end(box, bt);
evas_object_smart_callback_add(bt, "clicked", _bt_zoom_fill, map);
evas_object_smart_callback_add(map, "overlay,clicked", _overlay_cb, NULL);
city_clas = elm_map_overlay_class_add(map);
elm_map_overlay_icon_set(city_clas, _clas_city_icon_get(map));
country_clas = elm_map_overlay_class_add(map);
elm_map_overlay_icon_set(country_clas, _clas_country_icon_get(map));
ovl = elm_map_overlay_add(map, -43.2, -22.9);
elm_map_overlay_icon_set(ovl, _city_icon_get(map));
elm_map_overlay_data_set(ovl, &data_rio);
ovls = eina_list_append(ovls, ovl);
ovl = elm_map_overlay_add(map, -46.63, -23.55);
elm_map_overlay_icon_set(ovl, _city_icon_get(map));
elm_map_overlay_data_set(ovl, &data_sampa);
ovls = eina_list_append(ovls, ovl);
ovl = elm_map_overlay_add(map, -47.88, -15.78);
elm_map_overlay_icon_set(ovl, _city_icon_get(map));
elm_map_overlay_data_set(ovl, &data_brasilia);
ovls = eina_list_append(ovls, ovl);
ovl = elm_map_overlay_add(map, -65.23, -35.1);
elm_map_overlay_icon_set(ovl, _country_icon_get(map));
elm_map_overlay_data_set(ovl, &data_argentina);
elm_map_overlay_class_append(country_clas, ovl);
ovls = eina_list_append(ovls, ovl);
ovl = elm_map_overlay_add(map, -71.3, -31.75);
elm_map_overlay_icon_set(ovl, _country_icon_get(map));
elm_map_overlay_data_set(ovl, &data_chile);
elm_map_overlay_class_append(country_clas, ovl);
ovls = eina_list_append(ovls, ovl);
evas_object_resize(win, 512, 512);
ecore_timer_add(1, _nasty_hack, win);
return 0;
}
elm_map_overlay_displayed_zoom_min_set
void elm_map_overlay_displayed_zoom_min_set(Elm_Map_Overlay *overlay, int zoom)
Set the minimum zoom from where the overlay is displayed.
Definition: elm_map.c:4965
ELM_POLICY_QUIT_LAST_WINDOW_CLOSED
quit when the application's last window is closed
Definition: elm_general.h:248
evas_object_image_add
Evas_Object * evas_object_image_add(Evas *eo_e)
Creates a new image object on the given Evas e canvas.
Definition: evas_image_legacy.c:25
elm_map_overlay_icon_set
void elm_map_overlay_icon_set(Elm_Map_Overlay *overlay, Evas_Object *icon)
Set a icon of the overlay.
Definition: elm_map.c:5135
eina_list_append
EAPI Eina_List * eina_list_append(Eina_List *list, const void *data)
Appends the given data to the given linked list.
Definition: eina_list.c:584
elm_box_add
EAPI Evas_Object * elm_box_add(Evas_Object *parent)
Add a new box to the parent.
Definition: elm_box.c:366
elm_label_add
EAPI Evas_Object * elm_label_add(Evas_Object *parent)
Add a new label to the parent.
Definition: elm_label.c:413
elm_app_data_dir_get
const char * elm_app_data_dir_get(void)
Get the application's run time data prefix directory, as set by elm_app_info_set() and the way (envir...
Definition: elm_main.c:586
EINA_UNUSED
#define EINA_UNUSED
Definition: eina_types.h:321
elm_map_overlay_data_get
void * elm_map_overlay_data_get(const Elm_Map_Overlay *overlay)
Get the user data stored on a overlay.
Definition: elm_map.c:4931
_Elm_Map_Overlay
Definition: elm_widget_map.h:252
elm_map_overlay_class_append
void elm_map_overlay_class_append(Elm_Map_Overlay *klass, Elm_Map_Overlay *overlay)
Add a new overlay member to the class overlay.
Definition: elm_map.c:5325
elm_map_overlay_data_set
void elm_map_overlay_data_set(Elm_Map_Overlay *overlay, void *data)
Set a pointer of user data for a overlay.
Definition: elm_map.c:4920
elm_button_add
EAPI Evas_Object * elm_button_add(Evas_Object *parent)
Add a new button to the parent's canvas.
Definition: efl_ui_button.c:477
EVAS_HINT_EXPAND
#define EVAS_HINT_EXPAND
Use with evas_object_size_hint_weight_set(), evas_object_size_hint_weight_get(), evas_object_size_hin...
Definition: Evas_Common.h:292
ecore_timer_add
Ecore_Timer * ecore_timer_add(double in, Ecore_Task_Cb func, const void *data)
Creates a timer to call the given function in the given period of time.
Definition: ecore_timer.c:178
evas_smart_objects_calculate
void evas_smart_objects_calculate(Eo *eo_e)
Call user-provided calculate smart functions and unset the flag signalling that the object needs to g...
Definition: evas_main.c:1960
evas_object_smart_callback_add
void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition: evas_object_smart.c:980
Evas_Object
Efl_Canvas_Object Evas_Object
Definition: Evas_Common.h:180
elm_icon_add
Evas_Object * elm_icon_add(Evas_Object *parent)
Add a new icon object to the parent.
Definition: elm_icon.c:606
elm_run
void elm_run(void)
Run Elementary's main loop.
Definition: elm_main.c:1385
ELM_MAIN
#define ELM_MAIN()
macro to be used after the elm_main() function
Definition: elm_general.h:528
elm_app_info_set
void elm_app_info_set(void *mainfunc, const char *dom, const char *checkfile)
Re-locate the application somewhere else after compilation, if the developer wishes for easier distri...
Definition: elm_main.c:496
elm_map_add
Evas_Object * elm_map_add(Evas_Object *parent)
Add a new map widget to the given parent Elementary (container) object.
Definition: elm_map.c:4300
ELM_MAP_ZOOM_MODE_AUTO_FILL
Zoom until map fills scroll, ensuring no pixels are left unfilled.
Definition: elm_map_legacy.h:22
elm_win_util_standard_add
Evas_Object * elm_win_util_standard_add(const char *name, const char *title)
Adds a window object with standard setup.
Definition: efl_ui_win.c:9199
elm_image_file_set
EAPI Eina_Bool elm_image_file_set(Evas_Object *obj, const char *file, const char *group)
Set the file that will be used as the image's source.
Definition: efl_ui_image.c:2378
evas_object_show
void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition: evas_object_main.c:1853
Evas
Eo Evas
Definition: Evas_Common.h:158
EINA_TRUE
#define EINA_TRUE
Definition: eina_types.h:508
elm_policy_set
Eina_Bool elm_policy_set(unsigned int policy, int value)
Set a new policy's value (for a given policy group/identifier).
Definition: elm_main.c:1408
elm_map_overlay_bubble_content_append
void elm_map_overlay_bubble_content_append(Elm_Map_Overlay *bubble, Evas_Object *content)
Add a content object to the bubble overlay.
Definition: elm_map.c:5478
Eina_Bool
unsigned char Eina_Bool
Definition: eina_types.h:496
ECORE_CALLBACK_CANCEL
#define ECORE_CALLBACK_CANCEL
Return value to remove a callback.
Definition: Ecore_Common.h:152
elm_map_overlay_bubble_content_clear
void elm_map_overlay_bubble_content_clear(Elm_Map_Overlay *bubble)
Clear all contents inside the bubble overlay.
Definition: elm_map.c:5495
elm_map_overlays_show
void elm_map_overlays_show(Eina_List *overlays)
Move and zoom the map to display a list of overlays.
Definition: elm_map.c:5057
elm_map_zoom_set
void elm_map_zoom_set(Eo *obj, int zoom)
Set the zoom level of the map.
Definition: elm_map.c:4344
_Eina_List
Definition: eina_list.h:326
elm_win_resize_object_add
void elm_win_resize_object_add(Eo *obj, Evas_Object *subobj)
Add subobj as a resize object of window obj.
Definition: efl_ui_win.c:8899
ELM_MAP_ZOOM_MODE_MANUAL
Zoom controlled manually by elm_map_zoom_set().
Definition: elm_map_legacy.h:18
ELM_MAP_ZOOM_MODE_AUTO_FIT
Zoom until map fits inside the scroll frame with no pixels outside this area.
Definition: elm_map_legacy.h:20
elm_win_autodel_set
void elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
Set the window's autodel state.
Definition: efl_ui_win.c:6146
elm_map_zoom_get
int elm_map_zoom_get(const Eo *obj)
Get the zoom level of the map.
Definition: elm_map.c:4350
elm_map_zoom_mode_set
void elm_map_zoom_mode_set(Eo *obj, Elm_Map_Zoom_Mode mode)
Set the zoom mode used by the map object.
Definition: elm_map.c:4398
elm_map_overlay_bubble_follow
void elm_map_overlay_bubble_follow(Elm_Map_Overlay *bubble, const Elm_Map_Overlay *parent)
Follow a other overlay.
Definition: elm_map.c:5458
ELM_POLICY_QUIT
under which circumstances the application should quit automatically.
Definition: elm_general.h:227