Diff of /trunk/src/map-tool.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 57 by harbaum, Sun Aug 16 19:29:01 2009 UTC revision 58 by harbaum, Mon Aug 17 10:51:56 2009 UTC
# Line 282  on_map_button_press_event(GtkWidget *wid Line 282  on_map_button_press_event(GtkWidget *wid
282    return FALSE;    return FALSE;
283  }  }
284    
285    static void
286    cairo_draw_pixbuf(cairo_t *cr, GdkPixbuf *buf, gint x, gint y) {
287      /* convert the pixbuf into something cairo can handle */
288    
289      // Create a new ImageSurface
290      cairo_surface_t *image_surface =
291        cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
292                                   gdk_pixbuf_get_width(buf),
293                                   gdk_pixbuf_get_height(buf));
294    
295      // Create the new Context for the ImageSurface
296      cairo_t *context = cairo_create(image_surface);
297    
298      // Draw the image on the new Context
299      gdk_cairo_set_source_pixbuf(context, buf, 0.0, 0.0);
300      cairo_paint(context);
301    
302      // now draw this onto the original context
303      cairo_set_source_surface(cr, image_surface, x, y);
304      cairo_paint(cr);
305    }
306    
307    static void
308    balloon_draw_cb(cairo_t *cr, OsmGpsMapRect_t *rect, gpointer data) {
309      cache_t *cache = (cache_t*)data;
310    
311      //  printf("draw cb for \"%s\"\n", cache->name);
312    
313    #if 0
314      /* draw pink background to check clipping */
315      cairo_rectangle (cr, rect->x-20, rect->y-20, rect->w+40, rect->h+40);
316      cairo_set_source_rgba (cr, 1, 0, 0, 0.3);
317      cairo_fill_preserve (cr);
318      cairo_set_line_width (cr, 0);
319      cairo_stroke (cr);
320    #endif
321    
322      /* leave a little border top and left */
323      gint x = rect->x, y = rect->y;
324    
325      /* draw the cache type icon ... */
326      GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type);
327      cairo_draw_pixbuf(cr, icon, x, y);
328    
329      /* ... and right of it the waypoint id */
330      cairo_text_extents_t extents;
331    
332      cairo_select_font_face (cr, "Sans",
333                              CAIRO_FONT_SLANT_NORMAL,
334                              CAIRO_FONT_WEIGHT_BOLD);
335    
336      cairo_set_font_size (cr, 20.0);
337      cairo_text_extents (cr, cache->id, &extents);
338    
339      /* draw right of icon vertically centered */
340      x += gdk_pixbuf_get_width(icon) + 5;
341      y += (gdk_pixbuf_get_height(icon) + extents.height)/2;
342    
343      cairo_move_to (cr, x,y);
344      printf("trying to draw %s\n", cache->id);
345      cairo_set_source_rgba (cr, 0, 0, 0, 1);
346      cairo_show_text (cr, cache->id);
347      cairo_stroke (cr);
348    
349    }
350    
351  static gboolean  static gboolean
352  on_map_button_release_event(GtkWidget *widget,  on_map_button_release_event(GtkWidget *widget,
353                              GdkEventButton *event, map_context_t *context) {                              GdkEventButton *event, map_context_t *context) {
# Line 299  on_map_button_release_event(GtkWidget *w Line 365  on_map_button_release_event(GtkWidget *w
365        float dist = gpx_pos_get_distance(pos, nearest->pos, FALSE);        float dist = gpx_pos_get_distance(pos, nearest->pos, FALSE);
366        if(dist2pixel(context, dist, nearest->pos.lat) < CLICK_FUZZ) {        if(dist2pixel(context, dist, nearest->pos.lat) < CLICK_FUZZ) {
367    
368          osm_gps_map_draw_balloon(map, nearest->pos.lat, nearest->pos.lon);          osm_gps_map_draw_balloon(map, nearest->pos.lat, nearest->pos.lon,
369                                     balloon_draw_cb, nearest);
370        }        }
371      }      }
372      context->press_on = NULL;      context->press_on = NULL;

Legend:
Removed from v.57  
changed lines
  Added in v.58