diff options
| -rw-r--r-- | FL/Fl_PSfile_Device.H | 34 | ||||
| -rw-r--r-- | FL/Fl_Printer.H | 61 | ||||
| -rw-r--r-- | src/Fl_PS_Printer.cxx | 129 | ||||
| -rw-r--r-- | src/print_panel.cxx | 64 |
4 files changed, 177 insertions, 111 deletions
diff --git a/FL/Fl_PSfile_Device.H b/FL/Fl_PSfile_Device.H index 70bff5460..5eb9fa5db 100644 --- a/FL/Fl_PSfile_Device.H +++ b/FL/Fl_PSfile_Device.H @@ -38,7 +38,7 @@ This class has the same API as class Fl_Printer except for start_job() member function. \see class Fl_Printer. */ -class FL_EXPORT Fl_PSfile_Device : public Fl_Abstract_Printer { +FL_EXPORT class Fl_PSfile_Device : public Fl_Abstract_Printer { public: /** \brief Possible page formats. @@ -251,42 +251,12 @@ class FL_EXPORT Fl_PSfile_Device : public Fl_Abstract_Printer { int end_page (void); void end_job(void); #endif // FL_DOXYGEN - - /** - @brief The constructor. - */ Fl_PSfile_Device(void); - - /** - @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 start_job(int pagecount, enum Page_Format format = A4, enum Page_Layout layout = PORTRAIT); - - /** - @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 start_job(FILE *ps_output, int pagecount, enum Page_Format format = A4, enum Page_Layout layout = PORTRAIT); - - /** - @brief The destructor. - */ virtual ~Fl_PSfile_Device(); - // how to have the const value appear in Doxygen as occurs with Fl_File_Chooser ? - /** \brief "Select a .ps file" [this text may be customized at run-time] */ + /** [this text may be customized at run-time] */ static const char *file_chooser_title; }; diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H index 6636d2138..e3a90c806 100644 --- a/FL/Fl_Printer.H +++ b/FL/Fl_Printer.H @@ -94,6 +94,48 @@ public: #endif int end_page (void); void end_job (void); +#ifdef FL_DOXYGEN + /** \name These attributes apply to the Xlib platform only. + \{ + */ + /** [this text may be customized at run-time] */ + static const char *dialog_title; + /** [this text may be customized at run-time] */ + static const char *dialog_printer; + /** [this text may be customized at run-time] */ + static const char *dialog_range; + /** [this text may be customized at run-time] */ + static const char *dialog_copies; + /** [this text may be customized at run-time] */ + static const char *dialog_all; + /** [this text may be customized at run-time] */ + static const char *dialog_pages; + /** [this text may be customized at run-time] */ + static const char *dialog_from; + /** [this text may be customized at run-time] */ + static const char *dialog_to; + /** "Properties..." [this text may be customized at run-time] */ + static const char *dialog_properties; + /** [this text may be customized at run-time] */ + static const char *dialog_copyNo; + /** [this text may be customized at run-time] */ + static const char *dialog_print_button; + /** [this text may be customized at run-time] */ + static const char *dialog_cancel_button; + /** [this text may be customized at run-time] */ + static const char *property_title; + /** [this text may be customized at run-time] */ + static const char *property_pagesize; + /** [this text may be customized at run-time] */ + static const char *property_mode; + /** [this text may be customized at run-time] */ + static const char *property_use; + /** [this text may be customized at run-time] */ + static const char *property_save; + /** [this text may be customized at run-time] */ + static const char *property_cancel; + /** \} */ +#endif }; #else @@ -102,6 +144,25 @@ public: class Fl_Printer : public Fl_PSfile_Device { public: + static const char *dialog_title; + static const char *dialog_printer; + static const char *dialog_range; + static const char *dialog_copies; + static const char *dialog_all; + static const char *dialog_pages; + static const char *dialog_from; + static const char *dialog_to; + static const char *dialog_properties; + static const char *dialog_copyNo; + static const char *dialog_print_button; + static const char *dialog_cancel_button; + static const char *property_title; + static const char *property_pagesize; + static const char *property_mode; + static const char *property_use; + static const char *property_save; + static const char *property_cancel; + Fl_Printer(void) {}; ~Fl_Printer(void) {}; int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL); diff --git a/src/Fl_PS_Printer.cxx b/src/Fl_PS_Printer.cxx index 9a41908fe..e6c128818 100644 --- a/src/Fl_PS_Printer.cxx +++ b/src/Fl_PS_Printer.cxx @@ -25,23 +25,87 @@ // http://www.fltk.org/str.php // -#ifndef FL_DOXYGEN - -#include <FL/Fl_PSfile_Device.H> - #include <FL/Fl.H> #include <FL/fl_ask.H> #include <FL/fl_draw.H> -#include <FL/Fl_Native_File_Chooser.H> #include <stdio.h> -#include <math.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; +#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 char *Fl_PSfile_Device::file_chooser_title = "Select a .ps file"; - 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 @@ -394,19 +458,6 @@ static const char * prolog_3 = // prolog relevant only if lang_level >2 // end prolog -Fl_PSfile_Device::Fl_PSfile_Device(void) -{ - close_cmd_ = 0; - //lang_level_ = 3; - lang_level_ = 2; - mask = 0; - ps_filename_ = NULL; - type_ = postscript_device; -#ifdef __APPLE__ - gc = fl_gc; // the display context is used by fl_text_extents() -#endif -} - int Fl_PSfile_Device::start_postscript (int pagecount, enum Page_Format format, enum Page_Layout layout) //returns 0 iff OK { @@ -465,10 +516,6 @@ int Fl_PSfile_Device::start_postscript (int pagecount, enum Page_Format format, return 0; } -Fl_PSfile_Device::~Fl_PSfile_Device() { - if (ps_filename_) free(ps_filename_); -} - void Fl_PSfile_Device::recover(){ color(cr_,cg_,cb_); line_style(linestyle_,linewidth_,linedash_); @@ -1197,30 +1244,6 @@ int Fl_PSfile_Device::end_page (void) return 0; } -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; -} - -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; -} - void Fl_PSfile_Device::end_job (void) // finishes PostScript & closes file { @@ -1321,14 +1344,6 @@ int Fl_Printer::start_job(int pages, int *firstpage, int *lastpage) { return Fl_PSfile_Device::start_postscript(pages, format, layout); // start printing } -/* -void print_cb(Fl_Return_Button *, void *) { - printf ("print_cb called\n"); fflush(stdout); - print_panel->hide(); - // return Fl_PSfile_Device::start_postscript(pages, format); // temporary -} -*/ - #endif // ! (defined(__APPLE__) || defined(WIN32) ) #endif // FL_DOXYGEN diff --git a/src/print_panel.cxx b/src/print_panel.cxx index f8bfc2a1a..27631d8cc 100644 --- a/src/print_panel.cxx +++ b/src/print_panel.cxx @@ -69,6 +69,26 @@ static Fl_Spinner *print_copies=(Fl_Spinner *)0; static int print_start = 0; // 1 if print_okay has been clicked static int print_pipe = 0; // 0 = file, 1 = pipe (lp) +const char *Fl_Printer::dialog_title = "Print"; +const char *Fl_Printer::dialog_printer = "Printer:"; +const char *Fl_Printer::dialog_range = "Print Range"; +const char *Fl_Printer::dialog_copies = "Copies"; +const char *Fl_Printer::dialog_all = "All"; +const char *Fl_Printer::dialog_pages = "Pages"; +const char *Fl_Printer::dialog_from = "From:"; +const char *Fl_Printer::dialog_to = "To:"; +const char *Fl_Printer::dialog_properties = "Properties..."; +const char *Fl_Printer::dialog_copyNo = "# Copies:"; +const char *Fl_Printer::dialog_print_button = "Print"; +const char *Fl_Printer::dialog_cancel_button = "Cancel"; +const char *Fl_Printer::property_title = "Printer Properties"; +const char *Fl_Printer::property_pagesize = "Page Size:"; +const char *Fl_Printer::property_mode = "Output Mode:"; +const char *Fl_Printer::property_use = "Use"; +const char *Fl_Printer::property_save = "Save"; +const char *Fl_Printer::property_cancel = "Cancel"; + + static void cb_print_choice(Fl_Choice*, void*) { print_update_status(); } @@ -248,31 +268,31 @@ static void cb_Use(Fl_Button*, void*) { } Fl_Double_Window* make_print_panel() { - { print_panel = new Fl_Double_Window(465, 235, "Print"); + { print_panel = new Fl_Double_Window(465, 235, Fl_Printer::dialog_title); { print_panel_controls = new Fl_Group(10, 10, 447, 216); - { print_choice = new Fl_Choice(113, 10, 181, 25, "Printer:"); + { print_choice = new Fl_Choice(133, 10, 181, 25, Fl_Printer::dialog_printer); print_choice->down_box(FL_BORDER_BOX); print_choice->labelfont(1); print_choice->callback((Fl_Callback*)cb_print_choice); print_choice->when(FL_WHEN_CHANGED); } // Fl_Choice* print_choice - { print_properties = new Fl_Button(294, 10, 105, 25, "Properties..."); + { print_properties = new Fl_Button(314, 10, 115, 25, Fl_Printer::dialog_properties); print_properties->callback((Fl_Callback*)cb_print_properties); } // Fl_Button* print_properties - { print_status = new Fl_Box(111, 41, 288, 17, "printer/job status"); - print_status->align(Fl_Align(68|FL_ALIGN_INSIDE)); + { print_status = new Fl_Box(0, 41, print_panel_controls->w(), 17, "printer/job status"); + print_status->align(Fl_Align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE|FL_ALIGN_LEFT)); } // Fl_Box* print_status - { Fl_Group* o = new Fl_Group(10, 86, 227, 105, "Print Range"); + { Fl_Group* o = new Fl_Group(10, 86, 227, 105, Fl_Printer::dialog_range); o->box(FL_THIN_DOWN_BOX); o->labelfont(1); o->align(Fl_Align(FL_ALIGN_TOP_LEFT)); - { print_all = new Fl_Round_Button(20, 96, 38, 25, "All"); + { print_all = new Fl_Round_Button(20, 96, 38, 25, Fl_Printer::dialog_all); print_all->type(102); print_all->down_box(FL_ROUND_DOWN_BOX); print_all->value(1); print_all->callback((Fl_Callback*)cb_print_all); } // Fl_Round_Button* print_all - { print_pages = new Fl_Round_Button(20, 126, 64, 25, "Pages"); + { print_pages = new Fl_Round_Button(20, 126, 64, 25, Fl_Printer::dialog_pages); print_pages->type(102); print_pages->down_box(FL_ROUND_DOWN_BOX); print_pages->callback((Fl_Callback*)cb_print_pages); @@ -282,23 +302,23 @@ Fl_Double_Window* make_print_panel() { print_selection->down_box(FL_ROUND_DOWN_BOX); print_selection->callback((Fl_Callback*)cb_print_selection); } // Fl_Round_Button* print_selection - { print_from = new Fl_Int_Input(136, 126, 28, 25, "From:"); + { print_from = new Fl_Int_Input(136, 126, 28, 25, Fl_Printer::dialog_from); print_from->type(2); print_from->textfont(4); print_from->deactivate(); } // Fl_Int_Input* print_from - { print_to = new Fl_Int_Input(199, 126, 28, 25, "To:"); + { print_to = new Fl_Int_Input(199, 126, 28, 25, Fl_Printer::dialog_to); print_to->type(2); print_to->textfont(4); print_to->deactivate(); } // Fl_Int_Input* print_to o->end(); } // Fl_Group* o - { Fl_Group* o = new Fl_Group(247, 86, 210, 105, "Copies"); + { Fl_Group* o = new Fl_Group(247, 86, 210, 105, Fl_Printer::dialog_copies); o->box(FL_THIN_DOWN_BOX); o->labelfont(1); o->align(Fl_Align(FL_ALIGN_TOP_LEFT)); - { print_copies = new Fl_Spinner(321, 96, 45, 25, "# Copies:"); + { print_copies = new Fl_Spinner(321, 96, 45, 25, Fl_Printer::dialog_copyNo); print_copies->callback((Fl_Callback*)cb_print_copies); print_copies->when(FL_WHEN_CHANGED); } // Fl_Spinner* print_copies @@ -436,10 +456,10 @@ Fl_Double_Window* make_print_panel() { } // Fl_Group* print_collate_group[1] o->end(); } // Fl_Group* o - { Fl_Return_Button* o = new Fl_Return_Button(309, 201, 70, 25, "Print"); + { Fl_Return_Button* o = new Fl_Return_Button(279, 201, 100, 25, Fl_Printer::dialog_print_button); o->callback((Fl_Callback*)print_cb); } // Fl_Return_Button* o - { Fl_Button* o = new Fl_Button(389, 201, 68, 25, "Cancel"); + { Fl_Button* o = new Fl_Button(389, 201, 68, 25, Fl_Printer::dialog_cancel_button); o->callback((Fl_Callback*)cb_Cancel); } // Fl_Button* o print_panel_controls->end(); @@ -451,15 +471,15 @@ Fl_Double_Window* make_print_panel() { print_panel->set_modal(); print_panel->end(); } // Fl_Double_Window* print_panel - { print_properties_panel = new Fl_Double_Window(290, 130, "Printer Properties"); + { print_properties_panel = new Fl_Double_Window(290, 130, Fl_Printer::property_title); print_properties_panel->callback((Fl_Callback*)cb_print_properties_panel); - { print_page_size = new Fl_Choice(110, 10, 80, 25, "Page Size:"); + { print_page_size = new Fl_Choice(150, 10, 80, 25, Fl_Printer::property_pagesize); print_page_size->down_box(FL_BORDER_BOX); - print_page_size->labelfont(1); + print_page_size->labelfont(FL_HELVETICA); print_page_size->menu(menu_print_page_size); } // Fl_Choice* print_page_size - { Fl_Group* o = new Fl_Group(110, 45, 170, 40, "Output Mode:"); - o->labelfont(1); + { Fl_Group* o = new Fl_Group(110, 45, 170, 40, Fl_Printer::property_mode); + o->labelfont(FL_HELVETICA); o->align(Fl_Align(FL_ALIGN_LEFT)); { print_output_mode[0] = new Fl_Button(110, 45, 30, 40); print_output_mode[0]->type(102); @@ -496,13 +516,13 @@ Fl_Double_Window* make_print_panel() { } // Fl_Button* print_output_mode[3] o->end(); } // Fl_Group* o - { Fl_Return_Button* o = new Fl_Return_Button(123, 95, 79, 25, "Save"); + { Fl_Return_Button* o = new Fl_Return_Button(93, 95, 99, 25, Fl_Printer::property_save); o->callback((Fl_Callback*)cb_Save); } // Fl_Return_Button* o - { Fl_Button* o = new Fl_Button(212, 95, 68, 25, "Cancel"); + { Fl_Button* o = new Fl_Button(202, 95, 78, 25, Fl_Printer::property_cancel); o->callback((Fl_Callback*)cb_Cancel1); } // Fl_Button* o - { Fl_Button* o = new Fl_Button(60, 95, 53, 25, "Use"); + { Fl_Button* o = new Fl_Button(10, 95, 73, 25, Fl_Printer::property_use); o->callback((Fl_Callback*)cb_Use); } // Fl_Button* o print_properties_panel->set_modal(); |
