navit  0.5.3-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
graphics.c File Reference
#include <stdlib.h>
#include <glib.h>
#include <stdio.h>
#include <math.h>
#include "config.h"
#include "debug.h"
#include "string.h"
#include "draw_info.h"
#include "point.h"
#include "graphics.h"
#include "projection.h"
#include "item.h"
#include "xmlconfig.h"
#include "map.h"
#include "coord.h"
#include "transform.h"
#include "plugin.h"
#include "profile.h"
#include "mapset.h"
#include "layout.h"
#include "route.h"
#include "util.h"
#include "callback.h"
#include "file.h"
#include "event.h"

Data Structures

struct  graphics
 graphics object A graphics object serves as the target for drawing operations. It encapsulates various settings, and a drawing target, such as an image buffer or a window. Currently, in Navit, there is always one main graphics object, which is used to draw the map, and optionally additional graphics objects for overlays. More...
 
struct  display_context
 
struct  hash_entry
 
struct  displaylist
 
struct  displaylist_icon_cache
 
struct  displayitem
 
struct  circle
 
struct  draw_polyline_shape
 
struct  draw_polyline_context
 
struct  wpoint
 
struct  displaylist_handle
 

Macros

#define HASH_SIZE   1024
 

Enumerations

enum  relative_pos {
  INSIDE = 0, LEFT_OF = 1, RIGHT_OF = 2, ABOVE = 4,
  BELOW = 8
}
 
enum  clip_result { CLIPRES_INVISIBLE = 0, CLIPRES_VISIBLE = 1, CLIPRES_START_CLIPPED = 2, CLIPRES_END_CLIPPED = 4 }
 

Functions

static void circle_to_points (const struct point *center, int diameter, int scale, int start, int len, struct point *res, int *pos, int dir)
 Create a set of points on a circle or on a circular arc. More...
 
static void graphics_process_selection (struct graphics *gra, struct displaylist *dl)
 
static void graphics_gc_init (struct graphics *this_)
 
static void clear_hash (struct displaylist *dl)
 
static struct hash_entryget_hash_entry (struct displaylist *dl, enum item_type type)
 
static struct hash_entryset_hash_entry (struct displaylist *dl, enum item_type type)
 
static int graphics_set_attr_do (struct graphics *gra, struct attr *attr)
 Sets a generic attribute of the graphics instance. More...
 
int graphics_set_attr (struct graphics *gra, struct attr *attr)
 Sets an attribute of the graphics instance. More...
 
void graphics_set_rect (struct graphics *gra, struct point_rect *pr)
 
struct graphicsgraphics_new (struct attr *parent, struct attr **attrs)
 
int graphics_get_attr (struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
 Gets an attribute of the graphics instance. More...
 
struct graphicsgraphics_overlay_new (struct graphics *parent, struct point *p, int w, int h, int wraparound)
 Create a new graphics overlay. An overlay is a graphics object that is independent of the main graphics object. When drawing everything to a window, the overlay will be shown on top of the main graphics object. Navit uses overlays for OSD elements and for the vehicle on the map. This allows updating OSD elements and the vehicle without redrawing the map. More...
 
void graphics_overlay_resize (struct graphics *this_, struct point *p, int w, int h, int wraparound)
 Alters the size, position and wraparound for an overlay. More...
 
void graphics_init (struct graphics *this_)
 
void * graphics_get_data (struct graphics *this_, const char *type)
 
void graphics_add_callback (struct graphics *this_, struct callback *cb)
 
void graphics_remove_callback (struct graphics *this_, struct callback *cb)
 
struct graphics_fontgraphics_font_new (struct graphics *gra, int size, int flags)
 
struct graphics_fontgraphics_named_font_new (struct graphics *gra, char *font, int size, int flags)
 
void graphics_font_destroy (struct graphics_font *gra_font)
 
void graphics_free (struct graphics *gra)
 
void graphics_font_destroy_all (struct graphics *gra)
 
struct graphics_gcgraphics_gc_new (struct graphics *gra)
 
void graphics_gc_destroy (struct graphics_gc *gc)
 
static void graphics_convert_color (struct graphics *gra, struct color *in, struct color *out)
 
void graphics_gc_set_foreground (struct graphics_gc *gc, struct color *c)
 
void graphics_gc_set_background (struct graphics_gc *gc, struct color *c)
 
void graphics_gc_set_linewidth (struct graphics_gc *gc, int width)
 
void graphics_gc_set_dashes (struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n)
 
struct graphics_imagegraphics_image_new_scaled (struct graphics *gra, char *path, int w, int h)
 Create a new image from file path, optionally scaled to w and h pixels. More...
 
static void image_new_helper (struct graphics *gra, struct graphics_image *this_, char *path, char *name, int width, int height, int rotate, int zip)
 
struct graphics_imagegraphics_image_new_scaled_rotated (struct graphics *gra, char *path, int w, int h, int rotate)
 Create a new image from file path, optionally scaled to w and h pixels and rotated. More...
 
struct graphics_imagegraphics_image_new (struct graphics *gra, char *path)
 
void graphics_image_free (struct graphics *gra, struct graphics_image *img)
 
void graphics_draw_mode (struct graphics *this_, enum draw_mode_num mode)
 Start or finish a set of drawing operations. More...
 
void graphics_draw_lines (struct graphics *this_, struct graphics_gc *gc, struct point *p, int count)
 
void graphics_draw_circle (struct graphics *this_, struct graphics_gc *gc, struct point *p, int r)
 Draw a circle. More...
 
void graphics_draw_rectangle (struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h)
 
void graphics_draw_rectangle_rounded (struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill)
 
void graphics_draw_text (struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2, struct graphics_font *font, char *text, struct point *p, int dx, int dy)
 
void graphics_get_text_bbox (struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate)
 
void graphics_overlay_disable (struct graphics *this_, int disable)
 
int graphics_is_disabled (struct graphics *this_)
 
void graphics_draw_image (struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img)
 
int graphics_draw_drag (struct graphics *this_, struct point *p)
 
void graphics_background_gc (struct graphics *this_, struct graphics_gc *gc)
 
int graphics_show_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd)
 Shows the native on-screen keyboard or other input method. More...
 
int graphics_hide_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd)
 Hides the native on-screen keyboard or other input method. More...
 
static void xdisplay_free (struct displaylist *dl)
 
static void display_add (struct hash_entry *entry, struct item *item, int count, struct coord *c, char **label, int label_count)
 
static void label_line (struct graphics *gra, struct graphics_gc *fg, struct graphics_gc *bg, struct graphics_font *font, struct point *p, int count, char *label)
 
static void display_draw_arrow (struct point *p, int dx, int dy, int l, struct graphics_gc *gc, struct graphics *gra)
 
static void display_draw_arrows (struct graphics *gra, struct graphics_gc *gc, struct point *pnt, int count)
 
static int intersection (struct point *a1, int adx, int ady, struct point *b1, int bdx, int bdy, struct point *res)
 
static int fowler (int dy, int dx)
 
static void draw_shape_update (struct draw_polyline_shape *shape)
 
static void draw_shape (struct draw_polyline_context *ctx, struct point *pnt, int wi)
 
static void draw_point (struct draw_polyline_shape *shape, struct point *src, struct point *dst, int pos)
 
static void draw_begin (struct draw_polyline_context *ctx, struct point *p)
 
static int draw_middle (struct draw_polyline_context *ctx, struct point *p)
 
static void draw_end (struct draw_polyline_context *ctx, struct point *p)
 
static void draw_init_ctx (struct draw_polyline_context *ctx, int maxpoints)
 
static void graphics_draw_polyline_as_polygon (struct graphics_priv *gra_priv, struct graphics_gc_priv *gc_priv, struct point *pnt, int count, int *width, void(*draw)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count))
 
static int relative_pos (struct wpoint *p, struct point_rect *r)
 
static void clip_line_endoint_to_rect_edge (struct wpoint *p, int rel_pos, int dx, int dy, int dw, struct point_rect *clip_rect)
 
static int clip_line (struct wpoint *p1, struct wpoint *p2, struct point_rect *clip_rect)
 
void graphics_draw_polyline_clipped (struct graphics *gra, struct graphics_gc *gc, struct point *pa, int count, int *width, int poly)
 Draw polyline on the display. More...
 
static int is_inside (struct point *p, struct point_rect *r, int edge)
 
static void poly_intersection (struct point *p1, struct point *p2, struct point_rect *r, int edge, struct point *ret)
 
void graphics_draw_polygon_clipped (struct graphics *gra, struct graphics_gc *gc, struct point *pin, int count_in)
 Draw a plain polygon on the display. More...
 
static void display_context_free (struct display_context *dc)
 
static struct graphics_fontget_font (struct graphics *gra, int size)
 
void graphics_draw_text_std (struct graphics *this_, int text_size, char *text, struct point *p)
 
char * graphics_icon_path (const char *icon)
 
static int limit_count (struct coord *c, int count)
 
static void multiline_label_draw (struct graphics *gra, struct graphics_gc *fg, struct graphics_gc *bg, struct graphics_font *font, struct point pref, const char *label, int line_spacing)
 Draw a multi-line text next to a specified point pref. More...
 
static void displayitem_draw (struct displayitem *di, void *dummy, struct display_context *dc)
 Draw a displayitem element. More...
 
static void xdisplay_draw_elements (struct graphics *gra, struct displaylist *display_list, struct itemgra *itm)
 
void graphics_draw_itemgra (struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label)
 
static void xdisplay_draw_layer (struct displaylist *display_list, struct graphics *gra, struct layer *lay, int order)
 
static void xdisplay_draw (struct displaylist *display_list, struct graphics *gra, struct layout *l, int order)
 
static void displaylist_update_layers (struct displaylist *displaylist, GList *layers, int order)
 
static void displaylist_update_hash (struct displaylist *displaylist)
 
struct map_selectiondisplaylist_get_selection (struct displaylist *displaylist)
 Returns selection structure based on displaylist transform, projection and order. Use this function to get map selection if you are going to fetch complete item data from the map based on displayitem reference. More...
 
static int displaylist_cmp_zorder (const struct displayitem *a, const struct displayitem *b)
 Compare displayitems based on their zorder values. Use with g_list_insert_sorted to sort less shaded items to be before more shaded ones in the result list. More...
 
GListdisplaylist_get_clicked_list (struct displaylist *displaylist, struct point *p, int radius)
 Returns list of displayitems clicked at given coordinates. The deeper item is in current layout, the deeper it will be in the list. More...
 
static void do_draw (struct displaylist *displaylist, int cancel, int flags)
 
void graphics_displaylist_draw (struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags)
 
static void graphics_load_mapset (struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags)
 
void graphics_draw (struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags)
 
int graphics_draw_cancel (struct graphics *gra, struct displaylist *displaylist)
 
struct displaylist_handlegraphics_displaylist_open (struct displaylist *displaylist)
 
struct displayitemgraphics_displaylist_next (struct displaylist_handle *dlh)
 
void graphics_displaylist_close (struct displaylist_handle *dlh)
 
struct displaylistgraphics_displaylist_new (void)
 
void graphics_displaylist_destroy (struct displaylist *displaylist)
 
struct itemgraphics_displayitem_get_item (struct displayitem *di)
 
int graphics_displayitem_get_z_order (struct displayitem *di)
 
int graphics_displayitem_get_coord_count (struct displayitem *di)
 
char * graphics_displayitem_get_label (struct displayitem *di)
 
int graphics_displayitem_get_displayed (struct displayitem *di)
 
static int within_dist_point (struct point *p0, struct point *p1, int dist)
 
static int within_dist_line (struct point *p, struct point *line_p0, struct point *line_p1, int dist)
 
static int within_dist_polyline (struct point *p, struct point *line_pnt, int count, int dist, int close)
 
static int within_dist_polygon (struct point *p, struct point *poly_pnt, int count, int dist)
 
int graphics_displayitem_within_dist (struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist)
 
static void graphics_process_selection_item (struct displaylist *dl, struct item *item)
 
void graphics_add_selection (struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl)
 
void graphics_remove_selection (struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl)
 
void graphics_clear_selection (struct graphics *gra, struct displaylist *dl)
 

Variables

struct circle circle64 []
 
void * route_selection
 

Macro Definition Documentation

Enumeration Type Documentation

Enumerator
CLIPRES_INVISIBLE 
CLIPRES_VISIBLE 
CLIPRES_START_CLIPPED 
CLIPRES_END_CLIPPED 
Enumerator
INSIDE 
LEFT_OF 
RIGHT_OF 
ABOVE 
BELOW 

Function Documentation

static void circle_to_points ( const struct point center,
int  diameter,
int  scale,
int  start,
int  len,
struct point res,
int pos,
int  dir 
)
static

Create a set of points on a circle or on a circular arc.

Parameters
centerCenter point of the circle
diameterDiameter of the circle
scaleUnused
startPosition of the first point on the circle (in 1/1024th of the circle), -1 being the bottom of the circle, 511 being the top of the circle
lenLength of the arc on the circle, relative to start (in 1/1024th of the circle), 514 is half a circle, 1028 is a full circle (or 1027 if first and last points are connected with a line)
[out]resReturned an array of points that will form the resulting circle
[out]posIndex of the last point filled inside array res
dirDirection of the circle (valid values are 1 (counter-clockwise) or -1 (clockwise), other values may lead to unknown result)

References c, circle64, fowler(), startup::pos, point::x, circle::x, point::y, and circle::y.

Referenced by graphics_draw_circle(), and graphics_draw_rectangle_rounded().

static void clear_hash ( struct displaylist dl)
static
static int clip_line ( struct wpoint p1,
struct wpoint p2,
struct point_rect clip_rect 
)
static
static void clip_line_endoint_to_rect_edge ( struct wpoint p,
int  rel_pos,
int  dx,
int  dy,
int  dw,
struct point_rect clip_rect 
)
static
static void display_add ( struct hash_entry entry,
struct item item,
int  count,
struct coord c,
char **  label,
int  label_count 
)
static

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References displayitem::c, displayitem::count, hash_entry::di, item, displayitem::item, displayitem::label, displayitem::next, p, and displayitem::z_order.

Referenced by do_draw(), and graphics_process_selection_item().

static void display_draw_arrow ( struct point p,
int  dx,
int  dy,
int  l,
struct graphics_gc gc,
struct graphics gra 
)
static
static void display_draw_arrows ( struct graphics gra,
struct graphics_gc gc,
struct point pnt,
int  count 
)
static

References display_draw_arrow(), point::x, and point::y.

Referenced by displayitem_draw().

static void displayitem_draw ( struct displayitem di,
void *  dummy,
struct display_context dc 
)
static
static int displaylist_cmp_zorder ( const struct displayitem a,
const struct displayitem b 
)
static

Compare displayitems based on their zorder values. Use with g_list_insert_sorted to sort less shaded items to be before more shaded ones in the result list.

References displayitem::z_order.

Referenced by displaylist_get_clicked_list().

