summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2015-01-31 15:43:53 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2015-01-31 15:43:53 +0000
commita02e892b0169161017733efe5adc8f7708022512 (patch)
tree9eb8d241ef633efadafa2d14d081080595485475 /test
parent8887600f5fcd31cf67a38bffee68d2f876cb3b84 (diff)
Improve test/boxtype demo program to help boxtype debugging.
(1) Set window title to reflect current scheme. (2) Add class BoxGroup to show a red frame around each box and/or a white box background. Both features are disabled though. Edit the source file to enable. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10546 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
-rw-r--r--test/boxtype.cxx61
1 files changed, 60 insertions, 1 deletions
diff --git a/test/boxtype.cxx b/test/boxtype.cxx
index 9f570a3e8..26a7f61e0 100644
--- a/test/boxtype.cxx
+++ b/test/boxtype.cxx
@@ -3,7 +3,7 @@
//
// Boxtype test program for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2015 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
@@ -21,12 +21,59 @@
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
+#include <FL/fl_draw.H>
int N = 0;
#define W 200
#define H 50
#define ROWS 14
+// Note: Run the program with command line '-s abc' to view boxtypes
+// with scheme 'abc'.
+
+// class BoxGroup - minimal class to enable visible box size debugging
+//
+// Set the following static variables to 0 (default) to disable
+// or 1 to enable the given feature.
+//
+// If you enable the 'outline' variable, then a red frame should be drawn
+// around each box, and it should ideally be fully visible.
+//
+// The white background is optional (otherwise you see the window background).
+//
+// Set BOTH variables = 0 to show the default image for the FLTK manual.
+//
+// Note: As of FLTK 1.3.3 (probably since FLTK 1.0/1.1) there are some
+// shadows 'leaking' outside their widget bounding boxes (x,y,w,h).
+// Is this intentional?
+
+static const int outline = 0; // draw 1-px red frame around all boxes
+static const int box_bg = 0; // draw white background inside all boxes
+
+class BoxGroup : public Fl_Group {
+ public:
+ BoxGroup(int x, int y, int w, int h) : Fl_Group(x,y,w,h) {};
+ void draw() {
+ draw_box();
+ if (outline||box_bg) {
+ Fl_Widget*const* a = array();
+ for (int i=children(); i--;) {
+ Fl_Widget& o = **a++;
+ if (outline) {
+ fl_color(FL_RED);
+ fl_rect(o.x()-1,o.y()-1,o.w()+2,o.h()+2);
+ }
+ if (box_bg) {
+ fl_color(FL_WHITE);
+ fl_rectf(o.x(),o.y(),o.w(),o.h());
+ }
+ fl_color(FL_BLACK);
+ }
+ } // outline || box_bg
+ Fl_Group::draw_children();
+ } // draw()
+}; // class BoxGroup
+
Fl_Double_Window *window;
void bt(const char *name, Fl_Boxtype type, int square=0) {
@@ -55,6 +102,17 @@ int main(int argc, char ** argv) {
Fl::get_system_colors();
window->color(12);// light blue
#endif
+
+ // set window title to show active scheme
+ char title[100];
+ sprintf(title,"FLTK boxtypes: scheme = '%s'",Fl::scheme()?Fl::scheme():"none");
+ window->label(title);
+
+ // create special container group for box size debugging
+ BoxGroup *bg = new BoxGroup(0,0,window->w(),window->h());
+ bg->box(FL_NO_BOX);
+
+ // create demo boxes
bt("FL_NO_BOX",FL_NO_BOX);
bt("FL_FLAT_BOX",FL_FLAT_BOX);
N += 2; // go to start of next row to line up boxes & frames
@@ -108,6 +166,7 @@ int main(int argc, char ** argv) {
bt("FL_GTK_THIN_DOWN_FRAME",FL_GTK_THIN_DOWN_FRAME);
bt("FL_GTK_ROUND_UP_BOX",FL_GTK_ROUND_UP_BOX);
bt("FL_GTK_ROUND_DOWN_BOX",FL_GTK_ROUND_DOWN_BOX);
+ bg->end();
window->resizable(window);
window->end();
window->show();