301 |
|
|
302 |
// now draw this onto the original context |
// now draw this onto the original context |
303 |
cairo_set_source_surface(cr, image_surface, x, y); |
cairo_set_source_surface(cr, image_surface, x, y); |
304 |
|
|
305 |
cairo_paint(cr); |
cairo_paint(cr); |
306 |
} |
} |
307 |
|
|
308 |
#define LINE_SKIP 10 |
#define LINE_SKIP 7 |
309 |
|
|
310 |
static void |
static void |
311 |
balloon_draw_cb(cairo_t *cr, OsmGpsMapRect_t *rect, gpointer data) { |
balloon_draw_cb(cairo_t *cr, OsmGpsMapRect_t *rect, gpointer data) { |
332 |
/* ... and right of it the waypoint id */ |
/* ... and right of it the waypoint id */ |
333 |
cairo_text_extents_t extents; |
cairo_text_extents_t extents; |
334 |
|
|
335 |
cairo_select_font_face (cr, "Sans", |
if(cache->id) { |
336 |
CAIRO_FONT_SLANT_NORMAL, |
cairo_select_font_face (cr, "Sans", |
337 |
CAIRO_FONT_WEIGHT_BOLD); |
CAIRO_FONT_SLANT_NORMAL, |
338 |
|
CAIRO_FONT_WEIGHT_BOLD); |
339 |
|
|
340 |
cairo_set_font_size (cr, 20.0); |
cairo_set_font_size (cr, 20.0); |
341 |
cairo_text_extents (cr, cache->id, &extents); |
cairo_text_extents (cr, cache->id, &extents); |
342 |
|
|
343 |
/* display id right of icon vertically centered */ |
/* display id right of icon vertically centered */ |
344 |
x += gdk_pixbuf_get_width(icon) + 5; |
x += gdk_pixbuf_get_width(icon) + 5; |
345 |
y += (gdk_pixbuf_get_height(icon) + extents.height)/2; |
y += (gdk_pixbuf_get_height(icon) + extents.height)/2; |
346 |
cairo_move_to (cr, x,y); |
cairo_move_to (cr, x, y); |
347 |
cairo_set_source_rgba (cr, 0, 0, 0, 1); |
cairo_set_source_rgba (cr, 0, 0, 0, 1); |
348 |
cairo_show_text (cr, cache->id); |
cairo_show_text (cr, cache->id); |
349 |
cairo_stroke (cr); |
cairo_stroke (cr); |
350 |
|
|
351 |
|
y += (gdk_pixbuf_get_height(icon) - extents.height)/2 + LINE_SKIP; |
352 |
|
} else |
353 |
|
y += gdk_pixbuf_get_height(icon); |
354 |
|
|
355 |
/* return to the left border and below icon/text */ |
/* return to the left border and below icon/text */ |
356 |
x = rect->x; |
x = rect->x; |
|
y += (gdk_pixbuf_get_height(icon) - extents.height)/2 + LINE_SKIP; |
|
357 |
|
|
358 |
cairo_select_font_face (cr, "Sans", |
/* everything from here uses the same font */ |
359 |
CAIRO_FONT_SLANT_NORMAL, |
cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, |
360 |
CAIRO_FONT_WEIGHT_NORMAL); |
CAIRO_FONT_WEIGHT_NORMAL); |
361 |
cairo_set_font_size (cr, 14.0); |
cairo_set_font_size (cr, 14.0); |
|
cairo_text_extents (cr, cache->name, &extents); |
|
362 |
|
|
363 |
cairo_move_to (cr, x,y); |
if(cache->name) { |
364 |
cairo_show_text (cr, cache->name); |
/* draw cache name */ |
365 |
cairo_stroke (cr); |
cairo_text_extents (cr, cache->name, &extents); |
366 |
|
y += extents.height; |
367 |
|
cairo_move_to (cr, x, y); |
368 |
|
cairo_set_source_rgba (cr, 0, 0, 0, 1); |
369 |
|
cairo_show_text (cr, cache->name); |
370 |
|
cairo_stroke (cr); |
371 |
|
|
372 |
/* return to the left border and below text */ |
/* return to the left border and below text */ |
373 |
x = rect->x; |
y += LINE_SKIP; |
374 |
y += extents.height + LINE_SKIP; |
x = rect->x; |
375 |
|
} |
376 |
|
|
377 |
|
if(cache->terrain) { |
378 |
|
/* draw cache rating */ |
379 |
|
const char *terrain = "Terrain:"; |
380 |
|
icon = icon_get(ICON_STARS, (int)(cache->terrain*2-2)); |
381 |
|
cairo_text_extents (cr, _(terrain), &extents); |
382 |
|
y += (gdk_pixbuf_get_height(icon) + extents.height)/2; |
383 |
|
|
384 |
|
/* draw "Terrain:" string */ |
385 |
|
cairo_move_to (cr, x, y); |
386 |
|
cairo_set_source_rgba (cr, 0, 0, 0, 1); |
387 |
|
cairo_show_text (cr, _(terrain)); |
388 |
|
cairo_stroke (cr); |
389 |
|
x += extents.width + 2; |
390 |
|
|
391 |
|
/* draw terrain stars */ |
392 |
|
cairo_draw_pixbuf(cr, icon, x, y - |
393 |
|
(gdk_pixbuf_get_height(icon) + extents.height)/2); |
394 |
|
|
395 |
|
x += gdk_pixbuf_get_width(icon) + LINE_SKIP; |
396 |
|
y -= (gdk_pixbuf_get_height(icon) + extents.height)/2; |
397 |
|
} |
398 |
|
|
399 |
|
if(cache->difficulty) { |
400 |
|
const char *difficulty = "Difficulty:"; |
401 |
|
cairo_text_extents (cr, _(difficulty), &extents); |
402 |
|
y += (gdk_pixbuf_get_height(icon) + extents.height)/2; |
403 |
|
|
404 |
|
/* draw "Difficulty:" string */ |
405 |
|
cairo_move_to (cr, x, y); |
406 |
|
cairo_set_source_rgba (cr, 0, 0, 0, 1); |
407 |
|
cairo_show_text (cr, _(difficulty)); |
408 |
|
cairo_stroke (cr); |
409 |
|
x += extents.width + 2; |
410 |
|
|
411 |
|
icon = icon_get(ICON_STARS, (int)(cache->difficulty*2-2)); |
412 |
|
cairo_draw_pixbuf(cr, icon, x, y - |
413 |
|
(gdk_pixbuf_get_height(icon) + extents.height)/2); |
414 |
|
} |
415 |
} |
} |
416 |
|
|
417 |
static gboolean |
static gboolean |