aboutsummaryrefslogtreecommitdiff
path: root/zinclib.d/test
diff options
context:
space:
mode:
authorlecoanet2005-05-10 14:55:18 +0000
committerlecoanet2005-05-10 14:55:18 +0000
commit5abe4bd15642bbc83f46553aa5275430b14f5f91 (patch)
treeee9303b7dbeb1df88debd5ddef167db86df3bdac /zinclib.d/test
parentb8356d1bffb6a8fcb83af50fe8725140ae0ddd47 (diff)
downloadtkzinc-5abe4bd15642bbc83f46553aa5275430b14f5f91.zip
tkzinc-5abe4bd15642bbc83f46553aa5275430b14f5f91.tar.gz
tkzinc-5abe4bd15642bbc83f46553aa5275430b14f5f91.tar.bz2
tkzinc-5abe4bd15642bbc83f46553aa5275430b14f5f91.tar.xz
*** empty log message ***
Diffstat (limited to 'zinclib.d/test')
-rw-r--r--zinclib.d/test/Makefile36
-rw-r--r--zinclib.d/test/itemconf.cpp436
-rw-r--r--zinclib.d/test/items.cpp213
-rw-r--r--zinclib.d/test/paper-grey.gifbin0 -> 1540 bytes
-rw-r--r--zinclib.d/test/paper.gifbin0 -> 1529 bytes
-rw-r--r--zinclib.d/test/runtests.sh17
-rw-r--r--zinclib.d/test/test.cpp187
-rw-r--r--zinclib.d/test/test.svg40
-rw-r--r--zinclib.d/test/widget.cpp204
9 files changed, 1133 insertions, 0 deletions
diff --git a/zinclib.d/test/Makefile b/zinclib.d/test/Makefile
new file mode 100644
index 0000000..84938e6
--- /dev/null
+++ b/zinclib.d/test/Makefile
@@ -0,0 +1,36 @@
+########################################
+# zinclib tests makefile
+########################################
+
+# list of tests to make
+EXECS = items widget test itemconf
+
+# default : all tests
+all: $(EXECS)
+
+# usefull commons
+include ../../../v0.1/common.mk
+
+# specific options
+INCLUDE = -I../src
+LIBDIR = ../tmp
+LDFLAGS += -L../../../v0.1/lib -ltcl8.4 -ltk8.4 -lTkZinc $(LIBDIR)/zinclib.o
+
+# generic target
+%.o: %.cpp
+ $(CXX) $(CXXFLAGS) -o $@ -c $<
+
+clean:
+ rm -f *.o $(PROFFILES) $(EXECS) core.* *.exe
+
+clean_code: clean
+ rm -f *~ .\#*
+
+# function to create a target for each test
+define funct
+$(1): $(1).o $(LIBDIR)/zinclib.o
+ $$(GCC) $$(LDFLAGS) -o $$@ $$<
+endef
+
+# create a target for each test
+$(foreach prog,$(EXECS),$(eval $(call funct,$(prog))))
diff --git a/zinclib.d/test/itemconf.cpp b/zinclib.d/test/itemconf.cpp
new file mode 100644
index 0000000..7fbca78
--- /dev/null
+++ b/zinclib.d/test/itemconf.cpp
@@ -0,0 +1,436 @@
+/** itemconf.cpp
+ * zinclib/tests
+ *
+ * This software is the property of IntuiLab SA, France.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Some tests for zinclib
+ *
+ * 08/03/05
+ *
+ * Contributors:
+ * Benoit Peccatte <peccatte@intuilab.com>
+ *
+ */
+
+
+#include "Zinc.hpp"
+#include <math.h>
+//global variable
+Zinc *zn;
+
+//prepare constants
+//white color
+String white = String ("white");
+// red color
+String red = String ("red");
+// blue color
+String blue = String ("blue");
+// sample text
+String texte = String ("Hello world");
+// sample gradient
+String gradient = String ("=axial 0 | blue | white 50 | red");
+// sample gradient
+String gradient2 = String ("=axial 0 | yellow | green 50 | red");
+// gradient name
+String gname = "g1";
+// empty tag
+String tag = String("");
+
+String image =
+"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";
+
+//Let's test all item types
+int main (int argc, char** argv)
+{
+ double a,b,c,d,e,f;
+ //catch exceptions
+ try
+ {
+ //don't forget to load zinc
+ Zinc::loadZinc (argv[0]);
+ //create the widget
+ zn = new Zinc (ZINC_BACKEND_OPENGL);
+
+ //give it parameters
+ zn->setWidth (800);
+ zn->setHeight (600);
+
+ ZincItem *g1;
+ //create a group
+ g1 = zn->itemCreateGroup (NULL);
+ //create a rectangle
+ ZincItem *rect;
+ rect = zn->itemCreateRectangle (g1, 10, 10, 100, 100);
+
+ // create an arc
+ ZincItem *arc;
+ arc = zn->itemCreateArc (NULL, 10, 10, 200, 200);
+
+ // create a curve
+ ZincPath* path = new ZincPath(200,200);
+ //test lineto
+ path->lineTo (250,250);
+ //test quadraticBezierTo
+ path->quadraticBezierTo (300,200, 300,300);
+
+ //path->close ();
+ //display the curve
+ ZincItem *curve = zn->itemCreateCurve (g1, path);
+
+ // create a sample text
+ ZincItem *text = zn->itemCreateText (g1);
+ zn->itemSetPosition (text, 10, 300);
+
+ ZincItem *empty = zn->createTag(tag);
+ /**************************************
+ tests simple sets and gets
+ **************************************/
+
+ //transformations
+ zn->itemRotate (rect, 45, true);
+ zn->itemSetTransformation (rect, 1, 0, 0, 1, 0, 0);
+ zn->itemGetTransformation (rect, &a, &b, &c, &d, &e, &f);
+ printf ("Transformation \n%f,%f,%f,%f,%f,%f\n", a, b, c, d, e, f);
+
+ //closed
+ zn->itemSetClosed (arc, 1);
+ printf ("Closed %d\n",zn->itemGetClosed (arc));
+
+ //composeAlpha
+ zn->itemSetComposealpha (rect, 1);
+ printf ("composeAlpha %d\n", zn->itemGetComposealpha (rect));
+
+ //Composerotation
+ zn->itemSetComposerotation (rect, 1);
+ printf ("Composerotation %d\n", zn->itemGetComposerotation (rect));
+
+ //Composescale
+ zn->itemSetComposescale(rect,1);
+ printf ("Composescale %d\n", zn->itemGetComposescale (rect));
+
+ //extent
+ zn->itemSetExtent (arc, 230);
+ printf ("Extent %d\n", zn->itemGetExtent (arc));
+
+ //fillcolor
+ zn->itemSetFillcolor(rect, red);
+ printf ("Fillcolor %s\n", zn->itemGetFillcolor (rect).c_str ());
+
+ //filled
+ zn->itemSetFilled (rect, 1);
+ printf ("Filled %d\n", zn->itemGetFilled (rect));
+
+ //linecolor
+ zn->itemSetLinecolor (arc, blue);
+ printf ("linecolor %s\n", zn->itemGetLinecolor (arc).c_str ());
+
+ //linestyle
+ zn->itemSetLinestyle (arc, lineStyle_dashed);
+ printf ("linestyle %d\n", zn->itemGetLinestyle (arc));
+
+ //linewidth
+ zn->itemSetLinewidth (arc, 3);
+ printf ("linewidth %f\n", zn->itemGetLinewidth (arc));
+
+ //piesplice
+ zn->itemSetPieslice (arc, 1);
+ printf ("piesplice %d\n", zn->itemGetPieslice (arc));
+
+ //priority
+ zn->itemSetPriority (rect, 10);
+ printf ("priority %d\n", zn->itemGetPriority (rect));
+
+ //Sensitive
+ zn->itemSetSensitive (rect, 1);
+ printf ("Sensitive %d\n", zn->itemGetSensitive (rect));
+
+ //Startangle
+ zn->itemSetStartangle (arc, 90);
+ printf ("Startangle %d\n", zn->itemGetStartangle (arc));
+
+ //SetVisible
+ zn->itemSetVisible (rect, 1);
+ printf ("Visible %d\n", zn->itemGetVisible (rect));
+
+ //Capstyle
+ zn->itemSetCapstyle (curve, capStyle_projecting);
+ printf ("Capstyle %d\n", zn->itemGetCapstyle (curve));
+
+ //Fillrule
+ zn->itemSetFillrule (curve, fillRule_negative);
+ printf ("Fillrule %d\n", zn->itemGetFillrule (curve));
+
+ //Joinstyle
+ zn->itemSetJoinstyle (curve, joinStyle_miter);
+ printf ("Joinstyle %d\n", zn->itemGetJoinstyle (curve));
+
+ //Relief
+ zn->itemSetRelief (curve, relief_groove);
+ printf ("Relief %d\n", zn->itemGetRelief (curve));
+
+ //Smoothrelief
+ zn->itemSetSmoothrelief (curve, 1);
+ printf ("Smoothrelief %d\n", zn->itemGetSmoothrelief (curve));
+
+ //alpha
+ zn->itemSetAlpha (g1, 75);
+ printf ("alpha %d\n", zn->itemGetAlpha (g1));
+
+ //Atomic
+ zn->itemSetAtomic (g1, 1);
+ printf ("Atomic %d\n", zn->itemGetAtomic (g1));
+
+ //Anchor
+ zn->itemSetAnchor (text, anchor_nw);
+ printf ("Anchor %d\n", zn->itemGetAnchor (text));
+
+ //Color
+ zn->itemSetColor (text, blue);
+ printf ("Color %s\n", zn->itemGetColor (text).c_str ());
+
+ //ConnectedItem
+ zn->itemSetConnecteditem (text, rect);
+ ZincItem *it0 = zn->itemGetConnecteditem (text);
+ printf ("ConnectedItem %x\n", (int)it0);
+
+ //Connectionanchor
+ zn->itemSetConnectionanchor (text, anchor_se);
+ printf ("Connectionanchor %d\n", zn->itemGetConnectionanchor (text));
+
+ //Alignment
+ zn->itemSetAlignment (text, alignment_right);
+ printf ("Alignment %d\n", zn->itemGetAlignment (text));
+
+ //Overstriked
+ zn->itemSetOverstriked (text, 1);
+ printf ("Overstriked %d\n", zn->itemGetOverstriked (text));
+
+ //Spacing
+ zn->itemSetSpacing (text, 10);
+ printf ("Spacing %d\n", zn->itemGetSpacing (text));
+
+ //text
+ zn->itemSetText (text, texte);
+ printf ("text %s\n", zn->itemGetText (text).c_str ());
+
+ //Underlined
+ zn->itemSetUnderlined (text, 1);
+ printf ("Underlined %d\n", zn->itemGetUnderlined (text));
+
+ //width
+ zn->itemSetWidth (text, 500);
+ printf ("width %d\n", zn->itemGetWidth (text));
+
+ //Clip
+ zn->itemSetClip (g1, rect);
+ ZincItem *it1 = zn->itemGetClip (g1);
+ printf ("Clip %x\n", (int)it1);
+ zn->itemSetClip (g1, empty);
+
+
+ /**************************************
+ tests more sets and gets
+ **************************************/
+
+ //firt end
+ double a,b,c;
+ zn->itemSetLastend (curve, 5, 6, 7);
+ zn->itemGetLastend (curve, &a, &b, &c);
+ printf ("lastend %f, %f, %f\n", a, b, c);
+
+ //last end
+ zn->itemSetFirstend (curve, 5, 6, 7);
+ zn->itemGetFirstend (curve, &a, &b, &c);
+ printf ("firstend %f, %f, %f\n", a, b, c);
+
+
+ // position
+ zn->itemGetPosition (text, &a, &b);
+ printf ("position %f, %f\n", a, b);
+
+ //font
+ ZincFont *fn = zn->itemGetFont (text);
+ printf("Font %s\n", fn->name.c_str ());
+
+ // add tags
+ zn->addTag (rect, String ("tag0"));
+ zn->addTag (rect, String ("tag1"));
+
+ //tags
+ String **taglist;
+ int count = zn->getTags (rect, &taglist);
+ for ( int i = 0 ; i < count ; i++ )
+ {
+ printf("Tag %d : %s\n", i, taglist[i]->c_str ());
+ }
+
+ // delete tag
+ zn->dTag (rect, String ("tag0"));
+
+ // new rectangle
+ ZincItem *r2;
+ r2 = zn->itemCreateRectangle (g1, 210, 210, 300, 300);
+
+ //icons
+ ZincImage* img = zn->createImageFromData (image);
+ ZincItem *icon = zn->itemCreateIcon (g1, img);
+ zn->itemTranslate (icon, 500,10);
+
+ //getImage
+ ZincImage *it2 = zn->itemGetImage (icon);
+ printf("Image %x\n", (int)it2);
+
+ //bitmaps
+ ZincBitmap *bm = zn->createBitmapFromName ("AlphaStipple5");
+ zn->itemSetFillpattern (r2, bm);
+
+ //fillpattern
+ zn->itemSetFillpattern (curve, bm);
+ ZincBitmap *it3 = zn->itemGetFillpattern (curve);
+ printf("fillpattern %x\n", (int)it3);
+
+ //tile
+ zn->itemSetTile (curve, bm);
+ ZincBitmap *it4 = zn->itemGetTile (curve);
+ printf("Tile %x\n", (int)it4);
+
+ //mask
+ zn->itemSetMask (icon, bm);
+ ZincBitmap *it5 = zn->itemGetMask (icon);
+ printf("Mask %x\n", (int)it5);
+
+ //linepattern
+ zn->itemSetLinepattern (curve, bm);
+ ZincBitmap *it6 = zn->itemGetLinepattern (curve);
+ printf("linepattern %x\n", (int)it6);
+
+ /****************************************
+ tests other functions for items
+ ****************************************/
+
+ // raise and lower
+ zn->raise (icon);
+ zn->lower (icon);
+ zn->raise (icon, r2);
+ zn->lower (icon, r2);
+
+ //gradient name related
+ printf("Not gname %d\n", zn->isGname (gname));
+ zn->gname (gradient, gname);
+ printf("Is gname %d\n", zn->isGname (gname));
+
+ //clone
+ ZincItem *i2 = zn->clone (icon);
+ zn->itemTranslate (i2, 50, 50);
+
+ // type
+ printf("Type %d\n", zn->type (icon));
+
+ //font
+ delete fn;
+ fn = zn->getFont ();
+ printf("Font %s\n", fn->name.c_str ());
+
+ // get contour
+ printf ("n Contours %d\n", zn->contour (rect));
+
+ // set contour
+ ZincItem *curve2 = zn->itemCreateCurve (g1, path);
+ zn->contour (curve2, item_add_clockwise, r2);
+ zn->contour (curve2, item_add_counterclockwise, rect);
+
+ // set coords
+ zn->coords (curve2, path, false );
+ zn->coords (curve2, path, true, 1, 1 );
+
+ //remove coords
+ //zn->coordsRemove (curve2, 0);
+
+ //deletes
+ delete path;
+ delete empty;
+ delete arc;
+ delete r2;
+ for(int i=0;i<count;i++)
+ {
+ delete taglist[i];
+ }
+ delete[] taglist;
+ delete bm;
+ delete it0;
+ delete it1;
+ delete it2;
+ delete it3;
+ delete it4;
+ delete it5;
+ delete it6;
+ delete curve2;
+ delete rect;
+ delete img;
+ delete icon;
+ delete i2;
+ delete g1;
+ delete text;
+ delete fn;
+ delete curve;
+
+ //run all this
+ Zinc::zincMainLoop ();
+
+ // delete the widget
+ delete (zn);
+ }
+ catch (ZincException e)
+ {
+ printf("ERROR : %s\n",e.what ());
+ }
+}
diff --git a/zinclib.d/test/items.cpp b/zinclib.d/test/items.cpp
new file mode 100644
index 0000000..a169262
--- /dev/null
+++ b/zinclib.d/test/items.cpp
@@ -0,0 +1,213 @@
+/** items.cpp
+ * zinclib/tests
+ *
+ * This software is the property of IntuiLab SA, France.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Some tests for zinclib
+ *
+ * 08/03/05
+ *
+ * Contributors:
+ * Benoit Peccatte <peccatte@intuilab.com>
+ *
+ */
+
+
+#include "Zinc.hpp"
+#include <math.h>
+//global variable
+Zinc *zn;
+
+const double PI = atan2 (1., 1.) * 4.;
+
+//prepare constants
+//black color
+String black = String ("white");
+// red color
+String red = String ("red");
+// sample text
+String texte = String ("Hello world");
+// sample gradient
+String gradient = String ("=axial 0 | blue | white 50 | red");
+// sample gradient
+String gradient2 = String ("=axial 0 | yellow | green 50 | red");
+
+//Let's test all item types
+int main (int argc, char** argv)
+{
+ //catch exceptions
+ try
+ {
+ //don't forget to load zinc
+ Zinc::loadZinc (argv[0]);
+ ZincPath *path;
+
+ //create the widget
+ zn = new Zinc (ZINC_BACKEND_OPENGL);
+
+ //give it parameters
+ zn->setWidth (600);
+ zn->setHeight (400);
+
+ //change background color
+ printf ("%s\n",zn->getBackcolor ().c_str ());
+ zn->setBackcolor (black);
+ printf ("%s\n",zn->getBackcolor ().c_str ());
+
+ ZincItem *g1;
+ ZincItem *g2;
+ //create a group
+ g1 = zn->itemCreateGroup (NULL);
+ // create another group (with parent)
+ g2 = zn->itemCreateGroup (g1);
+
+ //create a rectangle
+ ZincItem *rect;
+ rect = zn->itemCreateRectangle (g1, 10, 10, 100, 100);
+ // fill the rectangle
+ zn->itemSetFilled (rect, 1);
+ // remove the rectangle
+ zn->itemRemove (rect);
+ delete rect;
+
+ //try a second one
+ rect = zn->itemCreateRectangle (g1, 10, 10, 100, 100);
+ // fill the rectangle
+ zn->itemSetFilled (rect, 1);
+ // in red
+ zn->itemSetFillcolor (rect, red);
+ zn->itemSetTransformation (rect, cos (PI / 4), sin (PI / 4),
+ -sin (PI / 4), cos (PI / 4), 100, 0);
+ delete rect;
+
+ // create an arc
+ ZincItem *arc;
+ arc = zn->itemCreateArc (NULL, 10, 10, 200, 200);
+
+ // give parameters to the arc
+ zn->itemSetClosed (arc, 1);
+ zn->itemSetExtent (arc, 230);
+ // fill the arc
+ zn->itemSetFilled (arc, 1);
+ // with a gradient
+ zn->itemSetFillcolor (arc, gradient);
+ delete arc;
+
+ // create a sample text
+ ZincItem *text = zn->itemCreateText (g2);
+ zn->itemSetText (text, texte);
+ zn->itemSetPosition (text, 10, 300);
+ zn->itemSetPosition (text, 10, 300);
+ delete text;
+
+ // create a curve
+ path = new ZincPath(200,200);
+ //test lineto
+ path->lineTo (250,250);
+ //test quadraticBezierTo
+ path->quadraticBezierTo (300,200, 300,300);
+ //test cubicBezierTo
+ path->cubicBezierTo (400,400, 500,300, 400,200);
+ path->curveTo (500,200, 500,100, 400,100);
+
+ //test arcs
+ path->arcTo (100, 100, 0, false, true, 300, 100);
+
+
+ // test close
+ path->close ();
+ //display the curve
+ ZincItem *pa = zn->itemCreateCurve (g2, path);
+ zn->contour (pa, false, path);
+ zn->contour (pa, true, path);
+ delete path;
+ // fill the arc
+ zn->itemSetFilled (pa, 1);
+ // with a gradient
+ zn->itemSetFillcolor (pa, gradient2);
+ zn->itemTranslate (pa, 30, 30, false);
+
+ // test bounding box
+ double bbox[4];
+ zn->bbox (pa, bbox);
+ printf ("bbox %f, %f, %f, %f\n", bbox[0], bbox[1], bbox[2], bbox[3]);
+ delete pa;
+
+ // create an icon from a file
+ ZincImage *image = zn->createImageFromFile ("paper.gif");
+ ZincItem *icon = zn->itemCreateIcon (g2, image);
+ printf("icon width %d, height %d\n",
+ zn->getImageWidth (image), zn->getImageHeight (image));
+ zn->itemSetPosition (icon, 200, 10);
+ zn->itemTranslate (icon, -20, 10);
+ zn->itemRotate (icon, 0);
+ zn->itemRotate (icon, -45, 0, 0);
+ zn->itemRotate (icon, 45, true);
+ zn->itemRotate (icon, 45, 0, 0, true);
+ delete icon;
+
+ // another icon to test other transforms
+ ZincItem *icon2 = zn->itemCreateIcon (g2, image);
+ zn->itemSetPosition (icon2, 300, 10);
+ zn->itemScale (icon2, 3., 3.);
+ zn->itemScale (icon2, .5, .5, 0, 0);
+ zn->itemSkew (icon2, 10, 10);
+ zn->itemSkewX (icon2, -10);
+ zn->itemSkewY (icon2, -10);
+
+ // test bounding box
+ zn->relativeBbox (icon2, bbox);
+ printf ("relativeBbox %f, %f, %f, %f\n", bbox[0], bbox[1], bbox[2], bbox[3]);
+ delete icon2;
+
+
+ // another icon to test other transforms
+ ZincItem *icon3 = zn->itemCreateIcon (g2, image);
+ zn->itemSetPosition (icon3, 400, 10);
+ zn->itemScale (icon3, 3., 3.);
+ zn->itemResetTransformation (icon3);
+ double a, b, c, d, e, f;
+ zn->itemGetTransformation (icon3, &a, &b, &c, &d, &e, &f);
+ printf ("Transform %f %f %f %f %f %f\n", a, b, c, d, e, f);
+ zn->itemSetTransformation (icon3, a, b, c, d, e, f+20);
+ zn->itemMatrix (icon3, 2, 0, 0, 2, 1, 1);
+ delete icon3;
+ delete image;
+
+ delete g1;
+ delete g2;
+
+ //run all this
+ Zinc::zincMainLoop ();
+
+ // delete the widget
+ delete (zn);
+ }
+ catch (ZincException e)
+ {
+ printf("ERROR : %s\n",e.what ());
+ }
+}
diff --git a/zinclib.d/test/paper-grey.gif b/zinclib.d/test/paper-grey.gif
new file mode 100644
index 0000000..96775b5
--- /dev/null
+++ b/zinclib.d/test/paper-grey.gif
Binary files differ
diff --git a/zinclib.d/test/paper.gif b/zinclib.d/test/paper.gif
new file mode 100644
index 0000000..3247d35
--- /dev/null
+++ b/zinclib.d/test/paper.gif
Binary files differ
diff --git a/zinclib.d/test/runtests.sh b/zinclib.d/test/runtests.sh
new file mode 100644
index 0000000..8cbdf96
--- /dev/null
+++ b/zinclib.d/test/runtests.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+TEST="test items widget itemconf"
+
+# execution
+#pour Unix stantard
+export LD_LIBRARY_PATH=../../../v0.1/lib:$LD_LIBRARY_PATH
+#pour MacOS X
+export DYLD_LIBRARY_PATH=../../../v0.1/lib:$DYLD_LIBRARY_PATH
+
+if ( make 1>&2 )
+then
+ for test in $TEST
+ do
+ ./$test
+ done
+fi
diff --git a/zinclib.d/test/test.cpp b/zinclib.d/test/test.cpp
new file mode 100644
index 0000000..f8a6a22
--- /dev/null
+++ b/zinclib.d/test/test.cpp
@@ -0,0 +1,187 @@
+/** test.cpp
+ * zinclib
+ *
+ * This software is the property of IntuiLab SA, France.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Some tests for zinclib
+ *
+ * 08/03/05
+ *
+ * Contributors:
+ * Benoit Peccatte <peccatte@intuilab.com>
+ *
+ */
+
+
+#include "Zinc.hpp"
+#include <stack>
+#include <queue>
+
+#define CNT 5000
+
+ZincPath *path;
+Zinc *zn;
+Zinc *zn2;
+int stop = 0;
+String gradient = String("=axial 0 | blue | red");
+std::queue<ZincItem*> pile;
+
+void znCb (Zinc *zinc, ZincItem *item, ZincEvent *event, void *userData)
+{
+ printf ("Callback : x=%d y=%d k=%d t=%ld K=%s\n",
+ event->x, event->y, event->k, event->t, event->K.c_str ());
+ try
+ {
+ ZincItem *rect;
+ int j;
+ if (stop == 0)
+ {
+ for (int i (0) ; i < CNT ; i++ )
+ {
+ j = i%300;
+
+ rect = zn->itemCreateRectangle (NULL, 10+j, 10+j, 100, 100);
+ zn->itemSetFilled (rect, 1);
+ zn->itemSetFillcolor (rect, gradient);
+ pile.push(rect);
+ }
+ stop = 1;
+ }
+ else
+ {
+ for (int i (0) ; i < CNT ; i++ )
+ {
+ rect = pile.front();
+// printf("rect %d %s\n",i,Tcl_GetString(rect->object));
+ zn->itemRemove (rect);
+ delete rect;
+ pile.pop();
+ }
+ stop = 0;
+ }
+ }
+ catch (ZincException e)
+ {
+ printf("ERRORCB : %s\n",e.what ());
+ }
+// return 0;
+}
+
+void znCb2 (Zinc *zinc, ZincItem *item, ZincEvent *event, void *userData)
+{
+ printf ("Callback2 : x=%d y=%d k=%d t=%1d K=%s\n",
+ event->x, event->y, event->k, event->t, event->K.c_str ());
+/// return 0;
+}
+
+int main (int argc, char** argv)
+{
+ try
+ {
+ Zinc::loadZinc (argv[0]);
+ String black = String("white");
+ String red = String("red");
+ String texte = String("Bonjour lé gen");
+ zn = new Zinc (ZINC_BACKEND_OPENGL);
+
+ zn->setWidth (600);
+ zn->setHeight (400);
+
+ printf ("%s\n",zn->getBackcolor ().c_str());
+ zn->setBackcolor (black);
+ printf ("%s\n",zn->getBackcolor ().c_str());
+
+ ZincItem *g1;
+ ZincItem *g2;
+ printf("create group1\n");
+ g1 = zn->itemCreateGroup (NULL);
+ printf("create group2\n");
+ g2 = zn->itemCreateGroup (g1);
+
+ printf("create rect\n");
+ ZincItem *rect;
+ rect = zn->itemCreateRectangle (g1, 10, 10, 100, 100);
+ zn->itemSetFilled (rect, 1);
+ zn->itemSetFillcolor (rect, red);
+ printf("create arc\n");
+ ZincItem *arc;
+ arc = zn->itemCreateArc (NULL, 10, 10, 200, 200);
+
+ zn->itemSetClosed (arc, 1);
+ zn->itemSetExtent (arc, 230);
+ zn->itemSetFilled (arc, 1);
+ zn->itemSetFillcolor (arc, gradient);
+
+ printf ("create text\n");
+ ZincItem *text = zn->itemCreateText (g2);
+ zn->itemSetText (text, texte);
+ zn->itemSetPosition (text, 10, 200);
+ delete text;
+
+ printf ("create curve\n");
+ path = new ZincPath(5,5);
+ path->lineTo (100,5);
+ path->lineTo (200,100);
+ ZincItem *curve = zn->itemCreateCurve (g2, path);
+ path->lineTo (200,200);
+ delete curve;
+
+ printf("create icon\n");
+ ZincImage *image = zn->createImageFromFile ("paper.gif");
+ ZincItem *icon = zn->itemCreateIcon (g2, image);
+ zn->itemSetPosition (icon, 200, 10);
+
+ printf("binding\n");
+ zn->focus (arc);
+ zn->itemBind (arc, String("<KeyPress-a>"), znCb, NULL);
+ zn->itemBind (arc, String("<Button-1>"), znCb2, NULL);
+
+
+/* zn2 = new Zinc (ZINC_BACKEND_OPENGL);
+ ZincItem *rect2;
+ rect2 = zn2->itemCreateRectangle (NULL, 10, 10, 100, 100);
+ zn2->focus (rect2);
+ zn2->itemSetFilled (rect2, 1);
+ zn2->itemSetFillcolor (rect2, red);
+ zn2->setWidth (600);
+ zn2->setHeight (400);
+ zn2->itemBind (rect2, String("<KeyPress-a>"), znCb2, NULL);
+*/
+ Zinc::zincMainLoop ();
+
+ delete g1;
+ delete g2;
+ delete icon;
+ delete image;
+ delete arc;
+ delete rect;
+ delete (zn);
+ }
+ catch (ZincException e)
+ {
+ printf("ERROR : %s\n",e.what ());
+ }
+}
diff --git a/zinclib.d/test/test.svg b/zinclib.d/test/test.svg
new file mode 100644
index 0000000..78b81f2
--- /dev/null
+++ b/zinclib.d/test/test.svg
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 10.0, SVG Export Plug-In . SVG Version: 3.0.0 Build 77) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
+ <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
+ <!ENTITY ns_svg "http://www.w3.org/2000/svg">
+ <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
+]>
+<svg xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
+ width="100" height="100" viewBox="0 0 100 100" overflow="visible" enable-background="new 0 0 100 100" xml:space="preserve">
+ <g id="Layer_1">
+
+ <image width="100" height="100" id="XMLID_1_" xlink:href="data:;base64,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"/>
+ </g>
+</svg>
diff --git a/zinclib.d/test/widget.cpp b/zinclib.d/test/widget.cpp
new file mode 100644
index 0000000..3a47ba7
--- /dev/null
+++ b/zinclib.d/test/widget.cpp
@@ -0,0 +1,204 @@
+/** items.cpp
+ * zinclib/tests
+ *
+ * This software is the property of IntuiLab SA, France.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Some tests for zinclib
+ *
+ * 08/03/05
+ *
+ * Contributors:
+ * Benoit Peccatte <peccatte@intuilab.com>
+ *
+ */
+
+
+#include "Zinc.hpp"
+//global variable
+Zinc *zn;
+Zinc *zn2;
+
+//prepare constants
+//black color
+String black = String("white");
+// red color
+String red = String("blue");
+// sample text
+String texte = String("Hello world");
+// sample gradient
+String gradient = String("=axial 0 | blue | white 50 | red");
+
+
+void znCb (Zinc *zinc, ZincItem *item, ZincEvent *event, void *userData)
+{
+ printf ("Callback1 : x=%d y=%d k=%d t=%ld K=%s w=%d h=%d X=%d Y=%d b=%d\n",
+ event->x, event->y, event->k, event->t, event->K.c_str (),
+ event->w, event->h, event->X, event->Y, event->b );
+}
+
+
+void znCb2 (Zinc *zinc, ZincItem *item, ZincEvent *event, void *userData)
+{
+ printf ("Callback2 : x=%d y=%d k=%d t=%ld K=%s w=%d h=%d X=%d Y=%d b=%d\n",
+ event->x, event->y, event->k, event->t, event->K.c_str (),
+ event->w, event->h, event->X, event->Y, event->b );
+}
+
+void znCb3 (Zinc *zinc, ZincEvent *event, void *userData)
+{
+ printf ("Callback3 : x=%d y=%d k=%d t=%ld K=%s w=%d h=%d X=%d Y=%d b=%d\n",
+ event->x, event->y, event->k, event->t, event->K.c_str (),
+ event->w, event->h, event->X, event->Y, event->b );
+}
+
+//Let's test all item types
+int main (int argc, char** argv)
+{
+ //catch exceptions
+ try
+ {
+ //don't forget to load zinc
+ Zinc::loadZinc (argv[0]);
+
+ //create the widget
+ zn = new Zinc (ZINC_BACKEND_OPENGL);
+
+ //give it parameters
+ zn->setWidth (600);
+ zn->setHeight (400);
+ zn->setTitle("window1");
+
+ //change background color
+ printf ("Backcolor %s\n",zn->getBackcolor ().c_str());
+ // test background color
+ zn->setBackcolor (black);
+ printf ("Backcolor %s\n",zn->getBackcolor ().c_str());
+
+ //change foreground color
+ printf ("Forecolor %s\n",zn->getForecolor ().c_str());
+ // test foreground color
+ zn->setForecolor (red);
+ printf ("Forecolor %s\n",zn->getForecolor ().c_str());
+
+ ZincItem *g1;
+ ZincItem *g2;
+ //create a group
+ g1 = zn->itemCreateGroup (NULL);
+ // create another group (with parent)
+ g2 = zn->itemCreateGroup (g1);
+
+ //create a rectangle
+ ZincItem *rect;
+ rect = zn->itemCreateRectangle (g1, 10, 10, 100, 100);
+ // fill the rectangle
+ zn->itemSetFilled (rect, 1);
+ // in red
+ zn->itemSetFillcolor (rect, red);
+
+ //test change group
+ zn->chggroup (rect, g2);
+ ZincItem *g = zn->group (rect);
+ printf("Group %x\n", (int)g);
+ delete g;
+ zn->chggroup (rect, g1);
+
+ // test bindings
+ zn->focus (rect);
+ zn->itemBind (rect, String("<KeyPress-a>"), znCb, NULL);
+ zn->itemBind (rect, String("<Button-1>"), znCb2, NULL);
+ zn->itemBind (rect, String("<KeyPress-a>"), znCb2, NULL,true);
+
+ //test widget properties
+ printf ("Borderwidth %d\n", zn->getBorderwidth ());
+ zn->setBorderwidth (3);
+ printf ("Borderwidth %d\n", zn->getBorderwidth ());
+
+ // fonts
+ ZincFont *font = zn->createFont ("courier", 24);
+ printf ("setFont\n");
+ zn->setFont (font);
+ printf ("fontAscent %d\n", zn->getFontAscent (font));
+ ZincItem* text = zn->itemCreateText (NULL);
+ zn->itemSetText (text, texte);
+ zn->itemSetPosition (text, 10, 300);
+ printf ("itemsetFont\n");
+ zn->itemSetFont (text, font);
+ delete text;
+ delete font;
+
+ //test a second widget
+ zn2 = new Zinc (ZINC_BACKEND_OPENGL);
+ zn2->setWidth (600);
+ zn2->setHeight (800);
+ zn2->setHeight (400);
+ zn2->setHeight (600);
+ zn2->setTitle("window2");
+ printf("Dimension %d x %d\n",
+ zn2->getWidth(), zn2->getHeight());
+ ZincItem *rect2;
+
+ //something on the 2nd widget
+ rect2 = zn2->itemCreateRectangle (NULL, 100, 100, 100, 100);
+
+ //binding on the 2nd widget directly
+ zn2->focus (rect2);
+ zn2->itemSetFilled (rect2, 1);
+ zn2->itemSetFillcolor (rect2, gradient);
+ zn2->bind (String("<KeyPress-a>"), znCb3, NULL);
+ zn2->bind (String("<KeyPress-a>"), znCb3, NULL,true);
+ zn2->unbind (String("<KeyPress-a>"));
+ zn2->bind (String("<KeyPress-a>"), znCb3, NULL);
+
+ //exception test
+ try
+ {
+ zn->itemSetClip (rect2, rect2);
+ }
+ catch (ZincException &e)
+ {
+ printf("Exception OK SUCCESS %s OK SUCCESS\n", e.what());
+ }
+
+ delete rect;
+ delete rect2;
+ delete g1;
+ delete g2;
+
+ //run all this
+ Zinc::zincMainLoop ();
+
+ // delete the widget
+ delete (zn);
+ }
+ catch (ZincException &e)
+ {
+ printf("ERROR : %s\n",e.what ());
+ }
+ catch (std::exception &e)
+ {
+ printf("STD ERROR : %s\n",e.what ());
+ }
+}