Author: manolo
Date: 2010-03-04 01:41:22 -0800 (Thu, 04 Mar 2010)
New Revision: 7209
Log:
Easier use of display output during printing operations: Fl_Virtual_Printer
memorizes its graphics context.
Modified:
branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H
branches/branch-1.3-Fl_Printer/src/Fl_Device.cxx
branches/branch-1.3-Fl_Printer/src/Fl_GDI_Printer.cxx
branches/branch-1.3-Fl_Printer/src/Fl_Quartz_Printer.mm
branches/branch-1.3-Fl_Printer/src/Fl_cocoa.mm
Modified: branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H
===================================================================
--- branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H 2010-03-03 20:18:48 UTC
(rev 7208)
+++ branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H 2010-03-04 09:41:22 UTC
(rev 7209)
@@ -58,9 +58,10 @@
int y_offset;
int x_offset;
struct chain_elt *image_list_; // chained list of Fl_Image's used in this
page
+ void *gc; // the printer's graphics context, if there's one, NULL otherwise
void delete_image_list(); // deletes the page image list
#ifndef FL_DOXYGEN
- Fl_Virtual_Printer(void) { current_display_ = (Fl_Display*)fl_device;};
+ Fl_Virtual_Printer(void) { current_display_ = (Fl_Display*)fl_device; gc
= NULL; };
#endif
public:
#ifdef FL_DOXYGEN
@@ -210,6 +211,8 @@
@brief Returns the display device of the platform.
*/
Fl_Display *current_display() {return current_display_; };
+
+ Fl_Device *Fl_Virtual_Printer::set_current(void);
};
#ifdef __APPLE__
Modified: branches/branch-1.3-Fl_Printer/src/Fl_Device.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_Device.cxx 2010-03-03 20:18:48 UTC
(rev 7208)
+++ branches/branch-1.3-Fl_Printer/src/Fl_Device.cxx 2010-03-04 09:41:22 UTC
(rev 7209)
@@ -91,20 +91,14 @@
void Fl_Virtual_Printer::print_window_part(Fl_Window *win, int x, int y, int
w, int h, int delta_x, int delta_y)
{
-#ifdef __APPLE__
- CGContextRef save_gc = fl_gc;
-#elif defined(WIN32)
- HDC save_gc = fl_gc;
-#else
- _XGC *save_gc = fl_gc;
-#endif
+ this->current_display()->set_current();
Fl_Window *save_front = Fl::first_window();
win->show();
Fl::check();
win->make_current();
uchar *image_data = fl_read_image(NULL, x, y, w, h);
save_front->show();
- fl_gc = save_gc;
+ this->set_current();
Fl_RGB_Image *image = new Fl_RGB_Image(image_data, w, h);
image->draw(delta_x, delta_y);
add_image(image, image_data);
@@ -130,6 +124,19 @@
}
}
+Fl_Device *Fl_Virtual_Printer::set_current(void)
+{
+#ifdef __APPLE__
+ fl_gc = (CGContextRef)gc;
+#elif defined(WIN32)
+ fl_gc = (HDC)gc;
+#else
+ fl_gc = (_XGC*)gc;
+#endif
+ return this->Fl_Device::set_current();
+}
+
+
int Fl_Virtual_Printer::start_job(int pagecount, int *frompage, int *topage)
{return 1;}
int Fl_Virtual_Printer::start_page (void) {return 1;}
int Fl_Virtual_Printer::printable_rect(int *w, int *h) {return 1;}
Modified: branches/branch-1.3-Fl_Printer/src/Fl_GDI_Printer.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_GDI_Printer.cxx 2010-03-03
20:18:48 UTC (rev 7208)
+++ branches/branch-1.3-Fl_Printer/src/Fl_GDI_Printer.cxx 2010-03-04
09:41:22 UTC (rev 7209)
@@ -165,6 +165,7 @@
origin(0, 0);
image_list_ = NULL;
fl_clip_region(0);
+ gc = (void *)fl_gc;
}
return rsult;
}
@@ -211,6 +212,7 @@
}
}
delete_image_list();
+ gc = NULL;
return rsult;
}
Modified: branches/branch-1.3-Fl_Printer/src/Fl_Quartz_Printer.mm
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_Quartz_Printer.mm 2010-03-03
20:18:48 UTC (rev 7208)
+++ branches/branch-1.3-Fl_Printer/src/Fl_Quartz_Printer.mm 2010-03-04
09:41:22 UTC (rev 7209)
@@ -240,6 +240,7 @@
fl_line_style(FL_SOLID);
fl_window = (void *)1; // TODO: something better
fl_clip_region(0);
+ if( status == noErr) gc = fl_gc;
return status != noErr;
}
@@ -250,6 +251,7 @@
CGContextRestoreGState(fl_gc);
OSStatus status = PMSessionEndPageNoDialog(printSession);
delete_image_list();
+ gc = NULL;
return status != noErr;
}
Modified: branches/branch-1.3-Fl_Printer/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_cocoa.mm 2010-03-03 20:18:48 UTC
(rev 7208)
+++ branches/branch-1.3-Fl_Printer/src/Fl_cocoa.mm 2010-03-04 09:41:22 UTC
(rev 7209)
@@ -2994,10 +2994,10 @@
printer.printable_rect(&w, &h);
printer.origin(w/2, h/2 );
printer.rotate(20.);
- //printer.print_window_part( win, 0,0, win->w(), win->h() , - win->w()/2, -
win->h()/2);
printer.print_widget( win, - win->w()/2, - win->h()/2 );
#else
printer.print_widget( win);
+ //printer.print_window_part( win, 0,0, win->w(), win->h() );
#endif
printer.end_page();
printer.end_job();
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit