-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
/*
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * cairo_markup_path.c: Cairo markup path module
+ * cairo-markup-path.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 "cairo-markup-path.h"
#include <math.h>
-#include <glib.h>
+
+#include "cairo-ellipse-path.h"
#include "debug.h"
+
/*===========================================*/
/* Private types */
/*===========================================*/
+
/*===========================================*/
/* Private globals */
/*===========================================*/
+
/*===========================================*/
/* Local function prototypes */
/*===========================================*/
const lglTemplateMarkup *markup,
glLabel *label);
+static void gl_cairo_markup_margin_ellipse_path (cairo_t *cr,
+ const lglTemplateMarkup *markup,
+ glLabel *label);
+
static void gl_cairo_markup_margin_round_path (cairo_t *cr,
const lglTemplateMarkup *markup,
glLabel *label);
static void gl_cairo_markup_rect_path (cairo_t *cr,
const lglTemplateMarkup *markup);
-\f
+static void gl_cairo_markup_ellipse_path (cairo_t *cr,
+ const lglTemplateMarkup *markup);
+
+
/*--------------------------------------------------------------------------*/
/* Create markup path */
/*--------------------------------------------------------------------------*/
case LGL_TEMPLATE_MARKUP_RECT:
gl_cairo_markup_rect_path (cr, markup);
break;
+ case LGL_TEMPLATE_MARKUP_ELLIPSE:
+ gl_cairo_markup_ellipse_path (cr, markup);
+ break;
default:
g_message ("Unknown template markup type");
break;
gl_debug (DEBUG_PATH, "END");
}
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. Draw margin markup. */
/*---------------------------------------------------------------------------*/
const lglTemplateMarkup *markup,
glLabel *label)
{
+ const lglTemplate *template;
const lglTemplateFrame *frame;
gl_debug (DEBUG_PATH, "START");
- frame = (lglTemplateFrame *)label->template->frames->data;
+ template = gl_label_get_template (label);
+ frame = (lglTemplateFrame *)template->frames->data;
switch (frame->shape) {
gl_cairo_markup_margin_rect_path (cr, markup, label);
break;
+ case LGL_TEMPLATE_FRAME_SHAPE_ELLIPSE:
+ gl_cairo_markup_margin_ellipse_path (cr, markup, label);
+ break;
+
case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
gl_cairo_markup_margin_round_path (cr, markup, label);
break;
gl_debug (DEBUG_PATH, "END");
}
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. Draw simple recangular margin. */
/*---------------------------------------------------------------------------*/
const lglTemplateMarkup *markup,
glLabel *label)
{
+ const lglTemplate *template;
const lglTemplateFrame *frame;
gdouble w, h, r, m;
gl_debug (DEBUG_PATH, "START");
- frame = (lglTemplateFrame *)label->template->frames->data;
+ template = gl_label_get_template (label);
+ frame = (lglTemplateFrame *)template->frames->data;
m = markup->margin.size;
gl_debug (DEBUG_PATH, "END");
}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Draw elliptical margin. */
+/*---------------------------------------------------------------------------*/
+static void
+gl_cairo_markup_margin_ellipse_path (cairo_t *cr,
+ const lglTemplateMarkup *markup,
+ glLabel *label)
+{
+ const lglTemplate *template;
+ const lglTemplateFrame *frame;
+ gdouble w, h, m;
+
+ gl_debug (DEBUG_PATH, "START");
+
+ template = gl_label_get_template (label);
+ frame = (lglTemplateFrame *)template->frames->data;
+
+ m = markup->margin.size;
+
+ lgl_template_frame_get_size (frame, &w, &h);
+ w = w - 2*m;
+ h = h - 2*m;
+
+ cairo_save (cr);
+ cairo_translate (cr, m, m);
+ gl_cairo_ellipse_path (cr, w/2.0, h/2.0);
+ cairo_restore (cr);
+
+ gl_debug (DEBUG_PATH, "END");
+}
+
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. Draw round margin. */
/*---------------------------------------------------------------------------*/
const lglTemplateMarkup *markup,
glLabel *label)
{
+ const lglTemplate *template;
const lglTemplateFrame *frame;
gdouble r, m;
gl_debug (DEBUG_PATH, "START");
- frame = (lglTemplateFrame *)label->template->frames->data;
+ template = gl_label_get_template (label);
+ frame = (lglTemplateFrame *)template->frames->data;
r = frame->round.r;
m = markup->margin.size;
gl_debug (DEBUG_PATH, "END");
}
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. Draw CD margins. */
/*---------------------------------------------------------------------------*/
const lglTemplateMarkup *markup,
glLabel *label)
{
+ const lglTemplate *template;
const lglTemplateFrame *frame;
gdouble m, r1, r2;
gdouble theta1, theta2;
gl_debug (DEBUG_PATH, "START");
- frame = (lglTemplateFrame *)label->template->frames->data;
+ template = gl_label_get_template (label);
+ frame = (lglTemplateFrame *)template->frames->data;
lgl_template_frame_get_size (frame, &w, &h);
xc = w/2.0;
gl_debug (DEBUG_PATH, "END");
}
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. Draw line markup. */
/*---------------------------------------------------------------------------*/
gl_debug (DEBUG_PATH, "END");
}
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. Draw circle markup. */
/*---------------------------------------------------------------------------*/
gl_debug (DEBUG_PATH, "END");
}
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. Draw rect markup. */
/*---------------------------------------------------------------------------*/
gl_debug (DEBUG_PATH, "END");
}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Draw ellipse markup. */
+/*---------------------------------------------------------------------------*/
+static void
+gl_cairo_markup_ellipse_path (cairo_t *cr,
+ const lglTemplateMarkup *markup)
+{
+ gdouble x1 = markup->ellipse.x1;
+ gdouble y1 = markup->ellipse.y1;
+ gdouble w = markup->ellipse.w;
+ gdouble h = markup->ellipse.h;
+
+ gl_debug (DEBUG_PATH, "START");
+
+ cairo_save (cr);
+ cairo_translate (cr, x1, y1);
+ gl_cairo_ellipse_path (cr, w/2.0, h/2.0);
+ cairo_restore (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
+ */