X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcairo-label-path.c;h=3d0585b5176bd8663d8be85595e20956e0fe9e33;hb=881b28a2d413358207bf82fa57db7870b3a025b4;hp=7f8f61f934d2f0fe08bd971d3d252171b3b4b428;hpb=b13649a65b7dfa46ba1ed7fe9e8afa4aaef70f79;p=glabels diff --git a/src/cairo-label-path.c b/src/cairo-label-path.c index 7f8f61f9..3d0585b5 100644 --- a/src/cairo-label-path.c +++ b/src/cairo-label-path.c @@ -1,25 +1,21 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - /* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * cairo_label_path.c: Cairo label path module + * cairo-label-path.c + * Copyright (C) 2001-2009 Jim Evins . * - * Copyright (C) 2001-2007 Jim Evins . + * 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 . */ #include @@ -27,42 +23,50 @@ #include "cairo-label-path.h" #include -#include + +#include "cairo-ellipse-path.h" #include "debug.h" + /*===========================================*/ /* Private types */ /*===========================================*/ + /*===========================================*/ /* Private globals */ /*===========================================*/ + /*===========================================*/ /* Local function prototypes */ /*===========================================*/ static void gl_cairo_rect_label_path (cairo_t *cr, - lglTemplate *template, + const lglTemplate *template, + gboolean rotate_flag, + gboolean waste_flag); +static void gl_cairo_ellipse_label_path (cairo_t *cr, + const lglTemplate *template, gboolean rotate_flag, gboolean waste_flag); static void gl_cairo_round_label_path (cairo_t *cr, - lglTemplate *template, + const lglTemplate *template, gboolean rotate_flag, gboolean waste_flag); static void gl_cairo_cd_label_path (cairo_t *cr, - lglTemplate *template, + const lglTemplate *template, gboolean rotate_flag, gboolean waste_flag); - + /*--------------------------------------------------------------------------*/ /* Create label path */ /*--------------------------------------------------------------------------*/ void gl_cairo_label_path (cairo_t *cr, - lglTemplate *template, + const lglTemplate *template, gboolean rotate_flag, gboolean waste_flag) { @@ -78,6 +82,10 @@ gl_cairo_label_path (cairo_t *cr, gl_cairo_rect_label_path (cr, template, rotate_flag, waste_flag); break; + case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE: + gl_cairo_ellipse_label_path (cr, template, rotate_flag, waste_flag); + break; + case LGL_TEMPLATE_FRAME_SHAPE_ROUND: gl_cairo_round_label_path (cr, template, rotate_flag, waste_flag); break; @@ -94,12 +102,13 @@ gl_cairo_label_path (cairo_t *cr, gl_debug (DEBUG_PATH, "END"); } + /*--------------------------------------------------------------------------*/ /* Create rectangular label path */ /*--------------------------------------------------------------------------*/ static void gl_cairo_rect_label_path (cairo_t *cr, - lglTemplate *template, + const lglTemplate *template, gboolean rotate_flag, gboolean waste_flag) { @@ -137,7 +146,7 @@ gl_cairo_rect_label_path (cairo_t *cr, if ( r == 0.0 ) { - cairo_rectangle (cr, -x_waste, -y_waste, w+x_waste, h+y_waste); + cairo_rectangle (cr, -x_waste, -y_waste, w+2*x_waste, h+2*y_waste); } else { @@ -152,12 +161,54 @@ gl_cairo_rect_label_path (cairo_t *cr, gl_debug (DEBUG_PATH, "END"); } + +/*--------------------------------------------------------------------------*/ +/* Create elliptical label path */ +/*--------------------------------------------------------------------------*/ +static void +gl_cairo_ellipse_label_path (cairo_t *cr, + const lglTemplate *template, + gboolean rotate_flag, + gboolean waste_flag) +{ + const lglTemplateFrame *frame; + gdouble w, h; + gdouble waste; + + gl_debug (DEBUG_PATH, "START"); + + frame = (lglTemplateFrame *)template->frames->data; + + if (rotate_flag) + { + lgl_template_frame_get_size (frame, &h, &w); + } + else + { + lgl_template_frame_get_size (frame, &w, &h); + } + + waste = 0.0; + if (waste_flag) + { + waste = frame->ellipse.waste; + } + + cairo_save (cr); + cairo_translate (cr, -waste, -waste); + gl_cairo_ellipse_path (cr, (w+waste)/2.0, (h+waste)/2.0); + cairo_restore (cr); + + gl_debug (DEBUG_PATH, "END"); +} + + /*--------------------------------------------------------------------------*/ /* Create round label path */ /*--------------------------------------------------------------------------*/ static void gl_cairo_round_label_path (cairo_t *cr, - lglTemplate *template, + const lglTemplate *template, gboolean rotate_flag, gboolean waste_flag) { @@ -194,12 +245,13 @@ gl_cairo_round_label_path (cairo_t *cr, gl_debug (DEBUG_PATH, "END"); } + /*--------------------------------------------------------------------------*/ /* Create cd label path */ /*--------------------------------------------------------------------------*/ static void gl_cairo_cd_label_path (cairo_t *cr, - lglTemplate *template, + const lglTemplate *template, gboolean rotate_flag, gboolean waste_flag) { @@ -262,3 +314,13 @@ gl_cairo_cd_label_path (cairo_t *cr, gl_debug (DEBUG_PATH, "END"); } + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */