printing.fl was for some network problem incomplete, here it is again !
# data file for the Fltk User Interface Designer (fluid)
version 1.0300
header_name {.h}
code_name {.cxx}
decl {\#include <FL/Fl_Double_Window.H>} {public global
}
decl {\#include <FL/Fl_Input.H>} {public global
}
decl {\#include <FL/Fl_Help_View.H>} {public global
}
decl {\#include <FL/Fl_Table.H>
\#include <FL/Fl_Printer.H>} {public global
}
decl {\#include <FL/Fl_Printer.H>} {public global
}
decl {\#include <vector>} {public global
}
decl {\#include <string>} {public global
}
decl {\#include <sstream>} {public global
}
decl {template<typename T>
void show_create(T*& aptr) {
if (!aptr) aptr = new T();
aptr->show();
}} {
comment {This template checks if the pointer is already assigned,
if not it creates a new object.} public global
}
Function {validate_product_id(Fl_Input *o, void *v)} {return_type void
} {
code {//printf("Hello, World!\\n");} {}
}
class DAD_Base_Window {
comment {This is the base class for all application windows and is used to
hold common code/functionality.} open : {public Fl_Double_Window}
} {
decl {DAD_Base_Window *callee;} {protected local
}
Function {DAD_Base_Window(int X, int Y, int W, int H, const char *L) :
Fl_Double_Window(X, Y, W, H, L)} {open
} {
code {callee = NULL;} {}
}
Function {DAD_Base_Window(int W, int H, const char *L):Fl_Double_Window(0, 0,
W, H, L)} {open
} {
code {//printf("Hello, World!\\n");} {}
}
Function {make_window_when_null(DAD_Base_Window &aref)} {open return_type
{static DAD_Base_Window*}
} {
code {//if (!aref) aref =
return &aref;} {}
}
}
widget_class DAD_Invoice_Print {
label {Invoice Print}
xywh {82 59 658 692} type Double color 7 hide resizable
class Fl_Double_Window
} {
Fl_Scroll pi_scroll {open
xywh {4 2 650 688} color 7
} {
Fl_Group pageA4 {open
xywh {20 10 628 685} color 7
} {
Fl_Box logo {
label FLTK
image {../help/logotipo-santiagopidal-s.bmp} xywh {28 20 200 41}
labeltype SHADOW_LABEL labelfont 3 labelsize 47 align 148
}
Fl_Box companyBox {
label {FLTK (pronounced "fulltick") is a cross-platform C++ GUI toolkit
for UNIX®/Linux® (X11), Microsoft® Windows®, and MacOS® X. FLTK provides
modern GUI functionality without the bloat and supports 3D graphics via
OpenGL® and its built-in GLUT emulation.}
xywh {28 66 308 80} labelfont 2 labelsize 12 align 144
}
Fl_Group invoiceNumber {open
xywh {347 20 286 40} box BORDER_FRAME color 31
} {
Fl_Box box_header_number_date {
xywh {348 21 284 18} box FLAT_BOX color 47 labeltype NO_LABEL
}
Fl_Box hline_header_number_date {
xywh {347 39 286 1} box BORDER_FRAME color 31 labeltype NO_LABEL
labelsize 18
}
Fl_Box vline_header_number_date {
xywh {492 20 1 40} box BORDER_FRAME color 39 labeltype NO_LABEL
}
Fl_Box header_date_box {
label DATE
xywh {492 20 139 20} labelfont 1 labelsize 12
}
}
Fl_Box box_to {
xywh {347 65 286 85} box BORDER_FRAME color 31 labelfont 1 labelsize 16
align 21
}
Fl_Box box_header {
xywh {28 160 606 20} box BORDER_FRAME color 31
}
Fl_Box box_header_fill {
xywh {29 161 604 18} box FLAT_BOX color 47 labeltype NO_LABEL labelsize
18
}
Fl_Box header_code_box {
label CODE
xywh {29 161 54 18} color 47 labelfont 1 labelsize 10
}
Fl_Box header_description_box {
label DESCRIPTION
xywh {82 161 338 18} color 47 labelfont 1 labelsize 10
}
Fl_Box header_quantity_box {
label {QTY.}
xywh {421 161 41 18} color 47 labelfont 1 labelsize 10
}
Fl_Box header_price_box {
label PRICE
xywh {461 161 64 18} color 47 labelfont 1 labelsize 10
}
Fl_Box header_discount_box {
label {DISC.}
xywh {525 161 40 18} color 47 labelfont 1 labelsize 10
}
Fl_Box header_subtotal_box {
label SUBTOTAL
xywh {567 161 66 18} color 47 labelfont 1 labelsize 10
}
Fl_Box box_totals {
xywh {28 615 606 30} box BORDER_FRAME color 31
}
Fl_Box notes_box {
label {FLTK is provided under the terms of the GNU Library Public
License, Version 2 with exceptions that allow for static linking.}
xywh {28 648 606 37} labelfont 2 labelsize 12 align 149
}
Fl_Box box_header_totals {
xywh {28 596 606 20} box BORDER_FRAME color 31
}
Fl_Box box_header_totals_fill {
xywh {29 597 604 18} box FLAT_BOX color 47
}
Fl_Box vline_totals_1 {
xywh {92 596 1 49} box BORDER_FRAME color 31 labeltype NO_LABEL
}
Fl_Box {} {
xywh {217 596 1 49} box BORDER_FRAME color 31 labeltype NO_LABEL
}
Fl_Box {} {
xywh {349 596 1 49} box BORDER_FRAME color 31 labeltype NO_LABEL
}
Fl_Box {} {
xywh {488 596 1 49} box BORDER_FRAME color 31 labeltype NO_LABEL
}
Fl_Box header_totals_page_box {
label PAGE
xywh {29 597 63 18} color 47 labelfont 1 labelsize 12
}
Fl_Box header_totals_subtotal_box {
label SUBTOTAL
xywh {93 597 124 18} color 47 labelfont 1 labelsize 12
}
Fl_Box header_totals_vat_percent_box {
label {V.A.T. %}
xywh {218 597 131 18} color 47 labelfont 1 labelsize 12
}
Fl_Box header_totals_vat_amount_box {
label {TOTAL V.A.T.}
xywh {351 597 137 18} color 47 labelfont 1 labelsize 12
}
Fl_Box header_totals_total_box {
label TOTAL
xywh {489 597 144 18} color 47 labelfont 1 labelsize 12
}
Fl_Box invoice_lines_box {
image {/home/mingo/dadbiz-1.8/dadbiz/help/alfarero2.bmp} xywh {28 179
606 406} box BORDER_FRAME color 31
}
Fl_Box vline_lines_1 {
xywh {82 160 1 425} box BORDER_FRAME color 31
}
Fl_Box {} {
xywh {420 160 1 425} box BORDER_FRAME color 31
}
Fl_Box {} {
xywh {461 160 1 425} box BORDER_FRAME color 31
}
Fl_Box {} {
xywh {524 160 1 425} box BORDER_FRAME color 31
}
Fl_Box {} {
xywh {566 160 1 425} box BORDER_FRAME color 31
}
Fl_Group printDataGroup {open
xywh {20 10 628 637}
} {
Fl_Box invoiceTypeBox {
label {Invoice Nº}
xywh {350 20 139 20} labelfont 1 labelsize 12
}
Fl_Box numberBox {
label {2010/4687}
xywh {350 40 139 20} labelfont 5 labelsize 15 align 16
}
Fl_Box dateBox {
label {01/03/2010}
xywh {496 40 133 20} labelfont 5 labelsize 15 align 16
}
Fl_Box clientBox {
label {Domingo Alvarez Duarte
50.566.789-L
c/ Felicidad, 34 4ºB
29999 - Málaga
Málaga - Spain}
xywh {349 66 277 82} labelsize 12 align 84
}
Fl_Group dataLinesGroup {open
xywh {28 179 605 407} align 16
} {
Fl_Box codeBox {
label {123
345
567
675
567
}
xywh {29 180 52 404} labelsize 11 align 25
}
Fl_Box descriptionBox {
label {Ceramica
Barro
Card
France
Debit
AZULEJOS BLANCOS 15X15/45 PRODESCO
ESMALTE DE ALTA TEMPERATURA ANARANJADO 0-6002}
xywh {86 180 332 404} labelsize 11 align 85
}
Fl_Box quantityBox {
label {123
345
567
675
567
}
xywh {422 180 38 404} labelsize 11 align 25
}
Fl_Box priceBox {
label {12.456,88
345
567
675
567
}
xywh {463 180 61 404} labelsize 11 align 25
}
Fl_Box discountBox {
label {123
345
567
675
567
}
xywh {526 180 39 404} labelsize 11 align 25
}
Fl_Box lineTotalBox {
label {23.456,90
345
567
675
567
}
xywh {568 180 63 404} labelsize 11 align 25
}
}
Fl_Group {} {open
xywh {28 595 609 52}
} {
Fl_Box invoicePageBox {
label {1/1}
xywh {28 618 65 25} labelfont 5 labelsize 15
}
Fl_Box fisrtTotalBox {
label {12.345,78}
xywh {95 618 120 25} labelfont 5 labelsize 15
}
Fl_Box vatPercentageBox {
label 16
xywh {223 618 125 25} labelfont 5 labelsize 15
}
Fl_Box vatAmountBox {
label {12.345,78}
xywh {350 618 138 25} labelfont 5 labelsize 15
}
Fl_Box totalBox {
label {12.345,78}
xywh {488 618 144 25} labelfont 5 labelsize 15
}
}
}
}
}
}
widget_class DAD_Address_Book_Html {
label {Address Book Html} open
xywh {122 83 800 560} type Double color 7 hide resizable
class Fl_Double_Window
} {
decl {Fl_Text_Buffer textbuf;} {protected local
}
Fl_Tabs tabs {open
xywh {0 0 800 560} resizable
} {
Fl_Group tabView {
label View open
xywh {0 33 800 527} color 7 labelsize 20 hide
} {
Fl_Help_View htmlView {
xywh {0 33 800 527} labelsize 18
code0 {o->load("test.html");}
}
}
Fl_Group tabEdit {
label {Edit/Print} open
xywh {0 37 800 523} labelsize 20
} {
Fl_Text_Editor editor {
xywh {0 87 800 473} labelsize 18 textsize 18
code0 {o->buffer(&textbuf);}
code1 {o->buffer()->text(htmlView->value());}
}
Fl_Button btnShow {
label Show
callback {htmlView->value(textbuf.text());
tabView->show();}
xywh {10 45 82 25} labelsize 18
}
Fl_Button btnShowPrint {
label Print
callback {print_html();}
xywh {105 45 82 25} labelsize 18
}
}
}
Function {print_html()} {open return_type void
} {
code {htmlView->value(textbuf.text());
tabView->show();
Fl_Printer printer;
//Fl_PSfile_Device printer;
int w, h;
float scale_tmp, scale;
printer.start_job(1);
w = h = 0;
printer.printable_rect(&w,&h);
// scale the printer device so that the window fits on the page
scale = 1;
if (htmlView->w() > w || htmlView->h() > h) {
scale = (float)w/htmlView->w();
scale_tmp = (float)h / htmlView->h();
if ( scale_tmp < scale) scale = scale_tmp;
printer.scale(scale, scale);
} else if (htmlView->w() < w || htmlView->h() < h) {
scale = (float)w/htmlView->w();
scale_tmp = (float)h / htmlView->h();
if ( scale_tmp < scale) scale = scale_tmp;
printer.scale(scale, scale);
}
printer.print_widget(htmlView);
printer.end_page();
printer.end_job();} {selected
}
}
}
widget_class Address_Book_Line {open
xywh {169 189 380 12} type Double hide
class Fl_Group
} {
Function {Address_Book_Line() : Fl_Group(0,0,380,12,0)} {open return_type void
} {
code {//printf("Hello, World!\\n");} {}
}
Fl_Box line_id_box {
label ID
xywh {2 1 29 10} labelsize 8 align 88
}
Fl_Box line_name_box {
label Name
xywh {62 1 180 10} labelsize 8 align 84
}
Fl_Box line_contact_box {
label Contact
xywh {254 1 60 10} labelsize 8 align 84
}
Fl_Box line_phone_box {
label Phone
xywh {318 1 60 10} labelsize 8 align 20
}
}
widget_class DAD_Address_Book_Print {
label {Address Book Print} open
xywh {162 42 409 571} type Double color 7 hide resizable
class Fl_Double_Window
} {
Fl_Scroll pi_scroll {open
xywh {4 2 400 564} color 7
} {
Fl_Group pageA4 {open
xywh {8 5 392 560} box ENGRAVED_FRAME color 7
} {
Fl_Box {} {
label {Address Book}
xywh {34 19 335 21} labeltype SHADOW_LABEL labelsize 20
}
Fl_Box hline_top {
xywh {13 54 380 2} box BORDER_FRAME color 31 labeltype NO_LABEL
labelsize 18
}
Fl_Box hline_bottom {
xywh {13 532 380 2} box BORDER_FRAME color 31 labeltype NO_LABEL
labelsize 18
}
Fl_Group header_group {open
xywh {13 43 380 12} labeltype NO_LABEL labelsize 18 align 0
} {
Fl_Box header_id_box {
label ID
xywh {13 43 29 10} labelsize 8 align 88
}
Fl_Box header_name_box {
label Name
xywh {73 43 180 10} labelsize 8 align 84
}
Fl_Box header_contact_box {
label Contact
xywh {265 43 60 10} labelsize 8 align 84
}
Fl_Box header_phone_box {
label Phone
xywh {329 43 60 10} labelsize 8 align 20
}
}
Fl_Group line_group {open
xywh {13 58 380 12} box FLAT_BOX color 215 labeltype NO_LABEL labelsize
18 align 0
} {
Fl_Box line_id_box {
label ID
xywh {13 58 29 10} labelsize 8 align 88
}
Fl_Box line_name_box {
label Name
xywh {73 58 180 10} labelsize 8 align 84
}
Fl_Box line_contact_box {
label Contact
xywh {265 58 60 10} labelsize 8 align 84
}
Fl_Box line_phone_box {
label Phone
xywh {329 58 60 10} labelsize 8 align 20
}
}
Fl_Box page_no_box {
label {Page nº 23}
xywh {177 538 55 10} labelsize 8
}
}
}
}
widget_class DAD_Main_Window {
label {DADBIZ Sales & Inventory} open
xywh {8 28 336 286} type Double hide
class DAD_Base_Window
} {
decl {DAD_Invoice_Print *sales_invoice;
DAD_Address_Book_Print *address_book;
DAD_Address_Book_Html *address_book_html;} {public local
}
Function {~DAD_Main_Window()} {open return_type virtual
} {
code {delete sales_invoice;} {}
}
code {sales_invoice = NULL;
address_book = NULL;
address_book_html = NULL;} {}
Fl_Tabs tabs {open
xywh {10 11 315 266}
} {
Fl_Group tabSales {
label Sales open
xywh {10 43 315 234} color 127 labelsize 20 hide
} {
Fl_Button btnPreview {
label {Invoice Preview}
callback {show_create(sales_invoice);
generate_invoice();}
xywh {30 61 275 55} box PLASTIC_UP_BOX labeltype SHADOW_LABEL labelfont
3 labelsize 32 align 16
}
Fl_Counter pageCount {
label Pages
xywh {90 161 150 30} type Simple labeltype SHADOW_LABEL labelfont 3
labelsize 31 align 1 minimum 1 maximum 20 step 1 value 1 textsize 32
}
Fl_Button btnPrint {
label {Print Invoice}
callback {print_invoice()}
xywh {30 201 275 55} box PLASTIC_UP_BOX labeltype SHADOW_LABEL
labelfont 3 labelsize 32
}
}
Fl_Group tabBuys {
label Buys open
xywh {10 43 315 234} color 174 labelsize 20
} {
Fl_Button btnPreview2 {
label {Address Book Preview}
callback {show_create(address_book_html);
//generate_address_book();}
xywh {40 71 275 55} box PLASTIC_UP_BOX labeltype SHADOW_LABEL labelfont
3 labelsize 23 align 16
}
Fl_Counter pageCount2 {
label Pages
xywh {100 171 150 30} type Simple labeltype SHADOW_LABEL labelfont 3
labelsize 31 align 1 minimum 1 maximum 20 step 1 value 1 textsize 32
}
Fl_Button btnPrint2 {
label {Print Address Book}
callback {print_address_book()}
xywh {40 211 275 55} box PLASTIC_UP_BOX labeltype SHADOW_LABEL
labelfont 3 labelsize 25
}
}
Fl_Group tabConfig {
label Config open
xywh {10 44 315 232} labelsize 20 hide
} {}
}
Function {generate_invoice()} {open return_type void
} {
code {std::ostringstream ss_code, ss_description, ss_quantity, ss_price,
ss_discount, ss_line_total;
double dbl_subtotal, dbl_vat, dbl_vat_total, dbl_total;
dbl_subtotal = dbl_vat_total = dbl_total = 0.0;
dbl_vat = 16.0;
for(int i=1; i < 28; i++){
int icode = i * 1000;
double line_price = i * 1.53;
double dbl_line_total = (line_price * i) ;
dbl_subtotal += dbl_line_total;
ss_code << icode << "\\n";
ss_description << "Implementantion of function " << icode << "\\n";
ss_quantity << i << "\\n";
ss_price << line_price << "\\n";
//ss_discount << 5 << "\\n";
ss_line_total << dbl_line_total << "\\n";
}
sales_invoice->codeBox->copy_label(ss_code.str().c_str());
sales_invoice->descriptionBox->copy_label(ss_description.str().c_str());
sales_invoice->quantityBox->copy_label(ss_quantity.str().c_str());
sales_invoice->priceBox->copy_label(ss_price.str().c_str());
sales_invoice->discountBox->copy_label(ss_discount.str().c_str());
sales_invoice->lineTotalBox->copy_label(ss_line_total.str().c_str());} {}
}
Function {print_invoice()} {open return_type void
} {
code {int pages = pageCount->value();
show_create(sales_invoice);
generate_invoice();
Fl::wait();
std::ostringstream ss_page;
//FILE *file_ps_out = fopen("output.ps", "w");
Fl_PSfile_Device ps_device;
Fl_Printer printer;
//p.page(Fl_Printer::A4);
//p.place(g, 70, 70, p->page_width() - 140, p->page_height() - 140,
FL_ALIGN_CENTER);
int w, h;
float scale_tmp, scale;
printer.start_job(1);
ps_device.start_job(1);
for(int i=1; i <= pages; i++) {
//calling Fl::wait() can switch context/device
Fl::wait();
ss_page.str("");
ss_page << i << "/" << pages;
sales_invoice->invoicePageBox->copy_label(ss_page.str().c_str());
//postscript generation
ps_device.set_current();
if( ps_device.start_page() ) break;
w = h = 0;
ps_device.printable_rect(&w,&h);
// scale the printer device so that the window fits on the page
scale = 1;
if (sales_invoice->pageA4->w() > w || sales_invoice->pageA4->h() > h) {
scale = (float)w/sales_invoice->pageA4->w();
scale_tmp = (float)h/sales_invoice->pageA4->h();
if ( scale_tmp < scale) scale = scale_tmp;
ps_device.scale(scale, scale);
}
ps_device.print_widget(sales_invoice->pageA4);
ps_device.end_page();
//Printer
printer.set_current();
if( printer.start_page() ) break;
w = h = 0;
printer.printable_rect(&w,&h);
// scale the printer device so that the window fits on the page
scale = 1;
if (sales_invoice->pageA4->w() > w || sales_invoice->pageA4->h() > h) {
scale = (float)w/sales_invoice->pageA4->w();
scale_tmp = (float)h/sales_invoice->pageA4->h();
if ( scale_tmp < scale) scale = scale_tmp;
printer.scale(scale, scale);
}
printer.print_widget(sales_invoice->pageA4);
printer.end_page();
}
ps_device.end_job();
printer.end_job();
//fclose(file_ps_out);} {}
}
Function {generate_address_book()} {open return_type void
} {
code {std::string str_id, str_name, str_contact, str_phone;
Fl_Color line_bgc = address_book->line_group->color();
int lines = ((address_book->hline_bottom->y() - address_book->hline_top->y())
/ address_book->line_group->h()) -2;
int start_y = address_book->line_group->y();
for(int i=0; i < lines; i++){
int icode = i * 1000;
if(i % 2) address_book->line_group->color(FL_WHITE);
else address_book->line_group->color(line_bgc);
address_book->line_group->position(address_book->x(), start_y*i);
char buf[32];
snprintf(buf, sizeof(buf), "%d", icode);
address_book->line_id_box->label(buf);
str_name = "Someone Name ";
str_name += buf;
address_book->line_name_box->label(str_name.c_str());
str_contact = "Contact ";
str_contact += buf;
address_book->line_contact_box->label(str_contact.c_str());
str_phone = "Phone ";
str_phone += buf;
address_book->line_phone_box->label(str_phone.c_str());
}} {}
}
Function {print_address_book()} {open return_type void
} {
code {int pages = pageCount2->value();
show_create(address_book);
generate_address_book();
Fl::wait();
std::ostringstream ss_page;
//FILE *file_ps_out = fopen("output.ps", "w");
Fl_PSfile_Device ps_device;
Fl_Printer printer;
//p.page(Fl_Printer::A4);
//p.place(g, 70, 70, p->page_width() - 140, p->page_height() - 140,
FL_ALIGN_CENTER);
int w, h;
float scale_tmp, scale;
printer.start_job(1);
ps_device.start_job(1);
for(int i=1; i <= pages; i++) {
//calling Fl::wait() can switch context/device
Fl::wait();
ss_page.str("");
ss_page << i << "/" << pages;
address_book->page_no_box->copy_label(ss_page.str().c_str());
//postscript generation
ps_device.set_current();
if( ps_device.start_page() ) break;
w = h = 0;
ps_device.printable_rect(&w,&h);
// scale the printer device so that the window fits on the page
scale = 1;
if (address_book->pageA4->w() > w || address_book->pageA4->h() > h) {
scale = (float)w/address_book->pageA4->w();
scale_tmp = (float)h / address_book->pageA4->h();
if ( scale_tmp < scale) scale = scale_tmp;
ps_device.scale(scale, scale);
} else if (address_book->pageA4->w() < w || address_book->pageA4->h() < h) {
scale = (float)w/address_book->pageA4->w();
scale_tmp = (float)h / address_book->pageA4->h();
if ( scale_tmp < scale) scale = scale_tmp;
ps_device.scale(scale, scale);
}
ps_device.print_widget(address_book->pageA4);
ps_device.end_page();
//Printer
printer.set_current();
if( printer.start_page() ) break;
w = h = 0;
printer.printable_rect(&w,&h);
// scale the printer device so that the window fits on the page
scale = 1;
if (address_book->pageA4->w() > w || address_book->pageA4->h() > h) {
scale = (float)w/address_book->pageA4->w();
scale_tmp = (float)h / address_book->pageA4->h();
if ( scale_tmp < scale) scale = scale_tmp;
printer.scale(scale, scale);
} else if (address_book->pageA4->w() < w || address_book->pageA4->h() < h) {
scale = (float)w/address_book->pageA4->w();
scale_tmp = (float)h / address_book->pageA4->h();
if ( scale_tmp < scale) scale = scale_tmp;
printer.scale(scale, scale);
}
printer.print_widget(address_book->pageA4);
printer.end_page();
}
ps_device.end_job();
printer.end_job();
//fclose(file_ps_out);} {}
}
}
Function {} {open
} {
code {DAD_Main_Window* w = new DAD_Main_Window();
w->show(argc, argv);} {}
}
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev