98 |
coord_t *gps; |
coord_t *gps; |
99 |
gboolean gps_valid; |
gboolean gps_valid; |
100 |
|
|
101 |
|
#ifdef ENABLE_BALLOON |
102 |
|
//a balloon with additional info |
103 |
|
struct { |
104 |
|
coord_t *coo; |
105 |
|
gboolean valid; |
106 |
|
OsmGpsMapRect_t rect; |
107 |
|
OsmGpsMapBalloonCallback cb; |
108 |
|
gpointer data; |
109 |
|
} balloon; |
110 |
|
#endif |
111 |
|
|
112 |
|
#ifdef ENABLE_OSD |
113 |
|
//the osd controls |
114 |
|
struct { |
115 |
|
GdkPixmap *backup; |
116 |
|
cairo_surface_t *overlay; |
117 |
|
gint backup_x, backup_y; |
118 |
|
OsmGpsMapOsdGpsCallback cb; |
119 |
|
gpointer data; |
120 |
|
} osd; |
121 |
|
#endif |
122 |
|
|
123 |
//additional images or tracks added to the map |
//additional images or tracks added to the map |
124 |
GSList *tracks; |
GSList *tracks; |
125 |
GSList *images; |
GSList *images; |
653 |
(mr*2)+lw+lw); |
(mr*2)+lw+lw); |
654 |
#endif |
#endif |
655 |
} |
} |
656 |
|
} |
657 |
|
|
658 |
|
#ifdef ENABLE_BALLOON |
659 |
|
/* most visual effects are hardcoded by now, but may be made */ |
660 |
|
/* available via properties later */ |
661 |
|
#ifndef BALLOON_AREA_WIDTH |
662 |
|
#define BALLOON_AREA_WIDTH 290 |
663 |
|
#endif |
664 |
|
#ifndef BALLOON_AREA_HEIGHT |
665 |
|
#define BALLOON_AREA_HEIGHT 75 |
666 |
|
#endif |
667 |
|
#ifndef BALLOON_CORNER_RADIUS |
668 |
|
#define BALLOON_CORNER_RADIUS 10 |
669 |
|
#endif |
670 |
|
|
671 |
|
#define BALLOON_BORDER (BALLOON_CORNER_RADIUS/2) |
672 |
|
#define BALLOON_WIDTH (BALLOON_AREA_WIDTH + 2 * BALLOON_BORDER) |
673 |
|
#define BALLOON_HEIGHT (BALLOON_AREA_HEIGHT + 2 * BALLOON_BORDER) |
674 |
|
#define BALLOON_TRANSPARENCY 0.8 |
675 |
|
#define POINTER_HEIGHT 20 |
676 |
|
#define POINTER_FOOT_WIDTH 20 |
677 |
|
#define POINTER_OFFSET (BALLOON_CORNER_RADIUS*3/4) |
678 |
|
#define BALLOON_SHADOW (BALLOON_CORNER_RADIUS/2) |
679 |
|
#define BALLOON_SHADOW_TRANSPARENCY 0.2 |
680 |
|
|
681 |
|
#define CLOSE_BUTTON_RADIUS (BALLOON_CORNER_RADIUS) |
682 |
|
|
683 |
|
|
684 |
|
/* draw the bubble shape. this is used twice, once for the shape and once */ |
685 |
|
/* for the shadow */ |
686 |
|
static void |
687 |
|
osm_gps_map_draw_balloon_shape (cairo_t *cr, int x0, int y0, int x1, int y1, |
688 |
|
gboolean bottom, int px, int py, int px0, int px1) { |
689 |
|
|
690 |
|
cairo_move_to (cr, x0, y0 + BALLOON_CORNER_RADIUS); |
691 |
|
cairo_arc (cr, x0 + BALLOON_CORNER_RADIUS, y0 + BALLOON_CORNER_RADIUS, |
692 |
|
BALLOON_CORNER_RADIUS, -M_PI, -M_PI/2); |
693 |
|
if(!bottom) { |
694 |
|
/* insert top pointer */ |
695 |
|
cairo_line_to (cr, px1, y0); |
696 |
|
cairo_line_to (cr, px, py); |
697 |
|
cairo_line_to (cr, px0, y0); |
698 |
|
} |
699 |
|
|
700 |
|
cairo_line_to (cr, x1 - BALLOON_CORNER_RADIUS, y0); |
701 |
|
cairo_arc (cr, x1 - BALLOON_CORNER_RADIUS, y0 + BALLOON_CORNER_RADIUS, |
702 |
|
BALLOON_CORNER_RADIUS, -M_PI/2, 0); |
703 |
|
cairo_line_to (cr, x1 , y1 - BALLOON_CORNER_RADIUS); |
704 |
|
cairo_arc (cr, x1 - BALLOON_CORNER_RADIUS, y1 - BALLOON_CORNER_RADIUS, |
705 |
|
BALLOON_CORNER_RADIUS, 0, M_PI/2); |
706 |
|
if(bottom) { |
707 |
|
/* insert bottom pointer */ |
708 |
|
cairo_line_to (cr, px0, y1); |
709 |
|
cairo_line_to (cr, px, py); |
710 |
|
cairo_line_to (cr, px1, y1); |
711 |
|
} |
712 |
|
|
713 |
|
cairo_line_to (cr, x0 + BALLOON_CORNER_RADIUS, y1); |
714 |
|
cairo_arc (cr, x0 + BALLOON_CORNER_RADIUS, y1 - BALLOON_CORNER_RADIUS, |
715 |
|
BALLOON_CORNER_RADIUS, M_PI/2, M_PI); |
716 |
|
|
717 |
|
cairo_close_path (cr); |
718 |
|
} |
719 |
|
|
720 |
|
static void |
721 |
|
osm_gps_map_draw_balloon_int (OsmGpsMap *map) |
722 |
|
{ |
723 |
|
OsmGpsMapPrivate *priv = map->priv; |
724 |
|
|
725 |
|
if (priv->balloon.valid) { |
726 |
|
|
727 |
|
/* ------- convert given coordinate into screen position --------- */ |
728 |
|
int x0 = lon2pixel(priv->map_zoom, priv->balloon.coo->rlon) - |
729 |
|
priv->map_x + EXTRA_BORDER; |
730 |
|
int y0 = lat2pixel(priv->map_zoom, priv->balloon.coo->rlat) - |
731 |
|
priv->map_y + EXTRA_BORDER; |
732 |
|
|
733 |
|
/* check position of this relative to screen center to determine */ |
734 |
|
/* pointer direction ... */ |
735 |
|
int pointer_x = x0, pointer_x0, pointer_x1; |
736 |
|
int pointer_y = y0; |
737 |
|
|
738 |
|
/* ... and calculate position */ |
739 |
|
if((x0 - EXTRA_BORDER) > GTK_WIDGET(map)->allocation.width/2) { |
740 |
|
x0 -= BALLOON_WIDTH - POINTER_OFFSET; |
741 |
|
pointer_x0 = pointer_x - (BALLOON_CORNER_RADIUS - POINTER_OFFSET); |
742 |
|
pointer_x1 = pointer_x0 - POINTER_FOOT_WIDTH; |
743 |
|
} else { |
744 |
|
x0 -= POINTER_OFFSET; |
745 |
|
pointer_x1 = pointer_x + (BALLOON_CORNER_RADIUS - POINTER_OFFSET); |
746 |
|
pointer_x0 = pointer_x1 + POINTER_FOOT_WIDTH; |
747 |
|
} |
748 |
|
|
749 |
|
gboolean bottom = FALSE; |
750 |
|
if((y0 - EXTRA_BORDER) > GTK_WIDGET(map)->allocation.height/2) { |
751 |
|
bottom = TRUE; |
752 |
|
y0 -= BALLOON_HEIGHT + POINTER_HEIGHT; |
753 |
|
} else |
754 |
|
y0 += POINTER_HEIGHT; |
755 |
|
|
756 |
|
/* calculate bottom/right of box */ |
757 |
|
int x1 = x0 + BALLOON_WIDTH, y1 = y0 + BALLOON_HEIGHT; |
758 |
|
|
759 |
|
/* save balloon screen coordinates for later use */ |
760 |
|
priv->balloon.rect.x = x0 + BALLOON_BORDER; |
761 |
|
priv->balloon.rect.y = y0 + BALLOON_BORDER; |
762 |
|
priv->balloon.rect.w = x1 - x0 - 2*BALLOON_BORDER; |
763 |
|
priv->balloon.rect.h = y1 - y0 - 2*BALLOON_BORDER; |
764 |
|
|
765 |
|
#ifdef USE_CAIRO |
766 |
|
cairo_t *cr = gdk_cairo_create(priv->pixmap); |
767 |
|
|
768 |
|
/* --------- draw shadow --------------- */ |
769 |
|
osm_gps_map_draw_balloon_shape (cr, |
770 |
|
x0 + BALLOON_SHADOW, y0 + BALLOON_SHADOW, |
771 |
|
x1 + BALLOON_SHADOW, y1 + BALLOON_SHADOW, |
772 |
|
bottom, pointer_x, pointer_y, |
773 |
|
pointer_x0 + BALLOON_SHADOW, pointer_x1 + BALLOON_SHADOW); |
774 |
|
|
775 |
|
cairo_set_source_rgba (cr, 0, 0, 0, BALLOON_SHADOW_TRANSPARENCY); |
776 |
|
cairo_fill_preserve (cr); |
777 |
|
cairo_set_source_rgba (cr, 1, 0, 0, 1.0); |
778 |
|
cairo_set_line_width (cr, 0); |
779 |
|
cairo_stroke (cr); |
780 |
|
|
781 |
|
/* --------- draw main shape ----------- */ |
782 |
|
osm_gps_map_draw_balloon_shape (cr, x0, y0, x1, y1, |
783 |
|
bottom, pointer_x, pointer_y, pointer_x0, pointer_x1); |
784 |
|
|
785 |
|
cairo_set_source_rgba (cr, 1, 1, 1, BALLOON_TRANSPARENCY); |
786 |
|
cairo_fill_preserve (cr); |
787 |
|
cairo_set_source_rgba (cr, 0, 0, 0, BALLOON_TRANSPARENCY); |
788 |
|
cairo_set_line_width (cr, 1); |
789 |
|
cairo_stroke (cr); |
790 |
|
|
791 |
|
|
792 |
|
/* ---------- draw close button --------- */ |
793 |
|
|
794 |
|
int cx = x1 - BALLOON_BORDER - CLOSE_BUTTON_RADIUS; |
795 |
|
int cy = y0 + BALLOON_BORDER + CLOSE_BUTTON_RADIUS; |
796 |
|
int crad = CLOSE_BUTTON_RADIUS; |
797 |
|
|
798 |
|
cairo_arc (cr, cx, cy, crad, 0, 2 * M_PI); |
799 |
|
cairo_set_source_rgba (cr, 0.8, 0, 0, 1.0); |
800 |
|
cairo_fill_preserve (cr); |
801 |
|
cairo_set_source_rgba (cr, 0.3, 0, 0, 1.0); |
802 |
|
cairo_set_line_width (cr, 2); |
803 |
|
cairo_stroke(cr); |
804 |
|
|
805 |
|
cairo_set_source_rgba (cr, 1, 1, 1, 1.0); |
806 |
|
cairo_set_line_width (cr, BALLOON_CORNER_RADIUS/3.3); |
807 |
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); |
808 |
|
cairo_move_to (cr, cx - crad/2, cy - crad/2); |
809 |
|
cairo_line_to (cr, cx + crad/2, cy + crad/2); |
810 |
|
cairo_stroke (cr); |
811 |
|
cairo_move_to (cr, cx + crad/2, cy - crad/2); |
812 |
|
cairo_line_to (cr, cx - crad/2, cy + crad/2); |
813 |
|
cairo_stroke (cr); |
814 |
|
|
815 |
|
if (priv->balloon.cb) { |
816 |
|
/* clip in case application tries to draw in */ |
817 |
|
/* exceed of the balloon */ |
818 |
|
cairo_rectangle (cr, priv->balloon.rect.x, priv->balloon.rect.y, |
819 |
|
priv->balloon.rect.w, priv->balloon.rect.h); |
820 |
|
cairo_clip (cr); |
821 |
|
cairo_new_path (cr); /* current path is not |
822 |
|
consumed by cairo_clip() */ |
823 |
|
|
824 |
|
priv->balloon.cb(cr, &priv->balloon.rect, priv->balloon.data); |
825 |
|
} |
826 |
|
|
827 |
|
cairo_destroy(cr); |
828 |
|
|
829 |
|
gtk_widget_queue_draw_area (GTK_WIDGET(map), |
830 |
|
x0, y0, BALLOON_WIDTH, |
831 |
|
BALLOON_HEIGHT + POINTER_HEIGHT); |
832 |
|
#else |
833 |
|
#warning "Balloon display lacks a non-cairo implementation!" |
834 |
|
#endif |
835 |
|
} |
836 |
} |
} |
837 |
|
|
838 |
|
/* the user clicked into the balloons main area. handle this */ |
839 |
|
static void |
840 |
|
osm_gps_map_handle_balloon_click(OsmGpsMap *map, gint x, gint y) |
841 |
|
{ |
842 |
|
OsmGpsMapPrivate *priv = map->priv; |
843 |
|
|
844 |
|
if (!priv->balloon.valid) |
845 |
|
return; |
846 |
|
|
847 |
|
/* check if the close button was clicked */ |
848 |
|
if ((x > priv->balloon.rect.w - 2*CLOSE_BUTTON_RADIUS) && |
849 |
|
(x < priv->balloon.rect.w) && |
850 |
|
(y > 0) && (y < 2*CLOSE_BUTTON_RADIUS)) { |
851 |
|
|
852 |
|
priv->balloon.valid = FALSE; |
853 |
|
osm_gps_map_map_redraw_idle(map); |
854 |
|
} |
855 |
|
} |
856 |
|
|
857 |
|
/* return true if balloon is being displayed and if */ |
858 |
|
/* the given coordinate is within this balloon */ |
859 |
|
static gboolean |
860 |
|
osm_gps_map_in_balloon(OsmGpsMapPrivate *priv, gint x, gint y) |
861 |
|
{ |
862 |
|
return (priv->balloon.valid && |
863 |
|
(x > priv->balloon.rect.x) && |
864 |
|
(x < priv->balloon.rect.x + priv->balloon.rect.w) && |
865 |
|
(y > priv->balloon.rect.y) && |
866 |
|
(y < priv->balloon.rect.y + priv->balloon.rect.h)); |
867 |
|
} |
868 |
|
#endif // ENABLE_BALLOON |
869 |
|
|
870 |
static void |
static void |
871 |
osm_gps_map_blit_tile(OsmGpsMap *map, GdkPixbuf *pixbuf, int offset_x, int offset_y) |
osm_gps_map_blit_tile(OsmGpsMap *map, GdkPixbuf *pixbuf, int offset_x, int offset_y) |
872 |
{ |
{ |
929 |
} |
} |
930 |
else |
else |
931 |
{ |
{ |
932 |
g_warning("Error creating tile download directory: %s", dl->folder); |
g_warning("Error creating tile download directory: %s", |
933 |
|
dl->folder); |
934 |
|
perror("perror:"); |
935 |
} |
} |
936 |
} |
} |
937 |
|
|
1423 |
g_hash_table_foreach_remove(priv->tile_cache, osm_gps_map_purge_cache_check, priv); |
g_hash_table_foreach_remove(priv->tile_cache, osm_gps_map_purge_cache_check, priv); |
1424 |
} |
} |
1425 |
|
|
1426 |
|
#ifdef ENABLE_OSD |
1427 |
|
/* position and extent of bounding box */ |
1428 |
|
#define OSD_X (10) |
1429 |
|
#define OSD_Y (10) |
1430 |
|
|
1431 |
|
#define OSD_COLOR 0.5, 0.5, 1 |
1432 |
|
#define OSD_COLOR_DISABLED 0.8, 0.8, 0.8 |
1433 |
|
|
1434 |
|
/* parameters of the direction shape */ |
1435 |
|
#ifndef OSM_GPS_MAP_OSD_DIAMETER |
1436 |
|
#define D_RAD (30) // diameter of dpad |
1437 |
|
#else |
1438 |
|
#define D_RAD (OSM_GPS_MAP_OSD_DIAMETER) |
1439 |
|
#endif |
1440 |
|
#define D_TIP (4*D_RAD/5) // distance of arrow tip from dpad center |
1441 |
|
#define D_LEN (D_RAD/4) // length of arrow |
1442 |
|
#define D_WID (D_LEN) // width of arrow |
1443 |
|
|
1444 |
|
/* parameters of the "zoom" pad */ |
1445 |
|
#define Z_STEP (D_RAD/4) // distance between dpad and zoom |
1446 |
|
#define Z_RAD (D_RAD/2) // radius of "caps" of zoom bar |
1447 |
|
|
1448 |
|
/* shadow also depends on control size */ |
1449 |
|
#define OSD_SHADOW (D_RAD/6) |
1450 |
|
|
1451 |
|
/* total width and height of controls incl. shadow */ |
1452 |
|
#define OSD_W (2*D_RAD + OSD_SHADOW) |
1453 |
|
#define OSD_H (2*D_RAD + Z_STEP + 2*Z_RAD + OSD_SHADOW) |
1454 |
|
|
1455 |
|
#define OSD_LBL_SHADOW (OSD_SHADOW/2) |
1456 |
|
|
1457 |
|
#define Z_TOP (2 * D_RAD + Z_STEP) |
1458 |
|
#define Z_MID (Z_TOP + Z_RAD) |
1459 |
|
#define Z_BOT (Z_MID + Z_RAD) |
1460 |
|
#define Z_LEFT (Z_RAD) |
1461 |
|
#define Z_RIGHT (2 * D_RAD - Z_RAD) |
1462 |
|
|
1463 |
|
/* create the cairo shape used for the zoom buttons */ |
1464 |
|
static void |
1465 |
|
osm_gps_map_osd_zoom_shape(cairo_t *cr, gint x, gint y) { |
1466 |
|
cairo_move_to (cr, x+Z_LEFT, y+Z_TOP); |
1467 |
|
cairo_line_to (cr, x+Z_RIGHT, y+Z_TOP); |
1468 |
|
cairo_arc (cr, x+Z_RIGHT, y+Z_MID, Z_RAD, -M_PI/2, M_PI/2); |
1469 |
|
cairo_line_to (cr, x+Z_LEFT, y+Z_BOT); |
1470 |
|
cairo_arc (cr, x+Z_LEFT, y+Z_MID, Z_RAD, M_PI/2, -M_PI/2); |
1471 |
|
} |
1472 |
|
|
1473 |
|
/* create the cairo shape used for the dpad */ |
1474 |
|
static void |
1475 |
|
osm_gps_map_osd_dpad_shape(cairo_t *cr, gint x, gint y) { |
1476 |
|
cairo_arc (cr, x+D_RAD, y+D_RAD, D_RAD, 0, 2 * M_PI); |
1477 |
|
} |
1478 |
|
|
1479 |
|
static gboolean |
1480 |
|
osm_gps_map_in_circle(gint x, gint y, gint cx, gint cy, gint rad) |
1481 |
|
{ |
1482 |
|
return( pow(cx - x, 2) + pow(cy - y, 2) < rad * rad); |
1483 |
|
} |
1484 |
|
|
1485 |
|
/* check whether x/y is within the dpad */ |
1486 |
|
static osd_button_t |
1487 |
|
osm_gps_map_osd_check_dpad(gint x, gint y) |
1488 |
|
{ |
1489 |
|
/* within entire dpad circle */ |
1490 |
|
if( osm_gps_map_in_circle(x, y, OSD_X + D_RAD, OSD_Y + D_RAD, D_RAD)) |
1491 |
|
{ |
1492 |
|
/* convert into position relative to dpads centre */ |
1493 |
|
x -= (OSD_X + D_RAD); |
1494 |
|
y -= (OSD_Y + D_RAD); |
1495 |
|
|
1496 |
|
/* check for dpad center goes here! */ |
1497 |
|
if( osm_gps_map_in_circle(x, y, 0, 0, D_RAD/3)) |
1498 |
|
return OSD_GPS; |
1499 |
|
|
1500 |
|
if( y < 0 && abs(x) < abs(y)) |
1501 |
|
return OSD_UP; |
1502 |
|
|
1503 |
|
if( y > 0 && abs(x) < abs(y)) |
1504 |
|
return OSD_DOWN; |
1505 |
|
|
1506 |
|
if( x < 0 && abs(y) < abs(x)) |
1507 |
|
return OSD_LEFT; |
1508 |
|
|
1509 |
|
if( x > 0 && abs(y) < abs(x)) |
1510 |
|
return OSD_RIGHT; |
1511 |
|
|
1512 |
|
return OSD_BG; |
1513 |
|
} |
1514 |
|
return OSD_NONE; |
1515 |
|
} |
1516 |
|
|
1517 |
|
/* check whether x/y is within the zoom pads */ |
1518 |
|
static osd_button_t |
1519 |
|
osm_gps_map_osd_check_zoom(gint x, gint y) { |
1520 |
|
if( x > OSD_X && x < (OSD_X + OSD_W) && y > Z_TOP && y < (OSD_Y+Z_BOT)) { |
1521 |
|
|
1522 |
|
/* within circle around (-) label */ |
1523 |
|
if( osm_gps_map_in_circle(x, y, OSD_X + Z_LEFT, OSD_Y + Z_MID, Z_RAD)) |
1524 |
|
return OSD_OUT; |
1525 |
|
|
1526 |
|
/* between center of (-) button and center of entire zoom control area */ |
1527 |
|
if(x > OSD_LEFT && x < OSD_X + D_RAD) |
1528 |
|
return OSD_OUT; |
1529 |
|
|
1530 |
|
/* within circle around (+) label */ |
1531 |
|
if( osm_gps_map_in_circle(x, y, OSD_X + Z_RIGHT, OSD_Y + Z_MID, Z_RAD)) |
1532 |
|
return OSD_IN; |
1533 |
|
|
1534 |
|
/* between center of (+) button and center of entire zoom control area */ |
1535 |
|
if(x < OSD_RIGHT && x > OSD_X + D_RAD) |
1536 |
|
return OSD_IN; |
1537 |
|
} |
1538 |
|
|
1539 |
|
return OSD_NONE; |
1540 |
|
} |
1541 |
|
|
1542 |
|
osd_button_t |
1543 |
|
osm_gps_map_osd_check(gint x, gint y) { |
1544 |
|
osd_button_t but = OSD_NONE; |
1545 |
|
|
1546 |
|
/* first do a rough test for the OSD area. */ |
1547 |
|
/* this is just to avoid an unnecessary detailed test */ |
1548 |
|
if(x > OSD_X && x < OSD_X + OSD_W && |
1549 |
|
y > OSD_Y && y < OSD_Y + OSD_H) { |
1550 |
|
but = osm_gps_map_osd_check_dpad(x, y); |
1551 |
|
|
1552 |
|
if(but == OSD_NONE) |
1553 |
|
but = osm_gps_map_osd_check_zoom(x, y); |
1554 |
|
} |
1555 |
|
|
1556 |
|
return but; |
1557 |
|
} |
1558 |
|
|
1559 |
|
static void |
1560 |
|
osm_gps_map_osd_shape_shadow(cairo_t *cr) { |
1561 |
|
cairo_set_source_rgba (cr, 0, 0, 0, 0.2); |
1562 |
|
cairo_fill (cr); |
1563 |
|
cairo_stroke (cr); |
1564 |
|
} |
1565 |
|
|
1566 |
|
static void |
1567 |
|
osm_gps_map_osd_shape(cairo_t *cr) { |
1568 |
|
cairo_set_source_rgb (cr, 1, 1, 1); |
1569 |
|
cairo_fill_preserve (cr); |
1570 |
|
cairo_set_source_rgb (cr, OSD_COLOR); |
1571 |
|
cairo_set_line_width (cr, 1); |
1572 |
|
cairo_stroke (cr); |
1573 |
|
} |
1574 |
|
|
1575 |
|
static void |
1576 |
|
osm_gps_map_osd_dpad_labels(cairo_t *cr, gint x, gint y) { |
1577 |
|
/* move reference to dpad center */ |
1578 |
|
x += D_RAD; |
1579 |
|
y += D_RAD; |
1580 |
|
|
1581 |
|
const static gint offset[][3][2] = { |
1582 |
|
/* left arrow/triangle */ |
1583 |
|
{ { -D_TIP+D_LEN, -D_WID }, { -D_LEN, D_WID }, { +D_LEN, D_WID } }, |
1584 |
|
/* right arrow/triangle */ |
1585 |
|
{ { +D_TIP-D_LEN, -D_WID }, { +D_LEN, D_WID }, { -D_LEN, D_WID } }, |
1586 |
|
/* top arrow/triangle */ |
1587 |
|
{ { -D_WID, -D_TIP+D_LEN }, { D_WID, -D_LEN }, { D_WID, +D_LEN } }, |
1588 |
|
/* bottom arrow/triangle */ |
1589 |
|
{ { -D_WID, +D_TIP-D_LEN }, { D_WID, +D_LEN }, { D_WID, -D_LEN } } |
1590 |
|
}; |
1591 |
|
|
1592 |
|
int i; |
1593 |
|
for(i=0;i<4;i++) { |
1594 |
|
cairo_move_to (cr, x + offset[i][0][0], y + offset[i][0][1]); |
1595 |
|
cairo_rel_line_to (cr, offset[i][1][0], offset[i][1][1]); |
1596 |
|
cairo_rel_line_to (cr, offset[i][2][0], offset[i][2][1]); |
1597 |
|
} |
1598 |
|
} |
1599 |
|
|
1600 |
|
/* draw the sattelite dish icon in the center of the dpad */ |
1601 |
|
#define GPS_V0 (D_RAD/8) |
1602 |
|
#define GPS_V1 (D_RAD/10) |
1603 |
|
#define GPS_V2 (D_RAD/5) |
1604 |
|
|
1605 |
|
/* draw a satellite receiver dish */ |
1606 |
|
static void |
1607 |
|
osm_gps_map_osd_dpad_gps(cairo_t *cr, gint x, gint y) { |
1608 |
|
/* move reference to dpad center */ |
1609 |
|
x += D_RAD; |
1610 |
|
y += D_RAD + GPS_V0; |
1611 |
|
|
1612 |
|
cairo_move_to (cr, x-GPS_V0, y+GPS_V0); |
1613 |
|
cairo_rel_line_to (cr, +GPS_V0, -GPS_V0); |
1614 |
|
cairo_rel_line_to (cr, +GPS_V0, +GPS_V0); |
1615 |
|
cairo_close_path (cr); |
1616 |
|
|
1617 |
|
cairo_move_to (cr, x+GPS_V1-GPS_V2, y-2*GPS_V2); |
1618 |
|
cairo_curve_to (cr, x-GPS_V2, y, x+GPS_V1, y+GPS_V1, x+GPS_V1+GPS_V2, y); |
1619 |
|
cairo_close_path (cr); |
1620 |
|
|
1621 |
|
x += GPS_V1; |
1622 |
|
cairo_move_to (cr, x, y-GPS_V2); |
1623 |
|
cairo_rel_line_to (cr, +GPS_V1, -GPS_V1); |
1624 |
|
} |
1625 |
|
|
1626 |
|
#define Z_LEN (2*Z_RAD/3) |
1627 |
|
|
1628 |
|
static void |
1629 |
|
osm_gps_map_osd_zoom_labels(cairo_t *cr, gint x, gint y) { |
1630 |
|
cairo_move_to (cr, x + Z_LEFT - Z_LEN, y + Z_MID); |
1631 |
|
cairo_line_to (cr, x + Z_LEFT + Z_LEN, y + Z_MID); |
1632 |
|
|
1633 |
|
cairo_move_to (cr, x + Z_RIGHT, y + Z_MID - Z_LEN); |
1634 |
|
cairo_line_to (cr, x + Z_RIGHT, y + Z_MID + Z_LEN); |
1635 |
|
cairo_move_to (cr, x + Z_RIGHT - Z_LEN, y + Z_MID); |
1636 |
|
cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID); |
1637 |
|
} |
1638 |
|
|
1639 |
|
static void |
1640 |
|
osm_gps_map_osd_labels(cairo_t *cr, gint width, gboolean enabled) { |
1641 |
|
if(enabled) cairo_set_source_rgb (cr, OSD_COLOR); |
1642 |
|
else cairo_set_source_rgb (cr, OSD_COLOR_DISABLED); |
1643 |
|
cairo_set_line_width (cr, width); |
1644 |
|
cairo_stroke (cr); |
1645 |
|
} |
1646 |
|
|
1647 |
|
static void |
1648 |
|
osm_gps_map_osd_labels_shadow(cairo_t *cr, gint width, gboolean enabled) { |
1649 |
|
cairo_set_source_rgba (cr, 0, 0, 0, enabled?0.3:0.15); |
1650 |
|
cairo_set_line_width (cr, width); |
1651 |
|
cairo_stroke (cr); |
1652 |
|
} |
1653 |
|
|
1654 |
|
static void |
1655 |
|
osm_gps_map_osd_render(OsmGpsMapPrivate *priv) { |
1656 |
|
|
1657 |
|
/* first fill with transparency */ |
1658 |
|
cairo_t *cr = cairo_create(priv->osd.overlay); |
1659 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1660 |
|
cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); |
1661 |
|
cairo_paint(cr); |
1662 |
|
|
1663 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
1664 |
|
|
1665 |
|
/* --------- draw zoom and dpad shape shadow ----------- */ |
1666 |
|
gint x = 0, y = 0; |
1667 |
|
|
1668 |
|
osm_gps_map_osd_zoom_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW); |
1669 |
|
osm_gps_map_osd_shape_shadow(cr); |
1670 |
|
osm_gps_map_osd_dpad_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW); |
1671 |
|
osm_gps_map_osd_shape_shadow(cr); |
1672 |
|
|
1673 |
|
/* --------- draw zoom and dpad shape ----------- */ |
1674 |
|
|
1675 |
|
osm_gps_map_osd_zoom_shape(cr, x, y); |
1676 |
|
osm_gps_map_osd_shape(cr); |
1677 |
|
osm_gps_map_osd_dpad_shape(cr, x, y); |
1678 |
|
osm_gps_map_osd_shape(cr); |
1679 |
|
|
1680 |
|
/* --------- draw zoom and dpad labels --------- */ |
1681 |
|
|
1682 |
|
osm_gps_map_osd_zoom_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); |
1683 |
|
osm_gps_map_osd_dpad_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); |
1684 |
|
osm_gps_map_osd_labels_shadow(cr, Z_RAD/3, TRUE); |
1685 |
|
osm_gps_map_osd_dpad_gps(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); |
1686 |
|
osm_gps_map_osd_labels_shadow(cr, Z_RAD/6, priv->osd.cb != NULL); |
1687 |
|
|
1688 |
|
osm_gps_map_osd_zoom_labels(cr, x, y); |
1689 |
|
osm_gps_map_osd_dpad_labels(cr, x, y); |
1690 |
|
osm_gps_map_osd_labels(cr, Z_RAD/3, TRUE); |
1691 |
|
osm_gps_map_osd_dpad_gps(cr, x, y); |
1692 |
|
osm_gps_map_osd_labels(cr, Z_RAD/6, priv->osd.cb != NULL); |
1693 |
|
|
1694 |
|
cairo_destroy(cr); |
1695 |
|
} |
1696 |
|
|
1697 |
|
static void |
1698 |
|
osm_gps_map_osd_draw_controls (OsmGpsMap *map, gint xoffset, gint yoffset) |
1699 |
|
{ |
1700 |
|
OsmGpsMapPrivate *priv = map->priv; |
1701 |
|
|
1702 |
|
/* backup previous contents */ |
1703 |
|
if(!priv->osd.backup) |
1704 |
|
priv->osd.backup = gdk_pixmap_new(priv->pixmap, OSD_W+2, OSD_H+2, -1); |
1705 |
|
|
1706 |
|
gint x = OSD_X + EXTRA_BORDER + xoffset; |
1707 |
|
gint y = OSD_Y + EXTRA_BORDER + yoffset; |
1708 |
|
|
1709 |
|
/* create backup of background */ |
1710 |
|
gdk_draw_drawable(priv->osd.backup, |
1711 |
|
GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))], |
1712 |
|
priv->pixmap, x-1, y-1, 0, 0, OSD_W+2, OSD_H+2); |
1713 |
|
|
1714 |
|
priv->osd.backup_x = x-1; |
1715 |
|
priv->osd.backup_y = y-1; |
1716 |
|
|
1717 |
|
|
1718 |
|
#ifdef USE_CAIRO |
1719 |
|
/* OSD itself uses some off-screen rendering, so check if the */ |
1720 |
|
/* offscreen buffer is present and create it if not */ |
1721 |
|
if(!priv->osd.overlay) { |
1722 |
|
/* create overlay ... */ |
1723 |
|
priv->osd.overlay = |
1724 |
|
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W, OSD_H); |
1725 |
|
/* ... and render it */ |
1726 |
|
osm_gps_map_osd_render(priv); |
1727 |
|
} |
1728 |
|
|
1729 |
|
// now draw this onto the original context |
1730 |
|
cairo_t *cr = gdk_cairo_create(priv->pixmap); |
1731 |
|
cairo_set_source_surface(cr, priv->osd.overlay, x, y); |
1732 |
|
cairo_paint(cr); |
1733 |
|
cairo_destroy(cr); |
1734 |
|
|
1735 |
|
#else |
1736 |
|
#warning "OSD control display lacks a non-cairo implementation!" |
1737 |
|
#endif |
1738 |
|
} |
1739 |
|
|
1740 |
|
static void |
1741 |
|
osm_gps_map_osd_restore (OsmGpsMap *map) |
1742 |
|
{ |
1743 |
|
OsmGpsMapPrivate *priv = map->priv; |
1744 |
|
|
1745 |
|
/* restore backup of previous contents */ |
1746 |
|
if(priv->osd.backup) { |
1747 |
|
/* create backup of background */ |
1748 |
|
gdk_draw_drawable(priv->pixmap, |
1749 |
|
GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))], |
1750 |
|
priv->osd.backup, 0, 0, |
1751 |
|
priv->osd.backup_x, priv->osd.backup_y, OSD_W+2, OSD_H+2); |
1752 |
|
} |
1753 |
|
} |
1754 |
|
|
1755 |
|
#endif |
1756 |
|
|
1757 |
static gboolean |
static gboolean |
1758 |
osm_gps_map_map_redraw (OsmGpsMap *map) |
osm_gps_map_map_redraw (OsmGpsMap *map) |
1759 |
{ |
{ |
1784 |
osm_gps_map_print_tracks(map); |
osm_gps_map_print_tracks(map); |
1785 |
osm_gps_map_draw_gps_point(map); |
osm_gps_map_draw_gps_point(map); |
1786 |
osm_gps_map_print_images(map); |
osm_gps_map_print_images(map); |
1787 |
|
#ifdef ENABLE_BALLOON |
1788 |
|
osm_gps_map_draw_balloon_int(map); |
1789 |
|
#endif |
1790 |
|
#ifdef ENABLE_OSD |
1791 |
|
osm_gps_map_osd_draw_controls(map, 0, 0); |
1792 |
|
#endif |
1793 |
|
|
1794 |
//osm_gps_map_osd_speed(map, 1.5); |
//osm_gps_map_osd_speed(map, 1.5); |
1795 |
osm_gps_map_purge_cache(map); |
osm_gps_map_purge_cache(map); |
1821 |
priv->gps = g_new0(coord_t, 1); |
priv->gps = g_new0(coord_t, 1); |
1822 |
priv->gps_valid = FALSE; |
priv->gps_valid = FALSE; |
1823 |
|
|
1824 |
|
#ifdef ENABLE_BALLOON |
1825 |
|
priv->balloon.coo = g_new0(coord_t, 1); |
1826 |
|
priv->balloon.valid = FALSE; |
1827 |
|
priv->balloon.cb = NULL; |
1828 |
|
#endif |
1829 |
|
|
1830 |
|
#ifdef ENABLE_OSD |
1831 |
|
priv->osd.backup = NULL; |
1832 |
|
priv->osd.overlay = NULL; |
1833 |
|
priv->osd.cb = NULL; |
1834 |
|
#endif |
1835 |
|
|
1836 |
priv->tracks = NULL; |
priv->tracks = NULL; |
1837 |
priv->images = NULL; |
priv->images = NULL; |
1838 |
|
|
1990 |
if (priv->idle_map_redraw != 0) |
if (priv->idle_map_redraw != 0) |
1991 |
g_source_remove (priv->idle_map_redraw); |
g_source_remove (priv->idle_map_redraw); |
1992 |
|
|
1993 |
|
g_free(priv->gps); |
1994 |
|
|
1995 |
|
#ifdef ENABLE_BALLOON |
1996 |
|
g_free(priv->balloon.coo); |
1997 |
|
#endif |
1998 |
|
|
1999 |
|
#ifdef ENABLE_OSD |
2000 |
|
if (priv->osd.backup) |
2001 |
|
g_object_unref(priv->osd.backup); |
2002 |
|
|
2003 |
|
if (priv->osd.overlay) |
2004 |
|
cairo_surface_destroy(priv->osd.overlay); |
2005 |
|
#endif |
2006 |
|
|
2007 |
G_OBJECT_CLASS (osm_gps_map_parent_class)->dispose (object); |
G_OBJECT_CLASS (osm_gps_map_parent_class)->dispose (object); |
2008 |
} |
} |
2009 |
|
|
2219 |
{ |
{ |
2220 |
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
2221 |
|
|
2222 |
|
#ifdef ENABLE_BALLOON |
2223 |
|
/* don't drag if the user clicked within the balloon */ |
2224 |
|
if (osm_gps_map_in_balloon(priv, |
2225 |
|
event->x + EXTRA_BORDER, |
2226 |
|
event->y + EXTRA_BORDER)) |
2227 |
|
{ |
2228 |
|
priv->drag_counter = -1; |
2229 |
|
return FALSE; |
2230 |
|
} |
2231 |
|
#endif |
2232 |
|
|
2233 |
|
#ifdef ENABLE_OSD |
2234 |
|
#define SCROLL_STEP 10 |
2235 |
|
|
2236 |
|
/* pressed inside OSD control? */ |
2237 |
|
osd_button_t but = osm_gps_map_osd_check(event->x, event->y); |
2238 |
|
if(but != OSD_NONE) |
2239 |
|
{ |
2240 |
|
priv->drag_counter = -1; |
2241 |
|
|
2242 |
|
switch(but) { |
2243 |
|
case OSD_GPS: |
2244 |
|
priv->osd.cb(priv->osd.data); |
2245 |
|
break; |
2246 |
|
|
2247 |
|
case OSD_UP: |
2248 |
|
priv->map_y -= GTK_WIDGET(widget)->allocation.height/SCROLL_STEP; |
2249 |
|
priv->center_coord_set = FALSE; |
2250 |
|
break; |
2251 |
|
|
2252 |
|
case OSD_DOWN: |
2253 |
|
priv->map_y += GTK_WIDGET(widget)->allocation.height/SCROLL_STEP; |
2254 |
|
priv->center_coord_set = FALSE; |
2255 |
|
break; |
2256 |
|
|
2257 |
|
case OSD_LEFT: |
2258 |
|
priv->map_x -= GTK_WIDGET(widget)->allocation.width/SCROLL_STEP; |
2259 |
|
priv->center_coord_set = FALSE; |
2260 |
|
break; |
2261 |
|
|
2262 |
|
case OSD_RIGHT: |
2263 |
|
priv->map_x += GTK_WIDGET(widget)->allocation.width/SCROLL_STEP; |
2264 |
|
priv->center_coord_set = FALSE; |
2265 |
|
break; |
2266 |
|
|
2267 |
|
case OSD_IN: |
2268 |
|
osm_gps_map_set_zoom(OSM_GPS_MAP(widget), priv->map_zoom+1); |
2269 |
|
break; |
2270 |
|
|
2271 |
|
case OSD_OUT: |
2272 |
|
osm_gps_map_set_zoom(OSM_GPS_MAP(widget), priv->map_zoom-1); |
2273 |
|
break; |
2274 |
|
|
2275 |
|
default: |
2276 |
|
break; |
2277 |
|
} |
2278 |
|
|
2279 |
|
osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); |
2280 |
|
|
2281 |
|
return FALSE; |
2282 |
|
} |
2283 |
|
#endif |
2284 |
|
|
2285 |
priv->drag_counter = 0; |
priv->drag_counter = 0; |
2286 |
priv->drag_start_mouse_x = (int) event->x; |
priv->drag_start_mouse_x = (int) event->x; |
2287 |
priv->drag_start_mouse_y = (int) event->y; |
priv->drag_start_mouse_y = (int) event->y; |
2296 |
{ |
{ |
2297 |
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
2298 |
|
|
2299 |
|
#ifdef ENABLE_BALLOON |
2300 |
|
/* released inside the balloon? */ |
2301 |
|
if (osm_gps_map_in_balloon(priv, |
2302 |
|
event->x + EXTRA_BORDER, |
2303 |
|
event->y + EXTRA_BORDER)) |
2304 |
|
{ |
2305 |
|
osm_gps_map_handle_balloon_click(OSM_GPS_MAP(widget), |
2306 |
|
event->x - priv->balloon.rect.x + EXTRA_BORDER, |
2307 |
|
event->y - priv->balloon.rect.y + EXTRA_BORDER); |
2308 |
|
} |
2309 |
|
#endif |
2310 |
|
|
2311 |
if (priv->dragging) |
if (priv->dragging) |
2312 |
{ |
{ |
2313 |
priv->dragging = FALSE; |
priv->dragging = FALSE; |
2325 |
|
|
2326 |
priv->drag_mouse_dx = 0; |
priv->drag_mouse_dx = 0; |
2327 |
priv->drag_mouse_dy = 0; |
priv->drag_mouse_dy = 0; |
2328 |
priv->drag_counter = 0; |
priv->drag_counter = -1; |
2329 |
|
|
2330 |
return FALSE; |
return FALSE; |
2331 |
} |
} |
2332 |
|
|
2333 |
static gboolean |
static gboolean |
2334 |
|
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event); |
2335 |
|
|
2336 |
|
static gboolean |
2337 |
osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion *event) |
osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion *event) |
2338 |
{ |
{ |
2339 |
int x, y; |
int x, y; |
2353 |
if (!(state & GDK_BUTTON1_MASK)) |
if (!(state & GDK_BUTTON1_MASK)) |
2354 |
return FALSE; |
return FALSE; |
2355 |
|
|
2356 |
|
if (priv->drag_counter < 0) |
2357 |
|
return FALSE; |
2358 |
|
|
2359 |
priv->drag_counter++; |
priv->drag_counter++; |
2360 |
|
|
2361 |
// we havent dragged more than 6 pixels |
// we havent dragged more than 6 pixels |
2362 |
if (priv->drag_counter < 6) |
if (priv->drag_counter < 6) |
2363 |
return FALSE; |
return FALSE; |
2364 |
|
|
2365 |
|
#ifdef USE_MAEMO |
2366 |
|
/* reduce update frequency on maemo to keep screen update fluid */ |
2367 |
|
static guint32 last_time = 0; |
2368 |
|
|
2369 |
|
if(event->time - last_time < 100) return FALSE; |
2370 |
|
last_time = event->time; |
2371 |
|
#endif |
2372 |
|
|
2373 |
priv->dragging = TRUE; |
priv->dragging = TRUE; |
2374 |
|
|
2375 |
if (priv->map_auto_center) |
if (priv->map_auto_center) |
2378 |
priv->drag_mouse_dx = x - priv->drag_start_mouse_x; |
priv->drag_mouse_dx = x - priv->drag_start_mouse_x; |
2379 |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
2380 |
|
|
2381 |
|
#ifdef ENABLE_OSD |
2382 |
|
/* undo OSD */ |
2383 |
|
osm_gps_map_osd_restore (OSM_GPS_MAP(widget)); |
2384 |
|
|
2385 |
|
/* draw new OSD */ |
2386 |
|
osm_gps_map_osd_draw_controls (OSM_GPS_MAP(widget), |
2387 |
|
-priv->drag_mouse_dx, |
2388 |
|
-priv->drag_mouse_dy); |
2389 |
|
#endif |
2390 |
|
|
2391 |
|
osm_gps_map_expose (widget, NULL); |
2392 |
|
|
2393 |
|
|
2394 |
|
return FALSE; |
2395 |
|
} |
2396 |
|
|
2397 |
|
static gboolean |
2398 |
|
osm_gps_map_configure (GtkWidget *widget, GdkEventConfigure *event) |
2399 |
|
{ |
2400 |
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
2401 |
|
|
2402 |
|
/* create pixmap */ |
2403 |
|
if (priv->pixmap) |
2404 |
|
g_object_unref (priv->pixmap); |
2405 |
|
|
2406 |
|
priv->pixmap = gdk_pixmap_new ( |
2407 |
|
widget->window, |
2408 |
|
widget->allocation.width + EXTRA_BORDER * 2, |
2409 |
|
widget->allocation.height + EXTRA_BORDER * 2, |
2410 |
|
-1); |
2411 |
|
|
2412 |
|
/* and gc, used for clipping (I think......) */ |
2413 |
|
if(priv->gc_map) |
2414 |
|
g_object_unref(priv->gc_map); |
2415 |
|
|
2416 |
|
priv->gc_map = gdk_gc_new(priv->pixmap); |
2417 |
|
|
2418 |
|
osm_gps_map_map_redraw(OSM_GPS_MAP(widget)); |
2419 |
|
|
2420 |
|
return FALSE; |
2421 |
|
} |
2422 |
|
|
2423 |
|
static gboolean |
2424 |
|
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event) |
2425 |
|
{ |
2426 |
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
2427 |
|
|
2428 |
gdk_draw_drawable ( |
gdk_draw_drawable ( |
2429 |
widget->window, |
widget->window, |
2430 |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
2431 |
priv->pixmap, |
priv->pixmap, |
2432 |
0,0, |
0,0, |
2433 |
priv->drag_mouse_dx - EXTRA_BORDER, priv->drag_mouse_dy - EXTRA_BORDER, |
priv->drag_mouse_dx - EXTRA_BORDER, |
2434 |
|
priv->drag_mouse_dy - EXTRA_BORDER, |
2435 |
-1,-1); |
-1,-1); |
2436 |
|
|
2437 |
//Paint white outside of the map if dragging. Its less |
//Paint white outside of the map if dragging. Its less |
2475 |
widget->allocation.width, |
widget->allocation.width, |
2476 |
-priv->drag_mouse_dy - EXTRA_BORDER); |
-priv->drag_mouse_dy - EXTRA_BORDER); |
2477 |
} |
} |
2478 |
|
#if 0 |
2479 |
return FALSE; |
if(!priv->dragging) |
2480 |
} |
gdk_draw_drawable ( |
|
|
|
|
static gboolean |
|
|
osm_gps_map_configure (GtkWidget *widget, GdkEventConfigure *event) |
|
|
{ |
|
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
|
|
|
|
|
/* create pixmap */ |
|
|
if (priv->pixmap) |
|
|
g_object_unref (priv->pixmap); |
|
|
|
|
|
priv->pixmap = gdk_pixmap_new ( |
|
|
widget->window, |
|
|
widget->allocation.width + EXTRA_BORDER * 2, |
|
|
widget->allocation.height + EXTRA_BORDER * 2, |
|
|
-1); |
|
|
|
|
|
/* and gc, used for clipping (I think......) */ |
|
|
if(priv->gc_map) |
|
|
g_object_unref(priv->gc_map); |
|
|
|
|
|
priv->gc_map = gdk_gc_new(priv->pixmap); |
|
|
|
|
|
osm_gps_map_map_redraw(OSM_GPS_MAP(widget)); |
|
|
|
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
static gboolean |
|
|
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event) |
|
|
{ |
|
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
|
|
|
|
|
gdk_draw_drawable ( |
|
2481 |
widget->window, |
widget->window, |
2482 |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
2483 |
priv->pixmap, |
priv->pixmap, |
2484 |
event->area.x + EXTRA_BORDER, event->area.y + EXTRA_BORDER, |
event->area.x + EXTRA_BORDER, |
2485 |
|
event->area.y + EXTRA_BORDER, |
2486 |
event->area.x, event->area.y, |
event->area.x, event->area.y, |
2487 |
event->area.width, event->area.height); |
event->area.width, event->area.height); |
2488 |
|
#endif |
2489 |
return FALSE; |
return FALSE; |
2490 |
} |
} |
2491 |
|
|
2671 |
"radius of the gps point inner circle", |
"radius of the gps point inner circle", |
2672 |
0, /* minimum property value */ |
0, /* minimum property value */ |
2673 |
G_MAXINT, /* maximum property value */ |
G_MAXINT, /* maximum property value */ |
2674 |
5, |
10, |
2675 |
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); |
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); |
2676 |
|
|
2677 |
g_object_class_install_property (object_class, |
g_object_class_install_property (object_class, |
3257 |
return osm_gps_map_get_scale_at_point(priv->map_zoom, priv->center_rlat, priv->center_rlon); |
return osm_gps_map_get_scale_at_point(priv->map_zoom, priv->center_rlat, priv->center_rlon); |
3258 |
} |
} |
3259 |
|
|
3260 |
|
#ifdef ENABLE_BALLOON |
3261 |
|
void |
3262 |
|
osm_gps_map_draw_balloon (OsmGpsMap *map, float latitude, float longitude, |
3263 |
|
OsmGpsMapBalloonCallback cb, gpointer data) |
3264 |
|
{ |
3265 |
|
OsmGpsMapPrivate *priv; |
3266 |
|
|
3267 |
|
/* remove and previously installed balloon */ |
3268 |
|
osm_gps_map_clear_balloon (map); |
3269 |
|
|
3270 |
|
g_return_if_fail (OSM_IS_GPS_MAP (map)); |
3271 |
|
priv = map->priv; |
3272 |
|
|
3273 |
|
priv->balloon.coo->rlat = deg2rad(latitude); |
3274 |
|
priv->balloon.coo->rlon = deg2rad(longitude); |
3275 |
|
priv->balloon.valid = TRUE; |
3276 |
|
|
3277 |
|
priv->balloon.cb = cb; |
3278 |
|
priv->balloon.data = data; |
3279 |
|
|
3280 |
|
// this redraws the map |
3281 |
|
osm_gps_map_map_redraw_idle(map); |
3282 |
|
} |
3283 |
|
|
3284 |
|
void |
3285 |
|
osm_gps_map_clear_balloon (OsmGpsMap *map) |
3286 |
|
{ |
3287 |
|
OsmGpsMapPrivate *priv; |
3288 |
|
|
3289 |
|
g_return_if_fail (OSM_IS_GPS_MAP (map)); |
3290 |
|
priv = map->priv; |
3291 |
|
|
3292 |
|
priv->balloon.valid = FALSE; |
3293 |
|
|
3294 |
|
osm_gps_map_map_redraw_idle(map); |
3295 |
|
} |
3296 |
|
#endif |
3297 |
|
|
3298 |
|
#ifdef ENABLE_OSD |
3299 |
|
void osm_gps_map_osd_enable_gps (OsmGpsMap *map, OsmGpsMapOsdGpsCallback cb, gpointer data) { |
3300 |
|
OsmGpsMapPrivate *priv; |
3301 |
|
|
3302 |
|
g_return_if_fail (OSM_IS_GPS_MAP (map)); |
3303 |
|
priv = map->priv; |
3304 |
|
|
3305 |
|
priv->osd.cb = cb; |
3306 |
|
priv->osd.data = data; |
3307 |
|
|
3308 |
|
/* this may have changed the state of the gps button */ |
3309 |
|
/* we thus re-render the overlay */ |
3310 |
|
osm_gps_map_osd_render(priv); |
3311 |
|
|
3312 |
|
osm_gps_map_map_redraw_idle(map); |
3313 |
|
} |
3314 |
|
#endif |