Author: greg.ercolano
Date: 2013-03-27 11:32:41 -0700 (Wed, 27 Mar 2013)
New Revision: 9850
Log:
Added unittest for checking symbol rendering and fl_measure() with symbols.


Added:
   branches/branch-1.3/test/unittest_symbol.cxx
Modified:
   branches/branch-1.3/test/Makefile
   branches/branch-1.3/test/unittests.cxx

Modified: branches/branch-1.3/test/Makefile
===================================================================
--- branches/branch-1.3/test/Makefile   2013-03-26 01:55:01 UTC (rev 9849)
+++ branches/branch-1.3/test/Makefile   2013-03-27 18:32:41 UTC (rev 9850)
@@ -275,7 +275,7 @@
 unittests$(EXEEXT): unittests.o
 
 unittests.o: unittests.cxx unittest_about.cxx unittest_points.cxx 
unittest_lines.cxx unittest_circles.cxx \
-       unittest_rects.cxx unittest_text.cxx unittest_viewport.cxx 
unittest_images.cxx \
+       unittest_rects.cxx unittest_text.cxx unittest_symbol.cxx 
unittest_viewport.cxx unittest_images.cxx \
        unittest_schemes.cxx
 
 adjuster$(EXEEXT): adjuster.o

Added: branches/branch-1.3/test/unittest_symbol.cxx
===================================================================
--- branches/branch-1.3/test/unittest_symbol.cxx                                
(rev 0)
+++ branches/branch-1.3/test/unittest_symbol.cxx        2013-03-27 18:32:41 UTC 
(rev 9850)
@@ -0,0 +1,90 @@
+//
+// "$Id$"
+//
+// Unit tests for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 1998-2010 by Bill Spitzak and others.
+//
+// This library is free software. Distribution and use rights are outlined in
+// the file "COPYING" which should have been included with this file.  If this
+// file is missing or damaged, see the license at:
+//
+//     http://www.fltk.org/COPYING.php
+//
+// Please report all bugs and problems on the following page:
+//
+//     http://www.fltk.org/str.php
+//
+
+#include <FL/Fl_Box.H>
+#include <FL/fl_draw.H>
+
+//
+// Test symbol rendering
+//
+class SymbolTest : public Fl_Widget
+{
+  void DrawTextAndBoxes(const char *txt, int X, int Y) {
+    int wo = 0, ho = 0;
+    fl_measure(txt, wo, ho, 0);
+    // Draw fl_measure() rect
+    fl_color(FL_RED);
+    fl_rect(X, Y, wo, ho);
+    // //////////////////////////////////////////////////////////////////////
+    // NOTE: fl_text_extents() currently does not support multiline strings..
+    //       until it does, let's leave this out, as we do multiline tests..
+    // //////////////////////////////////////////////////////////////////////
+    // // draw fl_text_extents() glyph bounding box
+    // int dx,dy;
+    // fl_text_extents(txt, dx, dy, wo, ho);
+    // fl_color(FL_GREEN);
+    // fl_rect(X+dx, Y+dy, wo, ho);
+    //
+    // Draw text with symbols enabled
+    fl_color(FL_BLACK);
+    fl_draw(txt, X, Y, 10, 10, FL_ALIGN_INSIDE|FL_ALIGN_TOP|FL_ALIGN_LEFT, 0, 
1);
+  }
+public: 
+  static Fl_Widget *create() {
+    return new SymbolTest(TESTAREA_X, TESTAREA_Y, TESTAREA_W, TESTAREA_H);
+  }
+  SymbolTest(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) {}
+  void draw(void) {
+    int x0 = x(); // origin is current window position for Fl_Box
+    int y0 = y();
+    int w0 = w();
+    int h0 = h();
+    fl_push_clip(x0, y0, w0, h0); // reset local clipping
+    {
+      // set the background colour - slightly off-white to enhance the green 
bounding box
+      fl_color(fl_gray_ramp(FL_NUM_GRAY - 3));
+      fl_rectf(x0, y0, w0, h0);
+      int fsize = 30;
+      fl_font(FL_HELVETICA, fsize);
+      int xx = x0+10;
+      int yy = y0+20;
+      DrawTextAndBoxes("Text"            ,xx,yy); yy += fsize+10;
+      DrawTextAndBoxes("@->"             ,xx,yy); yy += fsize+10;
+      DrawTextAndBoxes("@-> "            ,xx,yy); yy += fsize+10;
+      DrawTextAndBoxes("@-> Rt Arrow"    ,xx,yy); yy += fsize+10;
+      DrawTextAndBoxes("@-> Rt/Lt @<-"   ,xx,yy); yy += fsize+10;
+      DrawTextAndBoxes("@@ At/Lt @<-"    ,xx,yy); yy += fsize+10;
+      DrawTextAndBoxes("@-> Lt/At @@"    ,xx,yy); yy += fsize+10;
+      xx = x0+260;
+      yy = y0+10;
+      DrawTextAndBoxes("Line1\nLine2",xx,yy); yy += 100;
+      DrawTextAndBoxes("@-> Line1\nLine2 @<-",xx,yy); yy += 100;
+
+      fl_font(FL_HELVETICA, 14);
+      fl_color(FL_RED);
+      fl_draw("fl_measure bounding box in RED", x0+10,y0+h0-20);
+    }
+    fl_pop_clip(); // remove the local clip
+  }
+};
+
+UnitTest symbolExtents("symbol text", SymbolTest::create);
+
+//
+// End of "$Id$"
+//


Property changes on: branches/branch-1.3/test/unittest_symbol.cxx
___________________________________________________________________
Added: svn:keywords
   + author date id revision
Added: svn:eol-style
   + native

Modified: branches/branch-1.3/test/unittests.cxx
===================================================================
--- branches/branch-1.3/test/unittests.cxx      2013-03-26 01:55:01 UTC (rev 
9849)
+++ branches/branch-1.3/test/unittests.cxx      2013-03-27 18:32:41 UTC (rev 
9850)
@@ -148,6 +148,7 @@
 #include "unittest_rects.cxx"
 #include "unittest_circles.cxx"
 #include "unittest_text.cxx"
+#include "unittest_symbol.cxx"
 #include "unittest_images.cxx"
 #include "unittest_viewport.cxx"
 #include "unittest_scrollbarsize.cxx"

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to