Thanks again for Ian MacArthur to point out my mistake, and now that
it's working but not the way I was thinking it should be, I was thinking
that it will print the whole html content not only the viewport of it,
my idea is that Fl_Help_View could improved to be used as a kind of rich
text template for printing in general with fltk, becuase of the easy
html is to create on the fly and the fluid layout capabilities, that's
the reason I tried to improve it or at least on a first approach remove
duplications and make it a bit more efficient, I found that the actual
implementation do not allow tables inside tables, probably the table
data should be a structure and have a stack like actually fonts and do,
also right now the html code is parsed around three times:
1 - for extract formatting and sizes.
2- if there is a table gain for sizes.
3- for the final drawing.
On all three a big part of the code is almost identical, I was thinking
of have only one parsing function with a "state" parameter which will
signal if we are parsing for one of the three actual parsing needs
(considering that no other way to do this will appear).
The other less rich form to achieve rich text templating could be using
the Fl_Browser but it lacks easy layout, tables and probably will suffer
the same "viewport" problem of Fl_Help_view.
Has anyone an answer for this ?
I was looking at how dillo is doing it and borrow from it, but I emailed
the author and now answer till now.
# data file for the Fltk User Interface Designer (fluid)
version 1.0300
header_name {.h}
code_name {.cxx}
decl {\#include <FL/Fl_Help_View.H>} {public global
}
decl {\#include <Fl/Fl_Printer.H>} {public global
}
Function {print_html()} {open return_type void
} {
code {Fl_Printer printer;
//Fl_PSfile_Device printer;
int w, h;
float scale_tmp, scale;
printer.start_job(1);
printer.start_page();
w = h = 0;
printer.printable_rect(&w,&h);
// scale the printer device so that the window fits on the page
scale = 1;
if (view_html->w() > w || view_html->h() > h) {
scale = (float)w/view_html->w();
scale_tmp = (float)h / view_html->h();
if ( scale_tmp < scale) scale = scale_tmp;
printer.scale(scale, scale);
} else if (view_html->w() < w || view_html->h() < h) {
scale = (float)w/view_html->w();
scale_tmp = (float)h / view_html->h();
if ( scale_tmp < scale) scale = scale_tmp;
printer.scale(scale, scale);
}
printer.print_widget(view_html);
printer.end_page();
printer.end_job();} {selected
}
}
Function {} {open
} {
Fl_Window {} {open
xywh {35 131 800 500} type Double visible
} {
Fl_Group view_html {open
xywh {10 5 781 432} color 7 labelsize 18
code0 {o->load("test.html");}
class Fl_Help_View
} {}
Fl_Button btnPrint {
label Print
callback {print_html();}
xywh {350 460 82 25} labelsize 18
}
}
}
| Fecha |
Cantidad |
Total |
| 2008-03 |
41 |
1.094,50 |
| 2008-03 |
2 |
4.672,19 |
| 2008-02 |
126 |
9.832,62 |
| 2008-02 |
4 |
453,86 |
| 2008-01 |
143 |
12.365,37 |
| 2008-01 |
2 |
117,57 |
| 2007-12 |
105 |
11.799,79 |
| 2007-12 |
2 |
100,53 |
| 2007-11 |
168 |
19.328,28 |
| 2007-11 |
5 |
1.262,34 |
| Fecha |
Cantidad |
Total |
| 2008-03 |
41 |
1.094,50 |
| 2008-03 |
2 |
4.672,19 |
| 2008-02 |
126 |
9.832,62 |
| 2008-02 |
4 |
453,86 |
| 2008-01 |
143 |
12.365,37 |
| 2008-01 |
2 |
117,57 |
| 2007-12 |
105 |
11.799,79 |
| 2007-12 |
2 |
100,53 |
| 2007-11 |
168 |
19.328,28 |
| 2007-11 |
5 |
1.262,34 |
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev