DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2310
Version: 1.3-feature
Manolo, I tested your window position update, and it works. That's okay.
Unfortunately we worked in parallel, and meanwhile I had already made my
own modifications, and IMHO they are much easier and reduce code size. The
idea is that we print the subwindows while clipping and the widget origin
is still in effect, so that subwindow coordinates are always drawn
relative to the (then) current origin. The cost is a deeper clipping
stack.
I post window_pos.diff as a patch to current svn and leave it to you to
decide which one to take. [I vote for mine :-)]
This restores traverse(Fl_Widget*) to its previous signature, and you'll
see that traverse() now has less code WRT coordinate calculation.
Link: http://www.fltk.org/str.php?L2310
Version: 1.3-feature
Index: src/Fl_Printer.cxx
===================================================================
--- src/Fl_Printer.cxx (revision 7082)
+++ src/Fl_Printer.cxx (working copy)
@@ -43,30 +43,26 @@
// if widget is a window, clip all drawings to the window area
if (is_window) fl_push_clip(0, 0, widget->w(), widget->h() );
widget->draw();
+ // find subwindows of widget and print them
+ traverse(widget);
if (is_window) fl_pop_clip();
if (new_x != old_x + delta_x || new_y != old_y + delta_y) origin(old_x +
delta_x, old_y + delta_y);
- // find subwindows of widget and print them
- traverse(widget, widget);
// reset origin to where it was
if(delta_x || delta_y) origin(old_x, old_y);
}
-void Fl_Printer::traverse(Fl_Widget *widget, Fl_Widget *from)
+void Fl_Printer::traverse(Fl_Widget *widget)
{
Fl_Group *g = widget->as_group();
if (!g) return;
- int is_window = (from->as_window() != NULL);
int n = g->children();
for (int i = 0; i < n; i++) {
Fl_Widget *c = g->child(i);
if (!c->visible()) continue;
if (c->as_window()) {
- // compute desired position of top-left of window c
- int x_offset = c->x() - (is_window ? 0 : from->x());
- int y_offset = c->y() - (is_window ? 0 : from->y());
- print_widget(c, x_offset, y_offset);
- }
- else traverse(c, from);
+ print_widget(c,c->x(),c->y());
+ }
+ else traverse(c);
}
}
Index: FL/Fl_Printer.H
===================================================================
--- FL/Fl_Printer.H (revision 7082)
+++ FL/Fl_Printer.H (working copy)
@@ -50,7 +50,7 @@
void add_image(Fl_Image *image); // adds an image to the page image list
void delete_image_list(); // deletes the page image list
- void traverse(Fl_Widget *widget, Fl_Widget *from); // finds subwindows of
widget and prints them
+ void traverse(Fl_Widget *widget); // finds subwindows of widget and prints
them
#ifdef WIN32
void absolute_printable_rect(int *x, int *y, int *w, int *h);
#endif
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev