comparison gtk/dw.c @ 1177:c38ec904b6d3

Fixed dw_pixmap_bitblt() on printing context pixmaps in GTK3. Implemented dw_pixmap_bitblt() for cairo surfaces in GTK2. Which also fixes bitblt for priting on GTK2 as well.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 19 Sep 2011 21:09:58 +0000
parents 8be8607301c8
children 0a48149e93b9
comparison
equal deleted inserted replaced
1176:408ea33b19cf 1177:c38ec904b6d3
8450 free(pixmap->font); 8450 free(pixmap->font);
8451 free(pixmap); 8451 free(pixmap);
8452 DW_MUTEX_UNLOCK; 8452 DW_MUTEX_UNLOCK;
8453 } 8453 }
8454 8454
8455 #if GTK_CHECK_VERSION(2,10,0)
8456 /* Cairo version of dw_pixmap_bitblt() from GTK3, use if either pixmap is a cairo surface */
8457 void _cairo_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
8458 {
8459 int _locked_by_me = FALSE;
8460 cairo_t *cr = NULL;
8461
8462 if((!dest && (!destp || !destp->image)) || (!src && (!srcp || !srcp->image)))
8463 return;
8464
8465 DW_MUTEX_LOCK;
8466 if(dest)
8467 {
8468 GdkWindow *window = gtk_widget_get_window(dest);
8469 /* Safety check for non-existant windows */
8470 if(!window || !GDK_IS_WINDOW(window))
8471 {
8472 DW_MUTEX_UNLOCK;
8473 return;
8474 }
8475 cr = gdk_cairo_create(window);
8476 }
8477 else if(destp)
8478 cr = cairo_create(destp->image);
8479
8480 if(cr)
8481 {
8482 if(src)
8483 gdk_cairo_set_source_window (cr, gtk_widget_get_window(src), xdest -xsrc, ydest - ysrc);
8484 else if(srcp)
8485 cairo_set_source_surface (cr, srcp->image, xdest - xsrc, ydest - ysrc);
8486
8487 cairo_rectangle(cr, xdest, ydest, width, height);
8488 cairo_fill(cr);
8489 cairo_destroy(cr);
8490 }
8491 DW_MUTEX_UNLOCK;
8492 }
8493 #endif
8494
8455 /* 8495 /*
8456 * Copies from one item to another. 8496 * Copies from one item to another.
8457 * Parameters: 8497 * Parameters:
8458 * dest: Destination window handle. 8498 * dest: Destination window handle.
8459 * destp: Destination pixmap. (choose only one). 8499 * destp: Destination pixmap. (choose only one).
8474 * the code here a bit. -Brian 8514 * the code here a bit. -Brian
8475 */ 8515 */
8476 int _locked_by_me = FALSE; 8516 int _locked_by_me = FALSE;
8477 GdkGC *gc = NULL; 8517 GdkGC *gc = NULL;
8478 8518
8519 #if GTK_CHECK_VERSION(2,10,0)
8520 if((destp && destp->image) || (srcp && srcp->image))
8521 {
8522 _cairo_pixmap_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc);
8523 return;
8524 }
8525 #endif
8526
8479 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap))) 8527 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap)))
8480 return; 8528 return;
8481 8529
8482 DW_MUTEX_LOCK; 8530 DW_MUTEX_LOCK;
8483 if(dest) 8531 if(dest)