GList* displaylist_get_clicked_list ( struct displaylist displaylist,
struct point p,
int  radius 
)

Returns list of displayitems clicked at given coordinates. The deeper item is in current layout, the deeper it will be in the list.

Parameters
displaylist
pclicked point
radiusradius of clicked area
Returns
GList of displayitems

References displaylist_cmp_zorder(), graphics_displayitem_within_dist(), graphics_displaylist_close(), graphics_displaylist_next(), graphics_displaylist_open(), and displayitem::z_order.

Referenced by gui_internal_cmd_position_do().

struct map_selection* displaylist_get_selection ( struct displaylist displaylist)

Returns selection structure based on displaylist transform, projection and order. Use this function to get map selection if you are going to fetch complete item data from the map based on displayitem reference.

Parameters
displaylist
Returns
Pointer to selection structure

References displaylist::dc, displaylist::order, display_context::pro, display_context::trans, and transform_get_selection().

Referenced by do_draw(), and gui_internal_cmd_position_do().

static void displaylist_update_hash ( struct displaylist displaylist)
static
static void displaylist_update_layers ( struct displaylist displaylist,
GList layers,
int  order 
)
static
static void draw_init_ctx ( struct draw_polyline_context ctx,
int  maxpoints 
)
static
static void draw_point ( struct draw_polyline_shape shape,
struct point src,
struct point dst,
int  pos 
)
static
static int fowler ( int  dy,
int  dx 
)
static

Referenced by circle_to_points(), and draw_shape().

static struct graphics_font* get_font ( struct graphics gra,
int  size 
)
static
static struct hash_entry* get_hash_entry ( struct displaylist dl,
enum item_type  type 
)
static
void graphics_add_selection ( struct graphics gra,
struct item item,
enum item_type  type,
struct displaylist dl 
)
void graphics_background_gc ( struct graphics this_,
struct graphics_gc gc 
)
void graphics_clear_selection ( struct graphics gra,
struct displaylist dl 
)
static void graphics_convert_color ( struct graphics gra,
struct color in,
struct color out 
)
static
int graphics_displayitem_get_coord_count ( struct displayitem di)

References displayitem::count.

Referenced by popup_show_item().

int graphics_displayitem_get_displayed ( struct displayitem di)
struct item* graphics_displayitem_get_item ( struct displayitem di)

Get the map item which given displayitem is based on. NOTE: returned structure doesn't contain any attributes or coordinates. type, map, idhi and idlow seem to be the only useable members.

Parameters
dipointer to displayitem structure
Returns
Pointer to struct item
Author
Martin Schaller (04/2008)

References displayitem::item.

Referenced by gui_internal_cmd_position_do(), gui_internal_dbus_signal(), gui_qml_dbus_signal(), and popup_show_item().

char* graphics_displayitem_get_label ( struct displayitem di)

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References displayitem::label.

Referenced by popup_show_item().

int graphics_displayitem_get_z_order ( struct displayitem di)

Get the number of this item as it was last displayed on the screen, dependent of current layout. Items with lower numbers are shaded by items with higher ones when they overlap. Zero means item was not displayed at all. If the item is displayed twice, its topmost occurence is used.

Parameters
dipointer to displayitem structure
Returns
z-order of current item.

References displayitem::z_order.

int graphics_displayitem_within_dist ( struct displaylist displaylist,
struct displayitem di,
struct point p,
int  dist 
)
void graphics_displaylist_close ( struct displaylist_handle dlh)

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

Referenced by displaylist_get_clicked_list(), gui_internal_cmd_position_do(), gui_internal_dbus_signal(), gui_qml_dbus_signal(), and popup_display().

void graphics_displaylist_destroy ( struct displaylist displaylist)
struct displaylist* graphics_displaylist_new ( void  )

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References displaylist::dc, and display_context::maxlen.

Referenced by navit_new().

struct displaylist_handle* graphics_displaylist_open ( struct displaylist displaylist)

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References displaylist_handle::dl.

Referenced by displaylist_get_clicked_list(), gui_internal_cmd_position_do(), gui_internal_dbus_signal(), gui_qml_dbus_signal(), and popup_display().

void graphics_draw ( struct graphics gra,
struct displaylist displaylist,
struct mapset mapset,
struct transformation trans,
struct layout l,
int  async,
struct callback cb,
int  flags 
)

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References graphics_load_mapset().

Referenced by navit_draw_async(), osd_auxmap_draw(), and pedestrian_cmd_pedestrian_rocket().

int graphics_draw_cancel ( struct graphics gra,
struct displaylist displaylist 
)
void graphics_draw_circle ( struct graphics this_,
struct graphics_gc gc,
struct point p,
int  r 
)

Draw a circle.

Parameters
this_The graphics instance on which to draw
gcThe graphics context
pThe coordinates of the center of the circle
rThe radius of the circle
Author
Martin Schaller (04/2008)

References circle_to_points(), graphics_methods::draw_circle, graphics_methods::draw_lines, graphics::meth, graphics::priv, and graphics_gc::priv.

Referenced by displayitem_draw(), gui_internal_cmd2_route_height_profile(), osd_auxmap_draw(), osd_compass_draw(), and osd_speed_warner_draw().

