Add missing include glib/gprintf.h
[viking.git] / src / vikviewport.h
blob0135b17758fdfe96c9dd2a636d91b242f0e77273
1 /*
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*/
26 #include <glib.h>
27 #include <glib-object.h>
28 #include <gtk/gtkdrawingarea.h>
30 #include "vikcoord.h"
33 G_BEGIN_DECLS
36 #define VIK_VIEWPORT_TYPE (vik_viewport_get_type ())
37 #define VIK_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_VIEWPORT_TYPE, VikViewport))
38 #define VIK_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_VIEWPORT_TYPE, VikViewportClass))
39 #define IS_VIK_VIEWPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIK_VIEWPORT_TYPE))
40 #define IS_VIK_VIEWPORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VIK_VIEWPORT_TYPE))
42 #define VIK_VIEWPORT_MAX_ZOOM 8192.0
43 #define VIK_VIEWPORT_MIN_ZOOM 0.125
45 /* used for coord to screen etc, screen to coord */
46 #define VIK_VIEWPORT_UTM_WRONG_ZONE -9999999
47 #define VIK_VIEWPORT_OFF_SCREEN_DOUBLE -9999999.9
50 /* Glib type inheritance and initialization */
51 typedef struct _VikViewport VikViewport;
52 typedef struct _VikViewportClass VikViewportClass;
54 struct _VikViewportClass
56 GtkDrawingAreaClass drawing_area_class;
58 GType vik_viewport_get_type ();
61 /* Viking initialization */
62 VikViewport *vik_viewport_new ();
63 void vik_viewport_configure_manually ( VikViewport *vvp, gint width, guint height ); /* for off-screen viewports */
64 gboolean vik_viewport_configure ( VikViewport *vp );
67 /* coordinate transformations */
68 void vik_viewport_screen_to_coord ( VikViewport *vvp, int x, int y, VikCoord *coord );
69 void vik_viewport_coord_to_screen ( VikViewport *vvp, const VikCoord *coord, int *x, int *y );
72 /* viewport scale */
73 void vik_viewport_set_ympp ( VikViewport *vvp, gdouble ympp );
74 void vik_viewport_set_xmpp ( VikViewport *vvp, gdouble xmpp );
75 gdouble vik_viewport_get_ympp ( VikViewport *vvp );
76 gdouble vik_viewport_get_xmpp ( VikViewport *vvp );
77 void vik_viewport_set_zoom ( VikViewport *vvp, gdouble mpp );
78 gdouble vik_viewport_get_zoom ( VikViewport *vvp );
79 void vik_viewport_zoom_in ( VikViewport *vvp );
80 void vik_viewport_zoom_out ( VikViewport *vvp );
83 /* viewport position */
84 const VikCoord *vik_viewport_get_center ( VikViewport *vvp );
85 void vik_viewport_set_center_coord ( VikViewport *vvp, const VikCoord *coord );
86 void vik_viewport_set_center_screen ( VikViewport *vvp, int x, int y );
87 void vik_viewport_center_for_zonen ( VikViewport *vvp, struct UTM *center, int zone);
88 gchar vik_viewport_leftmost_zone ( VikViewport *vvp );
89 gchar vik_viewport_rightmost_zone ( VikViewport *vvp );
90 void vik_viewport_set_center_utm ( VikViewport *vvp, const struct UTM *utm );
91 void vik_viewport_set_center_latlon ( VikViewport *vvp, const struct LatLon *ll );
92 void vik_viewport_corners_for_zonen ( VikViewport *vvp, int zone, VikCoord *ul, VikCoord *br );
93 void vik_viewport_get_min_max_lat_lon ( VikViewport *vp, gdouble *min_lat, gdouble *max_lat, gdouble *min_lon, gdouble *max_lon );
96 /* drawmode management */
97 typedef enum {
98 VIK_VIEWPORT_DRAWMODE_UTM=0,
99 VIK_VIEWPORT_DRAWMODE_EXPEDIA,
100 VIK_VIEWPORT_DRAWMODE_MERCATOR,
101 VIK_VIEWPORT_NUM_DRAWMODES
102 } VikViewportDrawMode;
104 VikCoordMode vik_viewport_get_coord_mode ( const VikViewport *vvp );
105 gboolean vik_viewport_is_one_zone ( VikViewport *vvp );
106 const gchar *vik_viewport_get_drawmode_name(VikViewport *vv, VikViewportDrawMode mode);
107 void vik_viewport_set_drawmode ( VikViewport *vvp, VikViewportDrawMode drawmode );
108 VikViewportDrawMode vik_viewport_get_drawmode ( VikViewport *vvp );
109 /* Do not forget to update vik_viewport_get_drawmode_name() if you modify VikViewportDrawMode */
112 /* Triggers */
113 void vik_viewport_set_trigger ( VikViewport *vp, gpointer trigger );
114 gpointer vik_viewport_get_trigger ( VikViewport *vp );
115 void vik_viewport_snapshot_save ( VikViewport *vp );
116 void vik_viewport_snapshot_load ( VikViewport *vp );
117 void vik_viewport_set_half_drawn(VikViewport *vp, gboolean half_drawn);
118 gboolean vik_viewport_get_half_drawn( VikViewport *vp );
121 /***************************************************************************************************
122 * Drawing-related operations
123 ***************************************************************************************************/
125 /* Viewport buffer management/drawing to screen */
126 GdkPixmap *vik_viewport_get_pixmap ( VikViewport *vvp ); /* get pointer to drawing buffer */
127 void vik_viewport_sync ( VikViewport *vvp ); /* draw buffer to window */
128 void vik_viewport_pan_sync ( VikViewport *vvp, gint x_off, gint y_off );
129 void vik_viewport_clear ( VikViewport *vvp );
130 void vik_viewport_draw_pixbuf_with_alpha ( VikViewport *vvp, GdkPixbuf *pixbuf, gint alpha,
131 gint src_x, gint src_y, gint dest_x, gint dest_y, gint w, gint h );
132 void vik_viewport_draw_pixbuf ( VikViewport *vvp, GdkPixbuf *pixbuf, gint src_x, gint src_y,
133 gint dest_x, gint dest_y, gint w, gint h );
134 gint vik_viewport_get_width ( VikViewport *vvp );
135 gint vik_viewport_get_height ( VikViewport *vvp );
137 /* Viewport features */
138 void vik_viewport_draw_scale ( VikViewport *vvp );
139 void vik_viewport_set_draw_scale ( VikViewport *vvp, gboolean draw_scale );
140 gboolean vik_viewport_get_draw_scale ( VikViewport *vvp );
141 void vik_viewport_draw_centermark ( VikViewport *vvp );
142 void vik_viewport_set_draw_centermark ( VikViewport *vvp, gboolean draw_centermark );
143 gboolean vik_viewport_get_draw_centermark ( VikViewport *vvp );
145 /* Color/graphics context management */
146 void vik_viewport_set_background_color ( VikViewport *vvp, const gchar *color );
147 const gchar *vik_viewport_get_background_color ( VikViewport *vvp );
148 GdkColor *vik_viewport_get_background_gdkcolor ( VikViewport *vvp );
149 void vik_viewport_set_background_gdkcolor ( VikViewport *vvp, GdkColor * );
150 void vik_gc_get_fg_color ( GdkGC *gc, GdkColor *dest ); /* warning: could be slow, don't use obsessively */
151 GdkGC *vik_viewport_new_gc ( VikViewport *vvp, const gchar *colorname, gint thickness );
152 GdkGC *vik_viewport_new_gc_from_color ( VikViewport *vvp, GdkColor *color, gint thickness );
153 GdkFunction vik_gc_get_function ( GdkGC *gc );
155 /* Drawing primitives */
156 void a_viewport_clip_line ( gint *x1, gint *y1, gint *x2, gint *y2 ); /* run this before drawing a line. vik_viewport_draw_line runs it for you */
157 void vik_viewport_draw_line ( VikViewport *vvp, GdkGC *gc, gint x1, gint y1, gint x2, gint y2 );
158 void vik_viewport_draw_rectangle ( VikViewport *vvp, GdkGC *gc, gboolean filled, gint x1, gint y1, gint x2, gint y2 );
159 void vik_viewport_draw_string ( VikViewport *vvp, GdkFont *font, GdkGC *gc, gint x1, gint y1, const gchar *string );
160 void vik_viewport_draw_arc ( VikViewport *vvp, GdkGC *gc, gboolean filled, gint x, gint y, gint width, gint height, gint angle1, gint angle2 );
161 void vik_viewport_draw_polygon ( VikViewport *vvp, GdkGC *gc, gboolean filled, GdkPoint *points, gint npoints );
162 void vik_viewport_draw_layout ( VikViewport *vvp, GdkGC *gc, gint x, gint y, PangoLayout *layout );
166 G_END_DECLS
168 #endif