diff options
| -rw-r--r-- | FL/Fl_Device.H | 7 | ||||
| -rw-r--r-- | src/Fl_Paged_Device.cxx | 2 | ||||
| -rw-r--r-- | src/drivers/PostScript/Fl_PostScript.cxx | 5 | ||||
| -rw-r--r-- | src/drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx | 4 |
4 files changed, 10 insertions, 8 deletions
diff --git a/FL/Fl_Device.H b/FL/Fl_Device.H index 6bf7cb675..890d4f744 100644 --- a/FL/Fl_Device.H +++ b/FL/Fl_Device.H @@ -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 diff --git a/src/Fl_Paged_Device.cxx b/src/Fl_Paged_Device.cxx index 368e09856..3eb250aab 100644 --- a/src/Fl_Paged_Device.cxx +++ b/src/Fl_Paged_Device.cxx @@ -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. */ diff --git a/src/drivers/PostScript/Fl_PostScript.cxx b/src/drivers/PostScript/Fl_PostScript.cxx index 470f6df83..515450ce1 100644 --- a/src/drivers/PostScript/Fl_PostScript.cxx +++ b/src/drivers/PostScript/Fl_PostScript.cxx @@ -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) { diff --git a/src/drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx index 2e808f1f5..a92600d91 100644 --- a/src/drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx +++ b/src/drivers/WinAPI/Fl_WinAPI_Printer_Driver.cxx @@ -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; |
