Android: Further testing. Need circle drawing rountines.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12789 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Matthias Melcher 2018-03-23 23:01:13 +00:00
parent aeafea2041
commit d695ccb2d2

View File

@ -89,172 +89,144 @@ int main(int argc, char **argv)
#elif 1
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Value_Slider.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
static const int inactive = 0; // deactivate boxes and use green background
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) { // outline or box_bg or both
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 or box_bg or both
Fl_Group::draw_children();
} // draw()
}; // class BoxGroup
#define W 70
#define H 70
#define ROWS 7
#define COLS 6
Fl_Double_Window *window;
Fl_Value_Slider *orientation;
Fl_Value_Slider *size;
void bt(const char *name, Fl_Boxtype type, int square=0) {
int x = N%4;
int y = N/4;
void slider_cb(Fl_Widget *, void *) {
static char buf[80];
int val = (int)orientation->value();
int sze = (int)size->value();
for (int i = window->children(); i--; ) { // all window children
Fl_Widget *wc = window->child(i);
const char *l = (const char *)(wc->user_data());
if ( l && *l == '@' ) { // all children with '@'
l ++;
if ( wc->box() == FL_NO_BOX ) { // ascii legend?
if (val&&sze) sprintf(buf, "@@%+d%d%s", sze, val, l);
else if (val) sprintf(buf, "@@%d%s", val, l);
else if (sze) sprintf(buf, "@@%+d%s", sze, l);
else sprintf(buf, "@@%s", l);
} else { // box with symbol
if (val&&sze) sprintf(buf, "@%+d%d%s", sze, val, l);
else if (val) sprintf(buf, "@%d%s", val, l);
else if (sze) sprintf(buf, "@%+d%s", sze, l);
else sprintf(buf, "@%s", l);
}
wc->copy_label(buf);
}
}
window->redraw();
}
void bt(const char *name) {
int x = N%COLS;
int y = N/COLS;
char buf[255];
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);
if (inactive) {
b->color(FL_GREEN);
b->deactivate();
}
if (square) b->align(FL_ALIGN_RIGHT);
sprintf(buf, "@%s", name);
Fl_Box *a = new Fl_Box(x,y,W-20,H-20);
a->box(FL_NO_BOX);
a->copy_label(buf);
a->align(FL_ALIGN_BOTTOM);
a->labelsize(11);
a->user_data((void *)name);
Fl_Box *b = new Fl_Box(x,y,W-20,H-20);
b->box(FL_UP_BOX);
b->copy_label(name);
b->labelcolor(FL_DARK3);
b->user_data((void *)name);
}
int main(int argc, char ** argv) {
window = new Fl_Double_Window(-W, 0, 4*W,ROWS*H);
window->box(FL_FLAT_BOX);
#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
Fl::args(argc, argv);
Fl::get_system_colors();
window->color(12);// light blue
#endif
window = new Fl_Double_Window(COLS*W,ROWS*H+60);
bt("@->");
bt("@>");
bt("@>>");
bt("@>|");
bt("@>[]");
bt("@|>");
bt("@<-");
bt("@<");
bt("@<<");
bt("@|<");
bt("@[]<");
bt("@<|");
bt("@<->");
bt("@-->");
bt("@+");
bt("@->|");
bt("@||");
bt("@<|");
bt("@<->");
bt("@-->");
bt("@+");
bt("@->|");
bt("@||");
bt("@arrow");
bt("@returnarrow");
bt("@square");
bt("@circle");
bt("@line");
bt("@menu");
bt("@UpArrow");
bt("@DnArrow");
bt("@search");
bt("@FLTK");
bt("@filenew");
bt("@fileopen");
bt("@filesave");
bt("@filesaveas");
bt("@fileprint");
bt("@refresh");
bt("@reload");
bt("@undo");
bt("@redo");
// set window title to show active scheme
Fl::scheme(Fl::scheme()); // init scheme
char title[100];
sprintf(title,"FLTK boxtypes: scheme = '%s'",Fl::scheme()?Fl::scheme():"none");
window->label(title);
orientation = new Fl_Value_Slider(
(int)(window->w()*.05+.5), window->h()-40,
(int)(window->w()*.42+.5), 16, "Orientation");
orientation->type(FL_HORIZONTAL);
orientation->range(0.0, 9.0);
orientation->value(0.0);
orientation->step(1);
orientation->callback(slider_cb, 0);
// create special container group for box size debugging
BoxGroup *bg = new BoxGroup(0,0,window->w(),window->h());
bg->box(FL_NO_BOX);
size = new Fl_Value_Slider(
(int)(window->w()*.53+.5), window->h()-40,
(int)(window->w()*.42+.5), 16, "Size");
size->type(FL_HORIZONTAL);
size->range(-3.0, 9.0);
size->value(0.0);
size->step(1);
size->callback(slider_cb, 0);
// 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
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);
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);
bt("FL_PLASTIC_THIN_UP_BOX",FL_PLASTIC_THIN_UP_BOX);
bt("FL_PLASTIC_THIN_DOWN_BOX",FL_PLASTIC_THIN_DOWN_BOX);
N += 2;
bt("FL_PLASTIC_ROUND_UP_BOX",FL_PLASTIC_ROUND_UP_BOX);
bt("FL_PLASTIC_ROUND_DOWN_BOX",FL_PLASTIC_ROUND_DOWN_BOX);
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);
bg->end();
window->resizable(window);
window->end();
window->show();
window->show(argc,argv);
return Fl::run();
}
#else
#include <src/drivers/Android/Fl_Android_Application.H>
@ -384,17 +356,21 @@ int xmain(int argc, char **argv)
* proportions: pixels should be square
Need Work:
- Fl_Android_Graphics_Driver::pie(int) needs refactoring
- ...::line(...) has round ing issues (see rounded box type)
test/CubeMain.cxx test/line_style.cxx
test/CubeView.cxx test/list_visuals.cxx
test/adjuster.cxx test/mandelbrot.cxx
* test/adjuster.cxx : - missing bitmap drawing
test/mandelbrot.cxx
test/animated.cxx test/menubar.cxx
* test/arc.cxx : + 'arc' works as expected
test/message.cxx
test/ask.cxx test/minimum.cxx
test/ask.cxx
* test/minimum.cxx : + 'minimum' works
test/bitmap.cxx test/native-filechooser.cxx
test/blocks.cxx test/navigation.cxx
* test/boxtype.cxx : !! 'boxtype': must fix diamond box, plastic up frame, see fourth column
* test/boxtype.cxx : + 'boxtype': works
test/offscreen.cxx
test/browser.cxx test/output.cxx
test/button.cxx test/overlay.cxx
@ -407,7 +383,8 @@ test/color_chooser.cxx test/scroll.cxx
test/connect.cxx test/shape.cxx
test/cube.cxx test/subwindow.cxx
test/cursor.cxx test/sudoku.cxx
test/curve.cxx test/symbols.cxx
test/curve.cxx
* test/symbols.cxx : !! working this out: implement circle drawing
test/demo.cxx test/table.cxx
test/device.cxx test/threads.cxx
test/doublebuffer.cxx test/tile.cxx
@ -420,7 +397,7 @@ test/fracviewer.cxx test/unittest_lines.cxx
test/fullscreen.cxx test/unittest_points.cxx
test/gl_overlay.cxx test/unittest_rects.cxx
test/glpuzzle.cxx test/unittest_schemes.cxx
test/hello.cxx : + 'hello' works fine, italics, shadow, etc.
* test/hello.cxx : + 'hello' works fine, italics, shadow, etc.
test/unittest_scrollbarsize.cxx
test/help_dialog.cxx test/unittest_simple_terminal.cxx
test/icon.cxx test/unittest_symbol.cxx