diff win/dw.c @ 1261:61d0c5f84644

Initial attempt at adding dw_draw_arc() support on all platforms. This code doesn't yet work... will probably require a bunch of fixes... but I wanted to get the code committed while doing research on it.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 25 Oct 2011 10:51:59 +0000
parents 35b177e8a0a2
children 148daf522080
line wrap: on
line diff
--- a/win/dw.c	Tue Oct 25 06:21:59 2011 +0000
+++ b/win/dw.c	Tue Oct 25 10:51:59 2011 +0000
@@ -8815,6 +8815,44 @@
       ReleaseDC(handle, hdcPaint);
 }
 
+/* Draw an arc on a window (preferably a render window).
+ * Parameters:
+ *       handle: Handle to the window.
+ *       pixmap: Handle to the pixmap. (choose only one of these)
+ *       flags: For future use.
+ *       xorigin: X coordinate of center of arc.
+ *       yorigin: Y coordinate of center of arc.
+ *       x1: X coordinate of first segment of arc.
+ *       y1: Y coordinate of first segment of arc.
+ *       x2: X coordinate of second segment of arc.
+ *       y2: Y coordinate of second segment of arc.
+ */
+void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2)
+{
+   HDC hdcPaint;
+   HBRUSH oldBrush;
+   HPEN oldPen;
+   double dx = xorigin - x1;
+   double dy = yorigin - y1;
+   double r = sqrt(dx*dx + dy*dy);
+
+   if(handle)
+      hdcPaint = GetDC(handle);
+   else if(pixmap)
+      hdcPaint = pixmap->hdc;
+   else
+      return;
+      
+   oldBrush = SelectObject( hdcPaint, TlsGetValue(_hBrush) );
+   oldPen = SelectObject( hdcPaint, TlsGetValue(_hPen) );
+   Arc(hdcPaint, xorigin-r, yorigin-r, xorigin+r, yorigin+r, x1, y1, x2, y2);
+   SelectObject( hdcPaint, oldBrush );
+   SelectObject( hdcPaint, oldPen );
+
+   if(!pixmap)
+      ReleaseDC(handle, hdcPaint);
+}
+
 /* Draw text on a window (preferably a render window).
  * Parameters:
  *       handle: Handle to the window.