int graphics_draw_drag ( struct graphics this_,
struct point p 
)
void graphics_draw_lines ( struct graphics this_,
struct graphics_gc gc,
struct point p,
int  count 
)

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References graphics_methods::draw_lines, graphics::meth, graphics::priv, and graphics_gc::priv.

Referenced by draw_handle(), gui_internal_box_render(), gui_internal_cmd2_route_height_profile(), and osd_scale_draw().

void graphics_draw_mode ( struct graphics this_,
enum draw_mode_num  mode 
)

Start or finish a set of drawing operations.

graphics_draw_mode(draw_mode_begin) must be invoked before performing any drawing operations; this allows the graphics driver to perform any necessary setup. graphics_draw_mode(draw_mode_end) must be invoked to finish a set of drawing operations; this will typically clean up drawing resources and display the drawing result.

Parameters
this_graphics object that is being drawn to
modespecify beginning or end of drawing
Author
Martin Schaller (04/2008)

References graphics_methods::draw_mode, graphics::meth, and graphics::priv.

Referenced by draw_aligned_osd_text(), gui_internal_button(), gui_internal_cmd2(), gui_internal_cmd2_about(), gui_internal_cmd2_back(), gui_internal_cmd2_locale(), gui_internal_cmd2_network_info(), gui_internal_highlight_do(), gui_internal_highlight_possible_keys(), gui_internal_html_menu(), gui_internal_html_submit(), gui_internal_keypress(), gui_internal_leave(), gui_internal_motion_cb(), gui_internal_route_update(), gui_internal_search_idle(), gui_internal_set_attr(), navit_map_progress(), navit_motion_timeout(), navit_set_attr_do(), osd_auxmap_draw(), osd_button_init(), osd_cmd_interface_draw(), osd_compass_draw(), osd_fill_with_bgcolor(), osd_gps_status_draw(), osd_image_init(), osd_j1850_draw(), osd_nav_next_turn_draw(), osd_nav_toggle_announcer_draw(), osd_navigation_status_draw_do(), osd_odometer_draw(), osd_route_guard_draw(), osd_scale_draw(), osd_speed_cam_draw(), osd_speed_warner_draw(), osd_stopwatch_draw(), osd_text_draw(), osd_volume_draw(), and vehicle_draw_do().

void graphics_draw_polygon_clipped ( struct graphics gra,
struct graphics_gc gc,
struct point pin,
int  count_in 
)

Draw a plain polygon on the display.

Parameters
graThe graphics instance on which to draw
gcThe graphics context
[in]pinAn array of points forming the polygon
count_inThe number of elements inside pin

References graphics_methods::draw_polygon, is_inside(), limit, graphics::meth, p, poly_intersection(), graphics::priv, graphics_gc::priv, and graphics::r.

Referenced by displayitem_draw(), and draw_compass().

static void graphics_draw_polyline_as_polygon ( struct graphics_priv gra_priv,
struct graphics_gc_priv gc_priv,
struct point pnt,
int  count,
int width,
void(*)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)  draw 
)
static
void graphics_draw_polyline_clipped ( struct graphics gra,
struct graphics_gc gc,
struct point pa,
int  count,
int width,
int  poly 
)

Draw polyline on the display.

Polylines are a serie of lines connected to each other.

Parameters
graThe graphics instance on which to draw
gcThe graphics context
[in]pinAn array of points forming the polygon
count_inThe number of elements inside pin
[in]widthAn array of width matching the line starting from the corresponding pa (if all equal, all lines will have the same width)
polyA boolean indicating whether the polyline should be closed to form a polygon (only the contour of this polygon will be drawn)

References clip_line(), CLIPRES_END_CLIPPED, CLIPRES_INVISIBLE, CLIPRES_START_CLIPPED, dbg, graphics_methods::draw_lines, graphics_methods::draw_polygon, graphics_draw_polyline_as_polygon(), point_rect::lu, lvl_debug, graphics::meth, graphics::priv, graphics_gc::priv, graphics::r, point_rect::rl, wpoint::w, point::x, wpoint::x, point::y, and wpoint::y.

Referenced by displayitem_draw(), and draw_compass().

void graphics_draw_rectangle ( struct graphics this_,
struct graphics_gc gc,
struct point p,
int  w,
int  h 
)
void graphics_draw_rectangle_rounded ( struct graphics this_,
struct graphics_gc gc,
struct point plu,
int  w,
int  h,
int  r,
int  fill 
)
void graphics_draw_text ( struct graphics this_,
struct graphics_gc gc1,
struct graphics_gc gc2,
struct graphics_font font,
char *  text,
struct point p,
int  dx,
int  dy 
)
void graphics_draw_text_std ( struct graphics this_,
int  text_size,
char *  text,
struct point p 
)
void graphics_font_destroy ( struct graphics_font gra_font)
void graphics_font_destroy_all ( struct graphics gra)

Free all loaded fonts. Used when switching layouts.

Parameters
graThe graphics instance
Returns
nothing
Author
Sarah Nordstrom (05/2008)

