59 g = (c & 0xff00) >> 8;
60 b = (c & 0xff0000) >> 16;
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);
71 g / 255.0, b / 255.0, 1.0);
77 const char *
string,
size_t length,
80 PangoFontDescription *desc;
83 PangoLayoutLine *
line;
89 size = (gint) ((
double) pango_font_description_get_size(desc) *
92 if (pango_font_description_get_size_is_absolute(desc))
93 pango_font_description_set_absolute_size(desc, size);
95 pango_font_description_set_size(desc, size);
99 pango_layout_set_font_description(layout, desc);
100 pango_layout_set_text(layout,
string, length);
102 line = pango_layout_get_line(layout, 0);
108 g_object_unref(layout);
109 pango_font_description_free(desc);
125 double cdashes[] = { 1.0, 2.0 };
132 double cdashes[] = { 8.0, 2.0 };
160 "Clipping. x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i",
clip->x0,
172 clip_x1 - clip_x0, clip_y1 - clip_y0);
178 cliprect.height = clip_y1 - clip_y0;
203 int x,
int y,
int radius,
int angle1,
int angle2)
210 (angle1 + 90) * (
M_PI / 180),
211 (angle2 + 90) * (
M_PI / 180));
233 int x,
int y,
int radius)
333 NSLOG(netsurf, INFO,
"x0: %i ;\t y0: %i ;\t x1: %i ;\t y1: %i",
397 NSLOG(netsurf, INFO,
"Plotting polygon.");
405 NSLOG(netsurf, INFO,
"Starting line at: %i\t%i", p[0], p[1]);
407 for (i = 1; i != n; i++) {
409 NSLOG(netsurf, INFO,
"Drawing line to: %i\t%i", p[i * 2],
438 const float transform[6])
452 int dsrcx, dsrcy, dwidth, dheight;
453 int bmwidth, bmheight;
501 if (dwidth == 0 || dheight == 0)
505 bmwidth = cairo_image_surface_get_width(bmsurface);
506 bmheight = cairo_image_surface_get_height(bmsurface);
530 cairo_scale(cr, (
double)
width / bmwidth, (
double)
height / bmheight);
531 cairo_set_source_surface(cr, bmsurface, 0, 0);
537 cairo_pattern_set_extend(cairo_get_source(cr),
538 CAIRO_EXTEND_REFLECT);
543 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
594 int doneheight = 0, donewidth = 0;
598 if (!(repeat_x || repeat_y)) {
664 .option_knockout =
false,
696 GtkPrintContext *context, gpointer user_data)
699 double height_on_page, height_to_print;
701 NSLOG(netsurf, INFO,
"Begin print");
715 settings, &height_to_print) ==
false) {
716 gtk_print_operation_cancel(operation);
721 "page_width: %f ;page_height: %f; content height: %lf",
727 height_on_page = height_on_page -
732 page_number = height_to_print / height_on_page;
734 if (height_to_print - page_number * height_on_page > 0)
737 gtk_print_operation_set_n_pages(operation, page_number);
746 GtkPrintContext *context, gint page_nr, gpointer user_data)
748 NSLOG(netsurf, INFO,
"Draw Page");
758 GtkPrintContext *context, gpointer user_data)
760 NSLOG(netsurf, INFO,
"End print");
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.
bool print_cleanup(hlcache_handle *content, const struct printer *printer, struct print_settings *settings)
Memory allocated during printing is being freed here.
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.
Conception: Generalized output-in-pages.
nserror
Enumeration of error codes.
int nsgtk_bitmap_get_height(void *vbitmap)
int nsgtk_bitmap_get_width(void *vbitmap)
void gtk_print_signal_end_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
Handle the end_print signal from the GtkPrintOperation.
static GdkRectangle cliprect
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.
static void nsgtk_print_set_dotted(void)
Set cairo context to dotted plot operation.
static struct print_settings * settings
static void nsgtk_print_set_dashed(void)
Set cairo context to dashed plot operation.
cairo_t * gtk_print_current_cr
static void nsgtk_print_set_solid(void)
Set cairo context to solid plot operation.
static const struct plotter_table nsgtk_print_plotters
GTK print plotter table.
struct hlcache_handle * content_to_print
static nserror nsgtk_print_plot_clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
void gtk_print_signal_draw_page(GtkPrintOperation *operation, GtkPrintContext *context, gint page_nr, gpointer user_data)
Handle the draw_page signal from the GtkPrintOperation.
static nserror gtk_print_font_paint(int x, int y, const char *string, size_t length, const plot_font_style_t *fstyle)
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.
static nserror nsgtk_print_plot_rectangle(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *rect)
Plots a rectangle.
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 void gtk_print_end(void)
static nserror nsgtk_print_plot_polygon(const struct redraw_context *ctx, const plot_style_t *style, const int *p, unsigned int n)
static void nsgtk_print_set_colour(colour c)
static bool gtk_print_next_page(void)
void gtk_print_signal_begin_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
Handle the begin_print signal from the GtkPrintOperation.
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.
static const struct printer gtk_printer
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.
static bool nsgtk_print_plot_pixbuf(int x, int y, int width, int height, struct bitmap *bitmap, colour bg)
static nserror nsgtk_print_plot_line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
static void nsgtk_set_line_width(plot_style_fixed width)
Set cairo context line width.
GTK printing (interface).
Target independent plotting interface.
unsigned long bitmap_flags_t
PangoFontDescription * nsfont_style_to_description(const plot_font_style_t *fstyle)
struct gui_layout_table * nsgtk_layout_table
Interface to GTK layout handling using pango.
#define NSLOG(catname, level, logmsg, args...)
#define plot_style_fixed_to_double(v)
@ PLOT_OP_TYPE_NONE
No operation.
@ PLOT_OP_TYPE_DASH
Dashed plot.
@ PLOT_OP_TYPE_DOT
Dotted plot.
@ PLOT_OP_TYPE_SOLID
Solid colour.
RISC OS wimp toolkit bitmap.
cairo_surface_t * surface
cairo_surface_t * scsurface
colour foreground
Colour of text.
Plot style for stroke/fill plotters.
colour fill_colour
Colour of fill.
plot_style_fixed stroke_width
Width of stroke, in pixels.
plot_operation_type_t fill_type
Fill plot type.
colour stroke_colour
Colour of stroke.
plot_operation_type_t stroke_type
Stroke plot type.
Plotter operations table.
nserror(* clip)(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.
Settings for a print - filled in by print_make_settings or 'manually' by the caller.
const struct gui_layout_table * font_func
uint32_t colour
Colour type: XBGR.
Option reading and saving interface.
Interface to a number of general purpose functionality.
static nserror line(const struct redraw_context *ctx, const plot_style_t *style, const struct rect *line)
Plots a line.
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.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.