mirror of
https://github.com/fltk/fltk.git
synced 2026-05-27 10:57:58 +08:00
Improves the usability of member function: Fl_PostScript_File_Device::start_job (FILE *,...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7885 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+11
-11
@@ -105,11 +105,13 @@ int Fl_PostScript_File_Device::start_job (int pagecount, enum Fl_PostScript_Grap
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dont_close(FILE *f) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Begins the session where all graphics requests will go to FILE pointer.
|
@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
|
@param ps_output A writable FILE pointer that will receive PostScript output and that should not be closed
|
||||||
when end_job() will be called.
|
until after end_job() has been called.
|
||||||
@param pagecount The total number of pages to be created.
|
@param pagecount The total number of pages to be created.
|
||||||
@param format Desired page format.
|
@param format Desired page format.
|
||||||
@param layout Desired page layout.
|
@param layout Desired page layout.
|
||||||
@@ -121,6 +123,7 @@ int Fl_PostScript_File_Device::start_job (FILE *ps_output, int pagecount, enum F
|
|||||||
ps->output = ps_output;
|
ps->output = ps_output;
|
||||||
ps->ps_filename_ = NULL;
|
ps->ps_filename_ = NULL;
|
||||||
ps->start_postscript(pagecount, format, layout);
|
ps->start_postscript(pagecount, format, layout);
|
||||||
|
ps->close_command(dont_close); // so that end_job() doesn't close the file
|
||||||
this->set_current();
|
this->set_current();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1467,20 +1470,16 @@ void Fl_PostScript_File_Device::end_job (void)
|
|||||||
if(ferror(ps->output)) {
|
if(ferror(ps->output)) {
|
||||||
fl_alert ("Error during PostScript data output.");
|
fl_alert ("Error during PostScript data output.");
|
||||||
}
|
}
|
||||||
#if ! (defined(__APPLE__) || defined(WIN32) )
|
if (ps->close_cmd_) {
|
||||||
if (print_pipe)
|
(*ps->close_cmd_)(ps->output);
|
||||||
pclose(ps->output);
|
} else {
|
||||||
else
|
|
||||||
fclose(ps->output);
|
fclose(ps->output);
|
||||||
#else
|
}
|
||||||
fclose(ps->output);
|
|
||||||
#endif
|
|
||||||
while (ps->clip_){
|
while (ps->clip_){
|
||||||
Fl_PostScript_Graphics_Driver::Clip * c= ps->clip_;
|
Fl_PostScript_Graphics_Driver::Clip * c= ps->clip_;
|
||||||
ps->clip_= ps->clip_->prev;
|
ps->clip_= ps->clip_->prev;
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
if (ps->close_cmd_) (*ps->close_cmd_)(ps->output);
|
|
||||||
Fl_Display_Device::display_device()->set_current();
|
Fl_Display_Device::display_device()->set_current();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1525,7 +1524,7 @@ int Fl_Printer::start_job(int pages, int *firstpage, int *lastpage) {
|
|||||||
else if (print_output_mode[2]->value()) layout = Fl_PostScript_Graphics_Driver::PORTRAIT;
|
else if (print_output_mode[2]->value()) layout = Fl_PostScript_Graphics_Driver::PORTRAIT;
|
||||||
else layout = Fl_PostScript_Graphics_Driver::LANDSCAPE;
|
else layout = Fl_PostScript_Graphics_Driver::LANDSCAPE;
|
||||||
|
|
||||||
print_pipe = print_choice->value(); // 0 = print to file, >0 = printer (pipe)
|
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 *media = print_page_size->text(print_page_size->value());
|
||||||
const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
|
const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
|
||||||
@@ -1547,6 +1546,7 @@ int Fl_Printer::start_job(int pages, int *firstpage, int *lastpage) {
|
|||||||
fl_alert("could not run command: %s\n",command);
|
fl_alert("could not run command: %s\n",command);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
ps->close_command(pclose);
|
||||||
this->set_current();
|
this->set_current();
|
||||||
return ps->start_postscript(pages, format, layout); // start printing
|
return ps->start_postscript(pages, format, layout); // start printing
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ static Fl_Int_Input *print_to=(Fl_Int_Input *)0;
|
|||||||
static Fl_Spinner *print_copies=(Fl_Spinner *)0;
|
static Fl_Spinner *print_copies=(Fl_Spinner *)0;
|
||||||
|
|
||||||
static int print_start = 0; // 1 if print_okay has been clicked
|
static int print_start = 0; // 1 if print_okay has been clicked
|
||||||
static int print_pipe = 0; // 0 = file, 1 = pipe (lp)
|
|
||||||
|
|
||||||
static void cb_print_choice(Fl_Choice*, void*) {
|
static void cb_print_choice(Fl_Choice*, void*) {
|
||||||
print_update_status();
|
print_update_status();
|
||||||
|
|||||||
Reference in New Issue
Block a user