X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkprintcontext.c;h=4d55b75e7858bbedfc07c522e5ea8ab054230e6c;hb=aaedf5a35219b034a244730564b8fdf2b7d32540;hp=223a8f4d46debccb12f8f375e1fb167e1d4d286d;hpb=25c2569a5d8af574ccf3604f253d3aa2d21ab9fe;p=~andy%2Fgtk diff --git a/gtk/gtkprintcontext.c b/gtk/gtkprintcontext.c index 223a8f4d4..4d55b75e7 100644 --- a/gtk/gtkprintcontext.c +++ b/gtk/gtkprintcontext.c @@ -13,9 +13,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library. If not, see . */ #include "config.h" @@ -216,7 +214,7 @@ gtk_print_context_set_cairo_context (GtkPrintContext *context, switch (context->op->priv->unit) { default: - case GTK_UNIT_PIXEL: + case GTK_UNIT_NONE: /* Do nothing, this is the cairo default unit */ context->pixels_per_unit_x = 1.0; context->pixels_per_unit_y = 1.0; @@ -287,6 +285,36 @@ _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context) } } +void +_gtk_print_context_reverse_according_to_orientation (GtkPrintContext *context) +{ + cairo_t *cr = context->cr; + cairo_matrix_t matrix; + gdouble width, height; + + width = gtk_page_setup_get_paper_width (context->page_setup, GTK_UNIT_INCH); + width = width * context->surface_dpi_x / context->pixels_per_unit_x; + height = gtk_page_setup_get_paper_height (context->page_setup, GTK_UNIT_INCH); + height = height * context->surface_dpi_y / context->pixels_per_unit_y; + + switch (gtk_page_setup_get_orientation (context->page_setup)) + { + default: + case GTK_PAGE_ORIENTATION_PORTRAIT: + case GTK_PAGE_ORIENTATION_LANDSCAPE: + break; + case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT: + case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE: + cairo_translate (cr, width, height); + cairo_matrix_init (&matrix, + -1, 0, + 0, -1, + 0, 0); + cairo_transform (cr, &matrix); + break; + } +} + void _gtk_print_context_translate_into_margin (GtkPrintContext *context) { @@ -294,7 +322,7 @@ _gtk_print_context_translate_into_margin (GtkPrintContext *context) g_return_if_fail (GTK_IS_PRINT_CONTEXT (context)); - /* We do it this way to also handle GTK_UNIT_PIXELS */ + /* We do it this way to also handle GTK_UNIT_NONE */ left = gtk_page_setup_get_left_margin (context->page_setup, GTK_UNIT_INCH); top = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH); @@ -547,7 +575,7 @@ gtk_print_context_create_pango_context (GtkPrintContext *context) g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), NULL); - pango_context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (_gtk_print_context_get_fontmap (context))); + pango_context = pango_font_map_create_context (_gtk_print_context_get_fontmap (context)); options = cairo_font_options_create (); cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);