summaryrefslogtreecommitdiff
path: root/test/device.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'test/device.cxx')
-rw-r--r--test/device.cxx177
1 files changed, 85 insertions, 92 deletions
diff --git a/test/device.cxx b/test/device.cxx
index e242f6ae6..e922a77cd 100644
--- a/test/device.cxx
+++ b/test/device.cxx
@@ -1,6 +1,4 @@
//
-// "$Id$"
-//
// Device test program for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2020 by Roman Kantor and others.
@@ -9,11 +7,11 @@
// 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
+// https://www.fltk.org/COPYING.php
//
-// Please report all bugs and problems on the following page:
+// Please see the following page on how to report bugs and issues:
//
-// http://www.fltk.org/str.php
+// https://www.fltk.org/bugs.php
//
#include <math.h>
@@ -118,7 +116,7 @@ protected:
fl_color(FL_YELLOW);
fl_rectf(x()+7,y()+7,w()-14,h()-14);
fl_color(FL_BLUE);
-
+
fl_rect(x()+8,y()+8,w()-16,h()-16);
fl_push_clip(x()+25,y()+25,w()-50, h()-50);
fl_color(FL_BLACK);
@@ -127,7 +125,7 @@ protected:
fl_line(x()+27,y()+h()-27,x()+w()-27,y()+27);
//fl_rect(x()+30,y()+30,w()-60,h()-60);
fl_pop_clip();
-
+
}
public:
MyWidget(int x, int y):Fl_Box(x,y,100,100, "Clipping and rect(f):\nYellow rect.framed\nby B-Y-G-R rect. 1 p.\nthick. Your printer may \nrender very thin lines\nsurrounding \"X\""){
@@ -146,13 +144,13 @@ protected:
for(d=y()+5;d<48+y();d+=2){
fl_xyline(x()+5,d,x()+48);
}
-
+
fl_push_clip(x()+52,y()+5,45,43);
for(d=y()+5;d<150+y();d+=3){
fl_line(x()+52,d,x()+92,d-40);
}
fl_pop_clip();
-
+
fl_line_style(FL_DASH);
fl_xyline(x()+5,y()+55,x()+48);
fl_line_style(FL_DOT);
@@ -163,39 +161,39 @@ protected:
fl_xyline(x()+5,y()+64,x()+48);
fl_line_style(0,0,(char*)"\7\3\7\2");
fl_xyline(x()+5,y()+67,x()+48);
-
+
fl_line_style(0);
-
+
fl_line(x()+5,y()+72,x()+25,y()+95);
fl_line(x()+8,y()+72,x()+28,y()+95,x()+31,y()+72);
-
+
fl_color(FL_YELLOW);
fl_polygon(x()+11, y()+72,x()+27,y()+91,x()+29,y()+72);
fl_color(FL_RED);
fl_loop(x()+11, y()+72,x()+27,y()+91,x()+29,y()+72);
-
+
fl_color(FL_BLUE); ////
fl_line_style(FL_SOLID, 6);
fl_loop(x()+31, y()+12,x()+47,y()+31,x()+49,y()+12);
fl_line_style(0);
-
+
fl_color(200,0,200);
fl_polygon(x()+35,y()+72,x()+33,y()+95,x()+48,y()+95,x()+43,y()+72);
fl_color(FL_GREEN);
fl_loop(x()+35,y()+72,x()+33,y()+95,x()+48,y()+95,x()+43,y()+72);
-
- fl_color(FL_BLUE);
+
+ fl_color(FL_BLUE);
fl_yxline(x()+65,y()+63,y()+66);
- fl_color(FL_GREEN);
+ fl_color(FL_GREEN);
fl_yxline(x()+66,y()+66,y()+63);
-
+
fl_color(FL_BLUE);
fl_rect(x()+80,y()+55,5,5);
fl_color(FL_YELLOW);
fl_rectf(x()+81,y()+56,3,3);
fl_color(FL_BLACK);
fl_point(x()+82,y()+57);
-
+
fl_color(FL_BLUE);
fl_rect(x()+56, y()+79, 24, 17);
fl_color(FL_CYAN);
@@ -204,9 +202,9 @@ protected:
fl_arc(x()+57, y()+80, 22 ,15 ,40, 270);
fl_color(FL_YELLOW);
fl_pie(x()+58, y()+81, 20 ,13 ,40, 270);
-
+
fl_line_style(0);
-
+
fl_color(FL_BLACK);
fl_point(x()+58,y()+58);
fl_color(FL_RED);
@@ -217,7 +215,7 @@ protected:
fl_xyline(x()+61,y()+58,x()+62);
fl_color(FL_RED);
fl_xyline(x()+62,y()+59,x()+61);
-
+
fl_color(FL_GREEN);
fl_yxline(x()+57,y()+58,y()+59,x()+58);
fl_color(FL_BLUE);
@@ -226,15 +224,15 @@ protected:
fl_xyline(x()+58,y()+61,x()+56,y()+63);
fl_color(FL_GREEN);
fl_yxline(x()+57,y()+63,y()+62,x()+58);
-
+
fl_color(FL_BLUE);
fl_line(x()+58,y()+63, x()+60, y()+65);
fl_color(FL_BLACK);
fl_line(x()+61,y()+65, x()+59, y()+63);
-
+
fl_color(FL_BLACK);
};
-
+
public:
MyWidget2(int x, int y):Fl_Box(x,y,100,100, "Integer primitives"){
labelsize(10);
@@ -257,7 +255,7 @@ protected:
fl_end_line();
}
fl_pop_clip();
-
+
fl_push_clip(x()+52,y()+5,45,43);
for(d=y()+5;d<150+y();d+=2.3052){
fl_begin_line();
@@ -266,7 +264,7 @@ protected:
fl_end_line();
}
fl_pop_clip();
-
+
};
public:
MyWidget3(int x, int y):Fl_Box(x,y,100,100, "Sub-pixel drawing of\nlines 1.63 points apart\nOn the screen you\ncan see aliasing, the\nprinter should render\nthem properly"){
@@ -284,7 +282,7 @@ protected:
fl_push_matrix();
fl_translate(x(),y());
fl_scale(.75,.75);
-
+
fl_line_style(FL_SOLID , 5);
fl_begin_line();
fl_vertex(10, 160);
@@ -301,8 +299,8 @@ protected:
fl_vertex(50, 190);
fl_end_line();
fl_line_style(0);
-
- fl_color(FL_GREEN);
+
+ fl_color(FL_GREEN);
fl_line_style(FL_SOLID | FL_CAP_ROUND |FL_JOIN_ROUND , 5);
fl_begin_line();
fl_vertex(10, 140);
@@ -310,7 +308,7 @@ protected:
fl_vertex(60, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_BLUE);
fl_line_style(FL_SOLID | FL_CAP_SQUARE |FL_JOIN_BEVEL , 5);
fl_begin_line();
@@ -319,7 +317,7 @@ protected:
fl_vertex(70, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_BLACK);
fl_line_style(FL_DASH , 5);
fl_begin_line();
@@ -328,7 +326,7 @@ protected:
fl_vertex(80, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_RED);
fl_line_style(FL_DASH |FL_CAP_FLAT , 5);
fl_begin_line();
@@ -337,7 +335,7 @@ protected:
fl_vertex(90, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_GREEN);
fl_line_style(FL_DASH |FL_CAP_ROUND , 5);
fl_begin_line();
@@ -346,8 +344,8 @@ protected:
fl_vertex(100, 190);
fl_end_line();
fl_line_style(0);
-
-
+
+
fl_color(FL_BLUE);
fl_line_style(FL_DASH |FL_CAP_SQUARE , 5);
fl_begin_line();
@@ -356,7 +354,7 @@ protected:
fl_vertex(110, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_BLACK);
fl_line_style(FL_DOT, 5);
fl_begin_line();
@@ -365,7 +363,7 @@ protected:
fl_vertex(120, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_RED);
fl_line_style(FL_DOT | FL_CAP_FLAT, 5);
fl_begin_line();
@@ -374,7 +372,7 @@ protected:
fl_vertex(130, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_GREEN);
fl_line_style(FL_DOT | FL_CAP_ROUND, 5);
fl_begin_line();
@@ -383,7 +381,7 @@ protected:
fl_vertex(140, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_BLUE);
fl_line_style(FL_DOT | FL_CAP_SQUARE, 5);
fl_begin_line();
@@ -392,7 +390,7 @@ protected:
fl_vertex(150, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_BLACK);
fl_line_style(FL_DASHDOT |FL_CAP_ROUND |FL_JOIN_ROUND , 5);
fl_begin_line();
@@ -401,7 +399,7 @@ protected:
fl_vertex(160, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_RED);
fl_line_style(FL_DASHDOTDOT |FL_CAP_SQUARE |FL_JOIN_BEVEL , 5);
fl_begin_line();
@@ -410,8 +408,8 @@ protected:
fl_vertex(170, 190);
fl_end_line();
fl_line_style(0);
-
-
+
+
fl_color(FL_GREEN);
fl_line_style(FL_DASHDOTDOT |FL_CAP_ROUND |FL_JOIN_ROUND , 5);
fl_begin_line();
@@ -420,18 +418,18 @@ protected:
fl_vertex(180, 190);
fl_end_line();
fl_line_style(0);
-
+
fl_color(FL_BLUE);
fl_line_style(0, 5, (char*)"\12\3\4\2\2\1");
fl_begin_line();
fl_vertex(10, 10);
fl_vertex(190, 10);
fl_vertex(190, 190);
-
+
fl_end_line();
fl_line_style(0);
- fl_pop_matrix();
-
+ fl_pop_matrix();
+
fl_color(FL_BLACK);
};
public:
@@ -447,7 +445,7 @@ protected:
void draw(){
Fl_Box::draw();
fl_push_matrix();
-
+
fl_translate(x(),y());
fl_push_matrix();
fl_mult_matrix(1,3,0,1,0,-20);
@@ -457,39 +455,39 @@ protected:
fl_vertex(100,-80);
fl_vertex(100,-190);
fl_end_polygon();
-
+
fl_color(FL_RED);
fl_line_style(FL_DASHDOT, 7);
fl_begin_loop();
-
+
fl_vertex(10,10);
fl_vertex(100,-80);
fl_vertex(100,-190);
fl_end_loop();
fl_line_style(0);
-
+
fl_color(FL_BLUE);
fl_line_style(FL_SOLID, 3);
fl_begin_loop();
fl_circle(60,-50,30);
fl_end_loop();
fl_line_style(0);
-
+
fl_pop_matrix();
fl_scale(1.8,1);
-
+
fl_color(FL_YELLOW);
fl_begin_polygon();
fl_arc(30,90,20,-45,200);
fl_end_polygon();
-
+
fl_color(FL_BLACK);
fl_line_style(FL_DASH, 3);
fl_begin_line();
fl_arc(30,90,20,-45,200);
fl_end_line();
fl_line_style(0);
-
+
fl_translate(15,0);
fl_scale(1.5,3);
fl_begin_complex_polygon();
@@ -507,7 +505,7 @@ protected:
fl_vertex(40,10);
fl_vertex(35,20);
fl_end_complex_polygon();
-
+
fl_pop_matrix();
};
public:
@@ -530,12 +528,12 @@ void make_image() {
for (int x = 0; x < width; x++) {
double X = double(x)/(width-1);
*p++ = uchar(255*((1-X)*(1-Y))); // red in upper-left
- *p++ = uchar(255*((1-X)*Y)); // green in lower-left
- *p++ = uchar(255*(X*Y)); // blue in lower-right
+ *p++ = uchar(255*((1-X)*Y)); // green in lower-left
+ *p++ = uchar(255*(X*Y)); // blue in lower-right
X -= 0.5;
Y -= 0.5;
int alpha = (int)(350 * sqrt(X * X + Y * Y));
- if (alpha < 255) *p++ = uchar(alpha); // alpha transparency
+ if (alpha < 255) *p++ = uchar(alpha); // alpha transparency
else *p++ = 255;
Y += 0.5;
}
@@ -559,7 +557,7 @@ void copy(Fl_Widget *, void *data) {
W = target->as_window()->decorated_w();
H = target->as_window()->decorated_h();
decorated = 1;
- }
+ }
else {
W = target->w();
H = target->h();
@@ -586,8 +584,8 @@ void copy(Fl_Widget *, void *data) {
}
return;
}
-
-
+
+
if (strcmp(operation, "Fl_Copy_Surface") == 0) {
Fl_Copy_Surface *copy_surf;
if (target->as_window() && !target->parent()) {
@@ -604,7 +602,7 @@ void copy(Fl_Widget *, void *data) {
delete copy_surf;
Fl_Surface_Device::pop_current();
}
-
+
if (strcmp(operation, "Fl_Printer") == 0 || strcmp(operation, "Fl_PostScript_File_Device") == 0) {
Fl_Paged_Device *p;
int err;
@@ -626,7 +624,7 @@ void copy(Fl_Widget *, void *data) {
} else if (err > 1 && err_message) {fl_alert("%s", err_message); delete[] err_message;}
delete p;
}
-
+
if (strcmp(operation, "Fl_EPS_File_Surface") == 0) {
Fl_Native_File_Chooser fnfc;
fnfc.title("Save a .eps file");
@@ -694,7 +692,7 @@ protected:
fl_line(x()+w()-15,y()+10,x()+15,y()+h()-23);
fl_line_style(0);
draw_label();
-
+
};
public:
My_Button(int x, int y, int w, int h, const char * label = 0):Fl_Button(x,y,w,h,label){}
@@ -712,32 +710,32 @@ void operation_cb(Fl_Widget* wid, void *data)
}
int main(int argc, char ** argv) {
-
- Fl::scheme("plastic");
-
+
+ Fl::scheme("plastic");
+
Fl_Window * w2 = new Fl_Window(500,568,"Graphics test");
-
+
Fl_Group *c2 =new Fl_Group(3, 56, 494, 514 );
-
+
new MyWidget(10,140+16);
new MyWidget2(110,80+16);
new MyWidget3(220,140+16);
new MyWidget4(330,70+16);
new MyWidget5(140,270+16);
-
+
make_image();
Fl_RGB_Image *rgb = new Fl_RGB_Image(image, width, height, 4);
My_Button b_rgb(10,245+16,100,100,"RGB with alpha");
b_rgb.image(rgb);
-
+
My_Button b_pixmap(10,345+16,100,100,"Pixmap");
Fl_Pixmap *pixmap = new Fl_Pixmap(porsche_xpm);
b_pixmap.image(pixmap);
-
+
My_Button b_bitmap(10,445+16,100,100,"Bitmap");
b_bitmap.labelcolor(FL_GREEN);
b_bitmap.image(new Fl_Bitmap(sorceress_bits,sorceress_width,sorceress_height));
-
+
new Fl_Clock(360,230+16,120,120);
Fl_Return_Button * ret = new Fl_Return_Button (360, 360, 120,30, "Return");
ret->deactivate();
@@ -753,10 +751,10 @@ int main(int argc, char ** argv) {
but5.labelfont(FL_BOLD|FL_ITALIC);
but5.labeltype(FL_SHADOW_LABEL);
but5.box(FL_ROUND_UP_BOX);
-
+
Fl_Button but6(360, 460+16, 120, 30, "Plastic");
but6.box(FL_PLASTIC_UP_BOX);
-
+
Fl_Group *group;
{ Fl_Group* o = new Fl_Group(360, 495+16, 120, 40); group=o;
o->box(FL_UP_BOX);
@@ -767,7 +765,6 @@ int main(int argc, char ** argv) {
}
{ Fl_Check_Button* o = new Fl_Check_Button(410, 500+16, 60, 30, "check");
o->value(1);
-
}
o->end();
}
@@ -777,16 +774,16 @@ int main(int argc, char ** argv) {
Fl_Box tx(120,492+16,230,50,"Background is not printed because\nencapsulating group, which we are\n printing, has not set the box type");
tx.box(FL_SHADOW_BOX);
tx.labelsize(12);
-
+
tx.hide();
-
+
c2->end();
-
+
Fl_Radio_Round_Button *rb;
Fl_Window *w3 = new Fl_Window(2,5,w2->w()-10,73);
w3->box(FL_DOWN_BOX);
Fl_Group *g1 = new Fl_Group(w3->x(),w3->y(),w3->w(),w3->h());
- rb = new Fl_Radio_Round_Button(5,5,150,12, "Fl_Image_Surface");
+ rb = new Fl_Radio_Round_Button(5,5,150,12, "Fl_Image_Surface");
rb->set(); rb->callback(operation_cb, NULL); operation = rb->label(); rb->labelsize(12);
rb = new Fl_Radio_Round_Button(5,18,150,12, "Fl_Copy_Surface"); rb->callback(operation_cb, NULL); rb->labelsize(12);
rb = new Fl_Radio_Round_Button(5,31,150,12, "Fl_Printer"); rb->callback(operation_cb, NULL); rb->labelsize(12);
@@ -794,9 +791,9 @@ int main(int argc, char ** argv) {
rb = new Fl_Radio_Round_Button(5,57,150,12, "Fl_EPS_File_Surface"); rb->callback(operation_cb, NULL); rb->labelsize(12);
rb = new Fl_Radio_Round_Button(170,57,150,12, "Fl_SVG_File_Surface"); rb->callback(operation_cb, NULL); rb->labelsize(12);
g1->end();
-
+
Fl_Group *g2 = new Fl_Group(w3->x(),w3->y(),w3->w(),w3->h());
- rb = new Fl_Radio_Round_Button(170,5,150,12, "Decorated Window");
+ rb = new Fl_Radio_Round_Button(170,5,150,12, "Decorated Window");
rb->set(); rb->callback(target_cb, w2); target = w2;
rb = new Fl_Radio_Round_Button(170,22,150,12, "Sub-window"); rb->callback(target_cb, w3);
rb = new Fl_Radio_Round_Button(170,39,150,12, "Group"); rb->callback(target_cb, group);
@@ -804,22 +801,18 @@ int main(int argc, char ** argv) {
Fl_Button *b4 = new Fl_Button(330, (w3->h() - 25)/2, 150, 25, "GO");
b4->callback((Fl_Callback*)copy,NULL);
w3->end();
-
+
w2->end();
Fl_RGB_Image *rgba_icon = new Fl_RGB_Image(pixmap);
Fl_Window::default_icon(rgba_icon);
- //w2->icon(rgba_icon);
+ // w2->icon(rgba_icon);
delete rgba_icon;
w2->show(argc, argv);
-
+
Fl::run();
delete pixmap;
delete b_bitmap.image();
delete rgb;
-
+
return 0;
}
-
-//
-// End of "$Id$"
-//