NetSurf
print.c
Go to the documentation of this file.
1/*
2 * Copyright 2006 Rob Kendrick <rjek@rjek.com>
3 * Copyright 2005 James Bursa <bursa@users.sourceforge.net>
4 * Copyright 2008 Adam Blokus <adamblokus@gmail.com>
5 *
6 * This file is part of NetSurf, http://www.netsurf-browser.org/
7 *
8 * NetSurf is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * NetSurf is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21/**
22 * \file
23 * GTK printing implementation.
24 * All the functions and structures necessary for printing( signal handlers,
25 * plotters, printer) are here.
26 * Most of the plotters have been copied from the gtk_plotters.c file.
27 */
28
29#include "utils/config.h"
30
31#include <math.h>
32#include <assert.h>
33#include <gdk/gdk.h>
34#include <gtk/gtk.h>
35
36#include "utils/log.h"
37#include "utils/utils.h"
38#include "utils/nsoption.h"
39#include "netsurf/plotters.h"
40#include "desktop/print.h"
41#include "desktop/printer.h"
42
43#include "gtk/layout_pango.h"
44#include "gtk/bitmap.h"
45#include "gtk/print.h"
46#include "gtk/scaffolding.h"
47
48/* Globals */
50static struct print_settings* settings;
52static GdkRectangle cliprect;
53
54static inline void nsgtk_print_set_colour(colour c)
55{
56 int r, g, b;
57
58 r = c & 0xff;
59 g = (c & 0xff00) >> 8;
60 b = (c & 0xff0000) >> 16;
61
62#ifdef FIXME
63 GdkColor colour;
64 colour.red = r | (r << 8);
65 colour.green = g | (g << 8);
66 colour.blue = b | (b << 8);
67 colour.pixel = (r << 16) | (g << 8) | b;
68 gdk_colormap_alloc_color(gdk_colormap_get_system(), &colour, true, true);
69#endif
70 cairo_set_source_rgba(gtk_print_current_cr, r / 255.0,
71 g / 255.0, b / 255.0, 1.0);
72}
73
74
75
76static nserror gtk_print_font_paint(int x, int y,
77 const char *string, size_t length,
78 const plot_font_style_t *fstyle)
79{
80 PangoFontDescription *desc;
81 PangoLayout *layout;
82 gint size;
83 PangoLayoutLine *line;
84
85 if (length == 0)
86 return NSERROR_OK;
87
88 desc = nsfont_style_to_description(fstyle);
89 size = (gint) ((double) pango_font_description_get_size(desc) *
91
92 if (pango_font_description_get_size_is_absolute(desc))
93 pango_font_description_set_absolute_size(desc, size);
94 else
95 pango_font_description_set_size(desc, size);
96
97 layout = pango_cairo_create_layout(gtk_print_current_cr);
98
99 pango_layout_set_font_description(layout, desc);
100 pango_layout_set_text(layout, string, length);
101
102 line = pango_layout_get_line(layout, 0);
103
104 cairo_move_to(gtk_print_current_cr, x, y);
106 pango_cairo_show_layout_line(gtk_print_current_cr, line);
107
108 g_object_unref(layout);
109 pango_font_description_free(desc);
110
111 return NSERROR_OK;
112}
113
114
115/** Set cairo context to solid plot operation. */
116static inline void nsgtk_print_set_solid(void)
117{
118 double dashes = 0;
119 cairo_set_dash(gtk_print_current_cr, &dashes, 0, 0);
120}
121
122/** Set cairo context to dotted plot operation. */
123static inline void nsgtk_print_set_dotted(void)
124{
125 double cdashes[] = { 1.0, 2.0 };
126 cairo_set_dash(gtk_print_current_cr, cdashes, 1, 0);
127}
128
129/** Set cairo context to dashed plot operation. */
130static inline void nsgtk_print_set_dashed(void)
131{
132 double cdashes[] = { 8.0, 2.0 };
133 cairo_set_dash(gtk_print_current_cr, cdashes, 1, 0);
134}
135
136/** Set cairo context line width. */
138{
139 if (width == 0) {
140 cairo_set_line_width(gtk_print_current_cr, 1);
141 } else {
142 cairo_set_line_width(gtk_print_current_cr,
144 }
145}
146
147
148/**
149 * \brief Sets a clip rectangle for subsequent plot operations.
150 *
151 * \param ctx The current redraw context.
152 * \param clip The rectangle to limit all subsequent plot
153 * operations within.
154 * \return NSERROR_OK on success else error code.
155 */
156static nserror
157nsgtk_print_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
158{
159 NSLOG(netsurf, INFO,
160 "Clipping. x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i", clip->x0,
161 clip->y0, clip->x1, clip->y1);
162
163 /* Normalize cllipping area - to prevent overflows.
164 * See comment in pdf_plot_fill. */
165 int clip_x0 = min(max(clip->x0, 0), settings->page_width);
166 int clip_y0 = min(max(clip->y0, 0), settings->page_height);
167 int clip_x1 = min(max(clip->x1, 0), settings->page_width);
168 int clip_y1 = min(max(clip->y1, 0), settings->page_height);
169
170 cairo_reset_clip(gtk_print_current_cr);
171 cairo_rectangle(gtk_print_current_cr, clip_x0, clip_y0,
172 clip_x1 - clip_x0, clip_y1 - clip_y0);
173 cairo_clip(gtk_print_current_cr);
174
175 cliprect.x = clip_x0;
176 cliprect.y = clip_y0;
177 cliprect.width = clip_x1 - clip_x0;
178 cliprect.height = clip_y1 - clip_y0;
179
180 return NSERROR_OK;
181}
182
183
184/**
185 * Plots an arc
186 *
187 * plot an arc segment around (x,y), anticlockwise from angle1
188 * to angle2. Angles are measured anticlockwise from
189 * horizontal, in degrees.
190 *
191 * \param ctx The current redraw context.
192 * \param style Style controlling the arc plot.
193 * \param x The x coordinate of the arc.
194 * \param y The y coordinate of the arc.
195 * \param radius The radius of the arc.
196 * \param angle1 The start angle of the arc.
197 * \param angle2 The finish angle of the arc.
198 * \return NSERROR_OK on success else error code.
199 */
200static nserror
202 const plot_style_t *style,
203 int x, int y, int radius, int angle1, int angle2)
204{
207
208 cairo_set_line_width(gtk_print_current_cr, 1);
209 cairo_arc(gtk_print_current_cr, x, y, radius,
210 (angle1 + 90) * (M_PI / 180),
211 (angle2 + 90) * (M_PI / 180));
212 cairo_stroke(gtk_print_current_cr);
213
214 return NSERROR_OK;
215}
216
217
218/**
219 * Plots a circle
220 *
221 * Plot a circle centered on (x,y), which is optionally filled.
222 *
223 * \param ctx The current redraw context.
224 * \param style Style controlling the circle plot.
225 * \param x x coordinate of circle centre.
226 * \param y y coordinate of circle centre.
227 * \param radius circle radius.
228 * \return NSERROR_OK on success else error code.
229 */
230static nserror
232 const plot_style_t *style,
233 int x, int y, int radius)
234{
235 if (style->fill_type != PLOT_OP_TYPE_NONE) {
238 cairo_set_line_width(gtk_print_current_cr, 0);
239 cairo_arc(gtk_print_current_cr, x, y, radius, 0, M_PI * 2);
240 cairo_fill(gtk_print_current_cr);
241 cairo_stroke(gtk_print_current_cr);
242 }
243
244 if (style->stroke_type != PLOT_OP_TYPE_NONE) {
246
247 switch (style->stroke_type) {
248 case PLOT_OP_TYPE_SOLID: /**< Solid colour */
249 default:
251 break;
252
253 case PLOT_OP_TYPE_DOT: /**< Doted plot */
255 break;
256
257 case PLOT_OP_TYPE_DASH: /**< dashed plot */
259 break;
260 }
261
263
264 cairo_arc(gtk_print_current_cr, x, y, radius, 0, M_PI * 2);
265
266 cairo_stroke(gtk_print_current_cr);
267 }
268 return NSERROR_OK;
269}
270
271
272/**
273 * Plots a line
274 *
275 * plot a line from (x0,y0) to (x1,y1). Coordinates are at
276 * centre of line width/thickness.
277 *
278 * \param ctx The current redraw context.
279 * \param style Style controlling the line plot.
280 * \param line A rectangle defining the line to be drawn
281 * \return NSERROR_OK on success else error code.
282 */
283static nserror
285 const plot_style_t *style,
286 const struct rect *line)
287{
289
290 switch (style->stroke_type) {
291 case PLOT_OP_TYPE_SOLID: /**< Solid colour */
292 default:
294 break;
295
296 case PLOT_OP_TYPE_DOT: /**< Doted plot */
298 break;
299
300 case PLOT_OP_TYPE_DASH: /**< dashed plot */
302 break;
303 }
304
306
307 cairo_move_to(gtk_print_current_cr, line->x0 + 0.5, line->y0 + 0.5);
308 cairo_line_to(gtk_print_current_cr, line->x1 + 0.5, line->y1 + 0.5);
309 cairo_stroke(gtk_print_current_cr);
310
311 return NSERROR_OK;
312}
313
314
315/**
316 * Plots a rectangle.
317 *
318 * The rectangle can be filled an outline or both controlled
319 * by the plot style The line can be solid, dotted or
320 * dashed. Top left corner at (x0,y0) and rectangle has given
321 * width and height.
322 *
323 * \param ctx The current redraw context.
324 * \param style Style controlling the rectangle plot.
325 * \param rect A rectangle defining the line to be drawn
326 * \return NSERROR_OK on success else error code.
327 */
328static nserror
330 const plot_style_t *style,
331 const struct rect *rect)
332{
333 NSLOG(netsurf, INFO, "x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i",
334 rect->x0, rect->y0, rect->x1, rect->y1);
335
336 if (style->fill_type != PLOT_OP_TYPE_NONE) {
337 int x0,y0,x1,y1;
338
341
342 /* Normalize boundaries of the area - to prevent overflows.
343 * See comment in pdf_plot_fill. */
344 x0 = min(max(rect->x0, 0), settings->page_width);
345 y0 = min(max(rect->y0, 0), settings->page_height);
346 x1 = min(max(rect->x1, 0), settings->page_width);
347 y1 = min(max(rect->y1, 0), settings->page_height);
348
349 cairo_set_line_width(gtk_print_current_cr, 0);
350 cairo_rectangle(gtk_print_current_cr,
351 x0, y0,
352 x1 - x0, y1 - y0);
353 cairo_fill(gtk_print_current_cr);
354 cairo_stroke(gtk_print_current_cr);
355 }
356
357 if (style->stroke_type != PLOT_OP_TYPE_NONE) {
358
360
361 switch (style->stroke_type) {
362 case PLOT_OP_TYPE_SOLID: /**< Solid colour */
363 default:
365 break;
366
367 case PLOT_OP_TYPE_DOT: /**< Doted plot */
369 break;
370
371 case PLOT_OP_TYPE_DASH: /**< dashed plot */
373 break;
374 }
375
377
378 cairo_rectangle(gtk_print_current_cr,
379 rect->x0, rect->y0,
380 rect->x1 - rect->x0, rect->y1 - rect->y0);
381
382 cairo_stroke(gtk_print_current_cr);
383 }
384
385 return NSERROR_OK;
386}
387
388
389static nserror
391 const plot_style_t *style,
392 const int *p,
393 unsigned int n)
394{
395 unsigned int i;
396
397 NSLOG(netsurf, INFO, "Plotting polygon.");
398
401
402 cairo_set_line_width(gtk_print_current_cr, 0);
403 cairo_move_to(gtk_print_current_cr, p[0], p[1]);
404
405 NSLOG(netsurf, INFO, "Starting line at: %i\t%i", p[0], p[1]);
406
407 for (i = 1; i != n; i++) {
408 cairo_line_to(gtk_print_current_cr, p[i * 2], p[i * 2 + 1]);
409 NSLOG(netsurf, INFO, "Drawing line to: %i\t%i", p[i * 2],
410 p[i * 2 + 1]);
411 }
412
413 cairo_fill(gtk_print_current_cr);
414 cairo_stroke(gtk_print_current_cr);
415
416 return NSERROR_OK;
417}
418
419
420/**
421 * Plots a path.
422 *
423 * Path plot consisting of cubic Bezier curves. Line and fill colour is
424 * controlled by the plot style.
425 *
426 * \param ctx The current redraw context.
427 * \param pstyle Style controlling the path plot.
428 * \param p elements of path
429 * \param n nunber of elements on path
430 * \param transform A transform to apply to the path.
431 * \return NSERROR_OK on success else error code.
432 */
433static nserror
435 const plot_style_t *pstyle,
436 const float *p,
437 unsigned int n,
438 const float transform[6])
439{
440 /* Only the internal SVG renderer uses this plot call currently,
441 * and the GTK version uses librsvg. Thus, we ignore this complexity,
442 * and just return true obliviously. */
443
444 return NSERROR_OK;
445}
446
447
448static bool nsgtk_print_plot_pixbuf(int x, int y, int width, int height,
449 struct bitmap *bitmap, colour bg)
450{
451 int x0, y0, x1, y1;
452 int dsrcx, dsrcy, dwidth, dheight;
453 int bmwidth, bmheight;
454
455 cairo_surface_t *bmsurface = bitmap->surface;
456
457 /* Bail early if we can */
458 if (width == 0 || height == 0)
459 /* Nothing to plot */
460 return true;
461 if ((x > (cliprect.x + cliprect.width)) ||
462 ((x + width) < cliprect.x) ||
463 (y > (cliprect.y + cliprect.height)) ||
464 ((y + height) < cliprect.y)) {
465 /* Image completely outside clip region */
466 return true;
467 }
468
469 /* Get clip rectangle / image rectangle edge differences */
470 x0 = cliprect.x - x;
471 y0 = cliprect.y - y;
472 x1 = (x + width) - (cliprect.x + cliprect.width);
473 y1 = (y + height) - (cliprect.y + cliprect.height);
474
475 /* Set initial draw geometry */
476 dsrcx = x;
477 dsrcy = y;
478 dwidth = width;
479 dheight = height;
480
481 /* Manually clip draw coordinates to area of image to be rendered */
482 if (x0 > 0) {
483 /* Clip left */
484 dsrcx += x0;
485 dwidth -= x0;
486 }
487 if (y0 > 0) {
488 /* Clip top */
489 dsrcy += y0;
490 dheight -= y0;
491 }
492 if (x1 > 0) {
493 /* Clip right */
494 dwidth -= x1;
495 }
496 if (y1 > 0) {
497 /* Clip bottom */
498 dheight -= y1;
499 }
500
501 if (dwidth == 0 || dheight == 0)
502 /* Nothing to plot */
503 return true;
504
505 bmwidth = cairo_image_surface_get_width(bmsurface);
506 bmheight = cairo_image_surface_get_height(bmsurface);
507
508 /* Render the bitmap */
509 if ((bmwidth == width) && (bmheight == height)) {
510 /* Bitmap is not scaled */
511 /* Plot the bitmap */
512 cairo_set_source_surface(gtk_print_current_cr, bmsurface, x, y);
513 cairo_rectangle(gtk_print_current_cr, dsrcx, dsrcy, dwidth, dheight);
514 cairo_fill(gtk_print_current_cr);
515
516 } else {
517 /* Bitmap is scaled */
518 if ((bitmap->scsurface != NULL) &&
519 ((cairo_image_surface_get_width(bitmap->scsurface) != width) ||
520 (cairo_image_surface_get_height(bitmap->scsurface) != height))){
521 cairo_surface_destroy(bitmap->scsurface);
522 bitmap->scsurface = NULL;
523 }
524
525 if (bitmap->scsurface == NULL) {
526 bitmap->scsurface = cairo_surface_create_similar(bmsurface,CAIRO_CONTENT_COLOR_ALPHA, width, height);
527 cairo_t *cr = cairo_create(bitmap->scsurface);
528
529 /* Scale *before* setting the source surface (1) */
530 cairo_scale(cr, (double)width / bmwidth, (double)height / bmheight);
531 cairo_set_source_surface(cr, bmsurface, 0, 0);
532
533 /* To avoid getting the edge pixels blended with 0
534 * alpha, which would occur with the default
535 * EXTEND_NONE. Use EXTEND_PAD for 1.2 or newer (2)
536 */
537 cairo_pattern_set_extend(cairo_get_source(cr),
538 CAIRO_EXTEND_REFLECT);
539
540 /* Replace the destination with the source instead of
541 * overlaying
542 */
543 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
544
545 /* Do the actual drawing */
546 cairo_paint(cr);
547
548 cairo_destroy(cr);
549
550 }
551 /* Plot the scaled bitmap */
552 cairo_set_source_surface(gtk_print_current_cr, bitmap->scsurface, x, y);
553 cairo_rectangle(gtk_print_current_cr, dsrcx, dsrcy, dwidth, dheight);
554 cairo_fill(gtk_print_current_cr);
555
556 }
557
558 return true;
559}
560
561
562/**
563 * Plot a bitmap
564 *
565 * Tiled plot of a bitmap image. (x,y) gives the top left
566 * coordinate of an explicitly placed tile. From this tile the
567 * image can repeat in all four directions -- up, down, left
568 * and right -- to the extents given by the current clip
569 * rectangle.
570 *
571 * The bitmap_flags say whether to tile in the x and y
572 * directions. If not tiling in x or y directions, the single
573 * image is plotted. The width and height give the dimensions
574 * the image is to be scaled to.
575 *
576 * \param ctx The current redraw context.
577 * \param bitmap The bitmap to plot
578 * \param x The x coordinate to plot the bitmap
579 * \param y The y coordiante to plot the bitmap
580 * \param width The width of area to plot the bitmap into
581 * \param height The height of area to plot the bitmap into
582 * \param bg the background colour to alpha blend into
583 * \param flags the flags controlling the type of plot operation
584 * \return NSERROR_OK on success else error code.
585 */
586static nserror
588 struct bitmap *bitmap,
589 int x, int y,
590 int width, int height,
591 colour bg,
592 bitmap_flags_t flags)
593{
594 int doneheight = 0, donewidth = 0;
595 bool repeat_x = (flags & BITMAPF_REPEAT_X);
596 bool repeat_y = (flags & BITMAPF_REPEAT_Y);
597
598 if (!(repeat_x || repeat_y)) {
599 /* Not repeating at all, so just pass it on */
600 return nsgtk_print_plot_pixbuf(x, y, width, height, bitmap, bg);
601 }
602
605
606 /* Bail early if we can */
607 if (width == 0 || height == 0)
608 /* Nothing to plot */
609 return true;
610
611 if (y > cliprect.y) {
612 doneheight = (cliprect.y - height) + ((y - cliprect.y) % height);
613 } else {
614 doneheight = y;
615 }
616
617 while (doneheight < (cliprect.y + cliprect.height)) {
618 if (x > cliprect.x) {
619 donewidth = (cliprect.x - width) + ((x - cliprect.x) % width);
620 } else {
621 donewidth = x;
622 }
623
624 while (donewidth < (cliprect.x + cliprect.width)) {
625 nsgtk_print_plot_pixbuf(donewidth, doneheight,
626 width, height, bitmap, bg);
627 donewidth += width;
628 if (!repeat_x)
629 break;
630 }
631 doneheight += height;
632
633 if (!repeat_y)
634 break;
635 }
636
637 return true;
638}
639
640
641static nserror
643 const struct plot_font_style *fstyle,
644 int x,
645 int y,
646 const char *text,
647 size_t length)
648{
649 return gtk_print_font_paint(x, y, text, length, fstyle);
650}
651
652
653/** GTK print plotter table */
654static const struct plotter_table nsgtk_print_plotters = {
657 .disc = nsgtk_print_plot_disc,
658 .line = nsgtk_print_plot_line,
659 .rectangle = nsgtk_print_plot_rectangle,
660 .polygon = nsgtk_print_plot_polygon,
661 .path = nsgtk_print_plot_path,
662 .bitmap = nsgtk_print_plot_bitmap,
663 .text = nsgtk_print_plot_text,
664 .option_knockout = false,
665};
666
668{
669 return true;
670}
671
672static bool gtk_print_next_page(void)
673{
674 return true;
675}
676
677static void gtk_print_end(void)
678{
679}
680
681static const struct printer gtk_printer = {
686};
687
688/**
689 * Handle the begin_print signal from the GtkPrintOperation
690 *
691 * \param operation the operation which emited the signal
692 * \param context the print context used to set up the pages
693 * \param user_data nothing in here
694 */
695void gtk_print_signal_begin_print (GtkPrintOperation *operation,
696 GtkPrintContext *context, gpointer user_data)
697{
698 int page_number;
699 double height_on_page, height_to_print;
700
701 NSLOG(netsurf, INFO, "Begin print");
702
703 settings = user_data;
704
709 settings->page_width = gtk_print_context_get_width(context);
710 settings->page_height = gtk_print_context_get_height(context);
711 settings->scale = 0.7; /* at 0.7 the pages look the best */
713
715 settings, &height_to_print) == false) {
716 gtk_print_operation_cancel(operation);
717
718 } else {
719
720 NSLOG(netsurf, INFO,
721 "page_width: %f ;page_height: %f; content height: %lf",
724 height_to_print);
725
726 height_on_page = settings->page_height;
727 height_on_page = height_on_page -
728 FIXTOFLT(FSUB(settings->margins[MARGINTOP],
730 height_to_print *= settings->scale;
731
732 page_number = height_to_print / height_on_page;
733
734 if (height_to_print - page_number * height_on_page > 0)
735 page_number += 1;
736
737 gtk_print_operation_set_n_pages(operation, page_number);
738 }
739}
740
741/**
742 * Handle the draw_page signal from the GtkPrintOperation.
743 * This function changes only the cairo context to print on.
744 */
745void gtk_print_signal_draw_page(GtkPrintOperation *operation,
746 GtkPrintContext *context, gint page_nr, gpointer user_data)
747{
748 NSLOG(netsurf, INFO, "Draw Page");
749 gtk_print_current_cr = gtk_print_context_get_cairo_context(context);
751}
752
753/**
754 * Handle the end_print signal from the GtkPrintOperation.
755 * This functions calls only the print_cleanup function from the print interface
756 */
757void gtk_print_signal_end_print(GtkPrintOperation *operation,
758 GtkPrintContext *context, gpointer user_data)
759{
760 NSLOG(netsurf, INFO, "End print");
762}
763
764
#define M_PI
Definition: plotters.c:101
bool print_draw_next_page(const struct printer *printer, struct print_settings *settings)
This function draws one page, beginning with the height offset of done_height.
Definition: print.c:176
bool print_cleanup(hlcache_handle *content, const struct printer *printer, struct print_settings *settings)
Memory allocated during printing is being freed here.
Definition: print.c:228
bool print_set_up(hlcache_handle *content, const struct printer *printer, struct print_settings *settings, double *height)
This function prepares the content to be printed.
Definition: print.c:148
Conception: Generalized output-in-pages.
@ MARGINLEFT
Definition: print.h:42
@ MARGINTOP
Definition: print.h:42
@ MARGINRIGHT
Definition: print.h:42
@ MARGINBOTTOM
Definition: print.h:42
nserror
Enumeration of error codes.
Definition: errors.h:29
@ NSERROR_OK
No error.
Definition: errors.h:30
int nsgtk_bitmap_get_height(void *vbitmap)
Definition: bitmap.c:187
int nsgtk_bitmap_get_width(void *vbitmap)
Definition: bitmap.c:178
void gtk_print_signal_end_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
Handle the end_print signal from the GtkPrintOperation.
Definition: print.c:757
static GdkRectangle cliprect
Definition: print.c:52
static nserror nsgtk_print_plot_arc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius, int angle1, int angle2)
Plots an arc.
Definition: print.c:201
static void nsgtk_print_set_dotted(void)
Set cairo context to dotted plot operation.
Definition: print.c:123
static struct print_settings * settings
Definition: print.c:50
static void nsgtk_print_set_dashed(void)
Set cairo context to dashed plot operation.
Definition: print.c:130
cairo_t * gtk_print_current_cr
Definition: print.c:49
static void nsgtk_print_set_solid(void)
Set cairo context to solid plot operation.
Definition: print.c:116
static const struct plotter_table nsgtk_print_plotters
GTK print plotter table.
Definition: print.c:654
struct hlcache_handle * content_to_print
Definition: print.c:51
static nserror nsgtk_print_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: print.c:157
void gtk_print_signal_draw_page(GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr, gpointer user_data)
Handle the draw_page signal from the GtkPrintOperation.
Definition: print.c:745
static nserror gtk_print_font_paint(int x, int y, const char *string, size_t length, const plot_font_style_t *fstyle)
Definition: print.c:76
static nserror nsgtk_print_plot_bitmap(const struct redraw_context *ctx, struct bitmap *bitmap, int x, int y, int width, int height, colour bg, bitmap_flags_t flags)
Plot a bitmap.
Definition: print.c:587
static nserror nsgtk_print_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
Plots a rectangle.
Definition: print.c:329
static nserror nsgtk_print_plot_text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Definition: print.c:642
static bool gtk_print_begin(struct print_settings *settings)
Definition: print.c:667
static void gtk_print_end(void)
Definition: print.c:677
static nserror nsgtk_print_plot_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
Definition: print.c:390
static void nsgtk_print_set_colour(colour c)
Definition: print.c:54
static bool gtk_print_next_page(void)
Definition: print.c:672
void gtk_print_signal_begin_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
Handle the begin_print signal from the GtkPrintOperation.
Definition: print.c:695
static nserror nsgtk_print_plot_path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
Definition: print.c:434
static const struct printer gtk_printer
Definition: print.c:681
static nserror nsgtk_print_plot_disc(const struct redraw_context *ctx, const plot_style_t *style, int x, int y, int radius)
Plots a circle.
Definition: print.c:231
static bool nsgtk_print_plot_pixbuf(int x, int y, int width, int height, struct bitmap *bitmap, colour bg)
Definition: print.c:448
static nserror nsgtk_print_plot_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Definition: print.c:284
static void nsgtk_set_line_width(plot_style_fixed width)
Set cairo context line width.
Definition: print.c:137
GTK printing (interface).
Target independent plotting interface.
#define BITMAPF_REPEAT_X
Definition: plotters.h:38
#define BITMAPF_REPEAT_Y
Definition: plotters.h:39
unsigned long bitmap_flags_t
Definition: plotters.h:36
PangoFontDescription * nsfont_style_to_description(const plot_font_style_t *fstyle)
Definition: layout_pango.c:263
struct gui_layout_table * nsgtk_layout_table
Definition: layout_pango.c:317
Interface to GTK layout handling using pango.
#define NSLOG(catname, level, logmsg, args...)
Definition: log.h:116
#define plot_style_fixed_to_double(v)
Definition: plot_style.h:60
int32_t plot_style_fixed
Definition: plot_style.h:48
@ PLOT_OP_TYPE_NONE
No operation.
Definition: plot_style.h:66
@ PLOT_OP_TYPE_DASH
Dashed plot.
Definition: plot_style.h:69
@ PLOT_OP_TYPE_DOT
Dotted plot.
Definition: plot_style.h:68
@ PLOT_OP_TYPE_SOLID
Solid colour.
Definition: plot_style.h:67
Printer interface.
int width
Definition: gui.c:160
int height
Definition: gui.c:161
RISC OS wimp toolkit bitmap.
Definition: bitmap.c:68
cairo_surface_t * surface
Definition: bitmap.h:27
cairo_surface_t * scsurface
Definition: bitmap.h:28
High-level cache handle.
Definition: hlcache.c:66
Font style for plotting.
Definition: plot_style.h:111
colour foreground
Colour of text.
Definition: plot_style.h:123
Plot style for stroke/fill plotters.
Definition: plot_style.h:76
colour fill_colour
Colour of fill.
Definition: plot_style.h:81
plot_style_fixed stroke_width
Width of stroke, in pixels.
Definition: plot_style.h:78
plot_operation_type_t fill_type
Fill plot type.
Definition: plot_style.h:80
colour stroke_colour
Colour of stroke.
Definition: plot_style.h:79
plot_operation_type_t stroke_type
Stroke plot type.
Definition: plot_style.h:77
Plotter operations table.
Definition: plotters.h:102
nserror(* clip)(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plotters.h:111
Settings for a print - filled in by print_make_settings or 'manually' by the caller.
Definition: print.h:50
float scale
Definition: print.h:55
const struct gui_layout_table * font_func
Definition: print.h:63
float page_width
Definition: print.h:52
float page_height
Definition: print.h:52
css_fixed margins[4]
Definition: print.h:53
Printer interface.
Definition: printer.h:34
Rectangle coordinates.
Definition: types.h:40
int x0
Definition: types.h:41
int y0
Top left.
Definition: types.h:41
int x1
Definition: types.h:42
int y1
Bottom right.
Definition: types.h:42
Redraw context.
Definition: plotters.h:51
uint32_t colour
Colour type: XBGR.
Definition: types.h:35
Option reading and saving interface.
Interface to a number of general purpose functionality.
#define min(x, y)
Definition: utils.h:46
#define max(x, y)
Definition: utils.h:50
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
Definition: plot.c:579
static nserror text(const struct redraw_context *ctx, const struct plot_font_style *fstyle, int x, int y, const char *text, size_t length)
Text plotting.
Definition: plot.c:978
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Definition: plot.c:357