mirror of
https://github.com/fltk/fltk.git
synced 2026-05-23 07:46:09 +08:00
Consistently make Fl_Paged_Device::begin_page call Fl_Surface_Device::push_current.
This commit is contained in:
+4
-3
@@ -38,14 +38,15 @@ class Fl_Widget;
|
||||
|
||||
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).
|
||||
<li> Call \c Fl_Surface_Device::push_current(surface); to redirect all graphics requests to \c surface which becomes the new
|
||||
current drawing surface (not necessary with class Fl_Printer because it is done by Fl_Printer::begin_job()).
|
||||
<li> Call \c Fl_Surface_Device::push_current(surface); to redirect all graphics requests to
|
||||
\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
|
||||
(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
|
||||
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
|
||||
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.
|
||||
</ol>
|
||||
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,
|
||||
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
|
||||
*/
|
||||
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.
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,6 @@ int Fl_PostScript_File_Device::begin_job (int pagecount, enum Fl_Paged_Device::P
|
||||
if(ps->output == NULL) return 2;
|
||||
ps->ps_filename_ = fl_strdup(fnfc.filename());
|
||||
ps->start_postscript(pagecount, format, layout);
|
||||
Fl_Surface_Device::push_current(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -79,7 +78,6 @@ int Fl_PostScript_File_Device::begin_job (FILE *ps_output, int pagecount,
|
||||
ps->ps_filename_ = NULL;
|
||||
ps->start_postscript(pagecount, format, layout);
|
||||
ps->close_command(dont_close); // so that end_job() doesn't close the file
|
||||
Fl_Surface_Device::push_current(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1592,6 +1590,7 @@ void Fl_PostScript_File_Device::untranslate(void)
|
||||
int Fl_PostScript_File_Device::begin_page (void)
|
||||
{
|
||||
Fl_PostScript_Graphics_Driver *ps = driver();
|
||||
Fl_Surface_Device::push_current(this);
|
||||
#if USE_PANGO
|
||||
cairo_ps_surface_dsc_begin_page_setup(cairo_get_target(ps->cr()));
|
||||
char feature[200];
|
||||
@@ -1631,6 +1630,7 @@ int Fl_PostScript_File_Device::end_page (void)
|
||||
cairo_show_page(ps->cr());
|
||||
ps->check_status();
|
||||
#endif
|
||||
Fl_Surface_Device::pop_current();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1670,7 +1670,6 @@ void Fl_PostScript_File_Device::end_job (void)
|
||||
ps->clip_= ps->clip_->prev;
|
||||
delete c;
|
||||
}
|
||||
Fl_Surface_Device::pop_current();
|
||||
int err2 = (ps->close_cmd_ ? (ps->close_cmd_)(ps->output) : fclose(ps->output) );
|
||||
if (!error) error = err2;
|
||||
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;
|
||||
WIN_SetupPrinterDeviceContext (hPr);
|
||||
driver()->gc(hPr);
|
||||
this->set_current();
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
void Fl_WinAPI_Printer_Driver::end_job (void)
|
||||
{
|
||||
Fl_Display_Device::display_device()->set_current();
|
||||
if (hPr != NULL) {
|
||||
if (! abortPrint) {
|
||||
prerr = EndDoc (hPr);
|
||||
@@ -232,6 +230,7 @@ int Fl_WinAPI_Printer_Driver::begin_page (void)
|
||||
|
||||
rsult = 0;
|
||||
if (hPr != NULL) {
|
||||
Fl_Surface_Device::push_current(this);
|
||||
WIN_SetupPrinterDeviceContext (hPr);
|
||||
prerr = StartPage (hPr);
|
||||
if (prerr < 0) {
|
||||
@@ -280,6 +279,7 @@ int Fl_WinAPI_Printer_Driver::end_page (void)
|
||||
|
||||
rsult = 0;
|
||||
if (hPr != NULL) {
|
||||
Fl_Surface_Device::pop_current();
|
||||
prerr = EndPage (hPr);
|
||||
if (prerr < 0) {
|
||||
abortPrint = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user