2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
4 * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef _VIKING_VIEWPORT_H
23 #define _VIKING_VIEWPORT_H
24 /* Requires <gtk/gtk.h> or glib, and coords.h*/
27 #include <glib-object.h>
28 #include <gtk/gtkdrawingarea.h>
32 #define VIK_VIEWPORT_TYPE (vik_viewport_get_type ())
33 #define VIK_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_VIEWPORT_TYPE, VikViewport))
34 #define VIK_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_VIEWPORT_TYPE, VikViewportClass))
35 #define IS_VIK_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIK_VIEWPORT_TYPE))
36 #define IS_VIK_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIK_VIEWPORT_TYPE))
38 #define VIK_VIEWPORT_MAX_ZOOM 8192.0
39 #define VIK_VIEWPORT_MIN_ZOOM 0.125
41 /* used for coord to screen etc, screen to coord */
42 #define VIK_VIEWPORT_UTM_WRONG_ZONE -9999999
43 #define VIK_VIEWPORT_OFF_SCREEN_DOUBLE -9999999.9
45 typedef struct _VikViewport VikViewport
;
46 typedef struct _VikViewportClass VikViewportClass
;
48 struct _VikViewportClass
50 GtkDrawingAreaClass drawing_area_class
;
53 GType
vik_viewport_get_type ();
55 VikViewport
*vik_viewport_new ();
57 void vik_viewport_configure_manually ( VikViewport
*vvp
, gint width
, guint height
);
58 /* for off-screen viewports */
59 gboolean
vik_viewport_configure ( VikViewport
*vp
);
62 void vik_viewport_clear ( VikViewport
*vvp
);
64 GdkPixmap
*vik_viewport_get_pixmap ( VikViewport
*vvp
);
66 void vik_viewport_sync ( VikViewport
*vvp
);
68 void vik_viewport_set_ympp ( VikViewport
*vvp
, gdouble ympp
);
69 void vik_viewport_set_xmpp ( VikViewport
*vvp
, gdouble xmpp
);
70 gdouble
vik_viewport_get_ympp ( VikViewport
*vvp
);
71 gdouble
vik_viewport_get_xmpp ( VikViewport
*vvp
);
74 void vik_viewport_set_zoom ( VikViewport
*vvp
, gdouble mpp
);
75 gdouble
vik_viewport_get_zoom ( VikViewport
*vvp
);
76 void vik_viewport_zoom_in ( VikViewport
*vvp
);
77 void vik_viewport_zoom_out ( VikViewport
*vvp
);
79 const VikCoord
*vik_viewport_get_center ( VikViewport
*vvp
);
81 void vik_viewport_set_center_coord ( VikViewport
*vvp
, const VikCoord
*coord
);
82 void vik_viewport_set_center_screen ( VikViewport
*vvp
, int x
, int y
);
83 void vik_viewport_center_for_zonen ( VikViewport
*vvp
, struct UTM
*center
, int zone
);
84 gchar
vik_viewport_leftmost_zone ( VikViewport
*vvp
);
85 gchar
vik_viewport_rightmost_zone ( VikViewport
*vvp
);
87 void vik_viewport_screen_to_coord ( VikViewport
*vvp
, int x
, int y
, VikCoord
*coord
);
88 void vik_viewport_coord_to_screen ( VikViewport
*vvp
, const VikCoord
*coord
, int *x
, int *y
);
90 void vik_viewport_draw_pixbuf_with_alpha ( VikViewport
*vvp
, GdkPixbuf
*pixbuf
, gint alpha
,
91 gint src_x
, gint src_y
, gint dest_x
, gint dest_y
, gint w
, gint h
);
92 void vik_viewport_draw_pixbuf ( VikViewport
*vvp
, GdkPixbuf
*pixbuf
, gint src_x
, gint src_y
,
93 gint dest_x
, gint dest_y
, gint w
, gint h
);
96 gint
vik_viewport_get_width ( VikViewport
*vvp
);
97 gint
vik_viewport_get_height ( VikViewport
*vvp
);
99 GdkGC
*vik_viewport_new_gc ( VikViewport
*vvp
, const gchar
*colorname
, gint thickness
);
101 void vik_viewport_draw_line ( VikViewport
*vvp
, GdkGC
*gc
, gint x1
, gint y1
, gint x2
, gint y2
);
102 void vik_viewport_draw_rectangle ( VikViewport
*vvp
, GdkGC
*gc
, gboolean filled
, gint x1
, gint y1
, gint x2
, gint y2
);
103 void vik_viewport_draw_string ( VikViewport
*vvp
, GdkFont
*font
, GdkGC
*gc
, gint x1
, gint y1
, const gchar
*string
);
104 GdkGC
*vik_viewport_new_gc_from_color ( VikViewport
*vvp
, GdkColor
*color
, gint thickness
);
105 void vik_viewport_draw_arc ( VikViewport
*vvp
, GdkGC
*gc
, gboolean filled
, gint x
, gint y
, gint width
, gint height
, gint angle1
, gint angle2
);
106 void vik_viewport_draw_polygon ( VikViewport
*vvp
, GdkGC
*gc
, gboolean filled
, GdkPoint
*points
, gint npoints
);
108 void vik_viewport_set_center_utm ( VikViewport
*vvp
, const struct UTM
*utm
);
109 void vik_viewport_set_center_latlon ( VikViewport
*vvp
, const struct LatLon
*ll
);
111 /* you must set drawmode to set coord_mode */
112 VikCoordMode
vik_viewport_get_coord_mode ( const VikViewport
*vvp
);
114 gboolean
vik_viewport_is_one_zone ( VikViewport
*vvp
);
116 void vik_viewport_set_background_color ( VikViewport
*vvp
, const gchar
*color
);
117 /* pointer to static storage -- may change -- use quickly! */
118 const gchar
*vik_viewport_get_background_color ( VikViewport
*vvp
);
119 GdkColor
*vik_viewport_get_background_gdkcolor ( VikViewport
*vvp
);
120 void vik_viewport_set_background_gdkcolor ( VikViewport
*vvp
, GdkColor
* );
122 void vik_viewport_draw_layout ( VikViewport
*vvp
, GdkGC
*gc
, gint x
, gint y
, PangoLayout
*layout
);
124 /* warning: could be slow, don't obsessively use following function. */
125 void vik_gc_get_fg_color ( GdkGC
*gc
, GdkColor
*dest
);
127 GdkFunction
vik_gc_get_function ( GdkGC
*gc
);
129 void vik_viewport_pan_sync ( VikViewport
*vvp
, gint x_off
, gint y_off
);
131 typedef enum { VIK_VIEWPORT_DRAWMODE_UTM
=0, VIK_VIEWPORT_DRAWMODE_EXPEDIA
,
132 VIK_VIEWPORT_DRAWMODE_GOOGLE
, VIK_VIEWPORT_DRAWMODE_KH
, VIK_VIEWPORT_DRAWMODE_MERCATOR
} VikViewportDrawMode
;
135 void vik_viewport_set_drawmode ( VikViewport
*vvp
, VikViewportDrawMode drawmode
);
136 VikViewportDrawMode
vik_viewport_get_drawmode ( VikViewport
*vvp
);
137 void vik_viewport_corners_for_zonen ( VikViewport
*vvp
, int zone
, VikCoord
*ul
, VikCoord
*br
);