Consistently make Fl_Paged_Device::begin_page call Fl_Surface_Device::push_current.
This commit is contained in:
parent
96034b5657
commit
995a48dd00
@ -38,14 +38,15 @@ class Fl_Widget;
|
|||||||
|
|
||||||
A drawing surface other than the computer's display, is typically used as follows:
|
A drawing surface other than the computer's display, is typically used as follows:
|
||||||
<ol><li> Create \c surface, an object from a particular Fl_Surface_Device derived class (e.g., Fl_Copy_Surface, Fl_Printer).
|
<ol><li> Create \c surface, an object from a particular Fl_Surface_Device derived class (e.g., Fl_Copy_Surface, Fl_Printer).
|
||||||
<li> Call \c Fl_Surface_Device::push_current(surface); to redirect all graphics requests to \c surface which becomes the new
|
<li> Call \c Fl_Surface_Device::push_current(surface); to redirect all graphics requests to
|
||||||
current drawing surface (not necessary with class Fl_Printer because it is done by Fl_Printer::begin_job()).
|
\c surface which becomes the new current drawing surface (not necessary with classes Fl_Printer / Fl_PostScript_File_Device
|
||||||
|
because it is done by Fl_Paged_Device::begin_page()).
|
||||||
<li> At this point all of the \ref fl_drawings (e.g., fl_rect()) or the \ref fl_attributes or \ref drawing_images functions
|
<li> At this point all of the \ref fl_drawings (e.g., fl_rect()) or the \ref fl_attributes or \ref drawing_images functions
|
||||||
(e.g., fl_draw_image(), Fl_Image::draw()) operate on the new current drawing surface.
|
(e.g., fl_draw_image(), Fl_Image::draw()) operate on the new current drawing surface.
|
||||||
Drawing surfaces from Fl_Widget_Surface derived classes allow additional ways
|
Drawing surfaces from Fl_Widget_Surface derived classes allow additional ways
|
||||||
to draw to them (e.g., Fl_Printer::print_widget(), Fl_Image_Surface::draw()).
|
to draw to them (e.g., Fl_Printer::print_widget(), Fl_Image_Surface::draw()).
|
||||||
<li> After all drawing requests have been performed, redirect graphics requests back to their previous destination
|
<li> After all drawing requests have been performed, redirect graphics requests back to their previous destination
|
||||||
with \c Fl_Surface_Device::pop_current();.
|
with \c Fl_Surface_Device::pop_current(); (not necessary with classes Fl_Printer / Fl_PostScript_File_Device).
|
||||||
<li> Delete \c surface.
|
<li> Delete \c surface.
|
||||||
</ol>
|
</ol>
|
||||||
For back-compatibility, it is also possible to use the Fl_Surface_Device::set_current() member function
|
For back-compatibility, it is also possible to use the Fl_Surface_Device::set_current() member function
|
||||||
|
|||||||
@ -40,6 +40,7 @@ int Fl_Paged_Device::begin_job(int pagecount, int *frompage, int *topage, char *
|
|||||||
|
|
||||||
The page coordinates are initially in points, i.e., 1/72 inch,
|
The page coordinates are initially in points, i.e., 1/72 inch,
|
||||||
and with origin at the top left of the printable page area.
|
and with origin at the top left of the printable page area.
|
||||||
|
This function also makes this surface the current drawing surface with Fl_Surface_Device::push_current().
|
||||||
\return 0 if OK, non-zero if any error
|
\return 0 if OK, non-zero if any error
|
||||||
*/
|
*/
|
||||||
int Fl_Paged_Device::begin_page (void) {return 1;}
|
int Fl_Paged_Device::begin_page (void) {return 1;}
|
||||||
@ -82,6 +83,7 @@ void Fl_Paged_Device::rotate(float angle) {}
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
\brief To be called at the end of each page.
|
\brief To be called at the end of each page.
|
||||||
|
This function also stops this surface from being the current drawing surface with Fl_Surface_Device::pop_current().
|
||||||
|
|
||||||
\return 0 if OK, non-zero if any error.
|
\return 0 if OK, non-zero if any error.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -60,7 +60,6 @@ int Fl_PostScript_File_Device::begin_job (int pagecount, enum Fl_Paged_Device::P
|
|||||||
if(ps->output == NULL) return 2;
|
if(ps->output == NULL) return 2;
|
||||||
ps->ps_filename_ = fl_strdup(fnfc.filename());
|
ps->ps_filename_ = fl_strdup(fnfc.filename());
|
||||||
ps->start_postscript(pagecount, format, layout);
|
ps->start_postscript(pagecount, format, layout);
|
||||||
Fl_Surface_Device::push_current(this);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +78,6 @@ int Fl_PostScript_File_Device::begin_job (FILE *ps_output, int pagecount,
|
|||||||
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
|
ps->close_command(dont_close); // so that end_job() doesn't close the file
|
||||||
Fl_Surface_Device::push_current(this);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1592,6 +1590,7 @@ void Fl_PostScript_File_Device::untranslate(void)
|
|||||||
int Fl_PostScript_File_Device::begin_page (void)
|
int Fl_PostScript_File_Device::begin_page (void)
|
||||||
{
|
{
|
||||||
Fl_PostScript_Graphics_Driver *ps = driver();
|
Fl_PostScript_Graphics_Driver *ps = driver();
|
||||||
|
Fl_Surface_Device::push_current(this);
|
||||||
#if USE_PANGO
|
#if USE_PANGO
|
||||||
cairo_ps_surface_dsc_begin_page_setup(cairo_get_target(ps->cr()));
|
cairo_ps_surface_dsc_begin_page_setup(cairo_get_target(ps->cr()));
|
||||||
char feature[200];
|
char feature[200];
|
||||||
@ -1631,6 +1630,7 @@ int Fl_PostScript_File_Device::end_page (void)
|
|||||||
cairo_show_page(ps->cr());
|
cairo_show_page(ps->cr());
|
||||||
ps->check_status();
|
ps->check_status();
|
||||||
#endif
|
#endif
|
||||||
|
Fl_Surface_Device::pop_current();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1670,7 +1670,6 @@ void Fl_PostScript_File_Device::end_job (void)
|
|||||||
ps->clip_= ps->clip_->prev;
|
ps->clip_= ps->clip_->prev;
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
Fl_Surface_Device::pop_current();
|
|
||||||
int err2 = (ps->close_cmd_ ? (ps->close_cmd_)(ps->output) : fclose(ps->output) );
|
int err2 = (ps->close_cmd_ ? (ps->close_cmd_)(ps->output) : fclose(ps->output) );
|
||||||
if (!error) error = err2;
|
if (!error) error = err2;
|
||||||
if (error && ps->close_cmd_ == NULL) {
|
if (error && ps->close_cmd_ == NULL) {
|
||||||
|
|||||||
@ -152,14 +152,12 @@ int Fl_WinAPI_Printer_Driver::begin_job (int pagecount, int *frompage, int *topa
|
|||||||
y_offset = 0;
|
y_offset = 0;
|
||||||
WIN_SetupPrinterDeviceContext (hPr);
|
WIN_SetupPrinterDeviceContext (hPr);
|
||||||
driver()->gc(hPr);
|
driver()->gc(hPr);
|
||||||
this->set_current();
|
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fl_WinAPI_Printer_Driver::end_job (void)
|
void Fl_WinAPI_Printer_Driver::end_job (void)
|
||||||
{
|
{
|
||||||
Fl_Display_Device::display_device()->set_current();
|
|
||||||
if (hPr != NULL) {
|
if (hPr != NULL) {
|
||||||
if (! abortPrint) {
|
if (! abortPrint) {
|
||||||
prerr = EndDoc (hPr);
|
prerr = EndDoc (hPr);
|
||||||
@ -232,6 +230,7 @@ int Fl_WinAPI_Printer_Driver::begin_page (void)
|
|||||||
|
|
||||||
rsult = 0;
|
rsult = 0;
|
||||||
if (hPr != NULL) {
|
if (hPr != NULL) {
|
||||||
|
Fl_Surface_Device::push_current(this);
|
||||||
WIN_SetupPrinterDeviceContext (hPr);
|
WIN_SetupPrinterDeviceContext (hPr);
|
||||||
prerr = StartPage (hPr);
|
prerr = StartPage (hPr);
|
||||||
if (prerr < 0) {
|
if (prerr < 0) {
|
||||||
@ -280,6 +279,7 @@ int Fl_WinAPI_Printer_Driver::end_page (void)
|
|||||||
|
|
||||||
rsult = 0;
|
rsult = 0;
|
||||||
if (hPr != NULL) {
|
if (hPr != NULL) {
|
||||||
|
Fl_Surface_Device::pop_current();
|
||||||
prerr = EndPage (hPr);
|
prerr = EndPage (hPr);
|
||||||
if (prerr < 0) {
|
if (prerr < 0) {
|
||||||
abortPrint = TRUE;
|
abortPrint = TRUE;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user