summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Wildemann <metalstrolch@users.noreply.github.com>2019-08-29 14:47:54 +0200
committerGitHub <noreply@github.com>2019-08-29 14:47:54 +0200
commita76e30280c2a466f1e354614559e39513bdf918f (patch)
treeaaed0fb4891bf9b19c9dfaa3ffbeb3f3e2eca52c
parentb7e97275e7dc35c90f2e18ecd73434f7c7c0d406 (diff)
downloadnavit-a76e30280c2a466f1e354614559e39513bdf918f.tar.gz
Add:graphics/windows: draw polygon with holes (#855)
* Add:graphics/windows: drawing polygons with holes For all Windows except windows CE.
-rw-r--r--navit/graphics/win32/graphics_win32.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/navit/graphics/win32/graphics_win32.c b/navit/graphics/win32/graphics_win32.c
index 1c8172c7c..6bcad3be6 100644
--- a/navit/graphics/win32/graphics_win32.c
+++ b/navit/graphics/win32/graphics_win32.c
@@ -827,6 +827,62 @@ static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc,
SelectObject( gr->hMemDC, holdpen);
}
+#if HAVE_API_WIN32_CE
+/*
+ * Windows CE doesn't support PaintPath used for other versions. No polygon with holes support for CE yet.
+ */
+#else
+static void draw_polygon_with_holes (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count,
+ int hole_count, int* ccount, struct point **holes) {
+ /* remeber pen and brush */
+ HPEN holdpen = SelectObject( gr->hMemDC, gc->hpen );
+ HBRUSH holdbrush = SelectObject( gr->hMemDC, gc->hbrush );
+ /* remember fill mode */
+ int holdmode = GetPolyFillMode( gr->hMemDC );
+
+ /* set polygon fill mode */
+ SetPolyFillMode( gr->hMemDC, ALTERNATE );
+
+ /* use poly path */
+ if(BeginPath(gr->hMemDC)) {
+ int a;
+ /* add outer polygon */
+ if (sizeof(POINT) != sizeof(struct point)) {
+ int i;
+ POINT* points=g_alloca(sizeof(POINT)*count);
+ for ( i=0; i< count; i++ ) {
+ points[i].x = p[i].x;
+ points[i].y = p[i].y;
+ }
+ Polyline( gr->hMemDC, points, count );
+ } else
+ Polyline( gr->hMemDC, (POINT *)p, count);
+ /* add inner polygons */
+ for(a = 0; a<hole_count; a ++) {
+ if (sizeof(POINT) != sizeof(struct point)) {
+ int i;
+ POINT* points=g_alloca(sizeof(POINT)*ccount[a]);
+ for ( i=0; i< ccount[a]; i++ ) {
+ points[i].x = holes[a][i].x;
+ points[i].y = holes[a][i].y;
+ }
+ Polyline( gr->hMemDC, points, ccount[a] );
+ } else
+ Polyline( gr->hMemDC, (POINT *)(holes[a]), ccount[a]);
+ }
+ /* done with this path */
+ EndPath(gr->hMemDC);
+ /* fill the shape */
+ FillPath(gr->hMemDC);
+ }
+
+ /* restore fill mode */
+ SetPolyFillMode(gr->hMemDC, holdmode);
+ /* restore pen and brush */
+ SelectObject( gr->hMemDC, holdbrush);
+ SelectObject( gr->hMemDC, holdpen);
+}
+#endif
static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h) {
HPEN holdpen = SelectObject( gr->hMemDC, gc->hpen );
@@ -1462,8 +1518,15 @@ static struct graphics_methods graphics_methods = {
get_text_bbox,
overlay_disable,
overlay_resize,
+ NULL, /* set_attr */
NULL, /* show_native_keyboard */
NULL, /* hide_native_keyboard */
+ NULL, /* get dpi */
+#if HAVE_API_WIN32_CE
+ NULL, /* draw_polygon_with_holes */
+#else
+ draw_polygon_with_holes
+#endif
};