Fl_PSfile_Device::start_job(): allow user to customize the file chooser title
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7349 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
2a75e82e3d
commit
99f2e8b5be
@ -248,9 +248,8 @@ class FL_EXPORT Fl_PSfile_Device : public Fl_Abstract_Printer {
|
|||||||
void rotate(float angle);
|
void rotate(float angle);
|
||||||
void translate(int x, int y);
|
void translate(int x, int y);
|
||||||
void untranslate(void);
|
void untranslate(void);
|
||||||
int end_page (void);
|
int end_page (void);
|
||||||
void end_job (void);
|
void end_job(void);
|
||||||
|
|
||||||
#endif // FL_DOXYGEN
|
#endif // FL_DOXYGEN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -259,9 +258,9 @@ class FL_EXPORT Fl_PSfile_Device : public Fl_Abstract_Printer {
|
|||||||
Fl_PSfile_Device(void);
|
Fl_PSfile_Device(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Begins the session where all graphics will go to a local PostScript file.
|
@brief Begins the session where all graphics requests will go to a local PostScript file.
|
||||||
*
|
*
|
||||||
Opens a file dialog to select an output 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 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.
|
||||||
@ -270,20 +269,25 @@ class FL_EXPORT Fl_PSfile_Device : public Fl_Abstract_Printer {
|
|||||||
int start_job(int pagecount, enum Page_Format format = A4, enum Page_Layout layout = PORTRAIT);
|
int start_job(int pagecount, enum Page_Format format = A4, enum Page_Layout layout = PORTRAIT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Begins the session where all graphics will go to named PostScript file.
|
@brief Begins the session where all graphics requests will go to FILE pointer.
|
||||||
*
|
*
|
||||||
@param fname The name of the output local PostScript file.
|
@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 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.
|
||||||
@return 0 iff OK, 1 if fopen(fname, "w") call failed.
|
@return always 0.
|
||||||
*/
|
*/
|
||||||
int start_job(const char *fname, int pagecount, enum Page_Format format = A4, enum Page_Layout layout = PORTRAIT);
|
int start_job(FILE *ps_output, int pagecount, enum Page_Format format = A4, enum Page_Layout layout = PORTRAIT);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The destructor.
|
@brief The destructor.
|
||||||
*/
|
*/
|
||||||
virtual ~Fl_PSfile_Device();
|
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] */
|
||||||
|
static const char *file_chooser_title;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // Fl_PSfile_Device_H
|
#endif // Fl_PSfile_Device_H
|
||||||
|
|||||||
@ -40,6 +40,8 @@
|
|||||||
#include "print_panel.cxx"
|
#include "print_panel.cxx"
|
||||||
#endif
|
#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
|
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
|
// comes from appendix B of 5003.PPD_Spec_v4.3.pdf
|
||||||
|
|
||||||
@ -1198,7 +1200,7 @@ int Fl_PSfile_Device::end_page (void)
|
|||||||
int Fl_PSfile_Device::start_job (int pagecount, enum Page_Format format, enum Page_Layout layout)
|
int Fl_PSfile_Device::start_job (int pagecount, enum Page_Format format, enum Page_Layout layout)
|
||||||
{
|
{
|
||||||
Fl_Native_File_Chooser fnfc;
|
Fl_Native_File_Chooser fnfc;
|
||||||
fnfc.title("Create a .ps file");
|
fnfc.title(Fl_PSfile_Device::file_chooser_title);
|
||||||
fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE);
|
fnfc.type(Fl_Native_File_Chooser::BROWSE_SAVE_FILE);
|
||||||
fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM);
|
fnfc.options(Fl_Native_File_Chooser::SAVEAS_CONFIRM);
|
||||||
fnfc.filter("PostScript\t*.ps\n");
|
fnfc.filter("PostScript\t*.ps\n");
|
||||||
@ -1211,12 +1213,12 @@ int Fl_PSfile_Device::start_job (int pagecount, enum Page_Format format, enum Pa
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Fl_PSfile_Device::start_job (const char *fname, int pagecount, enum Page_Format format, enum Page_Layout layout)
|
int Fl_PSfile_Device::start_job (FILE *ps_output, int pagecount, enum Page_Format format, enum Page_Layout layout)
|
||||||
{
|
{
|
||||||
output = fopen(fname, "w");
|
output = ps_output;
|
||||||
if(output == NULL) return 1;
|
ps_filename_ = NULL;
|
||||||
ps_filename_ = strdup(fname);
|
start_postscript(pagecount, format, layout);
|
||||||
return start_postscript(pagecount, format, layout);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_PSfile_Device::end_job (void)
|
void Fl_PSfile_Device::end_job (void)
|
||||||
@ -1232,6 +1234,10 @@ void Fl_PSfile_Device::end_job (void)
|
|||||||
fprintf(output, "GR\n restore\n");
|
fprintf(output, "GR\n restore\n");
|
||||||
fputs("%%EOF",output);
|
fputs("%%EOF",output);
|
||||||
reset();
|
reset();
|
||||||
|
fflush(output);
|
||||||
|
if(ferror(output)) {
|
||||||
|
fl_alert ("Error during PostScript data output.");
|
||||||
|
}
|
||||||
#if ! (defined(__APPLE__) || defined(WIN32) )
|
#if ! (defined(__APPLE__) || defined(WIN32) )
|
||||||
if (print_pipe)
|
if (print_pipe)
|
||||||
pclose(output);
|
pclose(output);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user