[cairo-commit] pycairo/cairo pycairo-context.c,1.37,1.38

Steve Chaplin commit at pdx.freedesktop.org
Tue Apr 19 18:23:26 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv6085/cairo

Modified Files:
	pycairo-context.c 
Log Message:
SC

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- pycairo-context.c	18 Apr 2005 09:52:42 -0000	1.37
+++ pycairo-context.c	20 Apr 2005 01:23:24 -0000	1.38
@@ -223,7 +223,7 @@
     return PyInt_FromLong(cairo_get_operator(c->ctx));
 }
 
-/* struct and wrappers for cairo_get_path() */ 
+/* cairo_get_path() struct and wrappers */ 
 typedef struct {
 	PyObject* move_to;
 	PyObject* line_to;
@@ -395,6 +395,15 @@
 }
 
 static PyObject *
+pycairo_identity_matrix(PyCairoContext *c)
+{
+    cairo_identity_matrix(c->ctx);
+    if (pycairo_check_status(cairo_status(c->ctx)))
+	return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
 pycairo_in_fill(PyCairoContext *c, PyObject *args)
 {
     double x, y;
@@ -427,6 +436,24 @@
 }
 
 static PyObject *
+pycairo_paint(PyCairoContext *c)
+{
+    cairo_paint(c->ctx);
+    if (pycairo_check_status(cairo_status(c->ctx)))
+	return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_reset_clip(PyCairoContext *c)
+{
+    cairo_reset_clip(c->ctx);
+    if (pycairo_check_status(cairo_status(c->ctx)))
+	return NULL;
+    Py_RETURN_NONE;
+}
+
+static PyObject *
 pycairo_restore(PyCairoContext *c)
 {
     cairo_restore(c->ctx);
@@ -445,119 +472,133 @@
 }
 
 static PyObject *
-pycairo_set_operator(PyCairoContext *c, PyObject *args)
+pycairo_set_dash(PyCairoContext *c, PyObject *args)
 {
-    cairo_operator_t op;
+    double *dashes, offset = 0;
+    int ndash, i;
+    PyObject *py_dashes;
 
-    if (!PyArg_ParseTuple(args, "i:Context.set_operator", &op))
+    if (!PyArg_ParseTuple(args, "O|d:Context.set_dash", &py_dashes, &offset))
+	return NULL;
+    if (!(py_dashes = PySequence_Fast(py_dashes, "first argument must be a sequence")))
 	return NULL;
 
-    cairo_set_operator(c->ctx, op);
+    ndash = PySequence_Fast_GET_SIZE(py_dashes);
+    dashes = malloc(ndash * sizeof(double));
+    for (i = 0; i < ndash; i++) {
+	PyObject *item = PySequence_Fast_GET_ITEM(py_dashes, i);
+
+	dashes[i] = PyFloat_AsDouble(item);
+	if (PyErr_Occurred()) {
+	    free(dashes);
+	    Py_DECREF(py_dashes);
+	    return NULL;
+	}
+    }
+    Py_DECREF(py_dashes);
+
+    cairo_set_dash(c->ctx, dashes, ndash, offset);
+    free(dashes);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
-#if 0
-#ifdef CAIRO_HAS_PDF_SURFACE
 static PyObject *
-pycairo_set_target_pdf(PyCairoContext *c, PyObject *args)
+pycairo_set_fill_rule(PyCairoContext *c, PyObject *args)
 {
-    PyObject *file_object;
-    double width_inches, height_inches;
-    double x_pixels_per_inch, y_pixels_per_inch;
+    cairo_fill_rule_t fill_rule;
 
-    if (!PyArg_ParseTuple(args, "O!dddd:Context.set_target_pdf",
-			  &PyFile_Type, &file_object,
-			  &width_inches, &height_inches,
-			  &x_pixels_per_inch, &y_pixels_per_inch))
+    if (!PyArg_ParseTuple(args, "i:Context.set_fill_rule", &fill_rule))
 	return NULL;
 
-    cairo_set_target_pdf(c->ctx, PyFile_AsFile(file_object),
-			width_inches, height_inches,
-			x_pixels_per_inch, y_pixels_per_inch);
+    cairo_set_fill_rule(c->ctx, fill_rule);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
-#endif  /* CAIRO_HAS_PDF_SURFACE */
-#endif
 
-#ifdef CAIRO_HAS_PS_SURFACE
 static PyObject *
-pycairo_set_target_ps(PyCairoContext *c, PyObject *args)
+pycairo_set_line_cap(PyCairoContext *c, PyObject *args)
 {
-    PyObject *file_object;
-    double width_inches, height_inches;
-    double x_pixels_per_inch, y_pixels_per_inch;
+    cairo_line_cap_t line_cap;
 
-    if (!PyArg_ParseTuple(args, "O!dddd:Context.set_target_ps",
-			  &PyFile_Type, &file_object,
-			  &width_inches, &height_inches,
-			  &x_pixels_per_inch, &y_pixels_per_inch))
+    if (!PyArg_ParseTuple(args, "i:Context.set_line_cap", &line_cap))
 	return NULL;
 
-    cairo_set_target_ps(c->ctx, PyFile_AsFile(file_object),
-			width_inches, height_inches,
-			x_pixels_per_inch, y_pixels_per_inch);
+    cairo_set_line_cap(c->ctx, line_cap);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
-#endif  /* CAIRO_HAS_PS_SURFACE */
 
 static PyObject *
-pycairo_set_target_surface(PyCairoContext *c, PyObject *args)
+pycairo_set_line_join(PyCairoContext *c, PyObject *args)
 {
-    PyCairoSurface *surface;
+    cairo_line_join_t line_join;
 
-    if (!PyArg_ParseTuple(args, "O!:Context.set_target_surface",
-			  &PyCairoSurface_Type, &surface))
+    if (!PyArg_ParseTuple(args, "i:Context.set_line_join", &line_join))
 	return NULL;
 
-    cairo_set_target_surface(c->ctx, surface->surface);
+    cairo_set_line_join(c->ctx, line_join);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairo_stroke_extents(PyCairoContext *c)
+pycairo_set_line_width(PyCairoContext *c, PyObject *args)
 {
-    double x1, y1, x2, y2;
-    cairo_stroke_extents(c->ctx, &x1, &y1, &x2, &y2);
+    double width;
+
+    if (!PyArg_ParseTuple(args, "d:Context.set_line_width", &width))
+	return NULL;
+
+    cairo_set_line_width(c->ctx, width);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
-    return Py_BuildValue("(dddd)", x1, y1, x2, y2);
+    Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairo_identity_matrix(PyCairoContext *c)
+pycairo_set_matrix(PyCairoContext *c, PyObject *args)
 {
-    cairo_identity_matrix(c->ctx);
+    PyCairoMatrix *matrix;
+
+    if (!PyArg_ParseTuple(args, "O!:Context.set_matrix",
+			   &PyCairoMatrix_Type, &matrix))
+	return NULL;
+
+    cairo_set_matrix(c->ctx, &matrix->matrix);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairo_reset_clip(PyCairoContext *c)
+pycairo_set_operator(PyCairoContext *c, PyObject *args)
 {
-    cairo_reset_clip(c->ctx);
+    cairo_operator_t op;
+
+    if (!PyArg_ParseTuple(args, "i:Context.set_operator", &op))
+	return NULL;
+
+    cairo_set_operator(c->ctx, op);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairo_text_path(PyCairoContext *c, PyObject *args)
+pycairo_set_source(PyCairoContext *c, PyObject *args)
 {
-    const char *utf8;
+    PyCairoPattern *p;
 
-    if (!PyArg_ParseTuple(args, "s:Context.text_path", &utf8))
+    if (!PyArg_ParseTuple(args, "O!:Context.set_source",
+			  &PyCairoPattern_Type, &p))
 	return NULL;
 
-    cairo_text_path(c->ctx, utf8);
+    cairo_set_source(c->ctx, p->pattern);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
@@ -593,119 +634,102 @@
     Py_RETURN_NONE;
 }
 
+#if 0
+#ifdef CAIRO_HAS_PDF_SURFACE
 static PyObject *
-pycairo_set_source(PyCairoContext *c, PyObject *args)
-{
-    PyCairoPattern *p;
-
-    if (!PyArg_ParseTuple(args, "O!:Context.set_source",
-			  &PyCairoPattern_Type, &p))
-	return NULL;
-
-    cairo_set_source(c->ctx, p->pattern);
-    if (pycairo_check_status(cairo_status(c->ctx)))
-	return NULL;
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-pycairo_set_tolerance(PyCairoContext *c, PyObject *args)
+pycairo_set_target_pdf(PyCairoContext *c, PyObject *args)
 {
-    double tolerance;
+    PyObject *file_object;
+    double width_inches, height_inches;
+    double x_pixels_per_inch, y_pixels_per_inch;
 
-    if (!PyArg_ParseTuple(args, "d:Context.set_tolerance", &tolerance))
+    if (!PyArg_ParseTuple(args, "O!dddd:Context.set_target_pdf",
+			  &PyFile_Type, &file_object,
+			  &width_inches, &height_inches,
+			  &x_pixels_per_inch, &y_pixels_per_inch))
 	return NULL;
 
-    cairo_set_tolerance(c->ctx, tolerance);
+    cairo_set_target_pdf(c->ctx, PyFile_AsFile(file_object),
+			width_inches, height_inches,
+			x_pixels_per_inch, y_pixels_per_inch);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
+#endif  /* CAIRO_HAS_PDF_SURFACE */
+#endif
 
+#ifdef CAIRO_HAS_PS_SURFACE
 static PyObject *
-pycairo_set_fill_rule(PyCairoContext *c, PyObject *args)
+pycairo_set_target_ps(PyCairoContext *c, PyObject *args)
 {
-    cairo_fill_rule_t fill_rule;
+    PyObject *file_object;
+    double width_inches, height_inches;
+    double x_pixels_per_inch, y_pixels_per_inch;
 
-    if (!PyArg_ParseTuple(args, "i:Context.set_fill_rule", &fill_rule))
+    if (!PyArg_ParseTuple(args, "O!dddd:Context.set_target_ps",
+			  &PyFile_Type, &file_object,
+			  &width_inches, &height_inches,
+			  &x_pixels_per_inch, &y_pixels_per_inch))
 	return NULL;
 
-    cairo_set_fill_rule(c->ctx, fill_rule);
+    cairo_set_target_ps(c->ctx, PyFile_AsFile(file_object),
+			width_inches, height_inches,
+			x_pixels_per_inch, y_pixels_per_inch);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
+#endif  /* CAIRO_HAS_PS_SURFACE */
 
 static PyObject *
-pycairo_set_line_width(PyCairoContext *c, PyObject *args)
+pycairo_set_target_surface(PyCairoContext *c, PyObject *args)
 {
-    double width;
+    PyCairoSurface *surface;
 
-    if (!PyArg_ParseTuple(args, "d:Context.set_line_width", &width))
+    if (!PyArg_ParseTuple(args, "O!:Context.set_target_surface",
+			  &PyCairoSurface_Type, &surface))
 	return NULL;
 
-    cairo_set_line_width(c->ctx, width);
+    cairo_set_target_surface(c->ctx, surface->surface);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairo_set_line_cap(PyCairoContext *c, PyObject *args)
+pycairo_set_tolerance(PyCairoContext *c, PyObject *args)
 {
-    cairo_line_cap_t line_cap;
+    double tolerance;
 
-    if (!PyArg_ParseTuple(args, "i:Context.set_line_cap", &line_cap))
+    if (!PyArg_ParseTuple(args, "d:Context.set_tolerance", &tolerance))
 	return NULL;
 
-    cairo_set_line_cap(c->ctx, line_cap);
+    cairo_set_tolerance(c->ctx, tolerance);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
 }
 
 static PyObject *
-pycairo_set_line_join(PyCairoContext *c, PyObject *args)
+pycairo_stroke_extents(PyCairoContext *c)
 {
-    cairo_line_join_t line_join;
-
-    if (!PyArg_ParseTuple(args, "i:Context.set_line_join", &line_join))
-	return NULL;
-
-    cairo_set_line_join(c->ctx, line_join);
+    double x1, y1, x2, y2;
+    cairo_stroke_extents(c->ctx, &x1, &y1, &x2, &y2);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
-    Py_RETURN_NONE;
+    return Py_BuildValue("(dddd)", x1, y1, x2, y2);
 }
 
 static PyObject *
-pycairo_set_dash(PyCairoContext *c, PyObject *args)
+pycairo_text_path(PyCairoContext *c, PyObject *args)
 {
-    double *dashes, offset = 0;
-    int ndash, i;
-    PyObject *py_dashes;
+    const char *utf8;
 
-    if (!PyArg_ParseTuple(args, "O|d:Context.set_dash", &py_dashes, &offset))
-	return NULL;
-    if (!(py_dashes = PySequence_Fast(py_dashes, "first argument must be a sequence")))
+    if (!PyArg_ParseTuple(args, "s:Context.text_path", &utf8))
 	return NULL;
 
-    ndash = PySequence_Fast_GET_SIZE(py_dashes);
-    dashes = malloc(ndash * sizeof(double));
-    for (i = 0; i < ndash; i++) {
-	PyObject *item = PySequence_Fast_GET_ITEM(py_dashes, i);
-
-	dashes[i] = PyFloat_AsDouble(item);
-	if (PyErr_Occurred()) {
-	    free(dashes);
-	    Py_DECREF(py_dashes);
-	    return NULL;
-	}
-    }
-    Py_DECREF(py_dashes);
-
-    cairo_set_dash(c->ctx, dashes, ndash, offset);
-    free(dashes);
+    cairo_text_path(c->ctx, utf8);
     if (pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
@@ -783,21 +807,6 @@
 }
 
 static PyObject *
-pycairo_set_matrix(PyCairoContext *c, PyObject *args)
-{
-    PyCairoMatrix *matrix;
-
-    if (!PyArg_ParseTuple(args, "O!:Context.set_matrix",
-			   &PyCairoMatrix_Type, &matrix))
-	return NULL;
-
-    cairo_set_matrix(c->ctx, &matrix->matrix);
-    if (pycairo_check_status(cairo_status(c->ctx)))
-	return NULL;
-    Py_RETURN_NONE;
-}
-
-static PyObject *
 pycairo_user_to_device_distance(PyCairoContext *c, PyObject *args)
 {
     double dx, dy;
@@ -1167,6 +1176,7 @@
     { "line_to",       (PyCFunction)pycairo_line_to,       METH_VARARGS },
     { "move_to",       (PyCFunction)pycairo_move_to,       METH_VARARGS },
     { "new_path",      (PyCFunction)pycairo_new_path,      METH_NOARGS },
+    { "paint",         (PyCFunction)pycairo_paint,         METH_NOARGS },
     { "rectangle",     (PyCFunction)pycairo_rectangle,     METH_VARARGS },
     { "rel_curve_to",  (PyCFunction)pycairo_rel_curve_to,  METH_VARARGS },
     { "rel_line_to",   (PyCFunction)pycairo_rel_line_to,   METH_VARARGS },




More information about the cairo-commit mailing list