comparison gtk3/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 3df86772b625
children 6b605b0700e8
comparison
equal deleted inserted replaced
1260:3cbd8de0b50b 1261:61d0c5f84644
26 #include <dirent.h> 26 #include <dirent.h>
27 #include <sys/stat.h> 27 #include <sys/stat.h>
28 #include <signal.h> 28 #include <signal.h>
29 #include <fcntl.h> 29 #include <fcntl.h>
30 #include <unistd.h> 30 #include <unistd.h>
31 #include <math.h>
31 #include <gdk/gdkkeysyms.h> 32 #include <gdk/gdkkeysyms.h>
32 33
33 #ifdef USE_GTKMOZEMBED 34 #ifdef USE_GTKMOZEMBED
34 # include <gtkmozembed.h> 35 # include <gtkmozembed.h>
35 # undef GTK_TYPE_MOZ_EMBED 36 # undef GTK_TYPE_MOZ_EMBED
6920 cairo_destroy(cr); 6921 cairo_destroy(cr);
6921 } 6922 }
6922 DW_MUTEX_UNLOCK; 6923 DW_MUTEX_UNLOCK;
6923 } 6924 }
6924 6925
6926 /* Draw an arc on a window (preferably a render window).
6927 * Parameters:
6928 * handle: Handle to the window.
6929 * pixmap: Handle to the pixmap. (choose only one of these)
6930 * flags: For future use.
6931 * xorigin: X coordinate of center of arc.
6932 * yorigin: Y coordinate of center of arc.
6933 * x1: X coordinate of first segment of arc.
6934 * y1: Y coordinate of first segment of arc.
6935 * x2: X coordinate of second segment of arc.
6936 * y2: Y coordinate of second segment of arc.
6937 */
6938 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2)
6939 {
6940 int _locked_by_me = FALSE;
6941 cairo_t *cr = NULL;
6942
6943 DW_MUTEX_LOCK;
6944 if(handle)
6945 {
6946 GdkWindow *window = gtk_widget_get_window(handle);
6947 /* Safety check for non-existant windows */
6948 if(!window || !GDK_IS_WINDOW(window))
6949 {
6950 DW_MUTEX_UNLOCK;
6951 return;
6952 }
6953 cr = gdk_cairo_create(window);
6954 }
6955 else if(pixmap)
6956 cr = cairo_create(pixmap->image);
6957 if(cr)
6958 {
6959 GdkColor *foreground = pthread_getspecific(_dw_fg_color_key);
6960 double dx = xorigin - x1;
6961 double dy = yorigin - y1;
6962 double r = sqrt(dx*dx + dy*dy);
6963 double a1 = 180/M_PI * arctan((y1-yorigin)/(x1-xorigin));
6964 double a2 = 180/M_PI * arctan((y2-yorigin)/(x2-xorigin));
6965
6966 gdk_cairo_set_source_color (cr, foreground);
6967 cairo_set_line_width(cr, 1);
6968 cairo_arc(cr, xorigin, yorigin, r, a1, a2);
6969 cairo_stroke(cr);
6970 cairo_destroy(cr);
6971 }
6972 DW_MUTEX_UNLOCK;
6973 }
6974
6925 /* Draw text on a window (preferably a render window). 6975 /* Draw text on a window (preferably a render window).
6926 * Parameters: 6976 * Parameters:
6927 * handle: Handle to the window. 6977 * handle: Handle to the window.
6928 * pixmap: Handle to the pixmap. (choose only one of these) 6978 * pixmap: Handle to the pixmap. (choose only one of these)
6929 * x: X coordinate. 6979 * x: X coordinate.