static void translate (GnomePrintContext *gpc, gint x, gint y) { gnome_print_translate (gpc, (gdouble) x / PANGO_SCALE, (gdouble) y / PANGO_SCALE); }
void DrawPrint( GnomePrintContext *gpc ) { int bl_width = 32; int bl_height = 32; int seq_size = 32; int the_width = RUNG_WIDTH*bl_width; int the_height = RUNG_HEIGHT*bl_height; int iCurrentLanguage = SectionArray[ InfosGene->CurrentSection ].Language; GdkPixmap *pixmap_for_print; #ifdef SEQUENTIAL_SUPPORT if ( iCurrentLanguage==SECTION_IN_SEQUENTIAL ) { the_width = SEQ_PAGE_WIDTH*seq_size; the_height = SEQ_PAGE_HEIGHT*seq_size; } #endif pixmap_for_print = gdk_pixmap_new( drawing_area->window/*drawable*/, the_width, the_height, -1/*depth*/ ); if ( pixmap_for_print ) { char TheEnd = FALSE; char NewPage = TRUE; int SizePageOffset = 800; int ScanRung = InfosGene->FirstRung; int PageNumber = 1; do { char Buffer[ LGT_LABEL+LGT_COMMENT+20 ]; GdkPixbuf *pixbuf_for_print; if ( NewPage==TRUE ) { gnome_print_beginpage( gpc, (guchar *)"1" ); NewPage = FALSE; SizePageOffset = 800; sprintf(Buffer, "ClassicLadder" RELEASE_VER_STRING ". Section:%s - Page:%d", SectionArray[ InfosGene->CurrentSection ].Name, PageNumber ); gnome_print_moveto( gpc, 50, 20 ); gnome_print_show( gpc, (guchar *)Buffer ); } gdk_draw_rectangle (pixmap_for_print, drawing_area->style->white_gc, TRUE, 0, 0, the_width, the_height); if ( iCurrentLanguage==SECTION_IN_LADDER ) DrawRung( pixmap_for_print, &RungArray[ ScanRung ], 0/*PosiY*/, bl_width, bl_height, DRAW_FOR_PRINT ); #ifdef SEQUENTIAL_SUPPORT if ( iCurrentLanguage==SECTION_IN_SEQUENTIAL ) { DrawSequentialPage( pixmap_for_print, SectionArray[ InfosGene->CurrentSection ].SequentialPage, DRAW_FOR_PRINT ); TheEnd = TRUE; } #endif pixbuf_for_print = gdk_pixbuf_get_from_drawable( NULL /*GdkPixbuf *dest*/, pixmap_for_print, NULL /*cmap*/, 0 /*src_x*/, 0 /*src_y*/, 0 /*dest_x*/, 0 /*dest_y*/, the_width, the_height); if ( pixbuf_for_print ) { guchar *raw_image; gint rowstride; if ( iCurrentLanguage==SECTION_IN_LADDER ) { char BuffFormat[10] = "%s (%s)"; if ( RungArray[ ScanRung ].Comment[0]=='\0' ) strcpy( BuffFormat, "%s %s" ); sprintf( Buffer, BuffFormat, RungArray[ ScanRung ].Label, RungArray[ ScanRung ].Comment ); gnome_print_moveto( gpc, 50, SizePageOffset ); SizePageOffset = SizePageOffset-20; gnome_print_show( gpc, (guchar *)Buffer ); } raw_image = gdk_pixbuf_get_pixels( pixbuf_for_print ); rowstride = gdk_pixbuf_get_rowstride( pixbuf_for_print ); gnome_print_gsave( gpc ); gnome_print_translate( gpc, 20, SizePageOffset-the_height+15 ); gnome_print_scale( gpc, the_width, the_height ); gnome_print_rgbimage( gpc, raw_image, the_width, the_height, rowstride); gnome_print_grestore( gpc ); SizePageOffset = SizePageOffset-the_height-20; gdk_pixbuf_unref( pixbuf_for_print ); if ( iCurrentLanguage==SECTION_IN_LADDER ) { if ( ScanRung!=InfosGene->LastRung ) ScanRung = RungArray[ ScanRung ].NextRung; else TheEnd = TRUE; } if ( SizePageOffset<200 || TheEnd ) { NewPage = TRUE; PageNumber++; gnome_print_showpage ( gpc ); } } else { printf( "Failed to create pixbuf_for_print\n" ); } } while( !TheEnd ); gdk_pixmap_unref( pixmap_for_print ); } else { printf( "Failed to create pixmap_for_print\n" ); } }