DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2310
Version: 1.3-feature


Introduced in FLTK-Fl_Printer branch device abstraction and PostScript
output 
using Roman's ideas and code.
Many thanks to Roman!

Device abstraction allows the clean addition of a PostScript backend to
FLTK
graphics functions. I did it in the minimal fashion, that is, only the
PostScript
drawing is done by new code (there's no way out of that of course),
whereas output
to MSWindows and Mac OS X printers uses the extant FLTK code just changing
the value of fl_gc from a display context to a printer context. In other
words,
Win and Mac printing exploits the fact that graphics contexts of these
platforms
are already abstracted.

Abstraction is in essence done in three steps:
1. Define a hierarchy of device classes
Fl_Device
   Fl_Virtual_Printer
      Fl_GDI_Printer
         Fl_Printer (on Win)
      Fl_Quartz_Printer
         Fl_Printer (on Mac)
      Fl_PS_Printer
         Fl_Printer (on X11)
   Fl_Display
and a new global variable fl_device that points to an instance of one of
these
classes at any time.
2. The Fl_Device class contains a virtual member function for each element
of 
the graphics API of FLTK, e.g., fl_draw, fl_rect, fl_push_clip...  These
functions
are named without the "fl_" prefix and are implemented by each specific
device. 
As stated above, the Win and Mac platforms
share the same implementation for display and printing. Only the
Fl_PS_Printer
class needs a complete, specific implementation of its member functions.
3. The code of extant FLTK drawing functions is UNCHANGED, but becomes:
inline fl_XXX() { fl_device->XXX(); };
Thus, it's arguable that device abstraction does not modify the core of
FLTK, 
in the sense that only the calling of drawing functions is modified.

What is implemented now:
- the Win, Mac, and X11 platforms compile completely (with demos) using
the make
mechanism. I had no time yet to deal with Xcode or other IDEs.
- single-statement printing of all windows and widgets.
- the Win and Mac platforms fully support printing with system print
dialogs, translation,
scaling, and rotation, and reproduction of all of the FLTK drawing API (to
the
extent possible, because I failed to reproduce transparency on Win
printers).
- for X11 platforms, nearly all of the graphics API is implemented, except
images.
Image drawing is implemented in FLTK-1.2, so it's sure we can achieve that
also,
but I want to be sure device abstraction is accepted before transferring
that to 1.3.
- there's a way to print all windows of all demo programs with an
application menu
item under Mac and a small window on Win and X11.
- a new demo program, device, that tests most of the FLTK drawing API for 
its reproduction on paper.
- Mandelbrot demo can be printed by typing ctrl-P because this
progressively
updated widget prints empty with the standard widget-printing function.
- class Fl_Gl_Printer is a subclass of Fl_Printer that allows printing
of on-screen Fl_Gl_Window's by a snapshot mechanism.
- Cube OpenGL demo prints with an added menu because it needs use of
Fl_Gl_Printer.

What is still missing:
- image drawing in PostScript.
- print dialog for X11 (presently, printing is really output to a
PostScript
file). Help needed here please.
- PostScript translation, scaling and rotation.

At this point, we need to decide whether this direction is the right one
to
add printing support to FLTK-1.3.


Link: http://www.fltk.org/str.php?L2310
Version: 1.3-feature

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to