References graphics::font, graphics_font_methods::font_destroy, graphics::font_len, graphics_font::meth, and graphics_font::priv.

Referenced by graphics_free(), and navit_set_attr_do().

struct graphics_font* graphics_font_new ( struct graphics gra,
int  size,
int  flags 
)

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References graphics::default_font, graphics_methods::font_new, graphics::meth, graphics_font::meth, graphics::priv, and graphics_font::priv.

Referenced by get_font(), and gui_internal_apply_config().

void graphics_free ( struct graphics gra)
void graphics_gc_destroy ( struct graphics_gc gc)

Destroy a graphics context, freeing associated resources.

Parameters
gccontext to destroy
Author
Martin Schaller (04/2008)

References graphics_gc_methods::gc_destroy, graphics_gc::meth, and graphics_gc::priv.

Referenced by display_context_free(), graphics_free(), pedestrian_draw_arrow(), pedestrian_graphics_postdraw(), and vehicle_destroy().

static void graphics_gc_init ( struct graphics this_)
static
void graphics_gc_set_background ( struct graphics_gc gc,
struct color c 
)
void graphics_gc_set_dashes ( struct graphics_gc gc,
int  width,
int  offset,
unsigned char  dash_list[],
int  n 
)

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References graphics_gc_methods::gc_set_dashes, graphics_gc::meth, and graphics_gc::priv.

Referenced by displayitem_draw().

void graphics_gc_set_linewidth ( struct graphics_gc gc,
int  width 
)
int graphics_get_attr ( struct graphics this_,
enum attr_type  type,
struct attr attr,
struct attr_iter iter 
)

Gets an attribute of the graphics instance.

This function searches the attribute list of the graphics object for an attribute of a given type and stores it in the attr parameter.

Searching for attr_any or attr_any_xml is supported.

An iterator can be specified to get multiple attributes of the same type: The first call will return the first match from attr; each subsequent call with the same iterator will return the next match. If no more matching attributes are found in either of them, false is returned.

Note that currently this will only return the generic attributes which can be set with graphics_set_attr_do(struct graphics *, struct attr *). Attributes implemented by a graphics plugin cannot be retrieved with this method.

Parameters
thisThe graphics instance
typeThe attribute type to search for
attrPoints to a
struct attr
which will receive the attribute
iterAn iterator. This parameter may be NULL.
Returns
True if a matching attribute was found, false if not.
Author
Martin Schaller (04/2008)

References attr_generic_get_attr(), and graphics::attrs.

Referenced by navit_init().

void graphics_get_text_bbox ( struct graphics this_,
struct graphics_font font,
char *  text,
int  dx,
int  dy,
struct point ret,
int  estimate 
)
int graphics_hide_native_keyboard ( struct graphics this_,
struct graphics_keyboard kbd 
)

Hides the native on-screen keyboard or other input method.

This method is a wrapper around the respective method of the graphics plugin.

A call to this function indicates that Navit no longer needs the input method and is about to reclaim any screen real estate it may have previously reserved for the input method.

On platforms that don't support overlapping windows this means that the on-screen input method should be hidden, as it may otherwise obstruct parts of Navit's UI.

On windowed platforms, where on-screen input methods can be displayed alongside Navit or moved around as needed, the graphics driver should instead notify the on-screen method that it is no longer expecting user input, allowing the input method to take the appropriate action.

The graphics plugin must free any data it has stored in

kbd->gra_priv

and reset the pointer to

NULL

to indicate it has done so.

The caller may free

kbd

after this function returns.

Parameters
thisThe graphics instance
kbdThe keyboard instance
Returns
True if the call was successfully passed to the plugin, false if the method is not supported by the plugin

References graphics_methods::hide_native_keyboard, and graphics::meth.

Referenced by gui_internal_keyboard_hide_native().

struct graphics_image* graphics_image_new ( struct graphics gra,
char *  path 
)

Create a new image from file path

Parameters
grathe graphics instance
pathpath of the image to load
Returns
<>
Author
Martin Schaller (04/2008)

References graphics_image_new_scaled_rotated().

Referenced by osd_cmd_interface_set_attr(), osd_image_init(), and pedestrian_draw_arrow().

struct graphics_image* graphics_image_new_scaled ( struct graphics gra,
char *  path,
int  w,
int  h 
)

Create a new image from file path, optionally scaled to w and h pixels.

Parameters
grathe graphics instance
pathpath of the image to load
wwidth to rescale to, or IMAGE_W_H_UNSET for original width
hheight to rescale to, or IMAGE_W_H_UNSET for original height
Returns
<>
Author
Martin Schaller (04/2008)

References graphics_image_new_scaled_rotated().

Referenced by image_new_scaled(), osd_button_draw(), osd_button_init(), osd_button_set_attr(), osd_gps_status_draw(), osd_nav_next_turn_draw(), osd_nav_toggle_announcer_draw(), osd_navigation_status_draw_do(), and osd_volume_draw().

struct graphics_image* graphics_image_new_scaled_rotated ( struct graphics gra,
char *  path,
int  w,
int  h,
int  rotate 
)

