]> err.no Git - mapper/blob - src/map.h
Merge branch 'master' of git+ssh://tal.org/home/git/mapper
[mapper] / src / map.h
1 #include <config.h>
2
3 #define _GNU_SOURCE
4
5 #ifndef _MAPPER_MAP_H
6 #define _MAPPER_MAP_H
7
8 #include <unistd.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <strings.h>
12 #include <stddef.h>
13 #include <locale.h>
14 #include <math.h>
15 #include <errno.h>
16 #include <sys/wait.h>
17 #include <glib/gstdio.h>
18 #include <gtk/gtk.h>
19 #include <dbus/dbus-glib.h>
20
21 #include "utils.h"
22 #include "mapper-types.h"
23
24 typedef enum {
25         MAP_MODE_NORMAL=0,
26         MAP_MODE_DRAW_TRACK,
27         MAP_MODE_DRAW_ROUTE,
28         MAP_MODE_SET_ROUTE_FROM,
29         MAP_MODE_SET_ROUTE_POINT,
30         MAP_MODE_SET_ROUTE_TO,
31         MAP_MODES
32 } MapMode;
33
34 /** VARIABLES FOR MAINTAINING STATE OF THE CURRENT VIEW. */
35
36 /** The "zoom" level defines the resolution of a pixel, from 0 to MAX_ZOOM.
37  * Each pixel in the current view is exactly (1 << _zoom) "units" wide. */
38
39 Point _min_center;
40 Point _max_center;
41 Point _focus;
42
43 /** The "base tile" is the upper-left tile in the pixmap. */
44 guint _base_tilex;
45 guint _base_tiley;
46
47 guint _zoom;                    /* zoom level, from 0 to MAX_ZOOM. */
48 Point _center;                  /* current center location, X. */
49
50 /** The "offset" defines the upper-left corner of the visible portion of the
51  * 1024x768 pixmap. */
52 guint _offsetx;
53 guint _offsety;
54
55 /** CACHED SCREEN INFORMATION THAT IS DEPENDENT ON THE CURRENT VIEW. */
56 guint _screen_grids_halfwidth;
57 guint _screen_grids_halfheight;
58 guint _screen_width_pixels;
59 guint _screen_height_pixels;
60
61 guint _focus_unitwidth;
62 guint _focus_unitheight;
63 guint _world_size_tiles;
64
65 guint _key_zoom_new;
66 guint _key_zoom_timeout_sid;
67
68 gboolean _map_location_known;
69 gdouble _map_location_dist;
70
71 gboolean map_key_zoom_timeout();
72
73 int map_zoom(gint zdir);
74 void map_set_autozoom(gboolean az);
75 void map_render_path(Path * path, GdkGC ** gc);
76 void map_pan(gint delta_unitx, gint delta_unity);
77 void map_move_mark(void);
78 void map_set_mark(void);
79
80 void map_center_unit(guint new_center_unitx, guint new_center_unity);
81 void map_center_latlon(gdouble lat, gdouble lon);
82 gboolean map_goto_position(Position *pos);
83
84 gboolean map_cb_configure(GtkWidget * widget, GdkEventConfigure * event);
85 gboolean map_cb_expose(GtkWidget * widget, GdkEventExpose * event);
86 gboolean map_cb_button_press(GtkWidget * widget, GdkEventButton * event);
87 gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event);
88 gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event);
89
90 #endif