diff options
| -rw-r--r-- | src/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/Fl_Printer.cxx | 2 | ||||
| -rw-r--r-- | src/Makefile | 5 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm (renamed from src/Fl_Quartz_Printer.mm) | 2 | ||||
| -rw-r--r-- | src/drivers/Posix/Fl_Posix_Printer_Driver.cxx | 141 | ||||
| -rw-r--r-- | src/drivers/PostScript/Fl_PostScript.cxx | 122 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx (renamed from src/Fl_GDI_Printer.cxx) | 2 |
7 files changed, 152 insertions, 126 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cb32ff56b..6813773bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -169,6 +169,7 @@ if (USE_X11) set(DRIVER_FILES drivers/Posix/Fl_Posix_System_Driver.cxx + drivers/Posix/Fl_Posix_Printer_Driver.cxx drivers/X11/Fl_X11_Screen_Driver.cxx drivers/X11/Fl_X11_Window_Driver.cxx drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx @@ -264,6 +265,7 @@ else () drivers/WinAPI/Fl_WinAPI_System_Driver.cxx drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx + drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx drivers/GDI/Fl_GDI_Graphics_Driver.cxx drivers/GDI/Fl_GDI_Graphics_Driver_arci.cxx drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx @@ -373,7 +375,7 @@ add_definitions(-DFL_LIBRARY) if(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL)) set(MMFILES Fl_cocoa.mm - Fl_Quartz_Printer.mm + drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm Fl_Native_File_Chooser_MAC.mm Fl_Sys_Menu_Bar.mm ) diff --git a/src/Fl_Printer.cxx b/src/Fl_Printer.cxx index e82163e3b..1d824c9e3 100644 --- a/src/Fl_Printer.cxx +++ b/src/Fl_Printer.cxx @@ -68,7 +68,7 @@ const char *Fl_Printer::property_cancel = NULL; #else -#include "Fl_GDI_Printer.cxx" +//#include "Fl_GDI_Printer.cxx" // print dialog customization strings /** [this text may be customized at run-time] */ diff --git a/src/Makefile b/src/Makefile index f616a8f5a..af93cd432 100644 --- a/src/Makefile +++ b/src/Makefile @@ -165,7 +165,7 @@ CPPFILES = \ OBJCPPFILES = \ Fl_cocoa.mm \ - Fl_Quartz_Printer.mm \ + drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm \ Fl_Native_File_Chooser_MAC.mm \ Fl_Sys_Menu_Bar.mm @@ -252,6 +252,7 @@ XLIBCPPFILES = \ drivers/X11/Fl_X11_Window_Driver.cxx \ drivers/X11/Fl_X11_Screen_Driver.cxx \ drivers/Posix/Fl_Posix_System_Driver.cxx + drivers/Posix/Fl_Posix_Printer_Driver.cxx XLIBFONTFILES = \ drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx @@ -273,7 +274,7 @@ GDICPPFILES = \ drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx \ drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx \ drivers/WinAPI/Fl_WinAPI_System_Driver.cxx \ - Fl_GDI_Printer.cxx + drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx PSCPPFILES = \ drivers/PostScript/Fl_PostScript.cxx \ diff --git a/src/Fl_Quartz_Printer.mm b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm index d9817b7ea..525e545c0 100644 --- a/src/Fl_Quartz_Printer.mm +++ b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm @@ -19,7 +19,7 @@ #include <FL/Fl_Printer.H> #include <FL/Fl_Shared_Image.H> #include <FL/Fl_Window_Driver.H> -#include "drivers/Quartz/Fl_Quartz_Printer_Graphics_Driver.H" +#include "../Quartz/Fl_Quartz_Printer_Graphics_Driver.H" #include <FL/Fl.H> #include <FL/fl_ask.H> diff --git a/src/drivers/Posix/Fl_Posix_Printer_Driver.cxx b/src/drivers/Posix/Fl_Posix_Printer_Driver.cxx new file mode 100644 index 000000000..f06bef7f9 --- /dev/null +++ b/src/drivers/Posix/Fl_Posix_Printer_Driver.cxx @@ -0,0 +1,141 @@ +// +// "$Id: Fl_Posix_Printer_Driver.cxx 11364 2016-03-18 18:20:11Z manolo $" +// +// PostScript priting support for the Fast Light Tool Kit (FLTK). +// +// Copyright 2010-2016 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// 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 +// +// Please report all bugs and problems to: +// +// http://www.fltk.org/str.php +// + +#include "../../src/config_lib.h" + +#if defined(FL_CFG_PRN_PS) + +#include <FL/Fl_PostScript.H> +#include <FL/Fl_Printer.H> +#include <FL/fl_ask.H> + +#include <src/print_panel.cxx> + +/** Support for printing on the Unix/Linux platform */ +class Fl_Posix_Printer_Driver : public Fl_PostScript_File_Device { + virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); +}; + +Fl_Paged_Device* Fl_Paged_Device::newPrinterDriver(void) +{ + return new Fl_Posix_Printer_Driver(); +} + +/** Starts a print job. */ +int Fl_Posix_Printer_Driver::start_job(int pages, int *firstpage, int *lastpage) { + enum Fl_Paged_Device::Page_Format format; + enum Fl_Paged_Device::Page_Layout layout; + + // first test version for print dialog + if (!print_panel) make_print_panel(); + printing_style style = 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 + + switch (print_page_size->value()) { + case 0: + format = Fl_Paged_Device::LETTER; + break; + case 2: + format = Fl_Paged_Device::LEGAL; + break; + case 3: + format = Fl_Paged_Device::EXECUTIVE; + break; + case 4: + format = Fl_Paged_Device::A3; + break; + case 5: + format = Fl_Paged_Device::A5; + break; + case 6: + format = Fl_Paged_Device::B5; + break; + case 7: + format = Fl_Paged_Device::ENVELOPE; + break; + case 8: + format = Fl_Paged_Device::DLE; + break; + default: + format = Fl_Paged_Device::A4; + } + + { // 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; + if (pages > 0) pages = to - from + 1; + } + + if (print_output_mode[0]->value()) layout = Fl_Paged_Device::PORTRAIT; + else if (print_output_mode[1]->value()) layout = Fl_Paged_Device::LANDSCAPE; + else if (print_output_mode[2]->value()) layout = Fl_Paged_Device::PORTRAIT; + else layout = Fl_Paged_Device::LANDSCAPE; + + int 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_PostScript_File_Device::start_job (pages, format, layout); + + // Print: pipe the output into the lp command... + + char command[1024]; + if (style == SystemV) 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); + else snprintf(command, sizeof(command), "lpr -h -P%s -#%d -T FLTK ", + printer, print_collate_button->value() ? 1 : (int)(print_copies->value() + 0.5)); + + Fl_PostScript_Graphics_Driver *ps = driver(); + ps->output = popen(command, "w"); + if (!ps->output) { + fl_alert("could not run command: %s\n",command); + return 1; + } + ps->close_command(pclose); + this->set_current(); + return ps->start_postscript(pages, format, layout); // start printing +} + +#endif // defined(FL_CFG_PRN_PS) + + +// +// End of "$Id: Fl_Posix_Printer_Driver.cxx 11364 2016-03-18 18:20:11Z manolo $". +// diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx index b3e7d214d..7de93e48c 100644 --- a/src/drivers/PostScript/Fl_PostScript.cxx +++ b/src/drivers/PostScript/Fl_PostScript.cxx @@ -1,7 +1,7 @@ // // "$Id$" // -// PostScript device support for the Fast Light Tool Kit (FLTK). +// Classes Fl_PostScript_File_Device and Fl_PostScript_Graphics_Driver for the Fast Light Tool Kit (FLTK). // // Copyright 2010-2016 by Bill Spitzak and others. // @@ -16,8 +16,7 @@ // http://www.fltk.org/str.php // -#include <FL/Fl_Printer.H> -#include <src/config_lib.h> +#include <config.h> #include <FL/Fl.H> #include <FL/fl_ask.H> #include <FL/fl_draw.H> @@ -171,10 +170,6 @@ int Fl_PostScript_Graphics_Driver::clocale_printf(const char *format, ...) #ifndef FL_DOXYGEN -#if ! (defined(__APPLE__) || defined(WIN32) ) // PORTME: Fl_Surface_Driver - platform PostScript -# include <src/print_panel.cxx> -#endif - // Prolog string static const char * prolog = @@ -1557,119 +1552,6 @@ void Fl_PostScript_File_Device::end_job (void) #endif // FL_DOXYGEN - -#if defined(FL_CFG_PRN_PS) - -/** Support for printing on the Unix/Linux platform */ -class Fl_Posix_Printer_Driver : public Fl_PostScript_File_Device { - virtual int start_job(int pagecount, int *frompage = NULL, int *topage = NULL); -}; - -Fl_Paged_Device* Fl_Paged_Device::newPrinterDriver(void) -{ - return new Fl_Posix_Printer_Driver(); -} - -/** Starts a print job. */ -int Fl_Posix_Printer_Driver::start_job(int pages, int *firstpage, int *lastpage) { - enum Fl_Paged_Device::Page_Format format; - enum Fl_Paged_Device::Page_Layout layout; - - // first test version for print dialog - if (!print_panel) make_print_panel(); - printing_style style = 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 - - switch (print_page_size->value()) { - case 0: - format = Fl_Paged_Device::LETTER; - break; - case 2: - format = Fl_Paged_Device::LEGAL; - break; - case 3: - format = Fl_Paged_Device::EXECUTIVE; - break; - case 4: - format = Fl_Paged_Device::A3; - break; - case 5: - format = Fl_Paged_Device::A5; - break; - case 6: - format = Fl_Paged_Device::B5; - break; - case 7: - format = Fl_Paged_Device::ENVELOPE; - break; - case 8: - format = Fl_Paged_Device::DLE; - break; - default: - format = Fl_Paged_Device::A4; - } - - { // 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; - if (pages > 0) pages = to - from + 1; - } - - if (print_output_mode[0]->value()) layout = Fl_Paged_Device::PORTRAIT; - else if (print_output_mode[1]->value()) layout = Fl_Paged_Device::LANDSCAPE; - else if (print_output_mode[2]->value()) layout = Fl_Paged_Device::PORTRAIT; - else layout = Fl_Paged_Device::LANDSCAPE; - - int 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_PostScript_File_Device::start_job (pages, format, layout); - - // Print: pipe the output into the lp command... - - char command[1024]; - if (style == SystemV) 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); - else snprintf(command, sizeof(command), "lpr -h -P%s -#%d -T FLTK ", - printer, print_collate_button->value() ? 1 : (int)(print_copies->value() + 0.5)); - - Fl_PostScript_Graphics_Driver *ps = driver(); - ps->output = popen(command, "w"); - if (!ps->output) { - fl_alert("could not run command: %s\n",command); - return 1; - } - ps->close_command(pclose); - this->set_current(); - return ps->start_postscript(pages, format, layout); // start printing -} - -#endif // defined(FL_CFG_PRN_PS) - - // // End of "$Id$". // diff --git a/src/Fl_GDI_Printer.cxx b/src/drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx index 5491acfdd..0e4d53f8b 100644 --- a/src/Fl_GDI_Printer.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx @@ -18,7 +18,7 @@ #ifdef WIN32 -#include "drivers/GDI/Fl_GDI_Graphics_Driver.H" +#include "../GDI/Fl_GDI_Graphics_Driver.H" #include <FL/Fl_Printer.H> |