Create a new image from file path, optionally scaled to w and h pixels and rotated.

Parameters
grathe graphics instance
pathpath of the image to load
wwidth to rescale to, or IMAGE_W_H_UNSET for original width
hheight to rescale to, or IMAGE_W_H_UNSET for original height
rotateangle to rotate the image, in 90 degree steps (not supported by all plugins).
Returns
<>
Author
Martin Schaller (04/2008)

References dbg, file_wordexp_destroy(), file_wordexp_get_array(), file_wordexp_get_count(), file_wordexp_new(), graphics::image_cache_hash, image_new_helper(), lvl_debug, lvl_error, name, and file_wordexp::we.

Referenced by displayitem_draw(), graphics_image_new(), and graphics_image_new_scaled().

void graphics_init ( struct graphics this_)

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References graphics::gc, graphics_background_gc(), graphics_gc_init(), and graphics_gc_new().

Referenced by navit_handle_resize(), and vehicle_draw().

int graphics_is_disabled ( struct graphics this_)

References graphics::disabled, and graphics::parent.

Referenced by osd_std_keypress().

struct graphics_font* graphics_named_font_new ( struct graphics gra,
char *  font,
int  size,
int  flags 
)
struct graphics* graphics_new ( struct attr parent,
struct attr **  attrs 
)
struct graphics* graphics_overlay_new ( struct graphics parent,
struct point p,
int  w,
int  h,
int  wraparound 
)

Create a new graphics overlay. An overlay is a graphics object that is independent of the main graphics object. When drawing everything to a window, the overlay will be shown on top of the main graphics object. Navit uses overlays for OSD elements and for the vehicle on the map. This allows updating OSD elements and the vehicle without redrawing the map.

Parameters
parentparent graphics context (should be the main graphics context as returned by graphics_new)
pdrawing position for the overlay
wwidth of overlay
hheight of overlay
wraparounduse wraparound (0/1). If set, position, width and height "wrap around": negative position coordinates wrap around the window, negative width/height specify difference to window width/height.
Returns
new overlay
Author
Martin Schaller (04/2008)

References graphics::font_size, graphics_set_rect(), graphics::image_cache_hash, point_rect::lu, graphics::meth, graphics_methods::overlay_new, graphics::parent, graphics::priv, point_rect::rl, point::x, and point::y.

Referenced by osd_set_std_graphic(), and vehicle_draw().

void graphics_overlay_resize ( struct graphics this_,
struct point p,
int  w,
int  h,
int  wraparound 
)

Alters the size, position and wraparound for an overlay.

Parameters
this_The overlay's graphics struct
pThe new position of the overlay
wThe new width of the overlay
hThe new height of the overlay
wraparoundThe new wraparound of the overlay

References graphics::meth, graphics_methods::overlay_resize, and graphics::priv.

Referenced by osd_std_resize(), and vehicle_set_cursor().

static void graphics_process_selection ( struct graphics gra,
struct displaylist dl 
)
static
void graphics_remove_callback ( struct graphics this_,
struct callback cb 
)

References callback_list_remove(), and graphics::cbl.

Referenced by navit_destroy().

void graphics_remove_selection ( struct graphics gra,
struct item item,
enum item_type  type,
struct displaylist dl 
)
int graphics_set_attr ( struct graphics gra,
struct attr attr 
)

Sets an attribute of the graphics instance.

This method first tries to set one of the private attributes implemented by the current graphics plugin. If this fails, it tries to set one of the generic attributes.

If the graphics plugin does not supply a

method, this method currently does nothing and returns true, even if the attribute is a generic one.

Parameters
graThe graphics instance
attrThe attribute to set
Returns
True if the attribute was successfully set, false otherwise.

References dbg, graphics_set_attr_do(), lvl_debug, graphics::meth, graphics::priv, and graphics_methods::set_attr.

Referenced by NPP_SetWindow(), pedestrian_navit_init(), and request_graphics_set_attr().

static int graphics_set_attr_do ( struct graphics gra,
struct attr attr 
)
static

Sets a generic attribute of the graphics instance.

This will only set one of the supported generic graphics attributes (currently

gamma

,

brightness

,

contrast

or

font_size

) and fail for other attribute types.

To set an attribute provided by a graphics plugin, use graphics_set_attr(struct graphics *, struct attr *) instead.

Parameters
graThe graphics instance
attrThe attribute to set
Returns
True if the attribute was set, false if not

References graphics::brightness, graphics::colormgmt, graphics::contrast, graphics::font_size, graphics::gamma, graphics_gc_init(), attr::num, attr::type, and attr::u.

Referenced by graphics_new(), and graphics_set_attr().

void graphics_set_rect ( struct graphics gra,
struct point_rect pr 
)
int graphics_show_native_keyboard ( struct graphics this_,
struct graphics_keyboard kbd 
)

Shows the native on-screen keyboard or other input method.

This method is a wrapper around the respective method of the graphics plugin.

The caller should populate the

kbd

argument with appropriate

and

lang

members so the graphics plugin can determine the best matching layout.

If an input method is shown, the graphics plugin should try to select the configuration which best matches the specified

