Author: greg.ercolano
Date: 2009-04-02 01:18:24 -0700 (Thu, 02 Apr 2009)
New Revision: 6738
Log:
Rework of the unittests.cxx program, as per discussions
in fltk.dev:

        Subject: New unittest app suggestion -- RFC



Modified:
   branches/branch-1.3/test/unittests.cxx

Modified: branches/branch-1.3/test/unittests.cxx
===================================================================
--- branches/branch-1.3/test/unittests.cxx      2009-04-02 06:44:34 UTC (rev 
6737)
+++ branches/branch-1.3/test/unittests.cxx      2009-04-02 08:18:24 UTC (rev 
6738)
@@ -1,29 +1,3 @@
-//
-// "$Id$"
-//
-// Unit tests for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 1998-2009 by Bill Spitzak and others.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-//
-// Please report all bugs and problems on the following page:
-//
-//     http://www.fltk.org/str.php
-//
 // Fltk unit tests
 // v0.1 - Greg combines Matthias + Ian's tests
 // v0.2 - Ian's 02/12/09 fixes applied
@@ -105,15 +79,15 @@
     fl_color(FL_BLACK); fl_pie(a+55, b+65, 31, 31, 150.0, 300.0);
     //---- oval testing (horizontal squish)
     a +=120; b += 0; fl_color(FL_BLACK); fl_rect(a, b, 100, 100);
-    fl_color(FL_GREEN);
+    fl_color(FL_GREEN); 
     fl_rect(a+19, b+9, 63, 33); fl_rect(a+19, b+59, 63, 33);
-    fl_color(FL_BLACK);
+    fl_color(FL_BLACK); 
     fl_arc(a+20, b+10, 61, 31, 0, 360); fl_pie(a+20, b+60, 61, 31, 0, 360);
     //---- oval testing (horizontal squish)
     a += 120; b += 0; fl_color(FL_BLACK); fl_rect(a, b, 100, 100);
-    fl_color(FL_GREEN);
-    fl_rect(a+9, b+19, 33, 63); fl_rect(a+59, b+19, 33, 63);
-    fl_color(FL_BLACK);
+    fl_color(FL_GREEN); 
+    fl_rect(a+9, b+19, 33, 63); fl_rect(a+59, b+19, 33, 63);    
+    fl_color(FL_BLACK); 
     fl_arc(a+10, b+20, 31, 61, 0, 360); fl_pie(a+60, b+20, 31, 61, 0, 360);
   }
 };
@@ -147,7 +121,7 @@
   void draw() {
     Fl_Box::draw();
     int a = x()+10, b = y()+10; fl_color(FL_BLACK); fl_rect(a, b, 90, 90);
-    fl_point(a+10, b+10); fl_point(a+20, b+20);
+    fl_point(a+10, b+10); fl_point(a+20, b+20); 
     fl_point(a+10, b+20); fl_point(a+20, b+10);
     fl_color(FL_RED); a = x()+70;
     fl_point(a+10, b+10); fl_point(a+20, b+20);
@@ -339,9 +313,11 @@
 class TextExtentsTest : public Fl_Widget
 {
   void DrawTextAndBoxes(const char *txt, int X, int Y) {
+//ALBRECHT    // draw text
+//ALBRECHT    fl_color(FL_BLACK);
+//ALBRECHT    fl_draw(txt, X, Y);
     int wo = 0, ho = 0;
     int dx, dy;
-       // First, we draw the bounding boxes (fl_measure and fl_text_extents)
     // draw fl_measure() typographical bounding box
     fl_measure(txt, wo, ho, 0);
     int desc = fl_descent();
@@ -349,11 +325,12 @@
     fl_rect(X, Y-ho+desc, wo, ho);
     // draw fl_text_extents() glyph bounding box
     fl_text_extents(txt, dx, dy, wo, ho);
-    fl_color(FL_GREEN);
+//ALBRECHT    fl_color(FL_BLUE);
+    fl_color(FL_GREEN);                        // ALBRECHT
     fl_rect(X+dx, Y+dy, wo, ho);
-    // Then we draw the text to show how it fits insode each of the two boxes
-    fl_color(FL_BLACK);
-    fl_draw(txt, X, Y);
+    // draw text                       // ALBRECHT
+    fl_color(FL_BLACK);                        // ALBRECHT
+    fl_draw(txt, X, Y);                        // ALBRECHT
   }
 public: TextExtentsTest(int x, int y, int w, int h) : Fl_Widget(x, y, w, h) {}
   void draw(void) {
@@ -363,13 +340,13 @@
     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));
+      // set the background colour
+      fl_color(FL_WHITE);
       fl_rectf(x0, y0, w0, h0);
 
       fl_font(FL_HELVETICA, 30);
-      int xx = x0+55;
-      int yy = y0+40;
+      int xx = x()+55;
+      int yy = y()+40;
       DrawTextAndBoxes("!abcdeABCDE\"#A", xx, yy); yy += 50;   // mixed string
       DrawTextAndBoxes("oacs",     xx, yy); xx += 100;         // small glyphs
       DrawTextAndBoxes("qjgIPT",   xx, yy); yy += 50; xx -= 100;       // 
glyphs with descenders
@@ -379,13 +356,8 @@
 
       fl_font(FL_HELVETICA, 14);
       fl_color(FL_RED);  fl_draw("fl_measure bounding box in RED",       xx, 
yy); yy += 20;
-      fl_color(FL_GREEN); fl_draw("fl_text_extents bounding box in GREEN", xx, 
yy);
-      fl_color(FL_BLACK);
-      xx = x0 + 10;  yy += 30;
-      fl_draw("NOTE: On systems with text anti-aliasing (e.g. OSX Quartz)", 
xx, yy);
-      w0 = h0 = 0; fl_measure("NOTE: ", w0, h0, 0);
-      xx += w0; yy += h0;
-      fl_draw("text may leach slightly outside the fl_text_extents()", xx, yy);
+//ALBRECHT      fl_color(FL_BLUE); fl_draw("fl_text_extents bounding box in 
BLUE", xx, yy); yy += 20;
+      fl_color(FL_GREEN); fl_draw("fl_text_extents bounding box in GREEN", xx, 
yy); yy += 20;  //ALBRECHT
     }
     fl_pop_clip(); // remove the local clip
   }
@@ -506,7 +478,3 @@
   Browser_CB(browser,0);
   return(Fl::run());
 }
-
-//
-// End of "$Id$".
-//

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

Reply via email to