summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2010-05-27 17:30:03 +0000
committerManolo Gouy <Manolo>2010-05-27 17:30:03 +0000
commite0a798f1153fc70e3f52655d074953edf94d7bf3 (patch)
tree4985c555658553e1f4cc1c004b4eca0d4fc6a640 /src
parent6fb99e7ec73c48b1674f1ebb499f5e6507f1b6c7 (diff)
Reflecting deleted files by new device hierarchy
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7619 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Abstract_Printer.cxx299
-rw-r--r--src/Fl_PS_Printer.cxx1354
2 files changed, 0 insertions, 1653 deletions
diff --git a/src/Fl_Abstract_Printer.cxx b/src/Fl_Abstract_Printer.cxx
deleted file mode 100644
index 0490dcc68..000000000
--- a/src/Fl_Abstract_Printer.cxx
+++ /dev/null
@@ -1,299 +0,0 @@
-//
-// "$Id$"
-//
-// implementation of Fl_Abstract_Printer class for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 2010 by Bill Spitzak and others.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-//
-// Please report all bugs and problems to:
-//
-// http://www.fltk.org/str.php
-//
-/** \file Fl_Abstract_Printer.cxx
- \brief implementation of class Fl_Abstract_Printer.
- */
-
-#include <FL/Fl.H>
-#include <FL/Fl_Printer.H>
-
-/**
- @brief Draws the widget on the printed page.
- *
- The widget's position on the printed page is determined by the last call to origin()
- and by the optional delta_x and delta_y arguments.
- Its dimensions are in points unless there was a previous call to scale().
- @param[in] widget Any FLTK widget (e.g., standard, custom, window).
- @param[in] delta_x Optional horizontal offset for positioning the widget relatively
- to the current origin of graphics functions.
- @param[in] delta_y Same as above, vertically.
- */
-void Fl_Abstract_Printer::print_widget(Fl_Widget* widget, int delta_x, int delta_y)
-{
- int old_x, old_y, new_x, new_y, is_window;
- if ( ! widget->visible() ) return;
- is_window = (widget->as_window() != NULL);
- widget->damage(FL_DAMAGE_ALL);
- // set origin to the desired top-left position of the widget
- origin(&old_x, &old_y);
- new_x = old_x + delta_x;
- new_y = old_y + delta_y;
- if (!is_window) {
- new_x -= widget->x();
- new_y -= widget->y();
- }
- if (new_x != old_x || new_y != old_y) {
- translate(new_x - old_x, new_y - old_y );
- }
- // if widget is a window, clip all drawings to the window area
- if (is_window) fl_push_clip(0, 0, widget->w(), widget->h() );
- // we do some trickery to recognize OpenGL windows and draw them via a plugin
- int drawn_by_plugin = 0;
- if (widget->as_gl_window()) {
- Fl_Plugin_Manager pm("fltk:device");
- Fl_Device_Plugin *pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org");
- if (pi) {
- int width, height;
- this->printable_rect(&width, &height);
- drawn_by_plugin = pi->print(widget, 0, 0, height);
- }
- }
- if (!drawn_by_plugin) {
- widget->draw();
- }
- if (is_window) fl_pop_clip();
- // find subwindows of widget and print them
- traverse(widget);
- // reset origin to where it was
- if (new_x != old_x || new_y != old_y) {
- untranslate();
- }
-}
-
-
-void Fl_Abstract_Printer::traverse(Fl_Widget *widget)
-{
- Fl_Group *g = widget->as_group();
- if (!g) return;
- int n = g->children();
- for (int i = 0; i < n; i++) {
- Fl_Widget *c = g->child(i);
- if ( !c->visible() ) continue;
- if ( c->as_window() ) {
- print_widget(c, c->x(), c->y());
- }
- else traverse(c);
- }
-}
-
-/**
- @brief Computes the page coordinates of the current origin of graphics functions.
- *
- @param[out] x If non-null, *x is set to the horizontal page offset of graphics origin.
- @param[out] y Same as above, vertically.
- */
-void Fl_Abstract_Printer::origin(int *x, int *y)
-{
- if (x) *x = x_offset;
- if (y) *y = y_offset;
-}
-
-/**
- @brief Prints a rectangular part of an on-screen window.
- *
- @param win The window from where to capture.
- @param x The rectangle left
- @param y The rectangle top
- @param w The rectangle width
- @param h The rectangle height
- @param delta_x Optional horizontal offset from current graphics origin where to print the captured rectangle.
- @param delta_y As above, vertically.
- */
-void Fl_Abstract_Printer::print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x, int delta_y)
-{
- int slice, width, offset, count = 0;
- Fl_Device::display_device()->set_current();
- Fl_Window *save_front = Fl::first_window();
- win->show();
- fl_gc = NULL;
- Fl::check();
- win->make_current();
- uchar *image_data[20];
-#ifdef WIN32 // because of bug in StretchDIBits, vertically cut image in pieces of width slice
- slice = 500;
-#else
- slice = w;
-#endif
- for ( offset = 0; offset < w; offset += slice) {
- width = slice;
- if (offset + width > w) width = w - offset;
- image_data[count++] = fl_read_image(NULL, x + offset, y, width, h);
- }
- save_front->show();
- this->set_current();
- for ( int i = 0, offset = 0; i < count; i++, offset += slice) {
- width = slice;
- if (offset + width > w) width = w - offset;
- fl_draw_image(image_data[i], delta_x + offset, delta_y, width, h, 3);
-#ifdef __APPLE__
- add_image(NULL, image_data[i]);
-#else
- delete image_data[i];
-#endif
- }
-}
-
-#ifdef __APPLE__
-void Fl_Abstract_Printer::add_image(Fl_Image *image, const uchar *data)
-{
- struct chain_elt *elt = (struct chain_elt *)calloc(sizeof(struct chain_elt), 1);
- elt->image = image;
- elt->data = data;
- if (image_list_) { elt->next = image_list_; }
- image_list_ = elt;
-}
-
-void Fl_Abstract_Printer::delete_image_list()
-{
- while(image_list_) {
- struct chain_elt *next = image_list_->next;
- if(image_list_->image) delete image_list_->image;
- if (image_list_->data) delete (uchar*) image_list_->data; // msvc6 compilation fix
- free(image_list_);
- image_list_ = next;
- }
-}
-#endif
-
-Fl_Device *Fl_Abstract_Printer::set_current(void)
-{
-#ifdef __APPLE__
- fl_gc = (CGContextRef)gc;
-#elif defined(WIN32)
- fl_gc = (HDC)gc;
-#else
- fl_gc = (_XGC*)gc;
-#endif
- return this->Fl_Device::set_current();
-}
-
-
-/**
- @brief Starts a print job.
- *
- @param[in] pagecount the total number of pages of the job
- @param[out] frompage if non-null, *frompage is set to the first page the user wants printed
- @param[out] topage if non-null, *topage is set to the last page the user wants printed
- @return 0 iff OK
- */
-int Fl_Abstract_Printer::start_job(int pagecount, int *frompage, int *topage) {return 1;}
-
-/**
- @brief Starts a new printed page
- *
- The page coordinates are initially in points, i.e., 1/72 inch,
- and with origin at the top left of the printable page area.
- @return 0 iff OK
- */
-int Fl_Abstract_Printer::start_page (void) {return 1;}
-
-/**
- @brief Computes the width and height of the printable area of the page.
- *
- Values are in the same unit as that used by FLTK drawing functions,
- are unchanged by calls to origin(), but are changed by scale() calls.
- Values account for the user-selected paper type and print orientation.
- @return 0 iff OK.
- */
-int Fl_Abstract_Printer::printable_rect(int *w, int *h) {return 1;}
-
-/**
- @brief Computes the dimensions of margins that lie between the printable page area and
- the full page.
- *
- Values are in the same unit as that used by FLTK drawing functions. They are changed
- by scale() calls.
- @param[out] left If non-null, *left is set to the left margin size.
- @param[out] top If non-null, *top is set to the top margin size.
- @param[out] right If non-null, *right is set to the right margin size.
- @param[out] bottom If non-null, *bottom is set to the bottom margin size.
- */
-void Fl_Abstract_Printer::margins(int *left, int *top, int *right, int *bottom) {}
-
-/**
- @brief Sets the position in page coordinates of the origin of graphics functions.
- *
- Arguments should be expressed relatively to the result of a previous printable_rect() call.
- That is, <tt>printable_rect(&w, &h); origin(w/2, 0);</tt> sets the graphics origin at the
- top center of the page printable area.
- Origin() calls are not affected by rotate() calls.
- Successive origin() calls don't combine their effects.
- @param[in] x Horizontal position in page coordinates of the desired origin of graphics functions.
- @param[in] y Same as above, vertically.
- */
-void Fl_Abstract_Printer::origin(int x, int y) {}
-
-/**
- @brief Changes the scaling of page coordinates.
- *
- This function also resets the origin of graphics functions at top left of printable page area.
- After a scale() call, do a printable_rect() call to get the new dimensions of the printable page area.
- Successive scale() calls don't combine their effects.
- @param scale_x Horizontal dimensions of plot are multiplied by this quantity.
- @param scale_y Same as above, vertically.
- */
-void Fl_Abstract_Printer::scale (float scale_x, float scale_y) {}
-
-/**
- @brief Rotates the graphics operations relatively to paper.
- *
- The rotation is centered on the current graphics origin.
- Successive rotate() calls don't combine their effects.
- @param angle Rotation angle in counterclockwise degrees.
- */
-void Fl_Abstract_Printer::rotate(float angle) {}
-
-/**
- @brief To be called at the end of each page.
- *
- @return 0 iff OK.
- */
-int Fl_Abstract_Printer::end_page (void) {return 1;}
-
-/**
- @brief To be called at the end of a print job.
- */
-void Fl_Abstract_Printer::end_job (void) {}
-
-/**
- @brief Translates the current graphics origin accounting for the current rotation.
- *
- This function is only useful after a rotate() call.
- Each translate() call must be matched by an untranslate() call.
- Successive translate() calls add up their effects.
- */
-void Fl_Abstract_Printer::translate(int x, int y) {}
-
-/**
- @brief Undoes the effect of a previous translate() call.
- */
-void Fl_Abstract_Printer::untranslate(void) {}
-
-//
-// End of "$Id$".
-//
-
diff --git a/src/Fl_PS_Printer.cxx b/src/Fl_PS_Printer.cxx
deleted file mode 100644
index 347c40644..000000000
--- a/src/Fl_PS_Printer.cxx
+++ /dev/null
@@ -1,1354 +0,0 @@
-//
-// "$Id$"
-//
-// PostScript device support for the Fast Light Tool Kit (FLTK).
-//
-// Copyright 2010 by Bill Spitzak and others.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Library General Public
-// License as published by the Free Software Foundation; either
-// version 2 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Library General Public License for more details.
-//
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-//
-// Please report all bugs and problems to:
-//
-// http://www.fltk.org/str.php
-//
-
-#include <FL/Fl.H>
-#include <FL/fl_ask.H>
-#include <FL/fl_draw.H>
-#include <stdio.h>
-#include <FL/Fl_PSfile_Device.H>
-#include <FL/Fl_Native_File_Chooser.H>
-
-const char *Fl_PSfile_Device::file_chooser_title = "Select a .ps file";
-
-/**
- @brief The constructor.
- */
-Fl_PSfile_Device::Fl_PSfile_Device(void)
-{
- close_cmd_ = 0;
- //lang_level_ = 3;
- lang_level_ = 2;
- mask = 0;
- ps_filename_ = NULL;
- type_ = postscript_device;
- scale_x = scale_y = 1.;
-#ifdef __APPLE__
- gc = fl_gc; // the display context is used by fl_text_extents()
-#endif
-}
-
-/**
- @brief Begins the session where all graphics requests will go to a local PostScript file.
- *
- Opens a file dialog entitled with Fl_PSfile_Device::file_chooser_title to select an output PostScript file.
- @param pagecount The total number of pages to be created.
- @param format Desired page format.
- @param layout Desired page layout.
- @return 0 iff OK, 1 if user cancelled the file dialog, 2 if fopen failed on user-selected output file.
- */
-int Fl_PSfile_Device::start_job (int pagecount, enum Page_Format format, enum Page_Layout layout)
-{
- Fl_Native_File_Chooser fnfc;
- fnfc.title(Fl_PSfile_Device::file_chooser_title);
- fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE);
- fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM);
- fnfc.filter("PostScript\t*.ps\n");
- // Show native chooser
- if ( fnfc.show() ) return 1;
- output = fopen(fnfc.filename(), "w");
- if(output == NULL) return 2;
- ps_filename_ = strdup(fnfc.filename());
- start_postscript(pagecount, format, layout);
- return 0;
-}
-
-/**
- @brief Begins the session where all graphics requests will go to FILE pointer.
- *
- @param ps_output A writable FILE pointer that will receive PostScript output and that will be closed
- when end_job() will be called.
- @param pagecount The total number of pages to be created.
- @param format Desired page format.
- @param layout Desired page layout.
- @return always 0.
- */
-int Fl_PSfile_Device::start_job (FILE *ps_output, int pagecount, enum Page_Format format, enum Page_Layout layout)
-{
- output = ps_output;
- ps_filename_ = NULL;
- start_postscript(pagecount, format, layout);
- return 0;
-}
-
-/**
- @brief The destructor.
- */
-Fl_PSfile_Device::~Fl_PSfile_Device() {
- if (ps_filename_) free(ps_filename_);
-}
-
-#ifndef FL_DOXYGEN
-
-#if ! (defined(__APPLE__) || defined(WIN32) )
- #include "print_panel.cxx"
-#endif
-
-const Fl_PSfile_Device::page_format Fl_PSfile_Device::page_formats[NO_PAGE_FORMATS] = { // order of enum Page_Format
-// comes from appendix B of 5003.PPD_Spec_v4.3.pdf
-
- // A* // index(Ai) = i
- {2384, 3370, "A0"},
- {1684, 2384, "A1"},
- {1191, 1684, "A2"},
- { 842, 1191, "A3"},
- { 595, 842, "A4"},
- { 420, 595, "A5"},
- { 297, 420, "A6"},
- { 210, 297, "A7"},
- { 148, 210, "A8"},
- { 105, 148, "A9"},
-
- // B* // index(Bi) = i+10
- {2920, 4127, "B0"},
- {2064, 2920, "B1"},
- {1460, 2064, "B2"},
- {1032, 1460, "B3"},
- { 729, 1032, "B4"},
- { 516, 729, "B5"},
- { 363, 516, "B6"},
- { 258, 363, "B7"},
- { 181, 258, "B8"},
- { 127, 181, "B9"},
- { 91, 127, "B10"},
-
- // others
- { 459, 649, "EnvC5"}, // envelope
- { 312, 624, "EnvDL"}, // envelope
- { 522, 756, "Executive"},
- { 595, 935, "Folio"},
- {1224, 792, "Ledger"}, // landscape
- { 612, 1008, "Legal"},
- { 612, 792, "Letter"},
- { 792, 1224, "Tabloid"},
- { 297, 684, "Env10"} // envelope
-};
-
-// Prolog string
-
-static const char * prolog =
-"%%BeginProlog\n"
-"/L { /y2 exch def\n"
-"/x2 exch def\n"
-"/y1 exch def\n"
-"/x1 exch def\n"
-"newpath x1 y1 moveto x2 y2 lineto\n"
-"stroke}\n"
-"bind def\n"
-
-
-"/R { /dy exch def\n"
-"/dx exch def\n"
-"/y exch def\n"
-"/x exch def\n"
-"newpath\n"
-"x y moveto\n"
-"dx 0 rlineto\n"
-"0 dy rlineto\n"
-"dx neg 0 rlineto\n"
-"closepath stroke\n"
-"} bind def\n"
-
-"/CL {\n"
-"/dy exch def\n"
-"/dx exch def\n"
-"/y exch def\n"
-"/x exch def\n"
-"newpath\n"
-"x y moveto\n"
-"dx 0 rlineto\n"
-"0 dy rlineto\n"
-"dx neg 0 rlineto\n"
-"closepath\n"
-"clip\n"
-"} bind def\n"
-
-"/FR { /dy exch def\n"
-"/dx exch def\n"
-"/y exch def\n"
-"/x exch def\n"
-"currentlinewidth 0 setlinewidth newpath\n"
-"x y moveto\n"
-"dx 0 rlineto\n"
-"0 dy rlineto\n"
-"dx neg 0 rlineto\n"
-"closepath fill setlinewidth\n"
-"} bind def\n"
-
-"/GS { gsave } bind def\n"
-"/GR { grestore } bind def\n"
-
-"/SP { showpage } bind def\n"
-"/LW { setlinewidth } bind def\n"
-"/CF /Courier def\n"
-"/SF { /CF exch def } bind def\n"
-"/fsize 12 def\n"
-"/FS { /fsize exch def fsize CF findfont exch scalefont setfont }def \n"
-
-
-"/GL { setgray } bind def\n"
-"/SRGB { setrgbcolor } bind def\n"
-
-// color images
-
-"/CI { GS /py exch def /px exch def /sy exch def /sx exch def\n"
-"translate \n"
-"sx sy scale px py 8 \n"
-"[ px 0 0 py neg 0 py ]\n"
-"currentfile /ASCIIHexDecode filter\n false 3"
-" colorimage GR\n"
-"} bind def\n"
-
-// gray images
-
-"/GI { GS /py exch def /px exch def /sy exch def /sx exch def \n"
-"translate \n"
-"sx sy scale px py 8 \n"
-
-
-"[ px 0 0 py neg 0 py ]\n"
-"currentfile /ASCIIHexDecode filter\n"
-"image GR\n"
-"} bind def\n"
-
-// single-color bitmask
-
-"/MI { GS /py exch def /px exch def /sy exch def /sx exch def \n"
-"translate \n"
-"sx sy scale px py false \n"
-"[ px 0 0 py neg 0 py ]\n"
-"currentfile /ASCIIHexDecode filter\n"
-"imagemask GR\n"
-"} bind def\n"
-
-
-// path
-
-"/BFP { newpath moveto } def\n"
-"/BP { newpath } bind def \n"
-"/PL { lineto } bind def \n"
-"/PM { moveto } bind def \n"
-"/MT { moveto } bind def \n"
-"/LT { lineto } bind def \n"
-"/EFP { closepath fill } bind def\n" //was:stroke
-"/ELP { stroke } bind def\n"
-"/ECP { closepath stroke } bind def\n" // Closed (loop)
-"/LW { setlinewidth } bind def\n"
-
-// ////////////////////////// misc ////////////////
-"/TR { translate } bind def\n"
-"/CT { concat } bind def\n"
-"/RCT { matrix invertmatrix concat} bind def\n"
-"/SC { scale } bind def\n"
-//"/GPD { currentpagedevice /PageSize get} def\n"
-
-// show at position with desired width
-// usage:
-// width (string) x y show_pos_width
-"/show_pos_width {GS moveto dup dup stringwidth pop exch length exch 3 index exch sub exch "
-"div 0 2 index 1 -1 scale ashow pop pop GR} bind def\n" // spacing altered to match desired width
-//"/show_pos_width {GS moveto dup stringwidth pop 3 2 roll exch div -1 matrix scale concat "
-//"show GR } bind def\n" // horizontally scaled text to match desired width
-
-;
-
-
-static const char * prolog_2 = // prolog relevant only if lang_level >1
-
-// color image dictionaries
-"/CII {GS /inter exch def /py exch def /px exch def /sy exch def /sx exch def \n"
-"translate \n"
-"sx sy scale\n"
-"/DeviceRGB setcolorspace\n"
-"/IDD 8 dict def\n"
-"IDD begin\n"
-"/ImageType 1 def\n"
-"/Width px def\n"
-"/Height py def\n"
-"/BitsPerComponent 8 def\n"
-"/Interpolate inter def\n"
-"/DataSource currentfile /ASCIIHexDecode filter def\n"
-"/MultipleDataSources false def\n"
-"/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
-"/Decode [ 0 1 0 1 0 1 ] def\n"
-"end\n"
-"IDD image GR} bind def\n"
-
-// gray image dict
-
-
-"/GII {GS /inter exch def /py exch def /px exch def /sy exch def /sx exch def \n"
-"translate \n"
-"sx sy scale\n"
-"/DeviceGray setcolorspace\n"
-"/IDD 8 dict def\n"
-"IDD begin\n"
-"/ImageType 1 def\n"
-"/Width px def\n"
-"/Height py def\n"
-"/BitsPerComponent 8 def\n"
-
-"/Interpolate inter def\n"
-"/DataSource currentfile /ASCIIHexDecode filter def\n"
-"/MultipleDataSources false def\n"
-"/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
-"/Decode [ 0 1 ] def\n"
-"end\n"
-"IDD image GR} bind def\n"
-
-;
-
-static const char * prolog_2_pixmap = // prolog relevant only if lang_level == 2 for pixmaps
-"/pixmap_size { /pixmap_sy exch def /pixmap_sx exch def } bind def\n"
-
-"/pixmap_mat {[ pixmap_sx 0 0 pixmap_sy neg 0 pixmap_sy ]} bind def\n"
-
-"/pixmap_dict {"
-"<< /PatternType 1 "
-"/PaintType 1 "
-"/TilingType 2 "
-"/BBox [0 0 pixmap_sx pixmap_sy] "
-"/XStep pixmap_sx "
-"/YStep pixmap_sy\n"
-"/PaintProc "
-"{ begin "
-"pixmap_sx pixmap_sy scale "
-"pixmap_sx pixmap_sy 8 "
-"pixmap_mat "
-"pixmap_data "
-"false 3 "
-"colorimage "
-"end "
-"} bind "
-">>\n"
-"} bind def\n"
-
-"/pixmap_plot {"
-"GS "
-"/pixmap_y exch def /pixmap_x exch def\n"
-"pixmap_x pixmap_y translate\n"
-"pixmap_dict matrix makepattern setpattern\n"
-"pixmap_sx pixmap_sy scale\n"
-"pixmap_sx pixmap_sy\n"
-"true\n"
-"pixmap_mat\n"
-"pixmap_mask\n"
-"imagemask\n"
-"GR\n"
-"} bind def\n"
-
-"/pixmap_loaddata { /pixmap_data currentfile pixmap_sx pixmap_sy 3 mul mul string readhexstring "
-"} bind def\n"
-
-"/pixmap_loadmask { "
-"/pixmap_mask currentfile pixmap_sx 8 div ceiling cvi pixmap_sy mul string readhexstring "
-"} bind def\n"
-;
-
-
-
-static const char * prolog_3 = // prolog relevant only if lang_level >2
-
-// masked color images
-"/CIM {GS /inter exch def /my exch def /mx exch def /py exch def /px exch def /sy exch def /sx exch def \n"
-"translate \n"
-"sx sy scale\n"
-"/DeviceRGB setcolorspace\n"
-
-"/IDD 8 dict def\n"
-
-"IDD begin\n"
-"/ImageType 1 def\n"
-"/Width px def\n"
-"/Height py def\n"
-"/BitsPerComponent 8 def\n"
-"/Interpolate inter def\n"
-"/DataSource currentfile /ASCIIHexDecode filter def\n"
-"/MultipleDataSources false def\n"
-"/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
-
-"/Decode [ 0 1 0 1 0 1 ] def\n"
-"end\n"
-
-"/IMD 8 dict def\n"
-"IMD begin\n"
-"/ImageType 1 def\n"
-"/Width mx def\n"
-"/Height my def\n"
-"/BitsPerComponent 1 def\n"
-// "/Interpolate inter def\n"
-"/ImageMatrix [ mx 0 0 my neg 0 my ] def\n"
-"/Decode [ 1 0 ] def\n"
-"end\n"
-
-"<<\n"
-"/ImageType 3\n"
-"/InterleaveType 2\n"
-"/MaskDict IMD\n"
-"/DataDict IDD\n"
-">> image GR\n"
-"} bind def\n"
-
-
-// masked gray images
-"/GIM {GS /inter exch def /my exch def /mx exch def /py exch def /px exch def /sy exch def /sx exch def \n"
-"translate \n"
-"sx sy scale\n"
-"/DeviceGray setcolorspace\n"
-
-"/IDD 8 dict def\n"
-
-"IDD begin\n"
-"/ImageType 1 def\n"
-"/Width px def\n"
-"/Height py def\n"
-"/BitsPerComponent 8 def\n"
-"/Interpolate inter def\n"
-"/DataSource currentfile /ASCIIHexDecode filter def\n"
-"/MultipleDataSources false def\n"
-"/ImageMatrix [ px 0 0 py neg 0 py ] def\n"
-
-"/Decode [ 0 1 ] def\n"
-"end\n"
-
-"/IMD 8 dict def\n"
-
-"IMD begin\n"
-"/ImageType 1 def\n"
-"/Width mx def\n"
-"/Height my def\n"
-"/BitsPerComponent 1 def\n"
-"/ImageMatrix [ mx 0 0 my neg 0 my ] def\n"
-"/Decode [ 1 0 ] def\n"
-"end\n"
-
-"<<\n"
-"/ImageType 3\n"
-"/InterleaveType 2\n"
-"/MaskDict IMD\n"
-"/DataDict IDD\n"
-">> image GR\n"
-"} bind def\n"
-
-
-"\n"
-;
-
-// end prolog
-
-int Fl_PSfile_Device::start_postscript (int pagecount, enum Page_Format format, enum Page_Layout layout)
-//returns 0 iff OK
-{
- int w, h, x;
- this->set_current();
- if (format == A4) {
- left_margin = 18;
- top_margin = 18;
- }
- else {
- left_margin = 12;
- top_margin = 12;
- }
- page_format_ = (enum Page_Format)(format | layout);
-
- fputs("%!PS-Adobe-3.0\n", output);
- fputs("%%Creator: FLTK\n", output);
- if (lang_level_>1)
- fprintf(output, "%%%%LanguageLevel: %i\n" , lang_level_);
- if ((pages_ = pagecount))
- fprintf(output, "%%%%Pages: %i\n", pagecount);
- else
- fputs("%%Pages: (atend)\n", output);
- fprintf(output, "%%%%BeginFeature: *PageSize %s\n", page_formats[format].name );
- w = page_formats[format].width;
- h = page_formats[format].height;
- if (lang_level_ == 3 && (layout & LANDSCAPE) ) { x = w; w = h; h = x; }
- fprintf(output, "<</PageSize[%d %d]>>setpagedevice\n", w, h );
- fputs("%%EndFeature\n", output);
- fputs("%%EndComments\n", output);
- fputs(prolog, output);
- if (lang_level_ > 1) {
- fputs(prolog_2, output);
- }
- if (lang_level_ == 2) {
- fputs(prolog_2_pixmap, output);
- }
- if (lang_level_ > 2)
- fputs(prolog_3, output);
- if (lang_level_ >= 3) {
- fputs("/CS { clipsave } bind def\n", output);
- fputs("/CR { cliprestore } bind def\n", output);
- } else {
- fputs("/CS { GS } bind def\n", output);
- fputs("/CR { GR } bind def\n", output);
- }
- page_policy_ = 1;
-
-
- fputs("%%EndProlog\n",output);
- if (lang_level_ >= 2)
- fprintf(output,"<< /Policies << /Pagesize 1 >> >> setpagedevice\n");
-
- reset();
- nPages=0;
- return 0;
-}
-
-void Fl_PSfile_Device::recover(){
- color(cr_,cg_,cb_);
- line_style(linestyle_,linewidth_,linedash_);
- font(font_,size_);
-}
-
-void Fl_PSfile_Device::reset(){
- gap_=1;
- clip_=0;
- cr_=cg_=cb_=0;
- font_=FL_HELVETICA;
- size_=12;
- linewidth_=0;
- linestyle_=FL_SOLID;
- strcpy(linedash_,"");
- Clip *c=clip_; ////just not to have memory leaks for badly writen code (forgotten clip popping)
-
- while(c){
- clip_=clip_->prev;
- delete c;
- c=clip_;
- }
-
-}
-
-void Fl_PSfile_Device::page_policy(int p){
- page_policy_ = p;
- if(lang_level_>=2)
- fprintf(output,"<< /Policies << /Pagesize %i >> >> setpagedevice\n", p);
-}
-
-// //////////////////// paging //////////////////////////////////////////
-
-
-
-void Fl_PSfile_Device::page(double pw, double ph, int media) {
-
- if (nPages){
- fprintf(output, "CR\nGR\nGR\nGR\nSP\nrestore\n");
- }
- ++nPages;
- fprintf(output, "%%%%Page: %i %i\n" , nPages , nPages);
- if (pw>ph){
- fprintf(output, "%%%%PageOrientation: Landscape\n");
- }else{
- fprintf(output, "%%%%PageOrientation: Portrait\n");
- }
-
- fprintf(output, "%%%%BeginPageSetup\n");
- if((media & MEDIA) &&(lang_level_>1)){
- int r = media & REVERSED;
- if(r) r = 2;
- fprintf(output, "<< /PageSize [%i %i] /Orientation %i>> setpagedevice\n", (int)(pw+.5), (int)(ph+.5), r);
- }
- fprintf(output, "%%%%EndPageSetup\n");
-
- pw_ = pw;
- ph_ = ph;
- reset();
-
- fprintf(output, "save\n");
- fprintf(output, "GS\n");
- fprintf(output, "%g %g TR\n", (double)0 /*lm_*/ , ph_ /* - tm_*/);
- fprintf(output, "1 -1 SC\n");
- line_style(0);
- fprintf(output, "GS\n");
-
- if (!((media & MEDIA) &&(lang_level_>1))){
- if (pw > ph) {
- if(media & REVERSED) {
- fprintf(output, "-90 rotate %i 0 translate\n", int(-pw));
- }
- else {
- fprintf(output, "90 rotate -%i -%i translate\n", (lang_level_ == 2 ? int(pw - ph) : 0), int(ph));
- }
- }
- else {
- if(media & REVERSED)
- fprintf(output, "180 rotate %i %i translate\n", int(-pw), int(-ph));
- }
- }
- fprintf(output, "GS\nCS\n");
-};
-
-void Fl_PSfile_Device::page(int format){
-
-
- if(format & LANDSCAPE){
- ph_=Fl_PSfile_Device::page_formats[format & 0xFF].width;
- pw_=Fl_PSfile_Device::page_formats[format & 0xFF].height;
- }else{
- pw_=Fl_PSfile_Device::page_formats[format & 0xFF].width;
- ph_=Fl_PSfile_Device::page_formats[format & 0xFF].height;
- }
- page(pw_,ph_,format & 0xFF00);//,orientation only;
-};
-
-void Fl_PSfile_Device::rect(int x, int y, int w, int h) {
- // Commented code does not work, i can't find the bug ;-(
- // fprintf(output, "GS\n");
- // fprintf(output, "%i, %i, %i, %i R\n", x , y , w, h);
- // fprintf(output, "GR\n");
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x , y);
- fprintf(output, "%i %i LT\n", x+w-1 , y);
- fprintf(output, "%i %i LT\n", x+w-1 , y+h-1);
- fprintf(output, "%i %i LT\n", x , y+h-1);
- fprintf(output, "ECP\n");
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::rectf(int x, int y, int w, int h) {
- fprintf(output, "%g %g %i %i FR\n", x-0.5, y-0.5, w, h);
-}
-
-void Fl_PSfile_Device::line(int x1, int y1, int x2, int y2) {
- fprintf(output, "GS\n");
- fprintf(output, "%i %i %i %i L\n", x1 , y1, x2 ,y2);
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::line(int x0, int y0, int x1, int y1, int x2, int y2) {
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x0 , y0);
- fprintf(output, "%i %i LT\n", x1 , y1);
- fprintf(output, "%i %i LT\n", x2 , y2);
- fprintf(output, "ELP\n");
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::xyline(int x, int y, int x1, int y2, int x3){
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x , y );
- fprintf(output, "%i %i LT\n", x1 , y );
- fprintf(output, "%i %i LT\n", x1 , y2);
- fprintf(output,"%i %i LT\n", x3 , y2);
- fprintf(output, "ELP\n");
- fprintf(output, "GR\n");
-};
-
-
-void Fl_PSfile_Device::xyline(int x, int y, int x1, int y2){
-
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x , y);
- fprintf(output,"%i %i LT\n", x1 , y);
- fprintf(output, "%i %i LT\n", x1 , y2 );
- fprintf(output, "ELP\n");
- fprintf(output, "GR\n");
-};
-
-void Fl_PSfile_Device::xyline(int x, int y, int x1){
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x , y);
- fprintf(output, "%i %i LT\n", x1 , y );
- fprintf(output, "ELP\n");
-
- fprintf(output, "GR\n");
-};
-
-void Fl_PSfile_Device::yxline(int x, int y, int y1, int x2, int y3){
- fprintf(output, "GS\n");
-
- fprintf(output,"BP\n");
- fprintf(output,"%i %i MT\n", x , y);
- fprintf(output, "%i %i LT\n", x , y1 );
- fprintf(output, "%i %i LT\n", x2 , y1 );
- fprintf(output , "%i %i LT\n", x2 , y3);
- fprintf(output, "ELP\n");
- fprintf(output, "GR\n");
-};
-
-void Fl_PSfile_Device::yxline(int x, int y, int y1, int x2){
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x , y);
- fprintf(output, "%i %i LT\n", x , y1);
- fprintf(output, "%i %i LT\n", x2 , y1);
- fprintf(output, "ELP\n");
- fprintf(output, "GR\n");
-};
-
-void Fl_PSfile_Device::yxline(int x, int y, int y1){
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x , y);
- fprintf(output, "%i %i LT\n", x , y1);
- fprintf(output, "ELP\n");
- fprintf(output, "GR\n");
-};
-
-void Fl_PSfile_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2) {
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x0 , y0);
- fprintf(output, "%i %i LT\n", x1 , y1);
- fprintf(output, "%i %i LT\n", x2 , y2);
- fprintf(output, "ECP\n");
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x0 , y0);
- fprintf(output, "%i %i LT\n", x1 , y1);
- fprintf(output, "%i %i LT\n", x2 , y2);
- fprintf(output, "%i %i LT\n", x3 , y3);
- fprintf(output, "ECP\n");
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2) {
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x0 , y0);
- fprintf(output,"%i %i LT\n", x1 , y1);
- fprintf(output, "%i %i LT\n", x2 , y2);
- fprintf(output, "EFP\n");
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) {
- fprintf(output, "GS\n");
- fprintf(output,"BP\n");
- fprintf(output, "%i %i MT\n", x0 , y0 );
- fprintf(output, "%i %i LT\n", x1 , y1 );
- fprintf(output, "%i %i LT\n", x2 , y2 );
- fprintf(output, "%i %i LT\n", x3 , y3 );
-
- fprintf(output, "EFP\n");
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::point(int x, int y){
- rectf(x,y,1,1);
-}
-
-static int dashes_flat[5][7]={
-{-1,0,0,0,0,0,0},
-{3,1,-1,0,0,0,0},
-{1,1,-1,0,0,0,0},
-{3,1,1,1,-1,0,0},
-{3,1,1,1,1,1,-1}
-};
-
-
-//yeah, hack...
-static double dashes_cap[5][7]={
-{-1,0,0,0,0,0,0},
-{2,2,-1,0,0,0,0},
-{0.01,1.99,-1,0,0,0,0},
-{2,2,0.01,1.99,-1,0,0},
-{2,2,0.01,1.99,0.01,1.99,-1}
-};
-
-
-void Fl_PSfile_Device::line_style(int style, int width, char* dashes){
- //line_styled_=1;
-
- linewidth_=width;
- linestyle_=style;
- //dashes_= dashes;
- if(dashes){
- if(dashes != linedash_)
- strcpy(linedash_,dashes);
-
- }else
- linedash_[0]=0;
- char width0 = 0;
- if(!width){
- width=1; //for screen drawing compatability
- width0=1;
- }
-
- fprintf(output, "%i setlinewidth\n", width);
-
- if(!style && (!dashes || !(*dashes)) && width0) //system lines
- style = FL_CAP_SQUARE;
-
- int cap = (style &0xf00) >> 8;
- if(cap) cap--;
- fprintf(output,"%i setlinecap\n", cap);
-
- int join = (style & 0xf000) >> 12;
-
- if(join) join--;
- fprintf(output,"%i setlinejoin\n", join);
-
-
- fprintf(output, "[");
- if(dashes && *dashes){
- while(*dashes){
- fprintf(output, "%i ", *dashes);
- dashes++;
- }
- }else{
- int * ds;
- if(style & 0x200){ // round and square caps, dash length need to be adjusted
- double *dt = dashes_cap[style & 0xff];
- while (*dt >= 0){
- fprintf(output, "%g ",width * (*dt));
- dt++;
- }
- }else{
-
- ds = dashes_flat[style & 0xff];
- while (*ds >= 0){
- fprintf(output, "%i ",width * (*ds));
- ds++;
- }
- }
- }
- fprintf(output, "] 0 setdash\n");
-};
-
-static const char *_fontNames[] = {
-"Helvetica",
-"Helvetica-Bold",
-"Helvetica-Oblique",
-"Helvetica-BoldOblique",
-"Courier",
-"Courier-Bold",
-"Courier-Oblique",
-"Courier-BoldOblique",
-"Times",
-"Times-Bold",
-"Times-Italic",
-"Times-BoldItalic",
-"Symbol",
-"Courier",
-"Courier-Bold",
-"ZapfDingbats"
-};
-
-void Fl_PSfile_Device::font(int f, int s) {
- if (f >= FL_FREE_FONT)
- f = FL_COURIER;
- fprintf(output, "/%s SF\n" , _fontNames[f]);
- fprintf(output,"%i FS\n", s);
- Fl_Device::display_device()->font(f,s); // Use display fonts for font measurement
- font_ = f; size_ = s;
-};
-
-void Fl_PSfile_Device::color(Fl_Color c) {
- //colored_=1;
- color_=c;
- Fl::get_color(c, cr_, cg_, cb_);
- if (cr_==cg_ && cg_==cb_) {
- double gray = cr_/255.0;
- fprintf(output, "%g GL\n", gray);
-
- } else {
- double fr, fg, fb;
- fr = cr_/255.0;
- fg = cg_/255.0;
- fb = cb_/255.0;
- fprintf(output,"%g %g %g SRGB\n", fr , fg , fb);
- }
-}
-
-void Fl_PSfile_Device::color(unsigned char r, unsigned char g, unsigned char b) {
- //colored_=1;
- cr_=r;cg_=g;cb_=b;
- if (r==g && g==b) {
- double gray = r/255.0;
- fprintf(output, "%g GL\n", gray);
- } else {
- double fr, fg, fb;
- fr = r/255.0;
- fg = g/255.0;
- fb = b/255.0;
- fprintf(output, "%g %g %g SRGB\n", fr , fg , fb);
- }
-}
-
-void Fl_PSfile_Device::draw(int angle, const char *str, int n, int x, int y)
-{
- fprintf(output, "GS %d %d translate %d rotate\n", x, y, - angle);
- this->transformed_draw(str, n, 0, 0);
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::transformed_draw(const char* str, int n, double x, double y){
- if (!n || !str || !*str)return;
- fprintf(output,"%g (", fl_width(str, n));
- int i=1;
- for (int j=0;j<n;j++){
- if (i>240){
- fprintf(output, "\\\n");
- i=0;
- }
- i++;
- switch (*str) {
- case '(': case ')': case '\\' :
- putc('\\' , output);
- /* fallthrough */
- default:
- putc(*str , output);
- }
- str++;
- }
- fprintf(output, ") %g %g show_pos_width\n", x, y);
-}
-
-struct matrix {double a, b, c, d, x, y;};
-extern matrix * fl_matrix;
-
-void Fl_PSfile_Device::concat(){
- fprintf(output,"[%g %g %g %g %g %g] CT\n", fl_matrix->a , fl_matrix->b , fl_matrix->c , fl_matrix->d , fl_matrix->x , fl_matrix->y);
-}
-
-void Fl_PSfile_Device::reconcat(){
- fprintf(output, "[%g %g %g %g %g %g] RCT\n" , fl_matrix->a , fl_matrix->b , fl_matrix->c , fl_matrix->d , fl_matrix->x , fl_matrix->y);
-}
-
-///////////////// transformed (double) drawings ////////////////////////////////
-
-
-void Fl_PSfile_Device::begin_points(){
- fprintf(output, "GS\n");
- concat();
-
- fprintf(output, "BP\n");
- gap_=1;
- shape_=POINTS;
-};
-
-void Fl_PSfile_Device::begin_line(){
- fprintf(output, "GS\n");
- concat();
- fprintf(output, "BP\n");
- gap_=1;
- shape_=LINE;
-};
-
-void Fl_PSfile_Device::begin_loop(){
- fprintf(output, "GS\n");
- concat();
- fprintf(output, "BP\n");
- gap_=1;
- shape_=LOOP;
-};
-
-void Fl_PSfile_Device::begin_polygon(){
- fprintf(output, "GS\n");
- concat();
- fprintf(output, "BP\n");
- gap_=1;
- shape_=POLYGON;
-};
-
-void Fl_PSfile_Device::vertex(double x, double y){
- if(shape_==POINTS){
- fprintf(output,"%g %g MT\n", x , y);
- gap_=1;
- return;
- }
- if(gap_){
- fprintf(output,"%g %g MT\n", x , y);
- gap_=0;
- }else
- fprintf(output, "%g %g LT\n", x , y);
-};
-
-void Fl_PSfile_Device::curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3){
- if(shape_==NONE) return;
- if(gap_)
- fprintf(output,"%g %g MT\n", x , y);
- else
- fprintf(output, "%g %g LT\n", x , y);
- gap_=0;
-
- fprintf(output, "%g %g %g %g %g %g curveto \n", x1 , y1 , x2 , y2 , x3 , y3);
-};
-
-
-void Fl_PSfile_Device::circle(double x, double y, double r){
- if(shape_==NONE){
- fprintf(output, "GS\n");
- concat();
- // fprintf(output, "BP\n");
- fprintf(output,"%g %g %g 0 360 arc\n", x , y , r);
- reconcat();
- // fprintf(output, "ELP\n");
- fprintf(output, "GR\n");
- }else
-
- fprintf(output, "%g %g %g 0 360 arc\n", x , y , r);
-
-};
-
-void Fl_PSfile_Device::arc(double x, double y, double r, double start, double a){
- if(shape_==NONE) return;
- gap_=0;
- if(start>a)
- fprintf(output, "%g %g %g %g %g arc\n", x , y , r , -start, -a);
- else
- fprintf(output, "%g %g %g %g %g arcn\n", x , y , r , -start, -a);
-
-};
-
-void Fl_PSfile_Device::arc(int x, int y, int w, int h, double a1, double a2) {
- fprintf(output, "GS\n");
- //fprintf(output, "BP\n");
- begin_line();
- fprintf(output, "%g %g TR\n", x + w/2.0 -0.5 , y + h/2.0 - 0.5);
- fprintf(output, "%g %g SC\n", (w-1)/2.0 , (h-1)/2.0 );
- arc(0,0,1,a2,a1);
- // fprintf(output, "0 0 1 %g %g arc\n" , -a1 , -a2);
- fprintf(output, "%g %g SC\n", 2.0/(w-1) , 2.0/(h-1) );
- fprintf(output, "%g %g TR\n", -x - w/2.0 +0.5 , -y - h/2.0 +0.5);
- end_line();
-
- // fprintf(output, "%g setlinewidth\n", 2/sqrt(w*h));
- // fprintf(output, "ELP\n");
- // fprintf(output, 2.0/w , 2.0/w , " SC\n";
- // fprintf(output, (-x - w/2.0) , (-y - h/2) , " TR\n";
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::pie(int x, int y, int w, int h, double a1, double a2) {
-
- fprintf(output, "GS\n");
- fprintf(output, "%g %g TR\n", x + w/2.0 -0.5 , y + h/2.0 - 0.5);
- fprintf(output, "%g %g SC\n", (w-1)/2.0 , (h-1)/2.0 );
- begin_polygon();
- vertex(0,0);
- arc(0.0,0.0, 1, a2, a1);
- end_polygon();
- fprintf(output, "GR\n");
-}
-
-void Fl_PSfile_Device::end_points(){
- gap_=1;
- reconcat();
- fprintf(output, "ELP\n"); //??
- fprintf(output, "GR\n");
- shape_=NONE;
-}
-
-void Fl_PSfile_Device::end_line(){
- gap_=1;
- reconcat();
- fprintf(output, "ELP\n");
- fprintf(output, "GR\n");
- shape_=NONE;
-}
-void Fl_PSfile_Device::end_loop(){
- gap_=1;
- reconcat();
- fprintf(output, "ECP\n");
- fprintf(output, "GR\n");
- shape_=NONE;
-}
-
-void Fl_PSfile_Device::end_polygon(){
-
- gap_=1;
- reconcat();
- fprintf(output, "EFP\n");
- fprintf(output, "GR\n");
- shape_=NONE;
-}
-
-void Fl_PSfile_Device::transformed_vertex(double x, double y){
- reconcat();
- if(gap_){
- fprintf(output, "%g %g MT\n", x , y);
- gap_=0;
- }else
- fprintf(output, "%g %g LT\n", x , y);
- concat();
-};
-
-///////////////////////////// Clipping /////////////////////////////////////////////
-
-void Fl_PSfile_Device::push_clip(int x, int y, int w, int h) {
- Clip * c=new Clip();
- clip_box(x,y,w,h,c->x,c->y,c->w,c->h);
- c->prev=clip_;
- clip_=c;
- fprintf(output, "CR\nCS\n");
- if(lang_level_<3)
- recover();
- fprintf(output, "%g %g %i %i CL\n", clip_->x-0.5 , clip_->y-0.5 , clip_->w , clip_->h);
-
-}
-
-void Fl_PSfile_Device::push_no_clip() {
- Clip * c = new Clip();
- c->prev=clip_;
- clip_=c;
- clip_->x = clip_->y = clip_->w = clip_->h = -1;
- fprintf(output, "CR\nCS\n");
- if(lang_level_<3)
- recover();
-}
-
-void Fl_PSfile_Device::pop_clip() {
- if(!clip_)return;
- Clip * c=clip_;
- clip_=clip_->prev;
- delete c;
- fprintf(output, "CR\nCS\n");
- if(clip_ && clip_->w >0)
- fprintf(output, "%g %g %i %i CL\n", clip_->x - 0.5, clip_->y - 0.5, clip_->w , clip_->h);
- // uh, -0.5 is to match screen clipping, for floats there should be something beter
- if(lang_level_<3)
- recover();
-}
-
-int Fl_PSfile_Device::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H){
- if(!clip_){
- X=x;Y=y;W=w;H=h;
- return 1;
- }
- if(clip_->w < 0){
- X=x;Y=y;W=w;H=h;
- return 1;
- }
- int ret=0;
- if (x > (X=clip_->x)) {X=x; ret=1;}
- if (y > (Y=clip_->y)) {Y=y; ret=1;}
- if ((x+w) < (clip_->x+clip_->w)) {
- W=x+w-X;
-
- ret=1;
-
- }else
- W = clip_->x + clip_->w - X;
- if(W<0){
- W=0;
- return 1;
- }
- if ((y+h) < (clip_->y+clip_->h)) {
- H=y+h-Y;
- ret=1;
- }else
- H = clip_->y + clip_->h - Y;
- if(H<0){
- W=0;
- H=0;
- return 1;
- }
- return ret;
-};
-
-int Fl_PSfile_Device::not_clipped(int x, int y, int w, int h){
- if(!clip_) return 1;
- if(clip_->w < 0) return 1;
- int X, Y, W, H;
- clip_box(x, y, w, h, X, Y, W, H);
- if(W) return 1;
- return 0;
-};
-
-
-void Fl_PSfile_Device::margins(int *left, int *top, int *right, int *bottom) // to implement
-{
- if(left) *left = (int)(left_margin / scale_x + .5);
- if(right) *right = (int)(left_margin / scale_x + .5);
- if(top) *top = (int)(top_margin / scale_y + .5);
- if(bottom) *bottom = (int)(top_margin / scale_y + .5);
-}
-
-int Fl_PSfile_Device::printable_rect(int *w, int *h)
-//returns 0 iff OK
-{
- if(w) *w = (int)((pw_ - 2 * left_margin) / scale_x + .5);
- if(h) *h = (int)((ph_ - 2 * top_margin) / scale_y + .5);
- return 0;
-}
-
-void Fl_PSfile_Device::origin(int x, int y)
-{
- x_offset = x;
- y_offset = y;
- fprintf(output, "GR GR GS %d %d TR %f %f SC %d %d TR %f rotate GS\n",
- left_margin, top_margin, scale_x, scale_y, x, y, angle);
-}
-
-void Fl_PSfile_Device::scale (float s_x, float s_y)
-{
- scale_x = s_x;
- scale_y = s_y;
- fprintf(output, "GR GR GS %d %d TR %f %f SC %f rotate GS\n",
- left_margin, top_margin, scale_x, scale_y, angle);
-}
-
-void Fl_PSfile_Device::rotate (float rot_angle)
-{
- angle = - rot_angle;
- fprintf(output, "GR GR GS %d %d TR %f %f SC %d %d TR %f rotate GS\n",
- left_margin, top_margin, scale_x, scale_y, x_offset, y_offset, angle);
-}
-
-void Fl_PSfile_Device::translate(int x, int y)
-{
- fprintf(output, "GS %d %d translate GS\n", x, y);
-}
-
-void Fl_PSfile_Device::untranslate(void)
-{
- fprintf(output, "GR GR\n");
-}
-
-int Fl_PSfile_Device::start_page (void)
-{
- page(page_format_);
- x_offset = 0;
- y_offset = 0;
- scale_x = scale_y = 1.;
- angle = 0;
- fprintf(output, "GR GR GS %d %d translate GS\n", left_margin, top_margin);
- return 0;
-}
-
-int Fl_PSfile_Device::end_page (void)
-{
- return 0;
-}
-
-void Fl_PSfile_Device::end_job (void)
-// finishes PostScript & closes file
-{
- if (nPages) { // for eps nPages is 0 so it is fine ....
- fprintf(output, "CR\nGR\nGR\nGR\nSP\n restore\n");
- if (!pages_){
- fprintf(output, "%%%%Trailer\n");
- fprintf(output, "%%%%Pages: %i\n" , nPages);
- };
- } else
- fprintf(output, "GR\n restore\n");
- fputs("%%EOF",output);
- reset();
- fflush(output);
- if(ferror(output)) {
- fl_alert ("Error during PostScript data output.");
- }
-#if ! (defined(__APPLE__) || defined(WIN32) )
- if (print_pipe)
- pclose(output);
- else
- fclose(output);
-#else
- fclose(output);
-#endif
- while (clip_){
- Clip * c= clip_;
- clip_= clip_->prev;
- delete c;
- }
- if (close_cmd_) (*close_cmd_)(output);
- Fl_Device::display_device()->set_current();
-}
-
-#if ! (defined(__APPLE__) || defined(WIN32) )
-int Fl_Printer::start_job(int pages, int *firstpage, int *lastpage) {
- enum Page_Format format;
- enum Page_Layout layout;
-
- // first test version for print dialog
- if (!print_panel) make_print_panel();
- print_load();
- print_selection->deactivate();
- print_all->setonly();
- print_all->do_callback();
- print_from->value("1");
- { char tmp[10]; snprintf(tmp, sizeof(tmp), "%d", pages); print_to->value(tmp); }
- print_panel->show(); // this is modal
- while (print_panel->shown()) Fl::wait();
-
- if (!print_start) // user clicked cancel
- return 1;
-
- // get options
-
- format = print_page_size->value() ? A4 : LETTER;
- { // page range choice
- int from = 1, to = pages;
- if (print_pages->value()) {
- sscanf(print_from->value(), "%d", &from);
- sscanf(print_to->value(), "%d", &to);
- }
- if (from < 1) from = 1;
- if (to > pages) to = pages;
- if (to < from) to = from;
- if (firstpage) *firstpage = from;
- if (lastpage) *lastpage = to;
- pages = to - from + 1;
- }
-
- if (print_output_mode[0]->value()) layout = PORTRAIT;
- else if (print_output_mode[1]->value()) layout = LANDSCAPE;
- else if (print_output_mode[2]->value()) layout = PORTRAIT;
- else layout = LANDSCAPE;
-
- print_pipe = print_choice->value(); // 0 = print to file, >0 = printer (pipe)
-
- const char *media = print_page_size->text(print_page_size->value());
- const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
- if (!print_pipe) printer = "<File>";
-
- if (!print_pipe) // fall back to file printing
- return Fl_PSfile_Device::start_job (pages, format, layout);
-
- // Print: pipe the output into the lp command...
-
- char command[1024];
- snprintf(command, sizeof(command), "lp -s -d %s -n %d -t '%s' -o media=%s",
- printer, print_collate_button->value() ? 1 : (int)(print_copies->value() + 0.5),
- "FLTK", media);
-
- output = popen(command, "w");
- if (!output) {
- fl_alert("could not run command: %s\n",command);
- return 1;
- }
-
- return Fl_PSfile_Device::start_postscript(pages, format, layout); // start printing
-}
-
-#endif // ! (defined(__APPLE__) || defined(WIN32) )
-
-#endif // FL_DOXYGEN
-
-//
-// End of "$Id$".
-//