summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@gnome.org>2007-07-10 22:00:49 -0500
committerJonathon Jongsma <jjongsma@gnome.org>2007-07-10 22:00:49 -0500
commit0d0c849a633c5e696fe66069677f0f85fe4a863d (patch)
tree29708cf7233cb8a2b698c0cec055c41b0ca87bd6
parentdc5bc937ae5e48efe594a8a8767adbf5b339fecf (diff)
Add alternate API for Context::set_dash() which takes a std::vector argument
instead of the slightly unexpected std::valarray argument * tests/test-context.cc: test that both API work correctly and compile correctly without any problems
-rw-r--r--ChangeLog9
-rw-r--r--cairomm/context.cc6
-rw-r--r--cairomm/context.h7
-rw-r--r--tests/test-context.cc14
4 files changed, 35 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6fa231e..76a78f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-07-10 Jonathon Jongsma <jjongsma@gnome.org>
+
+ * cairomm/context.cc:
+ * cairomm/context.h: add alternate API for set_dash() which takes a
+ std::vector argument instead of the slightly unexpected std::valarray
+ argument
+ * tests/test-context.cc: test that both API work correctly and compile
+ correctly without any problems
+
2007-07-04 Jonathon Jongsma <jjongsma@gnome.org>
* tests/test-context.cc: add some tests for matrix transformations and
diff --git a/cairomm/context.cc b/cairomm/context.cc
index 1cbc7ee..ea398fc 100644
--- a/cairomm/context.cc
+++ b/cairomm/context.cc
@@ -151,6 +151,12 @@ void Context::set_dash(std::valarray<double>& dashes, double offset)
check_object_status_and_throw_exception(*this);
}
+void Context::set_dash(std::vector<double>& dashes, double offset)
+{
+ cairo_set_dash(m_cobject, &dashes[0], dashes.size(), offset);
+ check_object_status_and_throw_exception(*this);
+}
+
void Context::unset_dash()
{
cairo_set_dash(m_cobject, NULL, 0, 0.0);
diff --git a/cairomm/context.h b/cairomm/context.h
index e74da9c..6c47e3b 100644
--- a/cairomm/context.h
+++ b/cairomm/context.h
@@ -235,6 +235,11 @@ public:
*/
void set_line_join(LineJoin line_join);
+ /**
+ * Alternate version of set_dash(). You'll probably want to use the one that
+ * takes a std::vector argument instead.
+ */
+ void set_dash(std::valarray<double>& dashes, double offset);
/** Sets the dash pattern to be used by stroke(). A dash pattern is specified
* by dashes, an array of positive values. Each value provides the user-space
* length of altenate "on" and "off" portions of the stroke. The offset
@@ -252,7 +257,7 @@ public:
*
* @exception
*/
- void set_dash(std::valarray<double>& dashes, double offset);
+ void set_dash(std::vector<double>& dashes, double offset);
/** This function disables a dash pattern that was set with set_dash()
*/
diff --git a/tests/test-context.cc b/tests/test-context.cc
index 5efd0a7..1583842 100644
--- a/tests/test-context.cc
+++ b/tests/test-context.cc
@@ -37,6 +37,20 @@ test_dashes ()
BOOST_CHECK_EQUAL (dash_array[3], get_array[3]);
BOOST_CHECK_EQUAL (0.54, get_offset);
+ std::vector<double> dash_vect(4);
+ dash_vect[0] = 0.5;
+ dash_vect[1] = 0.25;
+ dash_vect[2] = 0.93;
+ dash_vect[3] = 1.31;
+ cr->set_dash(dash_vect, 0.4);
+
+ cr->get_dash (get_array, get_offset);
+ BOOST_CHECK_EQUAL (dash_vect[0], get_array[0]);
+ BOOST_CHECK_EQUAL (dash_vect[1], get_array[1]);
+ BOOST_CHECK_EQUAL (dash_vect[2], get_array[2]);
+ BOOST_CHECK_EQUAL (dash_vect[3], get_array[3]);
+ BOOST_CHECK_EQUAL (0.4, get_offset);
+
cr->unset_dash ();
cr->get_dash (get_array, get_offset);
BOOST_CHECK (get_array.empty ());