Clean up some inconsistencies in themes.
[ntk.git] / test / device.cxx
bloba02baf816662a412f23891ce6298b1e84a554ba1
1 //
2 // "$Id: device.cxx 8815 2011-06-16 15:11:18Z matt $"
3 //
4 // Device test program for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2011 by Roman Kantor and others.
7 //
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
21 // USA.
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
28 #include <math.h>
29 #include <FL/Fl.H>
31 #include <FL/Fl_Overlay_Window.H>
32 #include <FL/Fl_Light_Button.H>
33 #include <FL/fl_draw.H>
34 #include "pixmaps/porsche.xpm"
35 #include <FL/Fl_Pixmap.H>
36 #include <FL/Fl_Bitmap.H>
37 #include <FL/Fl_Round_Button.H>
40 #include <FL/Fl_Printer.H>
42 //#include "fl_printer_chooser.H"
44 #include <FL/Fl_File_Chooser.H>
45 #include <FL/fl_draw.H>
48 #define sorceress_width 75
49 #define sorceress_height 75
52 // shameles copy from bitmap...
53 static uchar sorceress_bits[] = {
54 0xfc, 0x7e, 0x40, 0x20, 0x90, 0x00, 0x07, 0x80, 0x23, 0x00, 0x00, 0xc6,
55 0xc1, 0x41, 0x98, 0xb8, 0x01, 0x07, 0x66, 0x00, 0x15, 0x9f, 0x03, 0x47,
56 0x8c, 0xc6, 0xdc, 0x7b, 0xcc, 0x00, 0xb0, 0x71, 0x0e, 0x4d, 0x06, 0x66,
57 0x73, 0x8e, 0x8f, 0x01, 0x18, 0xc4, 0x39, 0x4b, 0x02, 0x23, 0x0c, 0x04,
58 0x1e, 0x03, 0x0c, 0x08, 0xc7, 0xef, 0x08, 0x30, 0x06, 0x07, 0x1c, 0x02,
59 0x06, 0x30, 0x18, 0xae, 0xc8, 0x98, 0x3f, 0x78, 0x20, 0x06, 0x02, 0x20,
60 0x60, 0xa0, 0xc4, 0x1d, 0xc0, 0xff, 0x41, 0x04, 0xfa, 0x63, 0x80, 0xa1,
61 0xa4, 0x3d, 0x00, 0x84, 0xbf, 0x04, 0x0f, 0x06, 0xfc, 0xa1, 0x34, 0x6b,
62 0x01, 0x1c, 0xc9, 0x05, 0x06, 0xc7, 0x06, 0xbe, 0x11, 0x1e, 0x43, 0x30,
63 0x91, 0x05, 0xc3, 0x61, 0x02, 0x30, 0x1b, 0x30, 0xcc, 0x20, 0x11, 0x00,
64 0xc1, 0x3c, 0x03, 0x20, 0x0a, 0x00, 0xe8, 0x60, 0x21, 0x00, 0x61, 0x1b,
65 0xc1, 0x63, 0x08, 0xf0, 0xc6, 0xc7, 0x21, 0x03, 0xf8, 0x08, 0xe1, 0xcf,
66 0x0a, 0xfc, 0x4d, 0x99, 0x43, 0x07, 0x3c, 0x0c, 0xf1, 0x9f, 0x0b, 0xfc,
67 0x5b, 0x81, 0x47, 0x02, 0x16, 0x04, 0x31, 0x1c, 0x0b, 0x1f, 0x17, 0x89,
68 0x4d, 0x06, 0x1a, 0x04, 0x31, 0x38, 0x02, 0x07, 0x56, 0x89, 0x49, 0x04,
69 0x0b, 0x04, 0xb1, 0x72, 0x82, 0xa1, 0x54, 0x9a, 0x49, 0x04, 0x1d, 0x66,
70 0x50, 0xe7, 0xc2, 0xf0, 0x54, 0x9a, 0x58, 0x04, 0x0d, 0x62, 0xc1, 0x1f,
71 0x44, 0xfc, 0x51, 0x90, 0x90, 0x04, 0x86, 0x63, 0xe0, 0x74, 0x04, 0xef,
72 0x31, 0x1a, 0x91, 0x00, 0x02, 0xe2, 0xc1, 0xfd, 0x84, 0xf9, 0x30, 0x0a,
73 0x91, 0x00, 0x82, 0xa9, 0xc0, 0xb9, 0x84, 0xf9, 0x31, 0x16, 0x81, 0x00,
74 0x42, 0xa9, 0xdb, 0x7f, 0x0c, 0xff, 0x1c, 0x16, 0x11, 0x00, 0x02, 0x28,
75 0x0b, 0x07, 0x08, 0x60, 0x1c, 0x02, 0x91, 0x00, 0x46, 0x29, 0x0e, 0x00,
76 0x00, 0x00, 0x10, 0x16, 0x11, 0x02, 0x06, 0x29, 0x04, 0x00, 0x00, 0x00,
77 0x10, 0x16, 0x91, 0x06, 0xa6, 0x2a, 0x04, 0x00, 0x00, 0x00, 0x18, 0x24,
78 0x91, 0x04, 0x86, 0x2a, 0x04, 0x00, 0x00, 0x00, 0x18, 0x27, 0x93, 0x04,
79 0x96, 0x4a, 0x04, 0x00, 0x00, 0x00, 0x04, 0x02, 0x91, 0x04, 0x86, 0x4a,
80 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x23, 0x93, 0x04, 0x56, 0x88, 0x08, 0x00,
81 0x00, 0x00, 0x90, 0x21, 0x93, 0x04, 0x52, 0x0a, 0x09, 0x80, 0x01, 0x00,
82 0xd0, 0x21, 0x95, 0x04, 0x57, 0x0a, 0x0f, 0x80, 0x27, 0x00, 0xd8, 0x20,
83 0x9d, 0x04, 0x5d, 0x08, 0x1c, 0x80, 0x67, 0x00, 0xe4, 0x01, 0x85, 0x04,
84 0x79, 0x8a, 0x3f, 0x00, 0x00, 0x00, 0xf4, 0x11, 0x85, 0x06, 0x39, 0x08,
85 0x7d, 0x00, 0x00, 0x18, 0xb7, 0x10, 0x81, 0x03, 0x29, 0x12, 0xcb, 0x00,
86 0x7e, 0x30, 0x28, 0x00, 0x85, 0x03, 0x29, 0x10, 0xbe, 0x81, 0xff, 0x27,
87 0x0c, 0x10, 0x85, 0x03, 0x29, 0x32, 0xfa, 0xc1, 0xff, 0x27, 0x94, 0x11,
88 0x85, 0x03, 0x28, 0x20, 0x6c, 0xe1, 0xff, 0x07, 0x0c, 0x01, 0x85, 0x01,
89 0x28, 0x62, 0x5c, 0xe3, 0x8f, 0x03, 0x4e, 0x91, 0x80, 0x05, 0x39, 0x40,
90 0xf4, 0xc2, 0xff, 0x00, 0x9f, 0x91, 0x84, 0x05, 0x31, 0xc6, 0xe8, 0x07,
91 0x7f, 0x80, 0xcd, 0x00, 0xc4, 0x04, 0x31, 0x06, 0xc9, 0x0e, 0x00, 0xc0,
92 0x48, 0x88, 0xe0, 0x04, 0x79, 0x04, 0xdb, 0x12, 0x00, 0x30, 0x0c, 0xc8,
93 0xe4, 0x04, 0x6d, 0x06, 0xb6, 0x23, 0x00, 0x18, 0x1c, 0xc0, 0x84, 0x04,
94 0x25, 0x0c, 0xff, 0xc2, 0x00, 0x4e, 0x06, 0xb0, 0x80, 0x04, 0x3f, 0x8a,
95 0xb3, 0x83, 0xff, 0xc3, 0x03, 0x91, 0x84, 0x04, 0x2e, 0xd8, 0x0f, 0x3f,
96 0x00, 0x00, 0x5f, 0x83, 0x84, 0x04, 0x2a, 0x70, 0xfd, 0x7f, 0x00, 0x00,
97 0xc8, 0xc0, 0x84, 0x04, 0x4b, 0xe2, 0x2f, 0x01, 0x00, 0x08, 0x58, 0x60,
98 0x80, 0x04, 0x5b, 0x82, 0xff, 0x01, 0x00, 0x08, 0xd0, 0xa0, 0x84, 0x04,
99 0x72, 0x80, 0xe5, 0x00, 0x00, 0x08, 0xd2, 0x20, 0x44, 0x04, 0xca, 0x02,
100 0xff, 0x00, 0x00, 0x08, 0xde, 0xa0, 0x44, 0x04, 0x82, 0x02, 0x6d, 0x00,
101 0x00, 0x08, 0xf6, 0xb0, 0x40, 0x02, 0x82, 0x07, 0x3f, 0x00, 0x00, 0x08,
102 0x44, 0x58, 0x44, 0x02, 0x93, 0x3f, 0x1f, 0x00, 0x00, 0x30, 0x88, 0x4f,
103 0x44, 0x03, 0x83, 0x23, 0x3e, 0x00, 0x00, 0x00, 0x18, 0x60, 0xe0, 0x07,
104 0xe3, 0x0f, 0xfe, 0x00, 0x00, 0x00, 0x70, 0x70, 0xe4, 0x07, 0xc7, 0x1b,
105 0xfe, 0x01, 0x00, 0x00, 0xe0, 0x3c, 0xe4, 0x07, 0xc7, 0xe3, 0xfe, 0x1f,
106 0x00, 0x00, 0xff, 0x1f, 0xfc, 0x07, 0xc7, 0x03, 0xf8, 0x33, 0x00, 0xc0,
107 0xf0, 0x07, 0xff, 0x07, 0x87, 0x02, 0xfc, 0x43, 0x00, 0x60, 0xf0, 0xff,
108 0xff, 0x07, 0x8f, 0x06, 0xbe, 0x87, 0x00, 0x30, 0xf8, 0xff, 0xff, 0x07,
109 0x8f, 0x14, 0x9c, 0x8f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x07, 0x9f, 0x8d,
110 0x8a, 0x0f, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x07, 0xbf, 0x0b, 0x80, 0x1f,
111 0x00, 0x00, 0xff, 0xff, 0xff, 0x07, 0x7f, 0x3a, 0x80, 0x3f, 0x00, 0x80,
112 0xff, 0xff, 0xff, 0x07, 0xff, 0x20, 0xc0, 0x3f, 0x00, 0x80, 0xff, 0xff,
113 0xff, 0x07, 0xff, 0x01, 0xe0, 0x7f, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x07,
114 0xff, 0x0f, 0xf8, 0xff, 0x40, 0xe0, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff,
115 0xff, 0xff, 0x40, 0xf0, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff,
116 0x41, 0xf0, 0xff, 0xff, 0xff, 0x07};
118 class MyWidget: public Fl_Box{
119 protected:
120 void draw(){
121 Fl_Box::draw();
122 fl_color(FL_RED);
123 fl_rectf(x()+5,y()+5,w()-10,h()-10);
124 fl_push_clip(x()+6,y()+6,w()-12,h()-12);
125 fl_color(FL_DARK_GREEN);
126 fl_rectf(x()+5,y()+5,w()-10,h()-10);
127 fl_pop_clip();
128 fl_color(FL_YELLOW);
129 fl_rectf(x()+7,y()+7,w()-14,h()-14);
130 fl_color(FL_BLUE);
132 fl_rect(x()+8,y()+8,w()-16,h()-16);
133 fl_push_clip(x()+25,y()+25,w()-50, h()-50);
134 fl_color(FL_BLACK);
135 fl_rect(x()+24,y()+24,w()-48,h()-48);
136 fl_line(x()+27,y()+27,x()+w()-27,y()+h()-27);
137 fl_line(x()+27,y()+h()-27,x()+w()-27,y()+27);
138 //fl_rect(x()+30,y()+30,w()-60,h()-60);
139 fl_pop_clip();
142 public:
143 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\""){
144 align(FL_ALIGN_TOP);
145 labelsize(10);
150 class MyWidget2: public Fl_Box{
151 protected:
152 void draw(){
153 Fl_Box::draw();
154 int d;
155 // fl_line_style(0);
156 for(d=y()+5;d<48+y();d+=2){
157 fl_xyline(x()+5,d,x()+48);
160 fl_push_clip(x()+52,y()+5,45,43);
161 for(d=y()+5;d<150+y();d+=3){
162 fl_line(x()+52,d,x()+92,d-40);
164 fl_pop_clip();
166 fl_line_style(FL_DASH);
167 fl_xyline(x()+5,y()+55,x()+48);
168 fl_line_style(FL_DOT);
169 fl_xyline(x()+5,y()+58,x()+48);
170 fl_line_style(FL_DASHDOT);
171 fl_xyline(x()+5,y()+61,x()+48);
172 fl_line_style(FL_DASHDOTDOT);
173 fl_xyline(x()+5,y()+64,x()+48);
174 fl_line_style(0,0,(char*)"\7\3\7\2");
175 fl_xyline(x()+5,y()+67,x()+48);
177 fl_line_style(0);
179 fl_line(x()+5,y()+72,x()+25,y()+95);
180 fl_line(x()+8,y()+72,x()+28,y()+95,x()+31,y()+72);
182 fl_color(FL_YELLOW);
183 fl_polygon(x()+11, y()+72,x()+27,y()+91,x()+29,y()+72);
184 fl_color(FL_RED);
185 fl_loop(x()+11, y()+72,x()+27,y()+91,x()+29,y()+72);
187 fl_color(FL_BLUE); ////
188 fl_line_style(FL_SOLID, 6);
189 fl_loop(x()+31, y()+12,x()+47,y()+31,x()+49,y()+12);
190 fl_line_style(0);
192 fl_color(200,0,200);
193 fl_polygon(x()+35,y()+72,x()+33,y()+95,x()+48,y()+95,x()+43,y()+72);
194 fl_color(FL_GREEN);
195 fl_loop(x()+35,y()+72,x()+33,y()+95,x()+48,y()+95,x()+43,y()+72);
197 fl_color(FL_BLUE);
198 fl_yxline(x()+65,y()+63,y()+66);
199 fl_color(FL_GREEN);
200 fl_yxline(x()+66,y()+66,y()+63);
202 fl_color(FL_BLUE);
203 fl_rect(x()+80,y()+55,5,5);
204 fl_color(FL_YELLOW);
205 fl_rectf(x()+81,y()+56,3,3);
206 fl_color(FL_BLACK);
207 fl_point(x()+82,y()+57);
209 fl_color(FL_BLUE);
210 fl_rect(x()+56, y()+79, 24, 17);
211 fl_color(FL_CYAN);
212 fl_rectf(x()+57, y()+80, 22 , 15 );
213 fl_color(FL_RED);
214 fl_arc(x()+57, y()+80, 22 ,15 ,40, 270);
215 fl_color(FL_YELLOW);
216 fl_pie(x()+58, y()+81, 20 ,13 ,40, 270);
218 fl_line_style(0);
220 fl_color(FL_BLACK);
221 fl_point(x()+58,y()+58);
222 fl_color(FL_RED);
223 fl_yxline(x()+59,y()+58,y()+59);
224 fl_color(FL_GREEN);
225 fl_yxline(x()+60,y()+59,y()+58);
226 fl_color(FL_BLACK);
227 fl_xyline(x()+61,y()+58,x()+62);
228 fl_color(FL_RED);
229 fl_xyline(x()+62,y()+59,x()+61);
231 fl_color(FL_GREEN);
232 fl_yxline(x()+57,y()+58,y()+59,x()+58);
233 fl_color(FL_BLUE);
234 fl_xyline(x()+58,y()+60,x()+56,y()+58);
235 fl_color(FL_RED);
236 fl_xyline(x()+58,y()+61,x()+56,y()+63);
237 fl_color(FL_GREEN);
238 fl_yxline(x()+57,y()+63,y()+62,x()+58);
240 fl_color(FL_BLUE);
241 fl_line(x()+58,y()+63, x()+60, y()+65);
242 fl_color(FL_BLACK);
243 fl_line(x()+61,y()+65, x()+59, y()+63);
245 fl_color(FL_BLACK);
248 public:
249 MyWidget2(int x, int y):Fl_Box(x,y,100,100, "Integer primitives"){
250 labelsize(10);
251 align(FL_ALIGN_TOP);
256 class MyWidget3: public Fl_Box{
257 protected:
258 void draw(){
259 Fl_Box::draw();
260 double d;
261 // fl_line_style(0);
262 fl_push_clip(x()+5,y()+5,45,43);
263 for(d=y()+5;d<95+y();d+=1.63){
264 fl_begin_line();
265 fl_vertex(x()+5,d);
266 fl_vertex(x()+48,d);
267 fl_end_line();
269 fl_pop_clip();
271 fl_push_clip(x()+52,y()+5,45,43);
272 for(d=y()+5;d<150+y();d+=2.3052){
273 fl_begin_line();
274 fl_vertex(x()+52,d);
275 fl_vertex(x()+92,d-43);
276 fl_end_line();
278 fl_pop_clip();
281 public:
282 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"){
283 labelsize(10);
284 align(FL_ALIGN_TOP);
290 class MyWidget4: public Fl_Box{
291 protected:
292 void draw(){
293 Fl_Box::draw();
294 fl_push_matrix();
295 fl_translate(x(),y());
296 fl_scale(.75,.75);
298 fl_line_style(FL_SOLID , 5);
299 fl_begin_line();
300 fl_vertex(10, 160);
301 fl_vertex(40, 160);
302 fl_vertex(40, 190);
303 fl_end_line();
304 fl_line_style(0);
306 fl_color(FL_RED);
307 fl_line_style(FL_SOLID | FL_CAP_FLAT |FL_JOIN_MITER , 5);
308 fl_begin_line();
309 fl_vertex(10, 150);
310 fl_vertex(50, 150);
311 fl_vertex(50, 190);
312 fl_end_line();
313 fl_line_style(0);
315 fl_color(FL_GREEN);
316 fl_line_style(FL_SOLID | FL_CAP_ROUND |FL_JOIN_ROUND , 5);
317 fl_begin_line();
318 fl_vertex(10, 140);
319 fl_vertex(60, 140);
320 fl_vertex(60, 190);
321 fl_end_line();
322 fl_line_style(0);
324 fl_color(FL_BLUE);
325 fl_line_style(FL_SOLID | FL_CAP_SQUARE |FL_JOIN_BEVEL , 5);
326 fl_begin_line();
327 fl_vertex(10, 130);
328 fl_vertex(70, 130);
329 fl_vertex(70, 190);
330 fl_end_line();
331 fl_line_style(0);
333 fl_color(FL_BLACK);
334 fl_line_style(FL_DASH , 5);
335 fl_begin_line();
336 fl_vertex(10, 120);
337 fl_vertex(80, 120);
338 fl_vertex(80, 190);
339 fl_end_line();
340 fl_line_style(0);
342 fl_color(FL_RED);
343 fl_line_style(FL_DASH |FL_CAP_FLAT , 5);
344 fl_begin_line();
345 fl_vertex(10, 110);
346 fl_vertex(90, 110);
347 fl_vertex(90, 190);
348 fl_end_line();
349 fl_line_style(0);
351 fl_color(FL_GREEN);
352 fl_line_style(FL_DASH |FL_CAP_ROUND , 5);
353 fl_begin_line();
354 fl_vertex(10, 100);
355 fl_vertex(100, 100);
356 fl_vertex(100, 190);
357 fl_end_line();
358 fl_line_style(0);
361 fl_color(FL_BLUE);
362 fl_line_style(FL_DASH |FL_CAP_SQUARE , 5);
363 fl_begin_line();
364 fl_vertex(10, 90);
365 fl_vertex(110, 90);
366 fl_vertex(110, 190);
367 fl_end_line();
368 fl_line_style(0);
370 fl_color(FL_BLACK);
371 fl_line_style(FL_DOT, 5);
372 fl_begin_line();
373 fl_vertex(10, 80);
374 fl_vertex(120, 80);
375 fl_vertex(120, 190);
376 fl_end_line();
377 fl_line_style(0);
379 fl_color(FL_RED);
380 fl_line_style(FL_DOT | FL_CAP_FLAT, 5);
381 fl_begin_line();
382 fl_vertex(10, 70);
383 fl_vertex(130, 70);
384 fl_vertex(130, 190);
385 fl_end_line();
386 fl_line_style(0);
388 fl_color(FL_GREEN);
389 fl_line_style(FL_DOT | FL_CAP_ROUND, 5);
390 fl_begin_line();
391 fl_vertex(10, 60);
392 fl_vertex(140, 60);
393 fl_vertex(140, 190);
394 fl_end_line();
395 fl_line_style(0);
397 fl_color(FL_BLUE);
398 fl_line_style(FL_DOT | FL_CAP_SQUARE, 5);
399 fl_begin_line();
400 fl_vertex(10, 50);
401 fl_vertex(150, 50);
402 fl_vertex(150, 190);
403 fl_end_line();
404 fl_line_style(0);
406 fl_color(FL_BLACK);
407 fl_line_style(FL_DASHDOT |FL_CAP_ROUND |FL_JOIN_ROUND , 5);
408 fl_begin_line();
409 fl_vertex(10, 40);
410 fl_vertex(160, 40);
411 fl_vertex(160, 190);
412 fl_end_line();
413 fl_line_style(0);
415 fl_color(FL_RED);
416 fl_line_style(FL_DASHDOTDOT |FL_CAP_SQUARE |FL_JOIN_BEVEL , 5);
417 fl_begin_line();
418 fl_vertex(10, 30);
419 fl_vertex(170, 30);
420 fl_vertex(170, 190);
421 fl_end_line();
422 fl_line_style(0);
425 fl_color(FL_GREEN);
426 fl_line_style(FL_DASHDOTDOT |FL_CAP_ROUND |FL_JOIN_ROUND , 5);
427 fl_begin_line();
428 fl_vertex(10, 20);
429 fl_vertex(180, 20);
430 fl_vertex(180, 190);
431 fl_end_line();
432 fl_line_style(0);
434 fl_color(FL_BLUE);
435 fl_line_style(0, 5, (char*)"\12\3\4\2\2\1");
436 fl_begin_line();
437 fl_vertex(10, 10);
438 fl_vertex(190, 10);
439 fl_vertex(190, 190);
441 fl_end_line();
442 fl_line_style(0);
443 fl_pop_matrix();
445 fl_color(FL_BLACK);
447 public:
448 MyWidget4(int x, int y):Fl_Box(x,y,150,150, "Line styles"){
449 labelsize(10);
450 align(FL_ALIGN_TOP);
455 class MyWidget5: public Fl_Box{
456 protected:
457 void draw(){
458 Fl_Box::draw();
459 //fl_push_clip(x(),y(),w(),h());
460 fl_push_matrix();
462 fl_translate(x(),y());
463 fl_push_matrix();
464 fl_mult_matrix(1,3,0,1,0,-20);
465 fl_color(FL_GREEN);
466 fl_begin_polygon();
467 fl_vertex(10,10);
468 fl_vertex(100,-80);
469 fl_vertex(100,-190);
470 fl_end_polygon();
472 fl_color(FL_RED);
473 fl_line_style(FL_DASHDOT, 7);
474 fl_begin_loop();
476 fl_vertex(10,10);
477 fl_vertex(100,-80);
478 fl_vertex(100,-190);
479 fl_end_loop();
480 fl_line_style(0);
482 fl_color(FL_BLUE);
483 fl_line_style(FL_SOLID, 3);
484 fl_begin_loop();
485 fl_circle(60,-50,30);
486 fl_end_loop();
487 fl_line_style(0);
489 fl_pop_matrix();
490 fl_scale(1.8,1);
492 fl_color(FL_YELLOW);
493 fl_begin_polygon();
494 fl_arc(30,90,20,-45,200);
495 fl_end_polygon();
497 fl_color(FL_BLACK);
498 fl_line_style(FL_DASH, 3);
499 fl_begin_line();
500 fl_arc(30,90,20,-45,200);
501 fl_end_line();
502 fl_line_style(0);
504 fl_translate(15,0);
505 fl_scale(1.5,3);
506 fl_begin_complex_polygon();
507 fl_vertex(30,70);
508 fl_arc(45,55,10,200,90);
509 fl_arc(55,45,8,-170,20);
510 fl_vertex(60,40);
511 fl_vertex(30,20);
512 fl_vertex(40,5);
513 fl_vertex(60,25);
514 //fl_vertex(50,50);
515 fl_curve(35,30,30,53,0,35,65,65);
516 fl_gap();
517 fl_vertex(50,25);
518 fl_vertex(40,10);
519 fl_vertex(35,20);
520 fl_end_complex_polygon();
522 fl_pop_matrix();
524 // fl_color(FL_BLACK);
525 // fl_line_style(0);
526 //fl_pop_clip();
529 public:
530 MyWidget5(int x, int y):Fl_Box(x,y,230,250, "Complex (double) drawings:\nBlue ellipse may not be\ncorrectly transformed\ndue to non-orthogonal\ntransformation"){
531 labelsize(10);
532 align(FL_ALIGN_TOP);
537 uchar *image;
538 int width = 80;
539 int height = 80;
541 void make_image() {
542 image = new uchar[4*width*height];
543 uchar *p = image;
544 for (int y = 0; y < height; y++) {
545 double Y = double(y)/(height-1);
546 for (int x = 0; x < width; x++) {
547 double X = double(x)/(width-1);
548 *p++ = uchar(255*((1-X)*(1-Y))); // red in upper-left
549 *p++ = uchar(255*((1-X)*Y)); // green in lower-left
550 *p++ = uchar(255*(X*Y)); // blue in lower-right
551 X -= 0.5;
552 Y -= 0.5;
553 int alpha = (int)(350 * sqrt(X * X + Y * Y));
554 if (alpha < 255) *p++ = uchar(alpha); // alpha transparency
555 else *p++ = 255;
556 Y += 0.5;
562 void print(Fl_Widget *, void *w) {
563 Fl_Widget * g = (Fl_Widget *)w;
565 Fl_Printer * p = new Fl_Printer();
566 if (!p->start_job(1)) {
567 p->start_page();
568 p->print_window(g->window());
569 p->end_page();
570 p->end_job();
572 delete p;
575 /*void print2(Fl_Widget *, void *w) {
576 Fl_Widget * g = (Fl_Widget *)w;
577 Fl_Printer * p = fl_printer_chooser();
578 if(!p) return;
579 p->page(Fl_Printer::A4);
580 // fitting inside margins 1 inch wide
581 p->place(g, FL_INCH, FL_INCH, p->page_width() - 2 * FL_INCH, p->page_height() - 2 * FL_INCH, FL_ALIGN_CENTER);
582 Fl_Device * c = p->set_current();
583 fl_draw(g);
584 c->set_current();
585 delete p;
586 };*/
589 class My_Button:public Fl_Button{
590 protected:
591 void draw(){
592 // Fl_Button::draw();
593 if (type() == FL_HIDDEN_BUTTON) return;
594 Fl_Color col = value() ? selection_color() : color();
595 draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(), col);
596 fl_color(FL_WHITE);
597 fl_line_style(FL_SOLID,5);
598 fl_line(x()+15,y()+10,x()+w()-15,y()+h()-23);
599 fl_line(x()+w()-15,y()+10,x()+15,y()+h()-23);
600 fl_line_style(0);
601 draw_label();
604 public:
605 My_Button(int x, int y, int w, int h, const char * label = 0):Fl_Button(x,y,w,h,label){}
609 int main(int argc, char ** argv) {
611 //Fl::scheme("plastic");
615 Fl_Window * w2 = new Fl_Window(500,560,"Graphics test");
618 Fl_Group *c2 =new Fl_Group(3, 43, 494, 514 );
620 new MyWidget(10,140);
621 new MyWidget2(110,80);
622 new MyWidget3(220,140);
623 new MyWidget4(330,70);
624 new MyWidget5(140,270);
626 make_image();
627 Fl_RGB_Image *rgb = new Fl_RGB_Image(image, width, height, 4);
628 My_Button b_rgb(10,245,100,100,"RGB with alpha");
629 b_rgb.image(rgb);
631 My_Button b_pixmap(10,345,100,100,"Pixmap");
632 Fl_Pixmap *pixmap = new Fl_Pixmap(porsche_xpm);
633 b_pixmap.image(pixmap);
635 My_Button b_bitmap(10,445,100,100,"Bitmap");
636 b_bitmap.labelcolor(FL_GREEN);
637 b_bitmap.image(new Fl_Bitmap(sorceress_bits,sorceress_width,sorceress_height));
639 Fl_Return_Button * ret = new Fl_Return_Button (360, 360, 120,30, "Return");
640 ret->deactivate();
641 Fl_Button but1(360, 390, 30, 30, "@->|");
642 but1.labelcolor(FL_DARK3);
643 Fl_Button but2(390, 390, 30, 30, "@UpArrow");
644 but2.labelcolor(FL_DARK3);
645 Fl_Button but3(420, 390, 30, 30, "@DnArrow");
646 but3.labelcolor(FL_DARK3);
647 Fl_Button but4(450, 390, 30, 30, "@+");
648 but4.labelcolor(FL_DARK3);
649 Fl_Button but5(360, 425, 120, 30, "Hello, World");
650 but5.labelfont(FL_BOLD|FL_ITALIC);
651 but5.labeltype(FL_SHADOW_LABEL);
652 but5.box(FL_ROUND_UP_BOX);
653 // but5.selection_color(FL_WHITE);
655 Fl_Button but6(360, 460, 120, 30, "Plastic");
656 but6.box(FL_PLASTIC_UP_BOX);
658 //Fl_Button but7(, 480, 120, 30, "Engraved box");
659 //but7.box(FL_ENGRAVED_BOX);
660 { Fl_Group* o = new Fl_Group(360, 495, 120, 40);
661 o->box(FL_UP_BOX);
662 { Fl_Group* o = new Fl_Group(365, 500, 110, 30);
663 o->box(FL_THIN_UP_FRAME);
664 { Fl_Round_Button* o = new Fl_Round_Button(365, 500, 40, 30, "rad");
665 o->value(1);
667 { Fl_Check_Button* o = new Fl_Check_Button(410, 500, 60, 30, "check");
668 o->value(1);
671 o->end();
673 o->end();
674 o->deactivate();
676 Fl_Box tx(120,492,230,50,"Background is not printed because\nencapsulating group, which we are\n printing, has not set the box type");
677 tx.box(FL_SHADOW_BOX);
678 tx.labelsize(12);
680 tx.hide();
682 c2->end();
683 Fl_Button *b4 = new Fl_Button(10,5, 150, 25, "Print");
684 b4->callback(print,c2);
685 /*Fl_Button *b5 = new Fl_Button(165,5, 90, 25, "Print");
686 b5->tooltip("This is a tooltip");
687 b5->callback(print2,c2);*/
689 w2->end();
690 w2->show(argc, argv);
693 Fl::run();
694 return 0;
698 // End of "$Id: device.cxx 8815 2011-06-16 15:11:18Z matt $"