1998-10-20 17:25:25 +04:00
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// "$Id$"
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|
|
|
|
// Boxtype test program for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2015-01-31 18:43:53 +03:00
|
|
|
// Copyright 1998-2015 by Bill Spitzak and others.
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// 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
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <FL/Fl.H>
|
2007-02-08 10:58:47 +03:00
|
|
|
#include <FL/Fl_Double_Window.H>
|
1998-10-06 22:21:25 +04:00
|
|
|
#include <FL/Fl_Box.H>
|
2015-01-31 18:43:53 +03:00
|
|
|
#include <FL/fl_draw.H>
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
int N = 0;
|
2003-05-19 02:12:24 +04:00
|
|
|
#define W 200
|
1998-10-06 22:21:25 +04:00
|
|
|
#define H 50
|
2006-10-03 06:35:12 +04:00
|
|
|
#define ROWS 14
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2015-01-31 18:43:53 +03:00
|
|
|
// 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
|
2015-07-09 02:41:19 +03:00
|
|
|
static const int inactive = 0; // deactivate boxes and use green background
|
2015-01-31 18:43:53 +03:00
|
|
|
|
|
|
|
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();
|
2015-07-09 02:41:19 +03:00
|
|
|
if (outline + box_bg) { // outline or box_bg or both
|
2015-01-31 18:43:53 +03:00
|
|
|
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);
|
|
|
|
}
|
2015-07-09 02:41:19 +03:00
|
|
|
} // outline or box_bg or both
|
2015-01-31 18:43:53 +03:00
|
|
|
Fl_Group::draw_children();
|
|
|
|
} // draw()
|
|
|
|
}; // class BoxGroup
|
|
|
|
|
2009-04-21 13:09:37 +04:00
|
|
|
Fl_Double_Window *window;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
void bt(const char *name, Fl_Boxtype type, int square=0) {
|
|
|
|
int x = N%4;
|
|
|
|
int y = N/4;
|
|
|
|
N++;
|
|
|
|
x = x*W+10;
|
|
|
|
y = y*H+10;
|
|
|
|
Fl_Box *b = new Fl_Box(type,x,y,square ? H-20 : W-20,H-20,name);
|
|
|
|
b->labelsize(11);
|
2015-07-09 02:41:19 +03:00
|
|
|
if (inactive) {
|
|
|
|
b->color(FL_GREEN);
|
|
|
|
b->deactivate();
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
if (square) b->align(FL_ALIGN_RIGHT);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
2007-02-08 10:58:47 +03:00
|
|
|
window = new Fl_Double_Window(4*W,ROWS*H);
|
1998-10-06 22:21:25 +04:00
|
|
|
window->box(FL_FLAT_BOX);
|
2005-11-02 16:57:56 +03:00
|
|
|
#if 0 // this code uses the command line arguments to set arbitrary color schemes
|
|
|
|
Fl::args(argc, argv);
|
|
|
|
Fl::get_system_colors();
|
|
|
|
#elif 0 // this code uses a single color to define a scheme
|
|
|
|
Fl::args(argc, argv);
|
|
|
|
Fl::get_system_colors();
|
|
|
|
Fl::background(113,113,198);
|
|
|
|
#else // this code uses the nice bright blue background to show box vs. frame types
|
2006-12-22 01:39:11 +03:00
|
|
|
Fl::args(argc, argv);
|
2005-11-02 16:57:56 +03:00
|
|
|
Fl::get_system_colors();
|
1998-10-06 22:21:25 +04:00
|
|
|
window->color(12);// light blue
|
2005-11-02 16:57:56 +03:00
|
|
|
#endif
|
2015-01-31 18:43:53 +03:00
|
|
|
|
|
|
|
// set window title to show active scheme
|
2015-02-09 21:04:31 +03:00
|
|
|
Fl::scheme(Fl::scheme()); // init scheme
|
2015-01-31 18:43:53 +03:00
|
|
|
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
|
1998-10-06 22:21:25 +04:00
|
|
|
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
|
|
|
|
bt("FL_UP_BOX",FL_UP_BOX);
|
|
|
|
bt("FL_DOWN_BOX",FL_DOWN_BOX);
|
|
|
|
bt("FL_UP_FRAME",FL_UP_FRAME);
|
|
|
|
bt("FL_DOWN_FRAME",FL_DOWN_FRAME);
|
|
|
|
bt("FL_THIN_UP_BOX",FL_THIN_UP_BOX);
|
|
|
|
bt("FL_THIN_DOWN_BOX",FL_THIN_DOWN_BOX);
|
|
|
|
bt("FL_THIN_UP_FRAME",FL_THIN_UP_FRAME);
|
|
|
|
bt("FL_THIN_DOWN_FRAME",FL_THIN_DOWN_FRAME);
|
|
|
|
bt("FL_ENGRAVED_BOX",FL_ENGRAVED_BOX);
|
|
|
|
bt("FL_EMBOSSED_BOX",FL_EMBOSSED_BOX);
|
|
|
|
bt("FL_ENGRAVED_FRAME",FL_ENGRAVED_FRAME);
|
|
|
|
bt("FL_EMBOSSED_FRAME",FL_EMBOSSED_FRAME);
|
|
|
|
bt("FL_BORDER_BOX",FL_BORDER_BOX);
|
|
|
|
bt("FL_SHADOW_BOX",FL_SHADOW_BOX);
|
|
|
|
bt("FL_BORDER_FRAME",FL_BORDER_FRAME);
|
|
|
|
bt("FL_SHADOW_FRAME",FL_SHADOW_FRAME);
|
|
|
|
bt("FL_ROUNDED_BOX",FL_ROUNDED_BOX);
|
|
|
|
bt("FL_RSHADOW_BOX",FL_RSHADOW_BOX);
|
|
|
|
bt("FL_ROUNDED_FRAME",FL_ROUNDED_FRAME);
|
|
|
|
bt("FL_RFLAT_BOX",FL_RFLAT_BOX);
|
|
|
|
bt("FL_OVAL_BOX",FL_OVAL_BOX);
|
|
|
|
bt("FL_OSHADOW_BOX",FL_OSHADOW_BOX);
|
|
|
|
bt("FL_OVAL_FRAME",FL_OVAL_FRAME);
|
|
|
|
bt("FL_OFLAT_BOX",FL_OFLAT_BOX);
|
|
|
|
bt("FL_ROUND_UP_BOX",FL_ROUND_UP_BOX);
|
|
|
|
bt("FL_ROUND_DOWN_BOX",FL_ROUND_DOWN_BOX);
|
|
|
|
bt("FL_DIAMOND_UP_BOX",FL_DIAMOND_UP_BOX);
|
|
|
|
bt("FL_DIAMOND_DOWN_BOX",FL_DIAMOND_DOWN_BOX);
|
2006-10-03 06:35:12 +04:00
|
|
|
|
2001-11-29 00:37:35 +03:00
|
|
|
bt("FL_PLASTIC_UP_BOX",FL_PLASTIC_UP_BOX);
|
|
|
|
bt("FL_PLASTIC_DOWN_BOX",FL_PLASTIC_DOWN_BOX);
|
|
|
|
bt("FL_PLASTIC_UP_FRAME",FL_PLASTIC_UP_FRAME);
|
|
|
|
bt("FL_PLASTIC_DOWN_FRAME",FL_PLASTIC_DOWN_FRAME);
|
2003-05-19 02:12:24 +04:00
|
|
|
bt("FL_PLASTIC_THIN_UP_BOX",FL_PLASTIC_THIN_UP_BOX);
|
|
|
|
bt("FL_PLASTIC_THIN_DOWN_BOX",FL_PLASTIC_THIN_DOWN_BOX);
|
2006-08-15 02:42:46 +04:00
|
|
|
N += 2;
|
|
|
|
bt("FL_PLASTIC_ROUND_UP_BOX",FL_PLASTIC_ROUND_UP_BOX);
|
|
|
|
bt("FL_PLASTIC_ROUND_DOWN_BOX",FL_PLASTIC_ROUND_DOWN_BOX);
|
2006-10-03 06:35:12 +04:00
|
|
|
N += 2;
|
|
|
|
|
|
|
|
bt("FL_GTK_UP_BOX",FL_GTK_UP_BOX);
|
|
|
|
bt("FL_GTK_DOWN_BOX",FL_GTK_DOWN_BOX);
|
|
|
|
bt("FL_GTK_UP_FRAME",FL_GTK_UP_FRAME);
|
|
|
|
bt("FL_GTK_DOWN_FRAME",FL_GTK_DOWN_FRAME);
|
|
|
|
bt("FL_GTK_THIN_UP_BOX",FL_GTK_THIN_UP_BOX);
|
|
|
|
bt("FL_GTK_THIN_DOWN_BOX",FL_GTK_THIN_DOWN_BOX);
|
|
|
|
bt("FL_GTK_THIN_UP_FRAME",FL_GTK_THIN_UP_FRAME);
|
|
|
|
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);
|
2015-01-31 18:43:53 +03:00
|
|
|
bg->end();
|
1998-10-06 22:21:25 +04:00
|
|
|
window->resizable(window);
|
|
|
|
window->end();
|
2003-05-19 02:12:24 +04:00
|
|
|
window->show();
|
1998-10-06 22:21:25 +04:00
|
|
|
return Fl::run();
|
|
|
|
}
|
1998-10-20 17:25:25 +04:00
|
|
|
|
|
|
|
//
|
2005-02-25 00:55:12 +03:00
|
|
|
// End of "$Id$".
|
1998-10-20 17:25:25 +04:00
|
|
|
//
|