]> git.sur5r.net Git - glabels/blobdiff - glabels2/src/print.c
2009-09-22 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / src / print.c
index ec0420e41f5d474ec7b912439d19bd91f5452e52..2006e0eee64954f41109ad3c9a4355b6b18a69d1 100644 (file)
@@ -1,26 +1,23 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
 /*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  print.c:  Print module
+ *  print.c
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
  *
- *  Copyright (C) 2001-2007  Jim Evins <evins@snaught.com>.
+ *  This file is part of gLabels.
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  gLabels is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
+ *  gLabels is distributed in the hope that it will be useful,
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *  along with gLabels.  If not, see <http://www.gnu.org/licenses/>.
  */
+
 #include <config.h>
 
 #include "print.h"
 #include <time.h>
 #include <ctype.h>
 
+#include <libglabels/libglabels.h>
 #include "label.h"
-#include <libglabels/template.h>
 #include "cairo-label-path.h"
 
 #include "debug.h"
 
+
 /*===========================================*/
 /* Private macros and constants.             */
 /*===========================================*/
@@ -47,6 +45,7 @@
 #define TICK_OFFSET  2.25
 #define TICK_LENGTH 18.0
 
+
 /*=========================================================================*/
 /* Private types.                                                          */
 /*=========================================================================*/
@@ -91,7 +90,6 @@ static void       clip_to_outline             (PrintInfo        *pi,
                                               glLabel          *label);
 
 
-\f
 /*****************************************************************************/
 /* Print simple sheet (no merge data) command.                               */
 /*****************************************************************************/
@@ -137,6 +135,7 @@ gl_print_simple_sheet (glLabel          *label,
        gl_debug (DEBUG_PRINT, "END");
 }
 
+
 /*****************************************************************************/
 /* Print collated merge sheet command                                        */
 /*****************************************************************************/
@@ -228,6 +227,7 @@ gl_print_collated_merge_sheet   (glLabel          *label,
        gl_debug (DEBUG_PRINT, "END");
 }
 
+
 /*****************************************************************************/
 /* Print uncollated merge sheet command                                      */
 /*****************************************************************************/
@@ -321,6 +321,7 @@ gl_print_uncollated_merge_sheet (glLabel          *label,
        gl_debug (DEBUG_PRINT, "END");
 }
 
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  new print info structure                                        */
 /*---------------------------------------------------------------------------*/
@@ -335,14 +336,14 @@ print_info_new (cairo_t          *cr,
        g_return_val_if_fail (label && GL_IS_LABEL (label), NULL);
 
        g_return_val_if_fail (label->template, NULL);
-       g_return_val_if_fail (label->template->page_size, NULL);
+       g_return_val_if_fail (label->template->paper_id, NULL);
        g_return_val_if_fail (label->template->page_width > 0, NULL);
        g_return_val_if_fail (label->template->page_height > 0, NULL);
 
        pi->cr = cr;
 
        gl_debug (DEBUG_PRINT,
-                 "setting page size = \"%s\"", label->template->page_size);
+                 "setting page size = \"%s\"", label->template->paper_id);
 
        pi->page_width  = label->template->page_width;
        pi->page_height = label->template->page_height;
@@ -355,6 +356,7 @@ print_info_new (cairo_t          *cr,
        return pi;
 }
 
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  free print info structure                                       */
 /*---------------------------------------------------------------------------*/
@@ -370,6 +372,7 @@ print_info_free (PrintInfo **pi)
        gl_debug (DEBUG_PRINT, "END");
 }
 
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Print crop tick marks.                                          */
 /*---------------------------------------------------------------------------*/
@@ -478,6 +481,7 @@ print_crop_marks (PrintInfo *pi)
        gl_debug (DEBUG_PRINT, "END");
 }
 
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Print i'th label.                                               */
 /*---------------------------------------------------------------------------*/
@@ -504,6 +508,12 @@ print_label (PrintInfo     *pi,
        /* Transform coordinate system to be relative to upper corner */
        /* of the current label */
        cairo_translate (pi->cr, x, y);
+
+       clip_to_outline (pi, label);
+
+       cairo_save (pi->cr);
+
+        /* Special transformations. */
        if (label->rotate_flag) {
                gl_debug (DEBUG_PRINT, "Rotate flag set");
                cairo_rotate (pi->cr, -M_PI/2.0);
@@ -514,17 +524,20 @@ print_label (PrintInfo     *pi,
                cairo_scale (pi->cr, -1.0, 1.0);
        }
 
-       clip_to_outline (pi, label);
         gl_label_draw (label, pi->cr, FALSE, record);
+
+       cairo_restore (pi->cr); /* From special transformations. */
+
        if (outline_flag) {
                draw_outline (pi, label);
        }
 
-       cairo_restore (pi->cr);
+       cairo_restore (pi->cr); /* From translation. */
 
        gl_debug (DEBUG_PRINT, "END");
 }
 
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Draw outline.                                                   */
 /*---------------------------------------------------------------------------*/
@@ -548,6 +561,7 @@ draw_outline (PrintInfo *pi,
        gl_debug (DEBUG_PRINT, "END");
 }
 
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Clip to outline.                                                */
 /*---------------------------------------------------------------------------*/
@@ -565,3 +579,15 @@ clip_to_outline (PrintInfo *pi,
        gl_debug (DEBUG_PRINT, "END");
 }
 
+
+
+
+
+/*
+ * Local Variables:       -- emacs
+ * mode: C                -- emacs
+ * c-basic-offset: 8      -- emacs
+ * tab-width: 8           -- emacs
+ * indent-tabs-mode: nil  -- emacs
+ * End:                   -- emacs
+ */