. For example, if

specifies a numeric layout, the graphics plugin should select a numeric keyboard layout (if available), or the equivalent for another input method (such as setting stroke recognition to identify strokes as numbers). Likewise, when an alphanumeric-uppercase mode is requested, it should switch to uppercase input.

Implementations should, however, consider that Navit's internal keyboard allows the user to switch modes at will (the only exception being degree mode) and thus must not "lock" the user into a limited layout with no means to switch to a general-purpose one. For example, house number entry in an address search dialog may default to numeric mode, but since some house numbers may contain non-numeric characters, a pure numeric keyboard is suitable only if the user has the option to switch to an alphanumeric layout.

When multiple alphanumeric layouts are available, the graphics plugin should use the

lang

argument to determine the best layout.

When selecting an input method, preference should always be given to the default or last selected input method and configuration if it matches the requested

and

lang

.

If the native input method is going to obstruct parts of Navit's UI, the graphics plugin should set

kbd->w

and

kbd->h

to the height and width to the appropriate value in pixels. A value of -1 indicates that the input method fills the entire available width or height of the space available to Navit. On windowed platforms, where the on-screen input method and Navit's window may be moved relative to each other as needed and can be displayed alongside each other, the graphics plugin should report 0 for both dimensions.

Parameters
this_The graphics instance
kbdThe keyboard instance
Returns
1 if the native keyboard is going to be displayed, 0 if not, -1 if the method is not supported by the plugin

References dbg, lvl_debug, graphics::meth, and graphics_methods::show_native_keyboard.

Referenced by gui_internal_keyboard_show_native().

static int intersection ( struct point a1,
int  adx,
int  ady,
struct point b1,
int  bdx,
int  bdy,
struct point res 
)
static

References dbg, lvl_debug, point::x, and point::y.

Referenced by draw_middle().

static int is_inside ( struct point p,
struct point_rect r,
int  edge 
)
static
static void label_line ( struct graphics gra,
struct graphics_gc fg,
struct graphics_gc bg,
struct graphics_font font,
struct point p,
int  count,
char *  label 
)
static
static int limit_count ( struct coord c,
int  count 
)
static

Referenced by displayitem_draw().

static void multiline_label_draw ( struct graphics gra,
struct graphics_gc fg,
struct graphics_gc bg,
struct graphics_font font,
struct point  pref,
const char *  label,
int  line_spacing 
)
static

Draw a multi-line text next to a specified point pref.

Parameters
graThe graphics instance on which to draw
fgThe graphics color to use to draw the text
bgThe graphics background color to use to draw the text
fontThe font to use to draw the text
prefThe position to draw the text (draw at the right and vertically aligned relatively to this point)
labelThe text to draw (may contain '
' for multiline text, if so lines will be stacked vertically)
line_spacingThe delta between each line (set its value at to least the font text size, to be readable)

References dbg, graphics_methods::draw_text, lvl_warning, graphics::meth, graphics::priv, graphics_font::priv, graphics_gc::priv, point::x, and point::y.

Referenced by displayitem_draw().

static void poly_intersection ( struct point p1,
struct point p2,
struct point_rect r,
int  edge,
struct point ret 
)
static
static int relative_pos ( struct wpoint p,
struct point_rect r 
)
static
static struct hash_entry* set_hash_entry ( struct displaylist dl,
enum item_type  type 
)
static
static int within_dist_line ( struct point p,
struct point line_p0,
struct point line_p1,
int  dist 
)
static

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References c1, c2, within_dist_point(), point::x, and point::y.

Referenced by within_dist_polyline().

static int within_dist_point ( struct point p0,
struct point p1,
int  dist 
)
static

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References point::x, and point::y.

Referenced by graphics_displayitem_within_dist(), and within_dist_line().

static int within_dist_polygon ( struct point p,
struct point poly_pnt,
int  count,
int  dist 
)
static

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References c, within_dist_polyline(), point::x, and point::y.

Referenced by graphics_displayitem_within_dist().

static int within_dist_polyline ( struct point p,
struct point line_pnt,
int  count,
int  dist,
int  close 
)
static

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References within_dist_line().

Referenced by graphics_displayitem_within_dist(), and within_dist_polygon().

static void xdisplay_draw ( struct displaylist display_list,
struct graphics gra,
struct layout l,
int  order 
)
static

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References layer::active, graphics::current_z_order, layout::layers, layer::ref, and xdisplay_draw_layer().

Referenced by graphics_displaylist_draw().

static void xdisplay_draw_elements ( struct graphics gra,
struct displaylist display_list,
struct itemgra itm 
)
static
static void xdisplay_draw_layer ( struct displaylist display_list,
struct graphics gra,
struct layer lay,
int  order 
)
static

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References layer::itemgras, and xdisplay_draw_elements().

Referenced by xdisplay_draw().

static void xdisplay_free ( struct displaylist dl)
static

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

References hash_entry::di, displaylist::hash_entries, HASH_SIZE, next, and displayitem::next.

Referenced by graphics_load_mapset().

Variable Documentation

struct circle circle64[]
void* route_selection

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

Referenced by do_draw().