Author: manolo
Date: 2010-04-06 10:26:58 -0700 (Tue, 06 Apr 2010)
New Revision: 7457
Log:
Fl_Gl_Device_Plugin: more device-independant API that works with both print and 
clipboard contexts

Modified:
   branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H
   branches/branch-1.3-Fl_Printer/src/Fl_Abstract_Printer.cxx
   branches/branch-1.3-Fl_Printer/src/Fl_Clipboard_Writer.cxx
   branches/branch-1.3-Fl_Printer/src/Fl_Gl_Device_Plugin.cxx

Modified: branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H
===================================================================
--- branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H      2010-04-06 16:44:26 UTC 
(rev 7456)
+++ branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H      2010-04-06 17:26:58 UTC 
(rev 7457)
@@ -196,7 +196,6 @@
  window or screen types. It is currently used to provide an automated printing
  service for OpenGL windows, if linked with fltk_gl.
  */
-class Fl_Clipboard_Writer;
 class Fl_Device_Plugin : public Fl_Plugin {
 public:
   /** \brief The constructor */
@@ -207,17 +206,11 @@
   /** \brief Returns the plugin name */
   virtual const char *name() = 0;
   /** \brief Prints a widget 
-   \param p the printer
    \param w the widget
    \param x,y offsets where to print relatively to coordinates origin
+   \param height height of the current drawing area
    */
-  virtual int print(Fl_Abstract_Printer* p, Fl_Widget* w, int x, int y) { 
return 0; }
-  /** \brief copies a widget to the clipboard
-   \param c the clipboard writer
-   \param w the widget
-   \param x,y offsets where to print relatively to coordinates origin
-   */
-  virtual int copy(Fl_Clipboard_Writer* c, Fl_Widget* w, int x, int y) { 
return 0; }
+  virtual int print(Fl_Widget* w, int x, int y, int height) { return 0; }
 };
 
 #endif // Fl_Printer_H

Modified: branches/branch-1.3-Fl_Printer/src/Fl_Abstract_Printer.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_Abstract_Printer.cxx  2010-04-06 
16:44:26 UTC (rev 7456)
+++ branches/branch-1.3-Fl_Printer/src/Fl_Abstract_Printer.cxx  2010-04-06 
17:26:58 UTC (rev 7457)
@@ -66,7 +66,11 @@
   if (widget->as_gl_window()) {
     Fl_Plugin_Manager pm("fltk:device");  
     Fl_Device_Plugin *pi = 
(Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org");
-    if (pi) drawn_by_plugin = pi->print(this, widget, 0, 0);
+    if (pi) {
+      int width, height;
+      this->printable_rect(&width, &height);
+      drawn_by_plugin = pi->print(widget, 0, 0, height);
+      }
   }
   if (!drawn_by_plugin) {
     widget->draw();

Modified: branches/branch-1.3-Fl_Printer/src/Fl_Clipboard_Writer.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_Clipboard_Writer.cxx  2010-04-06 
16:44:26 UTC (rev 7456)
+++ branches/branch-1.3-Fl_Printer/src/Fl_Clipboard_Writer.cxx  2010-04-06 
17:26:58 UTC (rev 7457)
@@ -78,7 +78,11 @@
   if (widget->as_gl_window()) {
      Fl_Plugin_Manager pm("fltk:device");  
      Fl_Device_Plugin *pi = 
(Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org");
-     if (pi) drawn_by_plugin = pi->copy(this, widget, 0, 0);
+     if (pi) {
+       int width, height;
+       this->bounds(&width, &height);
+       drawn_by_plugin = pi->print(widget, 0, 0, height);
+       }
   }
   if (!drawn_by_plugin) {
     widget->draw();

Modified: branches/branch-1.3-Fl_Printer/src/Fl_Gl_Device_Plugin.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_Gl_Device_Plugin.cxx  2010-04-06 
16:44:26 UTC (rev 7456)
+++ branches/branch-1.3-Fl_Printer/src/Fl_Gl_Device_Plugin.cxx  2010-04-06 
17:26:58 UTC (rev 7457)
@@ -41,7 +41,7 @@
 }
 #endif
 
-static void print_gl_window(Fl_Abstract_Printer *printer, Fl_Clipboard_Writer 
*clipboard, Fl_Gl_Window *glw, int x, int y)
+static void print_gl_window(Fl_Gl_Window *glw, int x, int y, int height)
 {
 #ifdef WIN32
   HDC save_gc = fl_gc;
@@ -106,12 +106,9 @@
    , provider, NULL, false, kCGRenderingIntentDefault);
   if(image == NULL) return;
   CGContextSaveGState(fl_gc);
-  int w, h;
-  if(printer) printer->printable_rect(&w, &h);
-  else clipboard->bounds(&w, &h);
-  CGContextTranslateCTM(fl_gc, 0, h);
+  CGContextTranslateCTM(fl_gc, 0, height);
   CGContextScaleCTM(fl_gc, 1.0f, -1.0f);
-  CGRect rect = { { x, h - y - glw->h() }, { glw->w(), glw->h() } };
+  CGRect rect = { { x, height - y - glw->h() }, { glw->w(), glw->h() } };
   Fl_X::q_begin_image(rect, 0, 0, glw->w(), glw->h());
   CGContextDrawImage(fl_gc, rect, image);
   Fl_X::q_end_image();
@@ -132,25 +129,13 @@
 class Fl_Gl_Device_Plugin : public Fl_Device_Plugin {
 public:
   Fl_Gl_Device_Plugin() : Fl_Device_Plugin(name()) { }
-  /** \brief Returns the plugin name */
   virtual const char *name() { return "opengl.device.fltk.org"; }
-  /** \brief Prints a widget 
-   \param p the printer
-   \param w the widget
-   \param x,y offsets where to print relatively to coordinates origin
-   */
-  virtual int print(Fl_Abstract_Printer *p, Fl_Widget *w, int x, int y) {
+  virtual int print(Fl_Widget *w, int x, int y, int height) {
     Fl_Gl_Window *glw = w->as_gl_window();
     if (!glw) return 0;
-    print_gl_window(p, NULL, glw, x, y);
+    print_gl_window(glw, x, y, height);
     return 1; 
   }
-  virtual int copy(Fl_Clipboard_Writer *c, Fl_Widget *w, int x, int y) {
-    Fl_Gl_Window *glw = w->as_gl_window();
-    if (!glw) return 0;
-    print_gl_window(NULL, c, glw, x, y);
-    return 1; 
-  }
 };
 
 static Fl_Gl_Device_Plugin Gl_Device_Plugin;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to