Author: manolo
Date: 2010-03-08 10:26:36 -0800 (Mon, 08 Mar 2010)
New Revision: 7230
Log:
Setting Fl_Virtual_Printer::translate() and untranslate() public because
they're useful after rotate().
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
Modified: branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H
===================================================================
--- branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H 2010-03-08 17:24:31 UTC
(rev 7229)
+++ branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H 2010-03-08 18:26:36 UTC
(rev 7230)
@@ -41,18 +41,6 @@
};
void add_image(Fl_Image *image, const uchar *data); // adds an image to the
page image list
void traverse(Fl_Widget *widget); // finds subwindows of widget and prints
them
- /**
- @brief Translates the current graphics origin accounting for the current
rotation.
- *
- This function is only useful after a rotate() call.
- On Mac and X11, each translate() call must be matched by an untranslate()
call.
- */
- virtual void translate(int x, int y);
-
- /**
- @brief Undoes the effect of a previous translate() call.
- */
- virtual void untranslate(void);
protected:
int y_offset;
int x_offset;
@@ -127,6 +115,7 @@
Arguments should be expressed relatively to the result of a previous
printable_rect() call.
That is, <tt>printable_rect(&w, &h); origin(w/2, 0);</tt> sets the
graphics origin at the
top center of the page printable area.
+ Origin() calls are not affected by rotate() calls.
Successive origin() calls don't combine their effects.
@param[in] x Horizontal position in page coordinates of the desired
origin of graphics functions.
@param[in] y Same as above, vertically.
@@ -162,6 +151,20 @@
virtual void rotate(float angle);
/**
+ @brief Translates the current graphics origin accounting for the current
rotation.
+ *
+ This function is only useful after a rotate() call.
+ Each translate() call must be matched by an untranslate() call.
+ Successive translate() calls add up their effects.
+ */
+ virtual void translate(int x, int y);
+
+ /**
+ @brief Undoes the effect of a previous translate() call.
+ */
+ virtual void untranslate(void);
+
+ /**
@brief Draws the widget on the printed page.
*
The widget's position on the printed page is determined by the last call
to origin()
Modified: branches/branch-1.3-Fl_Printer/src/Fl_Device.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_Device.cxx 2010-03-08 17:24:31 UTC
(rev 7229)
+++ branches/branch-1.3-Fl_Printer/src/Fl_Device.cxx 2010-03-08 18:26:36 UTC
(rev 7230)
@@ -58,12 +58,8 @@
// find subwindows of widget and print them
traverse(widget);
// reset origin to where it was
- if(new_x != old_x || new_y != old_y) {
-#ifdef WIN32
- translate( - (new_x - old_x), - (new_y - old_y) );
-#else
+ if (new_x != old_x || new_y != old_y) {
untranslate();
-#endif
}
}
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-08
17:24:31 UTC (rev 7229)
+++ branches/branch-1.3-Fl_Printer/src/Fl_GDI_Printer.cxx 2010-03-08
18:26:36 UTC (rev 7230)
@@ -216,7 +216,12 @@
return rsult;
}
-void Fl_GDI_Printer::translate (int x, int y)
+static int translate_stack_depth = 0;
+const int translate_stack_max = 5;
+static int translate_stack_x[translate_stack_max];
+static int translate_stack_y[translate_stack_max];
+
+static void do_translate(int x, int y)
{
XFORM tr;
tr.eM11 = tr.eM22 = 1;
@@ -226,14 +231,22 @@
ModifyWorldTransform(fl_gc, &tr, MWT_LEFTMULTIPLY);
}
+void Fl_GDI_Printer::translate (int x, int y)
+{
+ do_translate(x, y);
+ if (translate_stack_depth < translate_stack_max) {
+ translate_stack_x[translate_stack_depth] = x;
+ translate_stack_y[translate_stack_depth] = y;
+ translate_stack_depth++;
+ }
+}
+
void Fl_GDI_Printer::untranslate (void)
{
-/* unused now
- XFORM mat;
- GetWorldTransform(fl_gc, &mat);
- mat.eDx = 0;
- mat.eDy = 0;
- SetWorldTransform(fl_gc, &mat); */
+ if (translate_stack_depth > 0) {
+ translate_stack_depth--;
+ do_translate( - translate_stack_x[translate_stack_depth], -
translate_stack_y[translate_stack_depth] );
+ }
}
#endif // WIN32
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit