]> git.sur5r.net Git - glabels/blobdiff - glabels2/src/mini-preview-pixbuf.c
2009-09-17 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / src / mini-preview-pixbuf.c
index 1fd467d11cb8c9572f2013e047e20ff4913a3276..0651263f287384f119a60e8ebb274394aa5e640c 100644 (file)
@@ -1,37 +1,46 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
 /*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  mini-preview-pixbuf.c:  mini preview pixbuf module
+ *  mini-preview-pixbuf.c
+ *  Copyright (C) 2006-2009  Jim Evins <evins@snaught.com>.
  *
- *  Copyright (C) 2006  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 "mini-preview-pixbuf.h"
-#include "cairo-label-path.h"
 
 #include <cairo.h>
 #include <math.h>
 
+#include "cairo-label-path.h"
+
 #include "debug.h"
 
+/*===========================================*/
+/* Private macros and constants.             */
+/*===========================================*/
+
+#define PAPER_RGB_ARGS          0.95,  0.95,  0.95
+#define PAPER_OUTLINE_RGB_ARGS  0.0,   0.0,   0.0
+#define LABEL_RGB_ARGS          1.0,   1.0,   1.0
+#define LABEL_OUTLINE_RGB_ARGS  0.25,  0.25,  0.25
+
+#define PAPER_OUTLINE_WIDTH_PIXELS  1.0
+#define LABEL_OUTLINE_WIDTH_PIXELS  1.0
+
 /*===========================================*/
 /* Private types                             */
 /*===========================================*/
 /*===========================================*/
 
 static void draw_paper                (cairo_t           *cr,
-                                      glTemplate        *template,
+                                      lglTemplate       *template,
                                       gdouble            scale);
 
 static void draw_label_outlines       (cairo_t           *cr,
-                                      glTemplate        *template,
+                                      lglTemplate       *template,
                                       gdouble            scale);
 
 static void draw_label_outline        (cairo_t           *cr,
-                                      glTemplate        *template,
+                                      lglTemplate       *template,
                                       gdouble            x0,
                                       gdouble            y0);
 
@@ -66,9 +75,9 @@ static void draw_label_outline        (cairo_t           *cr,
 /* Create new pixbuf with mini preview of template                          */
 /****************************************************************************/
 GdkPixbuf *
-gl_mini_preview_pixbuf_new (glTemplate *template,
-                           gint        width,
-                           gint        height)
+gl_mini_preview_pixbuf_new (lglTemplate *template,
+                           gint         width,
+                           gint         height)
 {
        cairo_surface_t   *surface;
        cairo_t           *cr;
@@ -129,17 +138,17 @@ gl_mini_preview_pixbuf_new (glTemplate *template,
 /*--------------------------------------------------------------------------*/
 static void
 draw_paper (cairo_t           *cr,
-           glTemplate        *template,
+           lglTemplate       *template,
            gdouble            scale)
 {
        gl_debug (DEBUG_MINI_PREVIEW, "START");
 
        cairo_save (cr);
        cairo_rectangle (cr, 0.0, 0.0, template->page_width, template->page_height);
-       cairo_set_source_rgb (cr, 0.95, 0.95, 0.95);
+       cairo_set_source_rgb (cr, PAPER_RGB_ARGS);
        cairo_fill_preserve (cr);
-       cairo_set_line_width (cr, 1/scale);
-       cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+       cairo_set_line_width (cr, PAPER_OUTLINE_WIDTH_PIXELS/scale);
+       cairo_set_source_rgb (cr, PAPER_OUTLINE_RGB_ARGS);
        cairo_stroke (cr);
        cairo_restore (cr);
 
@@ -151,23 +160,23 @@ draw_paper (cairo_t           *cr,
 /*--------------------------------------------------------------------------*/
 static void
 draw_label_outlines (cairo_t           *cr,
-                    glTemplate        *template,
+                    lglTemplate       *template,
                     gdouble            scale)
 {
-       const glTemplateLabelType *label_type;
-       gint                       i, n_labels;
-       glTemplateOrigin          *origins;
+       const lglTemplateFrame *frame;
+       gint                    i, n_labels;
+       lglTemplateOrigin      *origins;
 
        gl_debug (DEBUG_MINI_PREVIEW, "START");
 
        cairo_save (cr);
 
-       cairo_set_line_width (cr, 1.0/scale);
+       cairo_set_line_width (cr, LABEL_OUTLINE_WIDTH_PIXELS/scale);
 
-       label_type = gl_template_get_first_label_type (template);
+        frame = (lglTemplateFrame *)template->frames->data;
 
-       n_labels = gl_template_get_n_labels (label_type);
-       origins  = gl_template_get_origins (label_type);
+       n_labels = lgl_template_frame_get_n_labels (frame);
+       origins  = lgl_template_frame_get_origins (frame);
 
        for ( i=0; i < n_labels; i++ ) {
 
@@ -187,7 +196,7 @@ draw_label_outlines (cairo_t           *cr,
 /*--------------------------------------------------------------------------*/
 static void
 draw_label_outline (cairo_t           *cr,
-                   glTemplate        *template,
+                   lglTemplate       *template,
                    gdouble            x0,
                    gdouble            y0)
 {
@@ -199,11 +208,11 @@ draw_label_outline (cairo_t           *cr,
 
         gl_cairo_label_path (cr, template, FALSE, FALSE);
 
-       cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+       cairo_set_source_rgb (cr, LABEL_RGB_ARGS);
         cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
         cairo_fill_preserve (cr);
 
-       cairo_set_source_rgb (cr, 0.25, 0.25, 0.25);
+       cairo_set_source_rgb (cr, LABEL_OUTLINE_RGB_ARGS);
        cairo_stroke (cr);
 
        cairo_restore (cr);
@@ -211,3 +220,13 @@ draw_label_outline (cairo_t           *cr,
        gl_debug (DEBUG_MINI_PREVIEW, "END");
 }
 
+
+
+/*
+ * Local Variables:       -- emacs
+ * mode: C                -- emacs
+ * c-basic-offset: 8      -- emacs
+ * tab-width: 8           -- emacs
+ * indent-tabs-mode: nil  -- emacs
+ * End:                   -- emacs
+ */