2 // "$Id: unittest_rects.cxx 7913 2010-11-29 18:18:27Z greg.ercolano $"
4 // Unit tests for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 #include <FL/Fl_Box.H>
29 #include <FL/fl_draw.H> // fl_text_extents()
32 //------- test the rectangle drawing capabilities of this implementation ----------
34 class RectTest
: public Fl_Box
{
36 static Fl_Widget
*create() {
37 return new RectTest(TESTAREA_X
, TESTAREA_Y
, TESTAREA_W
, TESTAREA_H
);
39 RectTest(int x
, int y
, int w
, int h
) : Fl_Box(x
, y
, w
, h
) {
40 label("testing the fl_rect call\n"
41 "No red pixels should be visible. "
42 "If you see bright red lines, or if parts of the green frames are hidden, "
43 "the rect drawing alignment is off.");
44 align(FL_ALIGN_INSIDE
|FL_ALIGN_BOTTOM
|FL_ALIGN_LEFT
|FL_ALIGN_WRAP
);
49 int a
= x()+10, b
= y()+10; fl_color(FL_BLACK
); fl_rect(a
, b
, 100, 100);
50 // testing fl_rect() with positive size
51 fl_color(FL_RED
); fl_loop(a
+10, b
+10, a
+40, b
+10, a
+40, b
+40, a
+10, b
+40);
52 fl_color(FL_GREEN
); fl_loop(a
+ 9, b
+ 9, a
+41, b
+ 9, a
+41, b
+41, a
+ 9, b
+41);
53 fl_color(FL_GREEN
); fl_loop(a
+11, b
+11, a
+39, b
+11, a
+39, b
+39, a
+11, b
+39);
54 fl_color(FL_BLACK
); fl_rect(a
+10, b
+10, 31, 31);
55 // testing fl_rect() with positive size
56 fl_color(FL_RED
); fl_loop(a
+60, b
+60, a
+90, b
+60, a
+90, b
+90, a
+60, b
+90);
57 fl_color(FL_GREEN
); fl_loop(a
+59, b
+59, a
+91, b
+59, a
+91, b
+91, a
+59, b
+91);
58 fl_color(FL_BLACK
); fl_rectf(a
+60, b
+60, 31, 31);
62 UnitTest
rects("rectangles", RectTest::create
);
65 // End of "$Id: unittest_rects.cxx 7913 2010-11-29 18:18:27Z greg.ercolano $"