[goffice] Add go_path_copy and go_path_append



commit bad8298d9d74807c9d6572133e3d1f05b9039ac7
Author: Jean Brefort <jean brefort normalesup org>
Date:   Tue Apr 13 09:40:47 2010 +0200

    Add go_path_copy and go_path_append

 ChangeLog                               |    7 +++
 NEWS                                    |    1 +
 docs/reference/goffice-0.8-sections.txt |    5 ++
 goffice/utils/go-path.c                 |   68 +++++++++++++++++++++++++++++++
 goffice/utils/go-path.h                 |    3 +
 5 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 29a5bb2..3d2163a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-13  Jean Brefort  <jean brefort normalesup org>
+
+	* docs/reference/goffice-0.8-sections.txt: add new go_path entries.
+	* goffice/utils/go-path.c (go_path_copy),
+	(go_path_append): new functions.
+	* goffice/utils/go-path.h: ditto.
+
 2010-04-10  Valek Filippov  <frob gnome org>
 
 	* goffice/tests/mf-demo.c: move objects to drawing context,
diff --git a/NEWS b/NEWS
index c85e217..97e06a5 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ goffice 0.8.2:
 
 Jean:
 	* Support fd:// URIs on win32. [#608422]
+	* Add more GOPath API.
 
 Morten:
 	* Implement conf notification in keyfile case.  [#613523]
diff --git a/docs/reference/goffice-0.8-sections.txt b/docs/reference/goffice-0.8-sections.txt
index d467869..13dc5e3 100644
--- a/docs/reference/goffice-0.8-sections.txt
+++ b/docs/reference/goffice-0.8-sections.txt
@@ -693,8 +693,13 @@ go_path_pie_wedge
 go_path_rectangle
 go_path_ring_wedge
 go_path_interpret
+go_path_to_cairo
+go_path_copy
+go_path_append
 <SUBSECTION Standard>
 GO_IS_PATH
+GO_TYPE_PATH
+go_path_get_type
 </SECTION>
 
 ### Data
diff --git a/goffice/utils/go-path.c b/goffice/utils/go-path.c
index 3236d24..2565ee2 100644
--- a/goffice/utils/go-path.c
+++ b/goffice/utils/go-path.c
@@ -589,6 +589,14 @@ go_path_cairo_curve_to (cairo_t *cr, GOPathPoint const *point0,
 	cairo_curve_to (cr, point0->x, point0->y, point1->x, point1->y, point2->x, point2->y);
 }
 
+/** go_path_to_cairo:
+ * @path: #GOPath
+ * @direction: #GOPathDirection
+ * @cr: #cairo_t
+ *
+ * Renders the path to the cairo context using its current settings.
+ */
+
 void
 go_path_to_cairo (GOPath const *path, GOPathDirection direction, cairo_t *cr)
 {
@@ -598,3 +606,63 @@ go_path_to_cairo (GOPath const *path, GOPathDirection direction, cairo_t *cr)
 			   (GOPathCurveToFunc *) go_path_cairo_curve_to,
 			   (GOPathClosePathFunc *) cairo_close_path, cr);
 }
+
+static void
+go_path_append_move_to (GOPath *path, GOPathPoint const *point)
+{
+	go_path_move_to (path, point->x, point->y);
+}
+
+static void
+go_path_append_line_to (GOPath *path, GOPathPoint const *point)
+{
+	go_path_line_to (path, point->x, point->y);
+}
+
+static void
+go_path_append_curve_to (GOPath *path, GOPathPoint const *point0,
+			GOPathPoint const *point1, GOPathPoint const *point2)
+{
+	go_path_curve_to (path, point0->x, point0->y, point1->x, point1->y, point2->x, point2->y);
+}
+
+static void
+go_path_append_close (GOPath *path)
+{
+	go_path_close (path);
+}
+
+/** go_path_copy:
+ * @path: #GOPath
+ *
+ * Returns: a new #GOPath identical to @path.
+ */
+
+GOPath *go_path_copy (GOPath const *path)
+{
+	GOPath *new_path = go_path_new ();
+	new_path->options = path->options;
+	go_path_interpret (path, GO_PATH_DIRECTION_FORWARD,
+			   (GOPathMoveToFunc *) go_path_append_move_to,
+			   (GOPathLineToFunc *) go_path_append_line_to,
+			   (GOPathCurveToFunc *) go_path_append_curve_to,
+			   (GOPathClosePathFunc *) go_path_append_close, new_path);
+	return new_path;
+}
+
+/** go_path_append:
+ * @path1: #GOPath
+ * @path2: #GOPath
+ *
+ * Appends @path2 at the end of @path1.
+ * Returns: @path1
+ */
+GOPath *go_path_append (GOPath *path1, GOPath const *path2)
+{
+	go_path_interpret (path2, GO_PATH_DIRECTION_FORWARD,
+			   (GOPathMoveToFunc *) go_path_append_move_to,
+			   (GOPathLineToFunc *) go_path_append_line_to,
+			   (GOPathCurveToFunc *) go_path_append_curve_to,
+			   (GOPathClosePathFunc *) go_path_append_close, path1);
+	return path1;
+}
diff --git a/goffice/utils/go-path.h b/goffice/utils/go-path.h
index 08a9730..be909b9 100644
--- a/goffice/utils/go-path.h
+++ b/goffice/utils/go-path.h
@@ -108,6 +108,9 @@ void    go_path_to_cairo	(GOPath const *path,
 				 GOPathDirection direction,
 				 cairo_t *cr);
 
+GOPath *go_path_copy		(GOPath const *path);
+GOPath *go_path_append		(GOPath *path1, GOPath const *path2);
+
 G_END_DECLS
 
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]