NetSurf
|
GTK printing implementation. More...
#include "utils/config.h"
#include <math.h>
#include <assert.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "utils/log.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
#include "netsurf/plotters.h"
#include "desktop/print.h"
#include "desktop/printer.h"
#include "gtk/layout_pango.h"
#include "gtk/bitmap.h"
#include "gtk/print.h"
#include "gtk/scaffolding.h"
Go to the source code of this file.
Functions | |
static void | nsgtk_print_set_colour (colour c) |
static nserror | gtk_print_font_paint (int x, int y, const char *string, size_t length, const plot_font_style_t *fstyle) |
static void | nsgtk_print_set_solid (void) |
Set cairo context to solid plot operation. More... | |
static void | nsgtk_print_set_dotted (void) |
Set cairo context to dotted plot operation. More... | |
static void | nsgtk_print_set_dashed (void) |
Set cairo context to dashed plot operation. More... | |
static void | nsgtk_set_line_width (plot_style_fixed width) |
Set cairo context line width. More... | |
static nserror | nsgtk_print_plot_clip (const struct redraw_context *ctx, const struct rect *clip) |
Sets a clip rectangle for subsequent plot operations. More... | |
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. More... | |
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. More... | |
static nserror | nsgtk_print_plot_line (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line) |
Plots a line. More... | |
static nserror | nsgtk_print_plot_rectangle (const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect) |
Plots a rectangle. More... | |
static nserror | nsgtk_print_plot_polygon (const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n) |
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. More... | |
static bool | nsgtk_print_plot_pixbuf (int x, int y, int width, int height, struct bitmap *bitmap, colour bg) |
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. More... | |
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) |
static bool | gtk_print_begin (struct print_settings *settings) |
static bool | gtk_print_next_page (void) |
static void | gtk_print_end (void) |
void | gtk_print_signal_begin_print (GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data) |
Handle the begin_print signal from the GtkPrintOperation. More... | |
void | gtk_print_signal_draw_page (GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr, gpointer user_data) |
Handle the draw_page signal from the GtkPrintOperation. More... | |
void | gtk_print_signal_end_print (GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data) |
Handle the end_print signal from the GtkPrintOperation. More... | |
Variables | |
cairo_t * | gtk_print_current_cr |
static struct print_settings * | settings |
struct hlcache_handle * | content_to_print |
static GdkRectangle | cliprect |
static const struct plotter_table | nsgtk_print_plotters |
GTK print plotter table. More... | |
static const struct printer | gtk_printer |
GTK printing implementation.
All the functions and structures necessary for printing( signal handlers, plotters, printer) are here. Most of the plotters have been copied from the gtk_plotters.c file.
Definition in file print.c.
|
static |
|
static |
Definition at line 76 of file print.c.
References plot_font_style::foreground, gtk_print_current_cr, line(), NSERROR_OK, nsfont_style_to_description(), nsgtk_print_set_colour(), print_settings::scale, and settings.
Referenced by nsgtk_print_plot_text().
void gtk_print_signal_begin_print | ( | GtkPrintOperation * | operation, |
GtkPrintContext * | context, | ||
gpointer | user_data | ||
) |
Handle the begin_print signal from the GtkPrintOperation.
operation | the operation which emited the signal |
context | the print context used to set up the pages |
user_data | nothing in here |
Definition at line 695 of file print.c.
References content_to_print, print_settings::font_func, gtk_printer, MARGINBOTTOM, MARGINLEFT, MARGINRIGHT, print_settings::margins, MARGINTOP, nsgtk_layout_table, NSLOG, print_settings::page_height, print_settings::page_width, print_set_up(), print_settings::scale, and settings.
Referenced by print_button_clicked_cb().
void gtk_print_signal_draw_page | ( | GtkPrintOperation * | operation, |
GtkPrintContext * | context, | ||
gint | page_nr, | ||
gpointer | user_data | ||
) |
Handle the draw_page signal from the GtkPrintOperation.
This function changes only the cairo context to print on.
Definition at line 745 of file print.c.
References gtk_print_current_cr, gtk_printer, NSLOG, print_draw_next_page(), and settings.
Referenced by print_button_clicked_cb().
void gtk_print_signal_end_print | ( | GtkPrintOperation * | operation, |
GtkPrintContext * | context, | ||
gpointer | user_data | ||
) |
Handle the end_print signal from the GtkPrintOperation.
This functions calls only the print_cleanup function from the print interface
Definition at line 757 of file print.c.
References content_to_print, gtk_printer, NSLOG, and print_cleanup().
Referenced by print_button_clicked_cb().
|
static |
Plots an arc.
plot an arc segment around (x,y), anticlockwise from angle1 to angle2. Angles are measured anticlockwise from horizontal, in degrees.
ctx | The current redraw context. |
style | Style controlling the arc plot. |
x | The x coordinate of the arc. |
y | The y coordinate of the arc. |
radius | The radius of the arc. |
angle1 | The start angle of the arc. |
angle2 | The finish angle of the arc. |
Definition at line 201 of file print.c.
References plot_style_s::fill_colour, gtk_print_current_cr, M_PI, NSERROR_OK, nsgtk_print_set_colour(), and nsgtk_print_set_solid().
|
static |
Plot a bitmap.
Tiled plot of a bitmap image. (x,y) gives the top left coordinate of an explicitly placed tile. From this tile the image can repeat in all four directions – up, down, left and right – to the extents given by the current clip rectangle.
The bitmap_flags say whether to tile in the x and y directions. If not tiling in x or y directions, the single image is plotted. The width and height give the dimensions the image is to be scaled to.
ctx | The current redraw context. |
bitmap | The bitmap to plot |
x | The x coordinate to plot the bitmap |
y | The y coordiante to plot the bitmap |
width | The width of area to plot the bitmap into |
height | The height of area to plot the bitmap into |
bg | the background colour to alpha blend into |
flags | the flags controlling the type of plot operation |
Definition at line 587 of file print.c.
References BITMAPF_REPEAT_X, BITMAPF_REPEAT_Y, cliprect, height, nsgtk_bitmap_get_height(), nsgtk_bitmap_get_width(), nsgtk_print_plot_pixbuf(), and width.
|
static |
Sets a clip rectangle for subsequent plot operations.
ctx | The current redraw context. |
clip | The rectangle to limit all subsequent plot operations within. |
Definition at line 157 of file print.c.
References clip(), cliprect, gtk_print_current_cr, max, min, NSERROR_OK, NSLOG, print_settings::page_height, print_settings::page_width, and settings.
|
static |
Plots a circle.
Plot a circle centered on (x,y), which is optionally filled.
ctx | The current redraw context. |
style | Style controlling the circle plot. |
x | x coordinate of circle centre. |
y | y coordinate of circle centre. |
radius | circle radius. |
< Solid colour
< Doted plot
< dashed plot
Definition at line 231 of file print.c.
References plot_style_s::fill_colour, plot_style_s::fill_type, gtk_print_current_cr, M_PI, NSERROR_OK, nsgtk_print_set_colour(), nsgtk_print_set_dashed(), nsgtk_print_set_dotted(), nsgtk_print_set_solid(), nsgtk_set_line_width(), PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_NONE, PLOT_OP_TYPE_SOLID, plot_style_s::stroke_colour, plot_style_s::stroke_type, and plot_style_s::stroke_width.
|
static |
Plots a line.
plot a line from (x0,y0) to (x1,y1). Coordinates are at centre of line width/thickness.
ctx | The current redraw context. |
style | Style controlling the line plot. |
line | A rectangle defining the line to be drawn |
< Solid colour
< Doted plot
< dashed plot
Definition at line 284 of file print.c.
References gtk_print_current_cr, line(), NSERROR_OK, nsgtk_print_set_colour(), nsgtk_print_set_dashed(), nsgtk_print_set_dotted(), nsgtk_print_set_solid(), nsgtk_set_line_width(), PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_SOLID, plot_style_s::stroke_colour, plot_style_s::stroke_type, and plot_style_s::stroke_width.
|
static |
Plots a path.
Path plot consisting of cubic Bezier curves. Line and fill colour is controlled by the plot style.
ctx | The current redraw context. |
pstyle | Style controlling the path plot. |
p | elements of path |
n | nunber of elements on path |
transform | A transform to apply to the path. |
Definition at line 434 of file print.c.
References NSERROR_OK.
|
static |
Definition at line 448 of file print.c.
References cliprect, gtk_print_current_cr, height, bitmap::scsurface, bitmap::surface, and width.
Referenced by nsgtk_print_plot_bitmap().
|
static |
Definition at line 390 of file print.c.
References plot_style_s::fill_colour, gtk_print_current_cr, NSERROR_OK, nsgtk_print_set_colour(), nsgtk_print_set_solid(), and NSLOG.
|
static |
Plots a rectangle.
The rectangle can be filled an outline or both controlled by the plot style The line can be solid, dotted or dashed. Top left corner at (x0,y0) and rectangle has given width and height.
ctx | The current redraw context. |
style | Style controlling the rectangle plot. |
rect | A rectangle defining the line to be drawn |
< Solid colour
< Doted plot
< dashed plot
Definition at line 329 of file print.c.
References plot_style_s::fill_colour, plot_style_s::fill_type, gtk_print_current_cr, max, min, NSERROR_OK, nsgtk_print_set_colour(), nsgtk_print_set_dashed(), nsgtk_print_set_dotted(), nsgtk_print_set_solid(), nsgtk_set_line_width(), NSLOG, print_settings::page_height, print_settings::page_width, PLOT_OP_TYPE_DASH, PLOT_OP_TYPE_DOT, PLOT_OP_TYPE_NONE, PLOT_OP_TYPE_SOLID, settings, plot_style_s::stroke_colour, plot_style_s::stroke_type, plot_style_s::stroke_width, rect::x0, rect::x1, rect::y0, and rect::y1.
|
static |
Definition at line 642 of file print.c.
References gtk_print_font_paint(), and text().
|
inlinestatic |
Definition at line 54 of file print.c.
References gtk_print_current_cr.
Referenced by gtk_print_font_paint(), nsgtk_print_plot_arc(), nsgtk_print_plot_disc(), nsgtk_print_plot_line(), nsgtk_print_plot_polygon(), and nsgtk_print_plot_rectangle().
|
inlinestatic |
Set cairo context to dashed plot operation.
Definition at line 130 of file print.c.
References gtk_print_current_cr.
Referenced by nsgtk_print_plot_disc(), nsgtk_print_plot_line(), and nsgtk_print_plot_rectangle().
|
inlinestatic |
Set cairo context to dotted plot operation.
Definition at line 123 of file print.c.
References gtk_print_current_cr.
Referenced by nsgtk_print_plot_disc(), nsgtk_print_plot_line(), and nsgtk_print_plot_rectangle().
|
inlinestatic |
Set cairo context to solid plot operation.
Definition at line 116 of file print.c.
References gtk_print_current_cr.
Referenced by nsgtk_print_plot_arc(), nsgtk_print_plot_disc(), nsgtk_print_plot_line(), nsgtk_print_plot_polygon(), and nsgtk_print_plot_rectangle().
|
inlinestatic |
Set cairo context line width.
Definition at line 137 of file print.c.
References gtk_print_current_cr, plot_style_fixed_to_double, and width.
Referenced by nsgtk_print_plot_disc(), nsgtk_print_plot_line(), and nsgtk_print_plot_rectangle().
|
static |
Definition at line 52 of file print.c.
Referenced by nsgtk_print_plot_bitmap(), nsgtk_print_plot_clip(), and nsgtk_print_plot_pixbuf().
struct hlcache_handle* content_to_print |
Definition at line 51 of file print.c.
Referenced by gtk_print_signal_begin_print(), gtk_print_signal_end_print(), and print_button_clicked_cb().
cairo_t* gtk_print_current_cr |
Definition at line 49 of file print.c.
Referenced by gtk_print_font_paint(), gtk_print_signal_draw_page(), nsgtk_print_plot_arc(), nsgtk_print_plot_clip(), nsgtk_print_plot_disc(), nsgtk_print_plot_line(), nsgtk_print_plot_pixbuf(), nsgtk_print_plot_polygon(), nsgtk_print_plot_rectangle(), nsgtk_print_set_colour(), nsgtk_print_set_dashed(), nsgtk_print_set_dotted(), nsgtk_print_set_solid(), and nsgtk_set_line_width().
|
static |
Definition at line 681 of file print.c.
Referenced by gtk_print_signal_begin_print(), gtk_print_signal_draw_page(), and gtk_print_signal_end_print().
|
static |
GTK print plotter table.
|
static |
Definition at line 50 of file print.c.
Referenced by gtk_print_font_paint(), gtk_print_signal_begin_print(), gtk_print_signal_draw_page(), nsgtk_icon_size_lookup_for_settings(), nsgtk_print_plot_clip(), nsgtk_print_plot_rectangle(), pdf_button_clicked_cb(), print_apply_settings(), print_basic_run(), print_cleanup(), print_draw_next_page(), print_make_settings(), print_set_up(), and set_defaults().