mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 07:04:29 +00:00
printing: Translate context to correct position
Use correct margins of given page setup when translating context to imageable area. https://bugzilla.gnome.org/show_bug.cgi?id=671895
This commit is contained in:
parent
9ac9769f36
commit
779faafa22
@ -317,17 +317,35 @@ _gtk_print_context_reverse_according_to_orientation (GtkPrintContext *context)
|
|||||||
void
|
void
|
||||||
_gtk_print_context_translate_into_margin (GtkPrintContext *context)
|
_gtk_print_context_translate_into_margin (GtkPrintContext *context)
|
||||||
{
|
{
|
||||||
gdouble left, top;
|
gdouble dx, dy;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_PRINT_CONTEXT (context));
|
g_return_if_fail (GTK_IS_PRINT_CONTEXT (context));
|
||||||
|
|
||||||
/* We do it this way to also handle GTK_UNIT_NONE */
|
/* We do it this way to also handle GTK_UNIT_NONE */
|
||||||
left = gtk_page_setup_get_left_margin (context->page_setup, GTK_UNIT_INCH);
|
switch (gtk_page_setup_get_orientation (context->page_setup))
|
||||||
top = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
|
{
|
||||||
|
default:
|
||||||
|
case GTK_PAGE_ORIENTATION_PORTRAIT:
|
||||||
|
dx = gtk_page_setup_get_left_margin (context->page_setup, GTK_UNIT_INCH);
|
||||||
|
dy = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
|
||||||
|
break;
|
||||||
|
case GTK_PAGE_ORIENTATION_LANDSCAPE:
|
||||||
|
dx = gtk_page_setup_get_bottom_margin (context->page_setup, GTK_UNIT_INCH);
|
||||||
|
dy = gtk_page_setup_get_left_margin (context->page_setup, GTK_UNIT_INCH);
|
||||||
|
break;
|
||||||
|
case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
|
||||||
|
dx = gtk_page_setup_get_right_margin (context->page_setup, GTK_UNIT_INCH);
|
||||||
|
dy = gtk_page_setup_get_bottom_margin (context->page_setup, GTK_UNIT_INCH);
|
||||||
|
break;
|
||||||
|
case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
|
||||||
|
dx = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
|
||||||
|
dy = gtk_page_setup_get_right_margin (context->page_setup, GTK_UNIT_INCH);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
cairo_translate (context->cr,
|
cairo_translate (context->cr,
|
||||||
left * context->surface_dpi_x / context->pixels_per_unit_x,
|
dx * context->surface_dpi_x / context->pixels_per_unit_x,
|
||||||
top * context->surface_dpi_y / context->pixels_per_unit_y);
|
dy * context->surface_dpi_y / context->pixels_per_unit_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user