1 #ifndef ELM_WIDGET_MAP_H
2 #define ELM_WIDGET_MAP_H
4 #include "elm_interface_scrollable.h"
10 * @section elm-map-class The Elementary Map Class
12 * Elementary, besides having the @ref Map widget, exposes its
13 * foundation -- the Elementary Map Class -- in order to create
14 * other widgets which are a map with some more logic on top.
20 * Use this macro to cast whichever subclass of
21 * #Elm_Map_Smart_Class into it, so to access its fields.
25 #define ELM_MAP_CLASS(x) ((Elm_Map_Smart_Class *) x)
30 * Use this macro to cast whichever subdata of
31 * #Elm_Map_Smart_Data into it, so to access its fields.
35 #define ELM_MAP_DATA(x) ((Elm_Map_Smart_Data *) x)
38 * @def ELM_MAP_SMART_CLASS_VERSION
40 * Current version for Elementary map @b base smart class, a value
41 * which goes to _Elm_Map_Smart_Class::version.
45 #define ELM_MAP_SMART_CLASS_VERSION 1
48 * @def ELM_MAP_SMART_CLASS_INIT
50 * Initializer for a whole #Elm_Map_Smart_Class structure, with
51 * @c NULL values on its specific fields.
53 * @param smart_class_init initializer to use for the "base" field
54 * (#Evas_Smart_Class).
56 * @see EVAS_SMART_CLASS_INIT_NULL
57 * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
58 * @see ELM_MAP_SMART_CLASS_INIT_NULL
59 * @see ELM_MAP_SMART_CLASS_INIT_NAME_VERSION
63 #define ELM_MAP_SMART_CLASS_INIT(smart_class_init) \
64 {smart_class_init, ELM_MAP_SMART_CLASS_VERSION}
67 * @def ELM_MAP_SMART_CLASS_INIT_NULL
69 * Initializer to zero out a whole #Elm_Map_Smart_Class structure.
71 * @see ELM_MAP_SMART_CLASS_INIT_NAME_VERSION
72 * @see ELM_MAP_SMART_CLASS_INIT
76 #define ELM_MAP_SMART_CLASS_INIT_NULL \
77 ELM_MAP_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
80 * @def ELM_MAP_SMART_CLASS_INIT_NAME_VERSION
82 * Initializer to zero out a whole #Elm_Map_Smart_Class structure and
83 * set its name and version.
85 * This is similar to #ELM_MAP_SMART_CLASS_INIT_NULL, but it will
86 * also set the version field of #Elm_Map_Smart_Class (base field)
87 * to the latest #ELM_MAP_SMART_CLASS_VERSION and name it to the
90 * It will keep a reference to the name field as a <c>"const char *"</c>,
91 * i.e., the name must be available while the structure is
92 * used (hint: static or global variable!) and must not be modified.
94 * @see ELM_MAP_SMART_CLASS_INIT_NULL
95 * @see ELM_MAP_SMART_CLASS_INIT
99 #define ELM_MAP_SMART_CLASS_INIT_NAME_VERSION(name) \
100 ELM_MAP_SMART_CLASS_INIT(ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(name))
103 * Elementary map base smart class. This inherits directly from
104 * #Elm_Widget_Smart_Class and is meant to build widgets extending the
107 * All of the functions listed on @ref Map namespace will work for
108 * objects deriving from #Elm_Map_Smart_Class.
110 typedef struct _Elm_Map_Smart_Class
112 Elm_Widget_Smart_Class base;
114 int version; /**< Version of this smart class definition */
115 } Elm_Map_Smart_Class;
118 * Base widget smart data extended with map instance data.
120 typedef struct _Elm_Map_Smart_Data Elm_Map_Smart_Data;
122 typedef struct _Elm_Map_Name_List Elm_Map_Name_List;
123 typedef char *(*Elm_Map_Module_Source_Name_Func)(void);
124 typedef int (*Elm_Map_Module_Tile_Zoom_Min_Func)(void);
125 typedef int (*Elm_Map_Module_Tile_Zoom_Max_Func)(void);
126 typedef char *(*Elm_Map_Module_Tile_Url_Func)(const Evas_Object *,
130 typedef Eina_Bool (*Elm_Map_Module_Tile_Geo_to_Coord_Func)(const Evas_Object *,
137 typedef Eina_Bool (*Elm_Map_Module_Tile_Coord_to_Geo_Func)(const Evas_Object *,
144 typedef double (*Elm_Map_Module_Tile_Scale_Func)(const Evas_Object *,
148 typedef char *(*Elm_Map_Module_Route_Url_Func)(const Evas_Object *,
155 typedef char *(*Elm_Map_Module_Name_Url_Func)(const Evas_Object *,
161 typedef Evas_Object *(*Elm_Map_Module_Add_Func)(Evas_Object *parent);
162 typedef void (*Elm_Map_Module_Del_Func)(Evas_Object *parent);
163 typedef void (*Elm_Map_Module_Move_Func)(Evas_Object *parent,
166 typedef void (*Elm_Map_Module_Resize_Func)(Evas_Object *parent,
169 typedef void (*Elm_Map_Module_Pan_Func)(Evas_Object *,
174 typedef void (*Elm_Map_Module_Show_Func)(Evas_Object *,
178 typedef void (*Elm_Map_Module_Zoom_Func)(Evas_Object *,
181 typedef void (*Elm_Map_Module_Rotate_Func)(Evas_Object *,
186 typedef void (*Elm_Map_Module_Rotate_Get_Func)(const Evas_Object *,
190 typedef void (*Elm_Map_Module_Perspective_Set_Func)(Evas_Object *,
193 typedef void (*Elm_Map_Module_Region_Get_Func)(const Evas_Object *,
196 typedef void (*Elm_Map_Module_Canvas_to_Region_Func)(const Evas_Object *,
201 typedef void (*Elm_Map_Module_Region_to_Canvas_Func)(const Evas_Object *,
207 typedef struct _Source_Tile Source_Tile;
208 // FIXME: Currently tile size must be 256*256
209 // and the map size is pow(2.0, z) * (tile size)
215 Elm_Map_Module_Tile_Url_Func url_cb;
216 Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
217 Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
218 Elm_Map_Module_Tile_Scale_Func scale_cb;
221 typedef struct _Source_Route Source_Route;
225 Elm_Map_Module_Route_Url_Func url_cb;
228 typedef struct _Source_Name Source_Name;
232 Elm_Map_Module_Name_Url_Func url_cb;
235 typedef struct _Source_Engine Source_Engine;
236 struct _Source_Engine
242 Elm_Map_Module_Add_Func add;
243 Elm_Map_Module_Del_Func del;
244 Elm_Map_Module_Move_Func move;
245 Elm_Map_Module_Resize_Func resize;
246 Elm_Map_Module_Pan_Func pan;
247 Elm_Map_Module_Show_Func show;
248 Elm_Map_Module_Zoom_Func zoom;
249 Elm_Map_Module_Rotate_Func rotate;
250 Elm_Map_Module_Rotate_Get_Func rotate_get;
251 Elm_Map_Module_Perspective_Set_Func perpective;
252 Elm_Map_Module_Region_Get_Func region_get;
253 Elm_Map_Module_Canvas_to_Region_Func canvas_to_region;
254 Elm_Map_Module_Region_to_Canvas_Func region_to_canvas;
257 typedef struct _Path Path;
258 typedef struct _Color Color;
259 typedef struct _Region Region;
260 typedef struct _Grid Grid;
261 typedef struct _Grid_Item Grid_Item;
262 typedef struct _Overlay_Default Overlay_Default;
263 typedef struct _Overlay_Class Overlay_Class;
264 typedef struct _Overlay_Group Overlay_Group;
265 typedef struct _Overlay_Bubble Overlay_Bubble;
266 typedef struct _Overlay_Route Overlay_Route;
267 typedef struct _Overlay_Line Overlay_Line;
268 typedef struct _Overlay_Polygon Overlay_Polygon;
269 typedef struct _Overlay_Circle Overlay_Circle;
270 typedef struct _Overlay_Scale Overlay_Scale;
271 typedef struct _Path_Node Path_Node;
272 typedef struct _Path_Waypoint Path_Waypoint;
273 typedef struct _Route_Dump Route_Dump;
274 typedef struct _Name_Dump Name_Dump;
275 typedef struct _Calc_Job Calc_Job;
277 enum _Route_Xml_Attribute
281 ROUTE_XML_DESCRIPTION,
282 ROUTE_XML_COORDINATES,
284 } Route_Xml_Attibute;
286 enum _Name_Xml_Attribute
295 enum _Track_Xml_Attribute
298 TRACK_XML_COORDINATES,
300 } Track_Xml_Attibute;
317 struct _Overlay_Group
319 Elm_Map_Smart_Data *wsd;
321 Elm_Map_Overlay *overlay; // virtual group type overlay
322 Elm_Map_Overlay *klass; // class overlay for this virtual group
323 Overlay_Default *ovl; // rendered overlay
329 struct _Overlay_Default
331 Elm_Map_Smart_Data *wsd;
337 // Display priority is content > icon > clas_obj > clas_icon > layout
338 Evas_Object *content;
342 // if clas_content or icon exists, do not inherit from class
343 Evas_Object *clas_content; // Duplicated from class content
344 Evas_Object *clas_icon; // Duplicated from class icon
348 struct _Overlay_Class
350 Elm_Map_Smart_Data *wsd;
353 Evas_Object *content;
357 struct _Overlay_Bubble
359 Elm_Map_Smart_Data *wsd;
361 Evas_Object *obj, *sc, *bx;
363 Evas_Coord x, y, w, h;
366 struct _Overlay_Route
368 Elm_Map_Smart_Data *wsd;
377 Elm_Map_Smart_Data *wsd;
378 double flon, flat, tlon, tlat;
382 struct _Overlay_Polygon
384 Elm_Map_Smart_Data *wsd;
385 Eina_List *regions; // list of Regions
389 struct _Overlay_Circle
391 Elm_Map_Smart_Data *wsd;
393 double radius; // Intial pixel in intial view
394 double ratio; // initial-radius/map-size
398 struct _Overlay_Scale
400 Elm_Map_Smart_Data *wsd;
406 struct _Elm_Map_Overlay
408 Elm_Map_Smart_Data *wsd;
412 void *data; // user set data
414 Elm_Map_Overlay_Type type;
415 void *ovl; // Overlay Data for each type
417 Elm_Map_Overlay_Get_Cb cb;
420 Elm_Map_Overlay_Del_Cb del_cb;
423 // These are not used if overlay type is class or group
426 Eina_Bool visible : 1;
427 Eina_Bool paused : 1;
431 struct _Elm_Map_Route
433 Elm_Map_Smart_Data *wsd;
436 Elm_Map_Route_Type type;
437 Elm_Map_Route_Method method;
438 double flon, flat, tlon, tlat;
441 Ecore_File_Download_Job *job;
450 const char *waypoints;
451 double distance; /* unit : km */
460 Elm_Map_Smart_Data *wsd;
470 struct _Path_Waypoint
472 Elm_Map_Smart_Data *wsd;
479 Elm_Map_Smart_Data *wsd;
486 Ecore_File_Download_Job *job;
491 struct _Elm_Map_Name_List
493 Elm_Map_Smart_Data *wsd;
499 Ecore_File_Download_Job *job;
500 Elm_Map_Name_List_Cb cb;
525 Elm_Map_Smart_Data *wsd;
529 int x, y; // Tile coordinate
531 Ecore_File_Download_Job *job;
533 Eina_Bool file_have : 1;
538 Elm_Map_Smart_Data *wsd;
539 int zoom; /* zoom level tiles want for optimal
540 * display (1, 2, 4, 8) */
541 int tw, th; // size of grid in tiles
542 Eina_Matrixsparse *grid;
547 Eina_Bool show_changed : 1;
548 Eina_Bool show_anim : 1;
551 Eina_Bool zoom_changed : 1;
552 Eina_Bool zoom_anim : 1;
555 Eina_Bool overlays_changed : 1;
559 struct _Elm_Map_Smart_Data
561 Elm_Widget_Smart_Data base; /* base widget smart data as
562 * first member obligatory, as
563 * we're inheriting from it */
566 Evas_Object *hit_rect;
567 const Elm_Scrollable_Smart_Interface *s_iface;
568 Evas_Object *pan_obj;
569 Evas_Object *g_layer;
571 /* Tiles are below this and overlays are on top */
572 Evas_Object *sep_maps_overlays;
575 Eina_Array *src_mods;
577 Source_Engine *engine;
579 const char **engine_names;
581 Source_Tile *src_tile;
582 Eina_List *src_tiles;
583 const char **src_tile_names;
585 Source_Route *src_route;
586 Eina_List *src_routes;
587 const char **src_route_names;
589 Source_Name *src_name;
590 Eina_List *src_names;
591 const char **src_name_names;
595 int zoom_min, zoom_max;
603 int w, h; // Current pixel width, heigth of a grid
604 int tile; // Current pixel size of a grid item
607 Elm_Map_Zoom_Mode mode;
616 Ecore_Timer *zoom_timer;
617 Ecore_Animator *zoom_animator;
618 Ecore_Timer *loaded_timer;
624 Eina_List *download_list;
625 Ecore_Idler *download_idler;
627 const char *user_agent;
629 Evas_Coord pan_x, pan_y;
631 Ecore_Timer *scr_timer;
632 Ecore_Timer *long_timer;
633 Evas_Event_Mouse_Down ev;
660 Eina_List *group_overlays;
661 Eina_List *all_overlays;
663 Eina_Bool wheel_disabled : 1;
664 Eina_Bool on_hold : 1;
665 Eina_Bool paused : 1;
670 typedef struct _Elm_Map_Pan_Smart_Class
672 Elm_Pan_Smart_Class base;
673 } Elm_Map_Pan_Smart_Class;
675 typedef struct _Elm_Map_Pan_Smart_Data Elm_Map_Pan_Smart_Data;
676 struct _Elm_Map_Pan_Smart_Data
678 Elm_Pan_Smart_Data base;
679 Elm_Map_Smart_Data *wsd;
686 EAPI extern const char ELM_MAP_SMART_NAME[];
687 EAPI extern const char ELM_MAP_PAN_SMART_NAME[];
688 EAPI const Elm_Map_Smart_Class *elm_map_smart_class_get(void);
690 #define ELM_MAP_DATA_GET(o, sd) \
691 Elm_Map_Smart_Data * sd = evas_object_smart_data_get(o)
693 #define ELM_MAP_PAN_DATA_GET(o, sd) \
694 Elm_Map_Pan_Smart_Data * sd = evas_object_smart_data_get(o)
696 #define ELM_MAP_DATA_GET_OR_RETURN(o, ptr) \
697 ELM_MAP_DATA_GET(o, ptr); \
700 CRITICAL("No widget data for object %p (%s)", \
701 o, evas_object_type_get(o)); \
705 #define ELM_MAP_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
706 ELM_MAP_DATA_GET(o, ptr); \
709 CRITICAL("No widget data for object %p (%s)", \
710 o, evas_object_type_get(o)); \
714 #define ELM_MAP_CHECK(obj) \
715 if (!obj || !elm_widget_type_check \
716 ((obj), ELM_MAP_SMART_NAME, __func__)) \